Replace Section with .themeSection

Closes #676
This commit is contained in:
Davide De Rosa 2024-10-03 23:31:44 +02:00
parent 211b3b83d3
commit fc834ab367
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
12 changed files with 37 additions and 53 deletions

View File

@ -48,23 +48,21 @@ private extension LinksView {
} }
var supportSection: some View { var supportSection: some View {
Section { Group {
Link(Strings.Views.About.Links.Rows.joinCommunity, destination: constants.websites.subreddit) Link(Strings.Views.About.Links.Rows.joinCommunity, destination: constants.websites.subreddit)
Link(Strings.Views.About.Links.Rows.writeReview, destination: BundleConfiguration.urlForReview) Link(Strings.Views.About.Links.Rows.writeReview, destination: BundleConfiguration.urlForReview)
} header: {
Text(Strings.Views.About.Links.Sections.support)
} }
.themeSection(header: Strings.Views.About.Links.Sections.support)
} }
var webSection: some View { var webSection: some View {
Section { Group {
Link(Strings.Views.About.Links.Rows.homePage, destination: constants.websites.home) Link(Strings.Views.About.Links.Rows.homePage, destination: constants.websites.home)
Link(Strings.Unlocalized.faq, destination: constants.websites.faq) Link(Strings.Unlocalized.faq, destination: constants.websites.faq)
Link(Strings.Views.About.Links.Rows.disclaimer, destination: constants.websites.disclaimer) Link(Strings.Views.About.Links.Rows.disclaimer, destination: constants.websites.disclaimer)
Link(Strings.Views.About.Links.Rows.privacyPolicy, destination: constants.websites.privacyPolicy) Link(Strings.Views.About.Links.Rows.privacyPolicy, destination: constants.websites.privacyPolicy)
} header: {
Text(Strings.Views.About.Links.Sections.web)
} }
.themeSection(header: Strings.Views.About.Links.Sections.web)
} }
} }

View File

