Skip to content

Commit

Permalink
Stop making previews for light & dark colour schemes.
Browse files Browse the repository at this point in the history
Xcode 14 now has preview variants for this.
  • Loading branch information
pixlwave committed Nov 25, 2022
1 parent 00cd2ab commit e171c0f
Show file tree
Hide file tree
Showing 31 changed files with 28 additions and 207 deletions.
9 changes: 1 addition & 8 deletions DesignKit/Sources/Buttons/ElementActionButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct ElementActionButtonStyle: ButtonStyle {
}

public struct ElementActionButtonStyle_Previews: PreviewProvider {
public static var states: some View {
public static var previews: some View {
VStack {
Button("Enabled") { /* preview */ }
.buttonStyle(ElementActionButtonStyle())
Expand All @@ -87,11 +87,4 @@ public struct ElementActionButtonStyle_Previews: PreviewProvider {
}
.padding()
}

public static var previews: some View {
states
.preferredColorScheme(.light)
states
.preferredColorScheme(.dark)
}
}
9 changes: 1 addition & 8 deletions DesignKit/Sources/Buttons/ElementCapsuleButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct ElementCapsuleButtonStyle: ButtonStyle {
}

struct ElementCapsuleButtonStyle_Previews: PreviewProvider {
public static var states: some View {
public static var previews: some View {
VStack {
Button("Enabled") { /* preview */ }
.buttonStyle(.elementCapsuleProminent)
Expand All @@ -77,11 +77,4 @@ struct ElementCapsuleButtonStyle_Previews: PreviewProvider {
}
.padding()
}

public static var previews: some View {
states
.preferredColorScheme(.light)
states
.preferredColorScheme(.dark)
}
}
11 changes: 0 additions & 11 deletions DesignKit/Sources/Buttons/ElementGhostButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ public struct ElementGhostButtonStyle: ButtonStyle {

public struct ElementGhostButtonStyle_Previews: PreviewProvider {
public static var previews: some View {
Group {
states
}
.preferredColorScheme(.light)
Group {
states
}
.preferredColorScheme(.dark)
}

public static var states: some View {
VStack {
Button("Enabled") { /* preview */ }
.buttonStyle(ElementGhostButtonStyle())
Expand Down
11 changes: 1 addition & 10 deletions DesignKit/Sources/TextFields/BorderedInputFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public struct BorderedInputFieldStyle: TextFieldStyle {
}

public struct BorderedInputFieldStyle_Previews: PreviewProvider {
public static var states: some View {
public static var previews: some View {
VStack {
TextField("Placeholder", text: .constant(""))
.textFieldStyle(BorderedInputFieldStyle())
Expand All @@ -115,13 +115,4 @@ public struct BorderedInputFieldStyle_Previews: PreviewProvider {
}
.padding()
}

public static var previews: some View {
Group {
states
.preferredColorScheme(.light)
states
.preferredColorScheme(.dark)
}
}
}
11 changes: 1 addition & 10 deletions DesignKit/Sources/TextFields/ElementTextFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct ElementTextFieldStyle: TextFieldStyle {

@available(iOS 15.0, *)
struct ElementTextFieldStyle_Previews: PreviewProvider {
public static var states: some View {
public static var previews: some View {
VStack(spacing: 12) {
TextField("Placeholder", text: .constant(""))
.textFieldStyle(.elementInput(labelText: "Label", footerText: "Footer"))
Expand All @@ -88,13 +88,4 @@ struct ElementTextFieldStyle_Previews: PreviewProvider {
}
.padding()
}

public static var previews: some View {
Group {
states
.preferredColorScheme(.light)
states
.preferredColorScheme(.dark)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ struct UserNotificationModalView: View {

struct UserNotificationModalView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

private static var body: some View {
VStack {
UserNotificationModalView(notification: UserNotification(type: .modal,
title: "Successfully logged in",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ struct UserNotificationToastView: View {

struct UserNotificationToastView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

private static var body: some View {
VStack {
UserNotificationToastView(notification: UserNotification(title: "Successfully logged in",
iconName: "checkmark"))
Expand Down
6 changes: 0 additions & 6 deletions ElementX/Sources/Screens/BugReport/View/BugReportScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ struct BugReportScreen: View {

struct BugReport_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: Asset.Images.appLogo.image, isModallyPresented: false)
BugReportScreen(context: viewModel.context)
.previewInterfaceOrientation(.portrait)
Expand Down
8 changes: 2 additions & 6 deletions ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,9 @@ struct HomeScreen: View {

struct HomeScreen_Previews: PreviewProvider {
static var previews: some View {
body(.loading).preferredColorScheme(.light)
body(.loading)
.tint(.element.accent)
body(.loading).preferredColorScheme(.dark)
.tint(.element.accent)
body(.loaded).preferredColorScheme(.light)
.tint(.element.accent)
body(.loaded).preferredColorScheme(.dark)
body(.loaded)
.tint(.element.accent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ struct HomeScreenRoomCell: View {

struct HomeScreenRoomCell_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
.tint(.element.accent)
body.preferredColorScheme(.dark)
.tint(.element.accent)
body.tint(.element.accent)
}

static var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ private struct MessageComposerEditHeader: View {

struct MessageComposer_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
VStack {
MessageComposer(text: .constant(""),
focused: .constant(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ private class TextViewWithKeyDetection: UITextView {

struct MessageComposerTextField_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
VStack {
PreviewWrapper(text: "123")
PreviewWrapper(text: "")
Expand Down
6 changes: 2 additions & 4 deletions ElementX/Sources/Screens/RoomScreen/View/RoomHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ struct RoomHeaderView: View {

struct RoomHeaderView_Previews: PreviewProvider {
static var previews: some View {
bodyPlain.preferredColorScheme(.light)
bodyPlain.preferredColorScheme(.dark)
bodyEncrypted.preferredColorScheme(.light)
bodyEncrypted.preferredColorScheme(.dark)
bodyPlain
bodyEncrypted
}

@ViewBuilder
Expand Down
6 changes: 0 additions & 6 deletions ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ struct RoomScreen: View {

struct RoomScreen_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
let viewModel = RoomScreenViewModel(timelineController: MockRoomTimelineController(),
timelineViewFactory: RoomTimelineViewFactory(),
mediaProvider: MockMediaProvider(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ struct TimelineItemBubbledStylerView<Content: View>: View {

struct TimelineItemBubbledStylerView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading, spacing: 2) {
ForEach(1..<MockRoomTimelineController().timelineItems.count, id: \.self) { index in
let item = MockRoomTimelineController().timelineItems[index]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ struct TimelineItemPlainStylerView<Content: View>: View {

struct TimelineItemPlainStylerView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading) {
ForEach(1..<MockRoomTimelineController().timelineItems.count, id: \.self) { index in
let item = MockRoomTimelineController().timelineItems[index]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ struct EmoteRoomTimelineView: View {

struct EmoteRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading, spacing: 20.0) {
EmoteRoomTimelineView(timelineItem: itemWith(text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,10 @@ struct EncryptedRoomTimelineView: View {

struct EncryptedRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading, spacing: 20.0) {
EncryptedRoomTimelineView(timelineItem: itemWith(text: "Text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ struct FileRoomTimelineView: View {

struct FileRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder

static var body: some View {
VStack(spacing: 20.0) {
FileRoomTimelineView(timelineItem: FileRoomTimelineItem(id: UUID().uuidString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ extension FormattedBodyText {

struct FormattedBodyText_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,10 @@ struct ImageRoomTimelineView: View {

struct ImageRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder

static var body: some View {
VStack(spacing: 20.0) {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ struct NoticeRoomTimelineView: View {

struct NoticeRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
body.preferredColorScheme(.light)
.timelineStyle(.plain)
body.preferredColorScheme(.dark)
.timelineStyle(.plain)
body
body.timelineStyle(.plain)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading, spacing: 20.0) {
NoticeRoomTimelineView(timelineItem: itemWith(text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ struct PlaceholderAvatarImage: View {

struct PlaceholderAvatarImage_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
PlaceholderAvatarImage(text: "X", contentId: "@userid:matrix.org")
.clipShape(Circle())
.frame(width: 150, height: 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ struct RedactedRoomTimelineView: View {

struct RedactedRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
VStack(alignment: .leading, spacing: 20.0) {
RedactedRoomTimelineView(timelineItem: itemWith(text: ElementL10n.eventRedacted,
timestamp: "Later",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ struct SeparatorRoomTimelineView: View {

struct SeparatorRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
let item = SeparatorRoomTimelineItem(id: UUID().uuidString, text: "This is a separator")
SeparatorRoomTimelineView(timelineItem: item)
}
Expand Down
Loading

0 comments on commit e171c0f

Please sign in to comment.