Fix accent colour not being applied to Alerts etc. (#701)

This commit is contained in:
Doug
2023-03-14 13:38:36 +00:00
committed by GitHub
parent 8a069ecfa5
commit 1a81768c62
21 changed files with 20 additions and 50 deletions
@@ -22,6 +22,10 @@ struct Application: App {
private let applicationCoordinator: AppCoordinatorProtocol
init() {
// Set the tint colour app-wide. Using UIView ensures that alerts, confirmation dialogs
// and Xcode previews all take on the tint colour, similar to defining it in an asset catalog.
UIView.appearance().tintColor = .element.accent
if Tests.isRunningUITests {
applicationCoordinator = UITestsAppCoordinator()
} else {
@@ -35,7 +39,6 @@ struct Application: App {
EmptyView()
} else {
applicationCoordinator.toPresentable()
.accentColor(.element.accent)
.task {
applicationCoordinator.start()
}
@@ -371,11 +371,9 @@ private struct NavigationSplitCoordinatorView: View {
// through the NavigationSplitCoordinator as well.
.sheet(item: $navigationSplitCoordinator.sheetModule) { module in
module.coordinator?.toPresentable()
.tint(.element.accent)
}
.fullScreenCover(item: $navigationSplitCoordinator.fullScreenCoverModule) { module in
module.coordinator?.toPresentable()
.tint(.element.accent)
}
}
@@ -666,11 +664,9 @@ private struct NavigationStackCoordinatorView: View {
}
.sheet(item: $navigationStackCoordinator.sheetModule) { module in
module.coordinator?.toPresentable()
.tint(.element.accent)
}
.fullScreenCover(item: $navigationStackCoordinator.fullScreenCoverModule) { module in
module.coordinator?.toPresentable()
.tint(.element.accent)
}
}
}
@@ -69,6 +69,7 @@ struct AnalyticsPrompt: View {
.font(.element.body)
.multilineTextAlignment(.center)
.foregroundColor(.element.secondaryContent)
.tint(.element.links)
Divider()
.background(Color.element.quinaryContent)
@@ -115,6 +116,5 @@ struct AnalyticsPrompt_Previews: PreviewProvider {
static let viewModel = AnalyticsPromptViewModel(termsURL: ServiceLocator.shared.settings.analyticsConfiguration.termsURL)
static var previews: some View {
AnalyticsPrompt(context: viewModel.context)
.tint(.element.accent)
}
}
@@ -165,7 +165,6 @@ struct Login_Previews: PreviewProvider {
NavigationStack {
LoginScreen(context: viewModel.context)
.navigationBarTitleDisplayMode(.inline)
.tint(.element.accent)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button { } label: {
@@ -174,6 +173,5 @@ struct Login_Previews: PreviewProvider {
}
}
}
.tint(.element.accent)
}
}
@@ -106,7 +106,6 @@ struct ServerSelection_Previews: PreviewProvider {
ForEach(MockServerSelectionScreenState.allCases, id: \.self) { state in
NavigationStack {
ServerSelectionScreen(context: state.viewModel.context)
.tint(.element.accent)
}
}
}
@@ -182,7 +182,6 @@ struct SoftLogout_Previews: PreviewProvider {
NavigationStack {
SoftLogoutScreen(context: viewModel.context)
.navigationBarTitleDisplayMode(.inline)
.tint(.element.accent)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button { } label: {
@@ -191,6 +190,5 @@ struct SoftLogout_Previews: PreviewProvider {
}
}
}
.tint(.element.accent)
}
}
@@ -26,6 +26,8 @@ struct DeveloperOptionsScreenScreen: View {
Toggle(isOn: $context.shouldCollapseRoomStateEvents) {
Text("Collapse room state events")
}
.tint(.element.brand)
.labelStyle(FormRowLabelStyle())
.onChange(of: context.shouldCollapseRoomStateEvents) { _ in
context.send(viewAction: .changedShouldCollapseRoomStateEvents)
}
@@ -77,6 +79,5 @@ struct DeveloperOptionsScreen_Previews: PreviewProvider {
static var previews: some View {
let viewModel = DeveloperOptionsScreenViewModel()
DeveloperOptionsScreenScreen(context: viewModel.context)
.tint(.element.accent)
}
}
@@ -67,6 +67,5 @@ struct EmojiPickerScreen_Previews: PreviewProvider {
NavigationStack {
EmojiPickerScreen(context: EmojiPickerScreenViewModel(emojiProvider: EmojiProvider()).context)
}
.tint(.element.accent)
}
}
@@ -98,6 +98,5 @@ struct FilePreview_Previews: PreviewProvider {
let upgradeViewModel = FilePreviewViewModel(fileURL: URL(staticString: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"))
FilePreviewScreen(context: upgradeViewModel.context)
}
.tint(.element.accent)
}
}
@@ -240,9 +240,7 @@ struct HomeScreen: View {
struct HomeScreen_Previews: PreviewProvider {
static var previews: some View {
body(.loading)
.tint(.element.accent)
body(.loaded)
.tint(.element.accent)
}
static func body(_ state: MockRoomSummaryProviderState) -> some View {
@@ -161,10 +161,6 @@ private extension View {
struct HomeScreenRoomCell_Previews: PreviewProvider {
static var previews: some View {
body.tint(.element.accent)
}
static var body: some View {
let summaryProvider = MockRoomSummaryProvider(state: .loaded)
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProvider),
@@ -205,6 +205,5 @@ struct OnboardingScreen_Previews: PreviewProvider {
static var previews: some View {
OnboardingScreen(context: viewModel.context)
.tint(.element.accent)
}
}
@@ -171,6 +171,5 @@ struct RoomDetails_Previews: PreviewProvider {
static var previews: some View {
RoomDetailsScreen(context: viewModel.context)
.tint(.element.accent)
}
}
@@ -48,13 +48,6 @@ struct RoomMemberDetailsMemberCell: View {
struct RoomMemberDetailsMemberCell_Previews: PreviewProvider {
static var previews: some View {
body.preferredColorScheme(.light)
.tint(.element.accent)
body.preferredColorScheme(.dark)
.tint(.element.accent)
}
static var body: some View {
let members: [RoomMemberProxy] = [
.mockAlice,
.mockBob,
@@ -59,6 +59,5 @@ struct RoomMemberDetails_Previews: PreviewProvider {
members: members)
RoomMemberDetailsScreen(context: viewModel.context)
}
.tint(.element.accent)
}
}
@@ -217,7 +217,6 @@ struct MessageComposer_Previews: PreviewProvider {
replyCancellationAction: { },
editCancellationAction: { })
}
.tint(.element.accent)
.padding(.horizontal)
}
}
@@ -51,7 +51,6 @@ struct TimelineItemDebugView: View {
}
}
}
.tint(.element.accent)
}
}
@@ -226,15 +226,12 @@ struct SessionVerificationScreen: View {
struct SessionVerification_Previews: PreviewProvider {
static var previews: some View {
Group {
sessionVerificationScreen(state: .initial)
sessionVerificationScreen(state: .requestingVerification)
sessionVerificationScreen(state: .cancelled)
sessionVerificationScreen(state: .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
sessionVerificationScreen(state: .verified)
}
.tint(Color.element.accent)
sessionVerificationScreen(state: .initial)
sessionVerificationScreen(state: .requestingVerification)
sessionVerificationScreen(state: .cancelled)
sessionVerificationScreen(state: .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
sessionVerificationScreen(state: .verified)
}
static func sessionVerificationScreen(state: SessionVerificationStateMachine.State) -> some View {
@@ -192,7 +192,6 @@ struct SettingsScreen_Previews: PreviewProvider {
static var previews: some View {
NavigationStack {
SettingsScreen(context: viewModel.context)
.tint(.element.accent)
}
}
}
@@ -93,14 +93,12 @@ struct TemplateScreen: View {
// MARK: - Previews
struct Template_Previews: PreviewProvider {
static let regularViewModel = TemplateViewModel(promptType: .regular)
static let upgradeViewModel = TemplateViewModel(promptType: .upgrade)
static var previews: some View {
Group {
let regularViewModel = TemplateViewModel(promptType: .regular)
TemplateScreen(context: regularViewModel.context)
let upgradeViewModel = TemplateViewModel(promptType: .upgrade)
TemplateScreen(context: upgradeViewModel.context)
}
.tint(.element.accent)
TemplateScreen(context: regularViewModel.context)
.previewDisplayName("Regular")
TemplateScreen(context: upgradeViewModel.context)
.previewDisplayName("Upgrade")
}
}
+1
View File
@@ -0,0 +1 @@
Fix accent colour not being applied to Alerts etc.