Dark mode tweaks and rebase.

This commit is contained in:
Doug 2022-03-16 16:22:16 +00:00
parent 57d396887b
commit 293647cf03
6 changed files with 39 additions and 15 deletions

View file

@ -23,29 +23,34 @@ struct PrimaryActionButtonStyle: ButtonStyle {
var customColor: Color? = nil
private var fontColor: Color {
// Always white unless disabled with a dark theme.
.white.opacity(theme.isDark && !isEnabled ? 0.3 : 1.0)
}
private var backgroundColor: Color {
customColor ?? theme.colors.accent
}
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.padding(12.0)
.frame(maxWidth: .infinity)
.foregroundColor(.white)
.foregroundColor(fontColor)
.font(theme.fonts.body)
.background(backgroundColor(configuration.isPressed))
.opacity(isEnabled ? 1.0 : 0.6)
.background(backgroundColor.opacity(backgroundOpacity(when: configuration.isPressed)))
.cornerRadius(8.0)
}
func backgroundColor(_ isPressed: Bool) -> Color {
if let customColor = customColor {
return customColor
}
return isPressed ? theme.colors.accent.opacity(0.6) : theme.colors.accent
func backgroundOpacity(when isPressed: Bool) -> CGFloat {
guard isEnabled else { return 0.3 }
return isPressed ? 0.6 : 1.0
}
}
@available(iOS 14.0, *)
struct PrimaryActionButtonStyle_Previews: PreviewProvider {
static var previews: some View {
static var buttons: some View {
Group {
VStack {
Button("Enabled") { }
@ -67,4 +72,11 @@ struct PrimaryActionButtonStyle_Previews: PreviewProvider {
.padding()
}
}
static var previews: some View {
buttons
.theme(.light).preferredColorScheme(.light)
buttons
.theme(.dark).preferredColorScheme(.dark)
}
}

View file

@ -68,7 +68,7 @@ final class OnboardingAvatarCoordinator: Coordinator, Presentable {
onboardingAvatarViewModel = viewModel
onboardingAvatarHostingController = VectorHostingController(rootView: view)
onboardingAvatarHostingController.vc_removeBackTitle()
onboardingAvatarHostingController.enableNavigationBarScrollEdgesAppearance = true
onboardingAvatarHostingController.enableNavigationBarScrollEdgeAppearance = true
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: onboardingAvatarHostingController)
}

View file

@ -140,5 +140,9 @@ struct OnboardingAvatar_Previews: PreviewProvider {
static var previews: some View {
stateRenderer.screenGroup(addNavigation: true)
.navigationViewStyle(.stack)
.theme(.light).preferredColorScheme(.light)
stateRenderer.screenGroup(addNavigation: true)
.navigationViewStyle(.stack)
.theme(.dark).preferredColorScheme(.dark)
}
}

View file

@ -62,8 +62,10 @@ struct OnboardingCongratulationsScreen: View {
/// The main content of the view to be shown in a scroll view.
var mainContent: some View {
VStack(spacing: 62) {
VStack(spacing: 42) {
Image(Asset.Images.onboardingCongratulationsIcon.name)
.resizable()
.frame(width: 90, height: 90)
.accessibilityHidden(true)
VStack(spacing: 8) {
@ -93,7 +95,7 @@ struct OnboardingCongratulationsScreen: View {
VStack(spacing: 12) {
Button { viewModel.send(viewAction: .personaliseProfile) } label: {
Text(VectorL10n.onboardingCongratulationsPersonalizeButton)
.font(theme.fonts.bodySB)
.font(theme.fonts.body)
.foregroundColor(theme.colors.accent)
}
.buttonStyle(PrimaryActionButtonStyle(customColor: .white))
@ -110,7 +112,7 @@ struct OnboardingCongratulationsScreen: View {
var homeButton: some View {
Button { viewModel.send(viewAction: .takeMeHome) } label: {
Text(VectorL10n.onboardingCongratulationsHomeButton)
.font(theme.fonts.bodySB)
.font(theme.fonts.body)
.foregroundColor(theme.colors.accent)
}
.buttonStyle(PrimaryActionButtonStyle(customColor: .white))

View file

@ -53,7 +53,7 @@ final class OnboardingDisplayNameCoordinator: Coordinator, Presentable {
onboardingDisplayNameViewModel = viewModel
onboardingDisplayNameHostingController = VectorHostingController(rootView: view)
onboardingDisplayNameHostingController.vc_removeBackTitle()
onboardingDisplayNameHostingController.enableNavigationBarScrollEdgesAppearance = true
onboardingDisplayNameHostingController.enableNavigationBarScrollEdgeAppearance = true
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: onboardingDisplayNameHostingController)
}

View file

@ -67,6 +67,7 @@ struct OnboardingDisplayNameScreen: View {
Image(Asset.Images.onboardingCongratulationsIcon.name)
.renderingMode(.template)
.foregroundColor(theme.colors.accent)
.background(Circle().foregroundColor(.white).padding(2))
.padding(.bottom, 8)
.accessibilityHidden(true)
@ -122,5 +123,10 @@ struct OnboardingDisplayName_Previews: PreviewProvider {
static let stateRenderer = MockOnboardingDisplayNameScreenState.stateRenderer
static var previews: some View {
stateRenderer.screenGroup(addNavigation: true)
.navigationViewStyle(.stack)
.theme(.light).preferredColorScheme(.light)
stateRenderer.screenGroup(addNavigation: true)
.navigationViewStyle(.stack)
.theme(.dark).preferredColorScheme(.dark)
}
}