Skip to content

Commit

Permalink
#34 Set background colors explicitly on remaining screens
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailgulek committed Jun 23, 2022
1 parent 1c30dcf commit 9c6680d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
19 changes: 12 additions & 7 deletions ElementX/Sources/Screens/BugReport/View/BugReport.swift
Expand Up @@ -50,6 +50,7 @@ struct BugReport: View {
}
.navigationTitle(ElementL10n.titleActivityBugReport)
}
.background(Color.element.background, ignoresSafeAreaEdges: .all)
}

/// The main content of the view to be shown in a scroll view.
Expand All @@ -59,11 +60,11 @@ struct BugReport: View {
.accessibilityIdentifier("reportBugDescription")
ZStack(alignment: .topLeading) {
RoundedRectangle(cornerRadius: 8, style: .continuous)
.fill(Color(UIColor.secondarySystemBackground))
.fill(Color.element.system)

if context.reportText.isEmpty {
Text(ElementL10n.sendBugReportPlaceholder)
.foregroundColor(Color(UIColor.placeholderText))
.foregroundColor(Color.element.secondaryContent)
.padding(.horizontal, 8)
.padding(.vertical, 12)
}
Expand Down Expand Up @@ -131,10 +132,14 @@ struct BugReport: View {

struct BugReport_Previews: PreviewProvider {
static var previews: some View {
Group {
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: Asset.Images.appLogo.image)
BugReport(context: viewModel.context)
.previewInterfaceOrientation(.portrait)
}
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: Asset.Images.appLogo.image)
BugReport(context: viewModel.context)
.previewInterfaceOrientation(.portrait)
}
}
9 changes: 9 additions & 0 deletions ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
Expand Up @@ -34,6 +34,7 @@ struct HomeScreen: View {
Section("Rooms") {
ForEach(context.viewState.unencryptedRooms) { room in
RoomCell(room: room, context: context)
.listRowBackground(Color.clear)
}

let other = context.viewState.encryptedRooms
Expand All @@ -44,6 +45,7 @@ struct HomeScreen: View {
RoomCell(room: room, context: context)
}
}
.listRowBackground(Color.clear)
}
}

Expand All @@ -60,6 +62,7 @@ struct HomeScreen: View {
RoomCell(room: room, context: context)
}
}
.listRowBackground(Color.clear)
}
}
}
Expand All @@ -69,6 +72,7 @@ struct HomeScreen: View {

Spacer()
}
.background(Color.element.background)
.ignoresSafeArea(.all, edges: .bottom)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand Down Expand Up @@ -169,6 +173,11 @@ struct RoomCell: View {

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

static var body: some View {
let viewModel = HomeScreenViewModel(attributedStringBuilder: AttributedStringBuilder())

let eventBrief = EventBrief(eventId: "id",
Expand Down
21 changes: 16 additions & 5 deletions ElementX/Sources/Screens/Settings/View/Settings.swift
Expand Up @@ -34,13 +34,15 @@ struct Settings: View {
Button { context.send(viewAction: .reportBug) } label: {
Text(ElementL10n.sendBugReport)
}
.listRowBackground(Color.element.system)
.foregroundColor(Color.element.primaryContent)
.accessibilityIdentifier("reportBugButton")

if BuildSettings.settingsCrashButtonVisible {
Button("Crash the app",
role: .destructive) { context.send(viewAction: .crash)
}
.listRowBackground(Color.element.system)
.accessibilityIdentifier("crashButton")
}
}
Expand All @@ -49,6 +51,7 @@ struct Settings: View {
Button { showingLogoutConfirmation = true } label: {
Text(ElementL10n.actionSignOut)
}
.listRowBackground(Color.element.system)
.frame(maxWidth: .infinity)
.foregroundColor(Color.element.primaryContent)
.accessibilityIdentifier("logoutButton")
Expand All @@ -63,7 +66,11 @@ struct Settings: View {
versionText
}
}
.introspectTableView(customize: { tableView in
tableView.backgroundColor = .clear
})
.navigationTitle(ElementL10n.settings)
.background(Color.element.background, ignoresSafeAreaEdges: .all)
}

var versionText: some View {
Expand All @@ -75,10 +82,14 @@ struct Settings: View {

struct Settings_Previews: PreviewProvider {
static var previews: some View {
Group {
let viewModel = SettingsViewModel()
Settings(context: viewModel.context)
.previewInterfaceOrientation(.portrait)
}
body.preferredColorScheme(.light)
body.preferredColorScheme(.dark)
}

@ViewBuilder
static var body: some View {
let viewModel = SettingsViewModel()
Settings(context: viewModel.context)
.previewInterfaceOrientation(.portrait)
}
}

0 comments on commit 9c6680d

Please sign in to comment.