From f776575c810c51fc4c126f75739b2a1d10bb6406 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:49:13 +0000 Subject: [PATCH] Stop making previews for light & dark colour schemes. (#345) Xcode 14 now has preview variants for this. --- .../Sources/Buttons/ElementActionButtonStyle.swift | 9 +-------- .../Sources/Buttons/ElementCapsuleButtonStyle.swift | 9 +-------- .../Sources/Buttons/ElementGhostButtonStyle.swift | 11 ----------- .../Sources/TextFields/BorderedInputFieldStyle.swift | 11 +---------- .../Sources/TextFields/ElementTextFieldStyle.swift | 11 +---------- .../UserNotifications/UserNotificationModalView.swift | 5 ----- .../UserNotifications/UserNotificationToastView.swift | 5 ----- .../Screens/BugReport/View/BugReportScreen.swift | 6 ------ .../Sources/Screens/HomeScreen/View/HomeScreen.swift | 8 ++------ .../Screens/HomeScreen/View/HomeScreenRoomCell.swift | 5 +---- .../Screens/RoomScreen/View/MessageComposer.swift | 6 ------ .../RoomScreen/View/MessageComposerTextField.swift | 6 ------ .../Screens/RoomScreen/View/RoomHeaderView.swift | 6 ++---- .../Sources/Screens/RoomScreen/View/RoomScreen.swift | 6 ------ .../View/Style/TimelineItemBubbledStylerView.swift | 6 ------ .../View/Style/TimelineItemPlainStylerView.swift | 6 ------ .../View/Timeline/EmoteRoomTimelineView.swift | 9 ++------- .../View/Timeline/EncryptedRoomTimelineView.swift | 9 ++------- .../View/Timeline/FileRoomTimelineView.swift | 11 +++-------- .../RoomScreen/View/Timeline/FormattedBodyText.swift | 8 ++------ .../View/Timeline/ImageRoomTimelineView.swift | 11 +++-------- .../View/Timeline/NoticeRoomTimelineView.swift | 9 ++------- .../View/Timeline/PlaceholderAvatarImage.swift | 6 ------ .../View/Timeline/RedactedRoomTimelineView.swift | 6 ------ .../View/Timeline/SeparatorRoomTimelineView.swift | 6 ------ .../View/Timeline/TextRoomTimelineView.swift | 9 ++------- .../View/Timeline/VideoRoomTimelineView.swift | 11 +++-------- .../Screens/RoomScreen/View/TimelineItemList.swift | 6 ------ .../Screens/RoomScreen/View/TimelineView.swift | 6 ------ .../View/SessionVerificationScreen.swift | 6 ------ .../Screens/Settings/View/SettingsScreen.swift | 6 ------ changelog.d/pr-345.change | 1 + 32 files changed, 29 insertions(+), 207 deletions(-) create mode 100644 changelog.d/pr-345.change diff --git a/DesignKit/Sources/Buttons/ElementActionButtonStyle.swift b/DesignKit/Sources/Buttons/ElementActionButtonStyle.swift index 93b1e6f56..7ea139886 100644 --- a/DesignKit/Sources/Buttons/ElementActionButtonStyle.swift +++ b/DesignKit/Sources/Buttons/ElementActionButtonStyle.swift @@ -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()) @@ -87,11 +87,4 @@ public struct ElementActionButtonStyle_Previews: PreviewProvider { } .padding() } - - public static var previews: some View { - states - .preferredColorScheme(.light) - states - .preferredColorScheme(.dark) - } } diff --git a/DesignKit/Sources/Buttons/ElementCapsuleButtonStyle.swift b/DesignKit/Sources/Buttons/ElementCapsuleButtonStyle.swift index 086046e2b..ac957bdca 100644 --- a/DesignKit/Sources/Buttons/ElementCapsuleButtonStyle.swift +++ b/DesignKit/Sources/Buttons/ElementCapsuleButtonStyle.swift @@ -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) @@ -77,11 +77,4 @@ struct ElementCapsuleButtonStyle_Previews: PreviewProvider { } .padding() } - - public static var previews: some View { - states - .preferredColorScheme(.light) - states - .preferredColorScheme(.dark) - } } diff --git a/DesignKit/Sources/Buttons/ElementGhostButtonStyle.swift b/DesignKit/Sources/Buttons/ElementGhostButtonStyle.swift index a63b7cc87..9c684e5b3 100644 --- a/DesignKit/Sources/Buttons/ElementGhostButtonStyle.swift +++ b/DesignKit/Sources/Buttons/ElementGhostButtonStyle.swift @@ -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()) diff --git a/DesignKit/Sources/TextFields/BorderedInputFieldStyle.swift b/DesignKit/Sources/TextFields/BorderedInputFieldStyle.swift index a503e3ac0..57b6f4528 100644 --- a/DesignKit/Sources/TextFields/BorderedInputFieldStyle.swift +++ b/DesignKit/Sources/TextFields/BorderedInputFieldStyle.swift @@ -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()) @@ -115,13 +115,4 @@ public struct BorderedInputFieldStyle_Previews: PreviewProvider { } .padding() } - - public static var previews: some View { - Group { - states - .preferredColorScheme(.light) - states - .preferredColorScheme(.dark) - } - } } diff --git a/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift b/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift index 5285589b7..72e9075cb 100644 --- a/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift +++ b/DesignKit/Sources/TextFields/ElementTextFieldStyle.swift @@ -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")) @@ -88,13 +88,4 @@ struct ElementTextFieldStyle_Previews: PreviewProvider { } .padding() } - - public static var previews: some View { - Group { - states - .preferredColorScheme(.light) - states - .preferredColorScheme(.dark) - } - } } diff --git a/ElementX/Sources/Other/UserNotifications/UserNotificationModalView.swift b/ElementX/Sources/Other/UserNotifications/UserNotificationModalView.swift index ec56f1dd1..170f18547 100644 --- a/ElementX/Sources/Other/UserNotifications/UserNotificationModalView.swift +++ b/ElementX/Sources/Other/UserNotifications/UserNotificationModalView.swift @@ -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", diff --git a/ElementX/Sources/Other/UserNotifications/UserNotificationToastView.swift b/ElementX/Sources/Other/UserNotifications/UserNotificationToastView.swift index 83ef3bceb..4c3814e2b 100644 --- a/ElementX/Sources/Other/UserNotifications/UserNotificationToastView.swift +++ b/ElementX/Sources/Other/UserNotifications/UserNotificationToastView.swift @@ -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")) diff --git a/ElementX/Sources/Screens/BugReport/View/BugReportScreen.swift b/ElementX/Sources/Screens/BugReport/View/BugReportScreen.swift index b1462636d..596a1dce9 100644 --- a/ElementX/Sources/Screens/BugReport/View/BugReportScreen.swift +++ b/ElementX/Sources/Screens/BugReport/View/BugReportScreen.swift @@ -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) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift index b4e17b3f3..2e41fc523 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift @@ -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) } diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift index bc8320eeb..b3d8991fd 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift @@ -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 { diff --git a/ElementX/Sources/Screens/RoomScreen/View/MessageComposer.swift b/ElementX/Sources/Screens/RoomScreen/View/MessageComposer.swift index 559b8f7bb..4570bbcc3 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/MessageComposer.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/MessageComposer.swift @@ -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), diff --git a/ElementX/Sources/Screens/RoomScreen/View/MessageComposerTextField.swift b/ElementX/Sources/Screens/RoomScreen/View/MessageComposerTextField.swift index 8723651a1..bc9441d63 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/MessageComposerTextField.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/MessageComposerTextField.swift @@ -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: "") diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomHeaderView.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomHeaderView.swift index d5a0f4cc5..89061ddff 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomHeaderView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomHeaderView.swift @@ -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 diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index 9b469f58a..fdb87e518 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -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(), diff --git a/ElementX/Sources/Screens/RoomScreen/View/Style/TimelineItemBubbledStylerView.swift b/ElementX/Sources/Screens/RoomScreen/View/Style/TimelineItemBubbledStylerView.swift index edff8f750..a72cad750 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/Style/TimelineItemBubbledStylerView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/Style/TimelineItemBubbledStylerView.swift @@ -156,12 +156,6 @@ struct TimelineItemBubbledStylerView: 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..: 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..