From 429e79cd3a4f3573293975410d651289e24c212d Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 3 Oct 2024 17:03:53 +0200 Subject: [PATCH] Refactor theme section and some phrases --- .../Library/Sources/AppUI/L10n/SwiftGen+Strings.swift | 6 ++---- .../Sources/AppUI/Resources/en.lproj/Localizable.strings | 2 +- .../Library/Sources/AppUI/Views/Modules/OnDemandView.swift | 2 +- .../AppUI/Views/Modules/OpenVPNView+Credentials.swift | 6 +++--- .../Views/Profile/macOS/ProfileGeneralView+macOS.swift | 2 +- .../Library/Sources/AppUI/Views/Theme/Theme+UI.swift | 4 +++- .../Library/Sources/AppUI/Views/Theme/Theme+iOS.swift | 4 +++- .../Library/Sources/AppUI/Views/Theme/Theme+macOS.swift | 4 +++- Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift | 4 ++-- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift b/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift index bbaa83fd..14b12f24 100644 --- a/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift +++ b/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift @@ -372,6 +372,8 @@ public enum Strings { public enum Interactive { /// On-demand will be disabled. public static let footer = Strings.tr("Localizable", "modules.openvpn.credentials.interactive.footer", fallback: "On-demand will be disabled.") + /// Log in interactively + public static let purchase = Strings.tr("Localizable", "modules.openvpn.credentials.interactive.purchase", fallback: "Log in interactively") } public enum OtpMethod { public enum Approach { @@ -382,10 +384,6 @@ public enum Strings { } } } - public enum Purchase { - /// Log in interactively - public static let interactive = Strings.tr("Localizable", "modules.openvpn.purchase.interactive", fallback: "Log in interactively") - } } public enum Wireguard { /// Allowed IPs diff --git a/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings b/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings index 44301db9..57ebda04 100644 --- a/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings @@ -179,7 +179,6 @@ "modules.on_demand.ethernet" = "Ethernet"; "modules.on_demand.ssid.add" = "Add SSID"; -"modules.openvpn.purchase.interactive" = "Log in interactively"; "modules.openvpn.pull" = "Pull"; "modules.openvpn.redirect_gateway" = "Redirect gateway"; "modules.openvpn.credentials" = "Credentials"; @@ -196,6 +195,7 @@ "modules.openvpn.randomize_endpoint" = "Randomize endpoint"; "modules.openvpn.randomize_hostname" = "Randomize hostname"; "modules.openvpn.credentials.interactive" = "Interactive"; +"modules.openvpn.credentials.interactive.purchase" = "Log in interactively"; "modules.openvpn.credentials.interactive.footer" = "On-demand will be disabled."; "modules.openvpn.credentials.otp_method.approach.append" = "The OTP will be appended to the password."; "modules.openvpn.credentials.otp_method.approach.encode" = "The OTP will be encoded in Base64 with the password."; diff --git a/Passepartout/Library/Sources/AppUI/Views/Modules/OnDemandView.swift b/Passepartout/Library/Sources/AppUI/Views/Modules/OnDemandView.swift index 69cfa526..84813d15 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Modules/OnDemandView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Modules/OnDemandView.swift @@ -113,7 +113,7 @@ private extension OnDemandView { Text($0.localizedDescription) } } - .themeSectionWithFooter(policyFooterDescription) + .themeSection(footer: policyFooterDescription) } var policyFooterDescription: String { diff --git a/Passepartout/Library/Sources/AppUI/Views/Modules/OpenVPNView+Credentials.swift b/Passepartout/Library/Sources/AppUI/Views/Modules/OpenVPNView+Credentials.swift index 0593dba8..46ec1d84 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Modules/OpenVPNView+Credentials.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Modules/OpenVPNView+Credentials.swift @@ -89,7 +89,7 @@ private extension OpenVPNView.CredentialsView { var restrictedArea: some View { switch iapManager.paywallReason(forFeature: .interactiveLogin) { case .purchase(let appFeature): - Button(Strings.Modules.Openvpn.Purchase.interactive) { + Button(Strings.Modules.Openvpn.Credentials.Interactive.purchase) { paywallReason = .purchase(appFeature) } @@ -115,7 +115,7 @@ private extension OpenVPNView.CredentialsView { } } } - .themeSectionWithFooter(interactiveFooter) + .themeSection(footer: interactiveFooter) } var interactiveFooter: String? { @@ -140,7 +140,7 @@ private extension OpenVPNView.CredentialsView { .textContentType(.oneTimeCode) } } - .themeSectionWithFooter(inputFooter) + .themeSection(footer: inputFooter) } var inputFooter: String? { diff --git a/Passepartout/Library/Sources/AppUI/Views/Profile/macOS/ProfileGeneralView+macOS.swift b/Passepartout/Library/Sources/AppUI/Views/Profile/macOS/ProfileGeneralView+macOS.swift index 8a99e748..11311ae1 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Profile/macOS/ProfileGeneralView+macOS.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Profile/macOS/ProfileGeneralView+macOS.swift @@ -39,7 +39,7 @@ struct ProfileGeneralView: View { placeholder: Strings.Placeholders.Profile.name ) EmptyView() - .themeSectionWithFooter(Strings.Views.Profile.ModuleList.Section.footer) + .themeSection(footer: Strings.Views.Profile.ModuleList.Section.footer) StorageSection( uuid: profileEditor.id ) diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift index 6475fe6d..eb2cca29 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift @@ -187,7 +187,9 @@ struct ThemeAnimationModifier: ViewModifier where T: Equatable { } } -struct ThemeSectionWithFooterModifier: ViewModifier { +struct ThemeSectionWithHeaderFooterModifier: ViewModifier { + let header: String? + let footer: String? } diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+iOS.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+iOS.swift index 378fb622..b1ac4ad2 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+iOS.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+iOS.swift @@ -68,10 +68,12 @@ extension ThemeManualInputModifier { } } -extension ThemeSectionWithFooterModifier { +extension ThemeSectionWithHeaderFooterModifier { func body(content: Content) -> some View { Section { content + } header: { + header.map(Text.init) } footer: { footer.map(Text.init) } diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+macOS.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+macOS.swift index ff9ee586..9797713b 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+macOS.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+macOS.swift @@ -70,7 +70,7 @@ extension ThemeManualInputModifier { } } -extension ThemeSectionWithFooterModifier { +extension ThemeSectionWithHeaderFooterModifier { @ViewBuilder func body(content: Content) -> some View { @@ -82,6 +82,8 @@ extension ThemeSectionWithFooterModifier { .font(.callout) .frame(maxWidth: .infinity, alignment: .leading) } + } header: { + header.map(Text.init) } } } diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift index 9f382dd4..96fb442f 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift @@ -189,8 +189,8 @@ extension View { modifier(ThemeAnimationModifier(value: value, category: category)) } - public func themeSectionWithFooter(_ footer: String?) -> some View { - modifier(ThemeSectionWithFooterModifier(footer: footer)) + public func themeSection(header: String? = nil, footer: String? = nil) -> some View { + modifier(ThemeSectionWithHeaderFooterModifier(header: header, footer: footer)) } public func themeGridHeader(title: String?) -> some View {