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 {
Section {
Group {
Link(Strings.Views.About.Links.Rows.joinCommunity, destination: constants.websites.subreddit)
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 {
Section {
Group {
Link(Strings.Views.About.Links.Rows.homePage, destination: constants.websites.home)
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.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 {
List {
SettingsSectionGroup(profileManager: profileManager)
Section {
Group {
// TODO: #585, donations
// donateLink
linksLink
creditsLink
} header: {
Text(Strings.Views.About.Sections.resources)
}
.themeSection(header: Strings.Views.About.Sections.resources)
Section {
diagnosticsLink
Text(Strings.Global.version)

View File

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

View File

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

View File

@ -64,29 +64,26 @@ private struct HTTPProxyView: View {
private extension HTTPProxyView {
var httpSection: some View {
Section {
Group {
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)
} header: {
Text(Strings.Unlocalized.http)
}
.themeSection(header: Strings.Unlocalized.http)
}
var httpsSection: some View {
Section {
Group {
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)
} header: {
Text(Strings.Unlocalized.https)
}
.themeSection(header: Strings.Unlocalized.https)
}
var pacSection: some View {
Section {
Group {
ThemeTextField(Strings.Unlocalized.url, text: $draft.pacURLString, placeholder: Strings.Unlocalized.Placeholders.pacURL)
} header: {
Text(Strings.Unlocalized.pac)
}
.themeSection(header: Strings.Unlocalized.pac)
}
@ViewBuilder

View File

@ -137,7 +137,7 @@ private extension IPView {
}
var interfaceSection: some View {
Section {
Group {
ThemeTextField(
Strings.Unlocalized.mtu,
text: Binding {
@ -147,9 +147,8 @@ private extension IPView {
},
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 {
Section {
Group {
if Utils.hasCellularData() {
Toggle(Strings.Modules.OnDemand.mobile, isOn: $draft.withMobileNetwork)
} else if Utils.hasEthernet() {
Toggle(Strings.Modules.OnDemand.ethernet, isOn: $draft.withEthernetNetwork)
}
} header: {
Text(Strings.Global.networks)
}
.themeSection(header: Strings.Global.networks)
}
var wifiSection: some View {

View File

@ -52,17 +52,17 @@ struct ProfileEditView: View, Routable {
name: $profileEditor.name,
placeholder: Strings.Placeholders.Profile.name
)
Section {
Group {
ForEach(profileEditor.modules, id: \.id, content: moduleRow)
.onMove(perform: moveModules)
.onDelete(perform: removeModules)
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(
profileEditor: profileEditor
)

View File

@ -79,11 +79,10 @@ extension Collection {
extension View {
func moduleSection(for rows: [ModuleRow]?, header: String) -> some View {
rows.map { rows in
Section {
Group {
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
var body: some View {
Section {
Group {
#if os(macOS)
confirmsQuitToggle
#endif
#if os(iOS)
lockInBackgroundToggle
#endif
} header: {
Text(Strings.Global.general)
}
.themeSection(header: Strings.Global.general)
Group {
eraseCloudKitButton
}

View File

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