Skip to content

Commit 2d09a01

Browse files
authored
Backport refactoring of theme sections (#1450)
See #1426
1 parent 32a59fe commit 2d09a01

18 files changed

+128
-158
lines changed

Packages/App/Sources/AppUIMain/Views/Modules/DNSView.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,16 @@ private extension DNSView {
9090
}
9191

9292
var routingSection: some View {
93-
Group {
94-
Picker(Strings.Modules.Dns.routeThroughVpn, selection: $draft.module.routesThroughVPN) {
95-
Text(Strings.Global.Nouns.default)
96-
.tag(nil as Bool?)
97-
Text(Strings.Global.Nouns.yes)
98-
.tag(true as Bool?)
99-
Text(Strings.Global.Nouns.no)
100-
.tag(false as Bool?)
101-
}
102-
.themeRowWithSubtitle(Strings.Modules.Dns.RouteThroughVpn.footer)
93+
Picker(Strings.Modules.Dns.routeThroughVpn, selection: $draft.module.routesThroughVPN) {
94+
Text(Strings.Global.Nouns.default)
95+
.tag(nil as Bool?)
96+
Text(Strings.Global.Nouns.yes)
97+
.tag(true as Bool?)
98+
Text(Strings.Global.Nouns.no)
99+
.tag(false as Bool?)
103100
}
104-
.themeSection(footer: Strings.Modules.Dns.RouteThroughVpn.footer)
101+
.themeContainerWithSingleEntry(
102+
footer: Strings.Modules.Dns.RouteThroughVpn.footer)
105103
}
106104

107105
var domainSection: some View {

Packages/App/Sources/AppUIMain/Views/Modules/IPView.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,12 @@ private extension IPView {
9494

9595
@ViewBuilder
9696
func ipSections(for ip: Binding<IPSettings>, family: Address.Family) -> some View {
97-
Group {
98-
ThemeTextField(
99-
Strings.Global.Nouns.address,
100-
text: $subnets[family] ?? "",
101-
placeholder: Strings.Unlocalized.Placeholders.ipDestination(forFamily: family)
102-
)
103-
.themeRowWithSubtitle(Strings.Modules.Ip.Address.footer)
104-
}
105-
.themeSection(
97+
ThemeTextField(
98+
Strings.Global.Nouns.address,
99+
text: $subnets[family] ?? "",
100+
placeholder: Strings.Unlocalized.Placeholders.ipDestination(forFamily: family)
101+
)
102+
.themeContainerWithSingleEntry(
106103
header: family.localizedDescription,
107104
footer: Strings.Modules.Ip.Address.footer
108105
)

Packages/App/Sources/AppUIMain/Views/Modules/OnDemandView.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private extension OnDemandView {
9393
)
9494
}
9595
}
96-
.themeSectionWithSingleRow(footer: policyFooterDescription)
96+
.themeContainerWithSingleEntry(footer: policyFooterDescription)
9797
}
9898

9999
var policyFooterDescription: String {
@@ -122,8 +122,7 @@ private extension OnDemandView {
122122
}
123123
.themeSection(
124124
header: Strings.Global.Nouns.networks,
125-
footer: Strings.Modules.OnDemand.Networks.footer,
126-
forcesFooter: true
125+
footer: Strings.Modules.OnDemand.Networks.footer
127126
)
128127
}
129128

@@ -233,17 +232,18 @@ private extension OnDemandView {
233232
"Two": false,
234233
"Three": false
235234
]
236-
return module.preview {
237-
OnDemandView(
238-
draft: $1[$0],
239-
parameters: .init(
240-
registry: Registry(),
241-
editor: $1,
242-
impl: nil
243-
),
244-
observer: MockWifi()
245-
)
246-
}
235+
return module.preview()
236+
// return module.preview {
237+
// OnDemandView(
238+
// draft: $1[$0],
239+
// parameters: .init(
240+
// registry: Registry(),
241+
// editor: $1,
242+
// impl: nil
243+
// ),
244+
// observer: MockWifi()
245+
// )
246+
// }
247247
}
248248

249249
private class MockWifi: WifiObserver {

Packages/App/Sources/AppUIMain/Views/Modules/Provider/ProviderView+OpenVPN.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private extension ProviderView.OpenVPNCredentialsView {
7979
.onSubmit(saveCredentials)
8080
}
8181
}
82-
.themeSection(footer: guidanceString, forcesFooter: true)
82+
.themeSection(footer: guidanceString)
8383
}
8484

8585
var guidanceSection: some View {

Packages/App/Sources/AppUIMain/Views/Profile/ProfileBehaviorSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct ProfileBehaviorSection: View {
3232

3333
var body: some View {
3434
keepAliveToggle
35-
.themeSectionWithSingleRow(
35+
.themeContainerWithSingleEntry(
3636
header: Strings.Modules.General.Sections.Behavior.header,
3737
footer: Strings.Modules.General.Rows.KeepAliveOnSleep.footer
3838
)

Packages/App/Sources/AppUIMain/Views/Profile/ProfileStorageSection.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,15 @@ struct ProfileStorageSection: View {
4343
debugChanges()
4444
return Group {
4545
sharingToggle
46-
.themeSectionWithSingleRow(
46+
.themeContainerEntry(
4747
header: header,
48-
footer: sharingDescription
48+
subtitle: sharingDescription
4949
)
50-
51-
Group {
52-
tvToggle
53-
.themeRowWithSubtitle(tvDescription)
54-
}
55-
.themeSection(footer: tvDescription)
56-
.disabled(!profileEditor.isShared)
50+
tvToggle
51+
.themeContainerEntry(subtitle: tvDescription)
52+
.disabled(!profileEditor.isShared)
5753
}
54+
.themeContainer(header: header)
5855
}
5956
}
6057

Packages/App/Sources/AppUIMain/Views/Profile/macOS/SendToTVFormView+macOS.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private extension SendToTVFormView {
6060
Strings.Global.Nouns.profiles,
6161
Strings.Views.Tv.Profiles.importLocal,
6262
Strings.Unlocalized.appleTV
63-
), forcesFooter: true)
63+
))
6464
}
6565

6666
var passcodeSection: some View {

Packages/App/Sources/UILibrary/Views/Modules/OpenVPNView+Credentials.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,18 @@ private extension OpenVPNCredentialsGroup {
100100
)
101101
}
102102
}
103-
.themeRowWithSubtitle(interactiveFooter)
103+
.themeContainerEntry(subtitle: Strings.Modules.Openvpn.Credentials.Interactive.footer)
104104