@ -32,14 +32,13 @@ extension AboutView {
var listView: some View { var listView: some View {
List { List {
SettingsSectionGroup(profileManager: profileManager) SettingsSectionGroup(profileManager: profileManager)
Section { Group {
// TODO: #585, donations // TODO: #585, donations
// donateLink // donateLink
linksLink linksLink
creditsLink creditsLink
} header: {
Text(Strings.Views.About.Sections.resources)
} }
.themeSection(header: Strings.Views.About.Sections.resources)
Section { Section {
diagnosticsLink diagnosticsLink
Text(Strings.Global.version) Text(Strings.Global.version)

View File

@ -55,12 +55,11 @@ struct ProfileListView: View, ProfileManagerProviding, TunnelInstallationProvidi
if !isSearching { if !isSearching {
headerView(scrollProxy: scrollProxy) headerView(scrollProxy: scrollProxy)
} }
Section { Group {
ForEach(allHeaders, content: profileView) ForEach(allHeaders, content: profileView)
.onDelete(perform: removeProfiles) .onDelete(perform: removeProfiles)
} header: {
Text(Strings.Views.Profiles.Folders.default)
} }
.themeSection(header: Strings.Views.Profiles.Folders.default)
} }
.themeForm() .themeForm()
} }

View File

@ -98,7 +98,7 @@ struct DiagnosticsView: View {
private extension DiagnosticsView { private extension DiagnosticsView {
var liveLogSection: some View { var liveLogSection: some View {
Section { Group {
navLink(Strings.Views.Diagnostics.Rows.app, to: .appDebugLog(title: Strings.Views.Diagnostics.Rows.app)) navLink(Strings.Views.Diagnostics.Rows.app, to: .appDebugLog(title: Strings.Views.Diagnostics.Rows.app))
navLink(Strings.Views.Diagnostics.Rows.tunnel, to: .tunnelDebugLog(title: Strings.Views.Diagnostics.Rows.tunnel, url: nil)) navLink(Strings.Views.Diagnostics.Rows.tunnel, to: .tunnelDebugLog(title: Strings.Views.Diagnostics.Rows.tunnel, url: nil))
@ -107,13 +107,12 @@ private extension DiagnosticsView {
PassepartoutConfiguration.shared.logsAddresses = $0 PassepartoutConfiguration.shared.logsAddresses = $0
PassepartoutConfiguration.shared.logsModules = $0 PassepartoutConfiguration.shared.logsModules = $0
} }
} header: {
Text(Strings.Views.Diagnostics.Sections.live)
} }
.themeSection(header: Strings.Views.Diagnostics.Sections.live)
} }
var tunnelLogsSection: some View { var tunnelLogsSection: some View {
Section { Group {
Button(Strings.Views.Diagnostics.Rows.removeTunnelLogs) { Button(Strings.Views.Diagnostics.Rows.removeTunnelLogs) {
withAnimation(theme.animation(for: .diagnostics), removeTunnelLogs) withAnimation(theme.animation(for: .diagnostics), removeTunnelLogs)
} }
@ -121,23 +120,21 @@ private extension DiagnosticsView {
ForEach(tunnelLogs, id: \.date, content: logView) ForEach(tunnelLogs, id: \.date, content: logView)
.onDelete(perform: removeTunnelLogs) .onDelete(perform: removeTunnelLogs)
} header: {
Text(Strings.Views.Diagnostics.Sections.tunnel)
} }
.themeSection(header: Strings.Views.Diagnostics.Sections.tunnel)
.themeAnimation(on: tunnelLogs, category: .diagnostics) .themeAnimation(on: tunnelLogs, category: .diagnostics)
} }
var openVPNSection: some View { var openVPNSection: some View {
connectionObserver.value(forKey: TunnelEnvironmentKeys.OpenVPN.serverConfiguration) connectionObserver.value(forKey: TunnelEnvironmentKeys.OpenVPN.serverConfiguration)
.map { cfg in .map { cfg in
Section { Group {
NavigationLink(Strings.Views.Diagnostics.Openvpn.Rows.serverConfiguration) { NavigationLink(Strings.Views.Diagnostics.Openvpn.Rows.serverConfiguration) {
OpenVPNView(serverConfiguration: cfg) OpenVPNView(serverConfiguration: cfg)
.navigationTitle(Strings.Views.Diagnostics.Openvpn.Rows.serverConfiguration) .navigationTitle(Strings.Views.Diagnostics.Openvpn.Rows.serverConfiguration)
} }
} header: {
Text(Strings.Unlocalized.openVPN)
} }
.themeSection(header: Strings.Unlocalized.openVPN)
} }
} }

View File

@ -96,11 +96,10 @@ private extension DNSView {
} }
var domainSection: some View { var domainSection: some View {
Section { Group {
ThemeTextField(Strings.Global.domain, text: $draft.domainName ?? "", placeholder: Strings.Unlocalized.Placeholders.hostname) ThemeTextField(Strings.Global.domain, text: $draft.domainName ?? "", placeholder: Strings.Unlocalized.Placeholders.hostname)
} header: {
Text(Strings.Global.domain)
} }
.themeSection(header: Strings.Global.domain)
} }
var serversSection: some View { var serversSection: some View {

View File

@ -64,29 +64,26 @@ private struct HTTPProxyView: View {
private extension HTTPProxyView { private extension HTTPProxyView {
var httpSection: some View { var httpSection: some View {
Section { Group {
ThemeTextField(Strings.Global.address, text: $draft.address, placeholder: Strings.Unlocalized.Placeholders.proxyIPv4Address) ThemeTextField(Strings.Global.address, text: $draft.address, placeholder: Strings.Unlocalized.Placeholders.proxyIPv4Address)
ThemeTextField(Strings.Global.port, text: $draft.port.toString(omittingZero: true), placeholder: Strings.Unlocalized.Placeholders.proxyPort) ThemeTextField(Strings.Global.port, text: $draft.port.toString(omittingZero: true), placeholder: Strings.Unlocalized.Placeholders.proxyPort)
} header: {
Text(Strings.Unlocalized.http)
} }
.themeSection(header: Strings.Unlocalized.http)
} }
var httpsSection: some View { var httpsSection: some View {
Section { Group {
ThemeTextField(Strings.Global.address, text: $draft.secureAddress, placeholder: Strings.Unlocalized.Placeholders.proxyIPv4Address) ThemeTextField(Strings.Global.address, text: $draft.secureAddress, placeholder: Strings.Unlocalized.Placeholders.proxyIPv4Address)
ThemeTextField(Strings.Global.port, text: $draft.securePort.toString(omittingZero: true), placeholder: Strings.Unlocalized.Placeholders.proxyPort) ThemeTextField(Strings.Global.port, text: $draft.securePort.toString(omittingZero: true), placeholder: Strings.Unlocalized.Placeholders.proxyPort)
} header: {
Text(Strings.Unlocalized.https)
} }
.themeSection(header: Strings.Unlocalized.https)
} }
var pacSection: some View { var pacSection: some View {
Section { Group {
ThemeTextField(Strings.Unlocalized.url, text: $draft.pacURLString, placeholder: Strings.Unlocalized.Placeholders.pacURL) ThemeTextField(Strings.Unlocalized.url, text: $draft.pacURLString, placeholder: Strings.Unlocalized.Placeholders.pacURL)
} header: {
Text(Strings.Unlocalized.pac)
} }
.themeSection(header: Strings.Unlocalized.pac)
} }
@ViewBuilder @ViewBuilder

View File

@ -137,7 +137,7 @@ private extension IPView {
} }
var interfaceSection: some View { var interfaceSection: some View {
Section { Group {
ThemeTextField( ThemeTextField(
Strings.Unlocalized.mtu, Strings.Unlocalized.mtu,
text: Binding { text: Binding {
@ -147,9 +147,8 @@ private extension IPView {
}, },
placeholder: Strings.Unlocalized.Placeholders.mtu placeholder: Strings.Unlocalized.Placeholders.mtu
) )
} header: {
Text(Strings.Global.interface)
} }
.themeSection(header: Strings.Global.interface)
} }
} }

View File

@ -136,15 +136,14 @@ private extension OnDemandView {
} }
var networkSection: some View { var networkSection: some View {
Section { Group {
if Utils.hasCellularData() { if Utils.hasCellularData() {
Toggle(Strings.Modules.OnDemand.mobile, isOn: $draft.withMobileNetwork) Toggle(Strings.Modules.OnDemand.mobile, isOn: $draft.withMobileNetwork)
} else if Utils.hasEthernet() { } else if Utils.hasEthernet() {
Toggle(Strings.Modules.OnDemand.ethernet, isOn: $draft.withEthernetNetwork) Toggle(Strings.Modules.OnDemand.ethernet, isOn: $draft.withEthernetNetwork)
} }
} header: {
Text(Strings.Global.networks)
} }
.themeSection(header: Strings.Global.networks)
} }
var wifiSection: some View { var wifiSection: some View {

View File

@ -52,17 +52,17 @@ struct ProfileEditView: View, Routable {
name: $profileEditor.name, name: $profileEditor.name,
placeholder: Strings.Placeholders.Profile.name placeholder: Strings.Placeholders.Profile.name
) )
Section { Group {
ForEach(profileEditor.modules, id: \.id, content: moduleRow) ForEach(profileEditor.modules, id: \.id, content: moduleRow)
.onMove(perform: moveModules) .onMove(perform: moveModules)
.onDelete(perform: removeModules) .onDelete(perform: removeModules)
addModuleButton addModuleButton
} header: {
Text(Strings.Global.modules)
} footer: {
Text(Strings.Views.Profile.ModuleList.Section.footer)
} }
.themeSection(
header: Strings.Global.modules,
footer: Strings.Views.Profile.ModuleList.Section.footer
)
StorageSection( StorageSection(
profileEditor: profileEditor profileEditor: profileEditor
) )

View File

@ -79,11 +79,10 @@ extension Collection {
extension View { extension View {
func moduleSection(for rows: [ModuleRow]?, header: String) -> some View { func moduleSection(for rows: [ModuleRow]?, header: String) -> some View {
rows.map { rows in rows.map { rows in
Section { Group {
ForEach(rows, id: \.self, content: moduleRowView) ForEach(rows, id: \.self, content: moduleRowView)
} header: {
Text(header)
} }
.themeSection(header: header)
} }
} }
} }

View File

@ -46,16 +46,15 @@ struct SettingsSectionGroup: View {
private var isErasingiCloud = false private var isErasingiCloud = false
var body: some View { var body: some View {
Section { Group {
#if os(macOS) #if os(macOS)
confirmsQuitToggle confirmsQuitToggle
#endif #endif
#if os(iOS) #if os(iOS)
lockInBackgroundToggle lockInBackgroundToggle
#endif #endif
} header: {
Text(Strings.Global.general)
} }
.themeSection(header: Strings.Global.general)
Group { Group {
eraseCloudKitButton eraseCloudKitButton
} }

View File

@ -34,13 +34,12 @@ struct NameSection: View {
var body: some View { var body: some View {
debugChanges() debugChanges()
return Section { return Group {
ThemeTextField(Strings.Global.name, text: $name, placeholder: placeholder) ThemeTextField(Strings.Global.name, text: $name, placeholder: placeholder)
.labelsHidden() .labelsHidden()
.themeManualInput() .themeManualInput()
} header: {
Text(Strings.Global.name)
} }
.themeSection(header: Strings.Global.name)
} }
} }