From 44c8f21628518e010e1f4dbd7ca1bf728e6f8da2 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 19 Oct 2023 10:16:25 +1100 Subject: [PATCH] polish qrcode theme color --- LibSession-Util | 2 +- Session/Settings/RecoveryPasswordView.swift | 15 ++++++----- Session/Utilities/QRCode.swift | 29 ++++++++++++++++----- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/LibSession-Util b/LibSession-Util index e3ccf29db..577feacbf 160000 --- a/LibSession-Util +++ b/LibSession-Util @@ -1 +1 @@ -Subproject commit e3ccf29db08aaf0b9bb6bbe72ae5967cd183a78d +Subproject commit 577feacbfe4a523c5dc743335e187bf11062120c diff --git a/Session/Settings/RecoveryPasswordView.swift b/Session/Settings/RecoveryPasswordView.swift index d6cb05f1f..69dc305e7 100644 --- a/Session/Settings/RecoveryPasswordView.swift +++ b/Session/Settings/RecoveryPasswordView.swift @@ -13,8 +13,9 @@ struct RecoveryPasswordView: View { private let mnemonic: String private let flow: Onboarding.Flow - static let cornerRadius: CGFloat = 13 + static private let cornerRadius: CGFloat = 13 static private let backgroundCornerRadius: CGFloat = 17 + static private let buttonWidth: CGFloat = 120 public init(flow: Onboarding.Flow) throws { self.mnemonic = try Identity.mnemonic() @@ -71,11 +72,13 @@ struct RecoveryPasswordView: View { .font(.system(size: Values.smallFontSize)) .foregroundColor(themeColor: .textPrimary) .padding(.bottom, Values.mediumSpacing) + .fixedSize(horizontal: false, vertical: true) Text("recovery_password_explanation_2".localized()) .font(.system(size: Values.smallFontSize)) .foregroundColor(themeColor: .textPrimary) .padding(.bottom, Values.mediumSpacing) + .fixedSize(horizontal: false, vertical: true) if self.showQRCode { QRCodeView( @@ -95,7 +98,7 @@ struct RecoveryPasswordView: View { .font(.system(size: Values.verySmallFontSize)) .foregroundColor(themeColor: .textPrimary) .frame( - maxWidth: 120, + maxWidth: Self.buttonWidth, maxHeight: Values.mediumSmallButtonHeight, alignment: .center ) @@ -142,8 +145,8 @@ struct RecoveryPasswordView: View { .font(.system(size: Values.verySmallFontSize)) .foregroundColor(themeColor: .textPrimary) .frame( - maxWidth: .infinity, - maxHeight: Values.mediumSmallButtonHeight, + maxWidth: Self.buttonWidth, + minHeight: Values.mediumSmallButtonHeight, alignment: .center ) .overlay( @@ -163,8 +166,8 @@ struct RecoveryPasswordView: View { .font(.system(size: Values.verySmallFontSize)) .foregroundColor(themeColor: .textPrimary) .frame( - maxWidth: .infinity, - maxHeight: Values.mediumSmallButtonHeight, + maxWidth: Self.buttonWidth, + minHeight: Values.mediumSmallButtonHeight, alignment: .center ) .overlay( diff --git a/Session/Utilities/QRCode.swift b/Session/Utilities/QRCode.swift index 5086f3baa..9801e2724 100644 --- a/Session/Utilities/QRCode.swift +++ b/Session/Utilities/QRCode.swift @@ -51,18 +51,35 @@ struct QRCodeView: View { let hasBackground: Bool let hasLogo: Bool let themeStyle: UIUserInterfaceStyle + var backgroundThemeColor: ThemeValue { + switch themeStyle { + case .light: + return .backgroundSecondary + default: + return .textPrimary + } + } + var qrCodeThemeColor: ThemeValue { + switch themeStyle { + case .light: + return .textPrimary + default: + return .backgroundPrimary + } + } static private var cornerRadius: CGFloat = 10 + static private var logoSize: CGFloat = 66 var body: some View { ZStack(alignment: .center) { RoundedRectangle(cornerRadius: Self.cornerRadius) - .fill(themeColor: .textPrimary) + .fill(themeColor: backgroundThemeColor) Image(uiImage: QRCode.generate(for: string, hasBackground: hasBackground)) .resizable() .renderingMode(.template) - .foregroundColor(themeColor: .backgroundPrimary) + .foregroundColor(themeColor: qrCodeThemeColor) .scaledToFit() .frame( maxWidth: .infinity, @@ -73,12 +90,12 @@ struct QRCodeView: View { if hasLogo { ZStack(alignment: .center) { Rectangle() - .fill(themeColor: .textPrimary) + .fill(themeColor: backgroundThemeColor) Image("SessionShieldFilled") .resizable() .renderingMode(.template) - .foregroundColor(themeColor: .backgroundPrimary) + .foregroundColor(themeColor: qrCodeThemeColor) .scaledToFit() .frame( maxWidth: .infinity, @@ -87,8 +104,8 @@ struct QRCodeView: View { .padding(.all, 4) } .frame( - width: 66, - height: 66 + width: Self.logoSize, + height: Self.logoSize ) } }