105105
if distributionTarget.supportsPaidFeatures && draft.module.isInteractive && !isAuthenticating {
106106
Picker(Strings.Unlocalized.otp, selection: $builder.otpMethod) {
107107
ForEach(otpMethods, id: \.self) {
108108
Text($0.localizedDescription(style: .entity))
109109
}
110110
}
111+
.themeContainerEntry(subtitle: builder.otpMethod.localizedDescription(style: .approachDescription).nilIfEmpty)
111112
}
112113
}
113-
.themeSection(footer: interactiveFooter)
114-
}
115-
116-
var interactiveFooter: String? {
117-
if draft.module.isInteractive {
118-
return [
119-
Strings.Modules.Openvpn.Credentials.Interactive.footer,
120-
builder.otpMethod.localizedDescription(style: .approachDescription)
121-
].joined(separator: " ")
122-
}
123-
return nil
114+
.themeContainer()
124115
}
125116

126117
var inputSection: some View {
@@ -133,7 +124,7 @@ private extension OpenVPNCredentialsGroup {
133124
otpField
134125
}
135126
}
136-
.themeSection(footer: inputFooter, forcesFooter: true)
127+
.themeSection(footer: inputFooter)
137128
}
138129

139130
var inputFooter: String? {

Packages/App/Sources/UILibrary/Views/Paywall/PaywallView.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ private extension PaywallView {
131131
}
132132
.themeSection(
133133
header: Strings.Views.Paywall.Sections.Products.header,
134-
footer: Strings.Views.Paywall.Sections.Products.footer,
135-
forcesFooter: true
134+
footer: Strings.Views.Paywall.Sections.Products.footer
136135
)
137136
}
138137
}
@@ -169,8 +168,7 @@ private extension PaywallView {
169168
footer: [
170169
Strings.Views.Paywall.Sections.FullProducts.footer,
171170
Strings.Views.Paywall.Sections.Products.footer
172-
].joined(separator: " "),
173-
forcesFooter: true
171+
].joined(separator: " ")
174172
)
175173
}
176174
}
@@ -189,10 +187,10 @@ private extension PaywallView {
189187

190188
var restoreView: some View {
191189
RestorePurchasesButton(errorHandler: errorHandler)
192-
.themeSectionWithSingleRow(
190+
.themeContainerWithSingleEntry(
193191
header: Strings.Views.Paywall.Sections.Restore.header,
194192
footer: Strings.Views.Paywall.Sections.Restore.footer,
195-
above: true
193+
isAction: true
196194
)
197195
}
198196

Packages/App/Sources/UILibrary/Views/Preferences/PreferencesView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,34 +109,34 @@ private extension PreferencesView {
109109
#if os(iOS)
110110
var lockInBackgroundSection: some View {
111111
Toggle(Strings.Views.Preferences.locksInBackground, isOn: $locksInBackground)
112-
.themeSectionWithSingleRow(footer: Strings.Views.Preferences.LocksInBackground.footer)
112+
.themeContainerEntry(subtitle: Strings.Views.Preferences.LocksInBackground.footer)
113113
}
114114

115115
#elseif os(macOS)
116116
var launchesOnLoginSection: some View {
117117
Toggle(Strings.Views.Preferences.launchesOnLogin, isOn: $settings.launchesOnLogin)
118-
.themeSectionWithSingleRow(footer: Strings.Views.Preferences.LaunchesOnLogin.footer)
118+
.themeContainerEntry(subtitle: Strings.Views.Preferences.LaunchesOnLogin.footer)
119119
}
120120

121121
var keepsInMenuSection: some View {
122122
Toggle(Strings.Views.Preferences.keepsInMenu, isOn: $settings.keepsInMenu)
123-
.themeSectionWithSingleRow(footer: Strings.Views.Preferences.KeepsInMenu.footer)
123+
.themeContainerEntry(subtitle: Strings.Views.Preferences.KeepsInMenu.footer)
124124
}
125125
#endif
126126

127127
var pinActiveProfileSection: some View {
128128
PinActiveProfileToggle()
129-
.themeSectionWithSingleRow(footer: Strings.Views.Preferences.PinsActiveProfile.footer)
129+
.themeContainerEntry(subtitle: Strings.Views.Preferences.PinsActiveProfile.footer)
130130
}
131131

132132
var dnsFallsBackSection: some View {
133133
Toggle(Strings.Views.Preferences.dnsFallsBack, isOn: $dnsFallsBack)
134-
.themeSectionWithSingleRow(footer: Strings.Views.Preferences.DnsFallsBack.footer)
134+
.themeContainerEntry(subtitle: Strings.Views.Preferences.DnsFallsBack.footer)
135135
}
136136

137137
var enablesPurchasesSection: some View {
138138
Toggle(Strings.Views.Preferences.enablesIap, isOn: $iapManager.isEnabled)
139-
.themeRowWithSubtitle(Strings.Views.Preferences.EnablesIap.footer)
139+
.themeContainerEntry(subtitle: Strings.Views.Preferences.EnablesIap.footer)
140140
}
141141

142142
var eraseCloudKitSection: some View {
@@ -159,10 +159,10 @@ private extension PreferencesView {
159159
isErasingiCloud = false
160160
}
161161
}
162-
.themeSectionWithSingleRow(
162+
.themeContainerWithSingleEntry(
163163
header: Strings.Unlocalized.iCloud,
164164
footer: Strings.Views.Preferences.EraseIcloud.footer,
165-
above: true
165+
isAction: true
166166
)
167167
.disabled(isErasingiCloud)
168168
}

0 commit comments

Comments
 (0)