Skip to content

Commit

Permalink
⚰️ Remove SwiftUI previews that fail to load
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 24, 2022
1 parent 22fce12 commit a5b30ca
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ extension ExperienceComponent {
}

struct ImageModel: ComponentModel, Decodable {

let id: UUID
let imageUrl: URL
let blurHash: String?
Expand All @@ -126,30 +125,6 @@ extension ExperienceComponent {
let accessibilityLabel: String?

let style: Style?

/// URL init
internal init(imageUrl: URL, contentMode: String?, intrinsicSize: IntrinsicSize?, style: ExperienceComponent.Style?) {
self.id = UUID()
self.imageUrl = imageUrl
self.blurHash = nil
self.contentMode = contentMode
self.intrinsicSize = intrinsicSize
self.accessibilityLabel = nil
self.style = style
}

/// Symbol init
internal init(symbolName: String, style: ExperienceComponent.Style?) {
self.id = UUID()
// swiftlint:disable:next force_unwrapping
self.imageUrl = URL(string: "sf-symbol://\(symbolName)")!
self.blurHash = nil
self.contentMode = "fit"
self.intrinsicSize = nil
self.accessibilityLabel = nil
self.style = style
}

}

struct EmbedModel: ComponentModel, Decodable {
Expand All @@ -161,7 +136,6 @@ extension ExperienceComponent {

struct SpacerModel: ComponentModel, Decodable {
let id: UUID

let spacing: Double?

let style: Style?
Expand Down Expand Up @@ -194,60 +168,6 @@ extension ExperienceComponent {
let cornerRadius: Double?
let borderColor: DynamicColor?
let borderWidth: Double?

internal init(
verticalAlignment: String? = nil,
horizontalAlignment: String? = nil,
paddingTop: Double? = nil,
paddingLeading: Double? = nil,
paddingBottom: Double? = nil,
paddingTrailing: Double? = nil,
marginTop: Double? = nil,
marginLeading: Double? = nil,
marginBottom: Double? = nil,
marginTrailing: Double? = nil,
height: Double? = nil,
width: Double? = nil,
fontName: String? = nil,
fontSize: Double? = nil,
letterSpacing: Double? = nil,
lineHeight: Double? = nil,
textAlignment: String? = nil,
foregroundColor: DynamicColor? = nil,
backgroundColor: DynamicColor? = nil,
backgroundGradient: RawGradient? = nil,
shadow: RawShadow? = nil,
cornerRadius: Double? = nil,
borderColor: DynamicColor? = nil,
borderWidth: Double? = nil
) {
self.verticalAlignment = verticalAlignment
self.horizontalAlignment = horizontalAlignment
self.paddingTop = paddingTop
self.paddingLeading = paddingLeading
self.paddingBottom = paddingBottom
self.paddingTrailing = paddingTrailing
self.marginTop = marginTop
self.marginLeading = marginLeading
self.marginBottom = marginBottom
self.marginTrailing = marginTrailing
self.height = height
self.width = width

self.fontName = fontName
self.fontSize = fontSize
self.letterSpacing = letterSpacing
self.lineHeight = lineHeight
self.textAlignment = textAlignment
self.foregroundColor = foregroundColor
self.backgroundColor = backgroundColor
self.backgroundGradient = backgroundGradient
self.shadow = shadow
self.cornerRadius = cornerRadius
self.borderColor = borderColor
self.borderWidth = borderWidth
}

}

struct IntrinsicSize: Decodable {
Expand All @@ -258,15 +178,9 @@ extension ExperienceComponent {

extension ExperienceComponent.Style {

struct DynamicColor: Decodable, ExpressibleByStringLiteral {
struct DynamicColor: Decodable {
let light: String
let dark: String?

// A hex string maps to light mode only
init(stringLiteral: String) {
self.light = stringLiteral
self.dark = nil
}
}

struct RawGradient: Decodable {
Expand Down
22 changes: 0 additions & 22 deletions Sources/AppcuesKit/Presentation/Extensions/Inits/Axis+String.swift

This file was deleted.

25 changes: 0 additions & 25 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,3 @@ internal struct AppcuesBox: View {
.applyAllAppcues(style)
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesBoxPreview: PreviewProvider {

static var previews: some View {
Group {
AppcuesBox(model: EC.zstackHero)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesBox(model: EC.BoxModel(
id: UUID(),
items: [
.image(EC.imageBanner),
.text(EC.textTitle)
],
style: EC.Style(verticalAlignment: "top", horizontalAlignment: "leading"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()
}
}
}
#endif
25 changes: 0 additions & 25 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,3 @@ internal struct AppcuesButton: View {
.setupActions(viewModel.groupedActionHandlers(for: model.id))
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesButtonPreview: PreviewProvider {
static var previews: some View {
Group {
AppcuesButton(model: EC.ButtonModel(
id: UUID(),
content: ExperienceComponent.text(ExperienceComponent.TextModel(id: UUID(), text: "Default Button", style: nil)),
style: nil)
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesButton(model: EC.buttonPrimary)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesButton(model: EC.buttonSecondary)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()
}
}
}
#endif
13 changes: 0 additions & 13 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesEmbed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,3 @@ internal struct AppcuesEmbed: View {
.applyAllAppcues(AppcuesStyle(from: model.style))
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesEmbedPreview: PreviewProvider {
static var previews: some View {
Group {
AppcuesEmbed(model: EC.embedVideo)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()
}
}
}
#endif
28 changes: 0 additions & 28 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,3 @@ private extension URL {
return components.url
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesImagePreview: PreviewProvider {
// swiftlint:disable:next force_unwrapping
static let imageURL = URL(string: "https://res.cloudinary.com/dnjrorsut/image/upload/v1513187203/crx-assets/modal-slideout-hero-image.png")!
static var previews: some View {
Group {
AppcuesImage(model: EC.imageSymbol)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesImage(model: EC.imageBanner)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesImage(model: EC.ImageModel(
imageUrl: imageURL,
contentMode: "fit",
intrinsicSize: EC.IntrinsicSize(width: 1_920, height: 1_280),
style: EC.Style(height: 100, width: 100, backgroundColor: "#eee"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()
}
}
}
#endif
62 changes: 0 additions & 62 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,65 +53,3 @@ internal struct AppcuesStack: View {
}
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesStackPreview: PreviewProvider {

static var previews: some View {
// swiftlint:disable:next closure_body_length
Group {
AppcuesStack(model: EC.StackModel(
id: UUID(),
orientation: .vertical,
distribution: .center,
spacing: 8,
items: [
.text(EC.textTitle),
.text(EC.textSubtitle),
.button(EC.buttonPrimary)
],
style: EC.Style(backgroundColor: "#333"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesStack(model: EC.StackModel(
id: UUID(),
orientation: .vertical,
distribution: .center,
spacing: 48,
items: [
.text(EC.textTitle),
.text(EC.textSubtitle),
.button(EC.buttonPrimary)
],
style: EC.Style(
horizontalAlignment: "leading",
paddingTop: 8,
paddingLeading: 8,
paddingBottom: 8,
paddingTrailing: 8,
backgroundColor: "#333"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesStack(model: EC.StackModel(
id: UUID(),
orientation: .horizontal,
distribution: .center,
spacing: 8,
items: [
.image(EC.imageSymbol),
.text(EC.textPlain)
],
style: EC.Style(backgroundColor: "#eee"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

}
}
}
#endif
29 changes: 0 additions & 29 deletions Sources/AppcuesKit/Presentation/UI/Components/AppcuesText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,3 @@ internal struct AppcuesText: View {
.applyAllAppcues(style)
}
}

#if DEBUG
@available(iOS 13.0, *)
internal struct AppcuesTextPreview: PreviewProvider {
static var previews: some View {
Group {
AppcuesText(model: EC.textPlain)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesText(model: EC.TextModel(
id: UUID(),
text: "This is some text that wraps and is center aligned.",
style: EC.Style(width: 100, textAlignment: "center"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()

AppcuesText(model: EC.TextModel(
id: UUID(),
text: "Heading Sized Text",
style: EC.Style(fontSize: 36, foregroundColor: "#f00"))
)
.previewLayout(PreviewLayout.sizeThatFits)
.padding()
}
}
}
#endif
Loading

0 comments on commit a5b30ca

Please sign in to comment.