Refactor theme section and some phrases

This commit is contained in:
Davide De Rosa 2024-10-03 17:03:53 +02:00
parent 0917e47ea3
commit 429e79cd3a
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
9 changed files with 19 additions and 15 deletions

View File

@ -372,6 +372,8 @@ public enum Strings {
public enum Interactive { public enum Interactive {
/// On-demand will be disabled. /// On-demand will be disabled.
public static let footer = Strings.tr("Localizable", "modules.openvpn.credentials.interactive.footer", fallback: "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 OtpMethod {
public enum Approach { 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 { public enum Wireguard {
/// Allowed IPs /// Allowed IPs

View File

@ -179,7 +179,6 @@
"modules.on_demand.ethernet" = "Ethernet"; "modules.on_demand.ethernet" = "Ethernet";
"modules.on_demand.ssid.add" = "Add SSID"; "modules.on_demand.ssid.add" = "Add SSID";
"modules.openvpn.purchase.interactive" = "Log in interactively";
"modules.openvpn.pull" = "Pull"; "modules.openvpn.pull" = "Pull";
"modules.openvpn.redirect_gateway" = "Redirect gateway"; "modules.openvpn.redirect_gateway" = "Redirect gateway";
"modules.openvpn.credentials" = "Credentials"; "modules.openvpn.credentials" = "Credentials";
@ -196,6 +195,7 @@
"modules.openvpn.randomize_endpoint" = "Randomize endpoint"; "modules.openvpn.randomize_endpoint" = "Randomize endpoint";
"modules.openvpn.randomize_hostname" = "Randomize hostname"; "modules.openvpn.randomize_hostname" = "Randomize hostname";
"modules.openvpn.credentials.interactive" = "Interactive"; "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.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.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."; "modules.openvpn.credentials.otp_method.approach.encode" = "The OTP will be encoded in Base64 with the password.";

View File

@ -113,7 +113,7 @@ private extension OnDemandView {
Text($0.localizedDescription) Text($0.localizedDescription)
} }
} }
.themeSectionWithFooter(policyFooterDescription) .themeSection(footer: policyFooterDescription)
} }
var policyFooterDescription: String { var policyFooterDescription: String {

View File

@ -89,7 +89,7 @@ private extension OpenVPNView.CredentialsView {
var restrictedArea: some View { var restrictedArea: some View {
switch iapManager.paywallReason(forFeature: .interactiveLogin) { switch iapManager.paywallReason(forFeature: .interactiveLogin) {
case .purchase(let appFeature): case .purchase(let appFeature):
Button(Strings.Modules.Openvpn.Purchase.interactive) { Button(Strings.Modules.Openvpn.Credentials.Interactive.purchase) {
paywallReason = .purchase(appFeature) paywallReason = .purchase(appFeature)
} }
@ -115,7 +115,7 @@ private extension OpenVPNView.CredentialsView {
} }
} }
} }
.themeSectionWithFooter(interactiveFooter) .themeSection(footer: interactiveFooter)
} }
var interactiveFooter: String? { var interactiveFooter: String? {
@ -140,7 +140,7 @@ private extension OpenVPNView.CredentialsView {
.textContentType(.oneTimeCode) .textContentType(.oneTimeCode)
} }
} }
.themeSectionWithFooter(inputFooter) .themeSection(footer: inputFooter)
} }
var inputFooter: String? { var inputFooter: String? {

View File

@ -39,7 +39,7 @@ struct ProfileGeneralView: View {
placeholder: Strings.Placeholders.Profile.name placeholder: Strings.Placeholders.Profile.name
) )
EmptyView() EmptyView()
.themeSectionWithFooter(Strings.Views.Profile.ModuleList.Section.footer) .themeSection(footer: Strings.Views.Profile.ModuleList.Section.footer)
StorageSection( StorageSection(
uuid: profileEditor.id uuid: profileEditor.id
) )

View File

@ -187,7 +187,9 @@ struct ThemeAnimationModifier<T>: ViewModifier where T: Equatable {
} }
} }
struct ThemeSectionWithFooterModifier: ViewModifier { struct ThemeSectionWithHeaderFooterModifier: ViewModifier {
let header: String?
let footer: String? let footer: String?
} }

View File

@ -68,10 +68,12 @@ extension ThemeManualInputModifier {
} }
} }
extension ThemeSectionWithFooterModifier { extension ThemeSectionWithHeaderFooterModifier {
func body(content: Content) -> some View { func body(content: Content) -> some View {
Section { Section {
content content
} header: {
header.map(Text.init)
} footer: { } footer: {
footer.map(Text.init) footer.map(Text.init)
} }

View File

@ -70,7 +70,7 @@ extension ThemeManualInputModifier {
} }
} }
extension ThemeSectionWithFooterModifier { extension ThemeSectionWithHeaderFooterModifier {
@ViewBuilder @ViewBuilder
func body(content: Content) -> some View { func body(content: Content) -> some View {
@ -82,6 +82,8 @@ extension ThemeSectionWithFooterModifier {
.font(.callout) .font(.callout)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }
} header: {
header.map(Text.init)
} }
} }
} }

View File

@ -189,8 +189,8 @@ extension View {
modifier(ThemeAnimationModifier(value: value, category: category)) modifier(ThemeAnimationModifier(value: value, category: category))
} }
public func themeSectionWithFooter(_ footer: String?) -> some View { public func themeSection(header: String? = nil, footer: String? = nil) -> some View {
modifier(ThemeSectionWithFooterModifier(footer: footer)) modifier(ThemeSectionWithHeaderFooterModifier(header: header, footer: footer))
} }
public func themeGridHeader(title: String?) -> some View { public func themeGridHeader(title: String?) -> some View {