Merge Settings into About on iOS (#670)

Closes #669
This commit is contained in:
Davide 2024-10-03 11:25:39 +02:00 committed by GitHub
parent e8d5f2477b
commit 63b0199a39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 69 additions and 33 deletions

View File

@ -35,7 +35,6 @@ struct AboutView: View {
var body: some View { var body: some View {
listView listView
.navigationTitle(Strings.Views.About.title)
} }
} }

View File

@ -31,6 +31,7 @@ import SwiftUI
extension AboutView { extension AboutView {
var listView: some View { var listView: some View {
List { List {
SettingsSection()
Section { Section {
// TODO: #585, donations // TODO: #585, donations
// donateLink // donateLink
@ -45,6 +46,7 @@ extension AboutView {
.withTrailingText(BundleConfiguration.mainVersionString) .withTrailingText(BundleConfiguration.mainVersionString)
} }
} }
.navigationTitle(Strings.Global.settings)
} }
} }

View File

@ -43,6 +43,7 @@ extension AboutView {
Text(BundleConfiguration.mainVersionString) Text(BundleConfiguration.mainVersionString)
.padding(.bottom) .padding(.bottom)
} }
.navigationTitle(Strings.Views.About.title)
} }
} }

View File

@ -58,7 +58,7 @@ struct AppToolbar: ToolbarContent {
} }
} else { } else {
ToolbarItem(placement: .navigation) { ToolbarItem(placement: .navigation) {
moreMenu moreButton
} }
ToolbarItemGroup(placement: .primaryAction) { ToolbarItemGroup(placement: .primaryAction) {
addProfileMenu addProfileMenu
@ -77,12 +77,9 @@ private extension AppToolbar {
) )
} }
var moreMenu: some View { var moreButton: some View {
Menu { Button(action: onAbout) {
settingsButton ThemeImageLabel(Strings.Global.about, .moreDetails)
aboutButton
} label: {
ThemeImage(.moreDetails)
} }
} }

View File

@ -0,0 +1,61 @@
//
// SettingsSection.swift
// Passepartout
//
// Created by Davide De Rosa on 10/3/24.
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
//
// This file is part of Passepartout.
//
// Passepartout is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Passepartout is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
import CommonLibrary
import SwiftUI
struct SettingsSection: View {
@AppStorage(AppPreference.confirmsQuit.key)
private var confirmsQuit = true
@AppStorage(AppPreference.locksInBackground.key)
private var locksInBackground = false
var header: String?
var body: some View {
Section {
#if os(macOS)
confirmsQuitToggle
#endif
#if os(iOS)
lockInBackgroundToggle
#endif
} header: {
header.map(Text.init)
}
}
}
private extension SettingsSection {
var confirmsQuitToggle: some View {
Toggle(Strings.Views.Settings.Rows.confirmQuit, isOn: $confirmsQuit)
}
var lockInBackgroundToggle: some View {
Toggle(Strings.Views.Settings.Rows.lockInBackground, isOn: $locksInBackground)
}
}

View File

@ -23,17 +23,10 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>. // along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
// //
import CommonLibrary
import SwiftUI import SwiftUI
public struct SettingsView: View { public struct SettingsView: View {
@AppStorage(AppPreference.confirmsQuit.key)
private var confirmsQuit = true
@AppStorage(AppPreference.locksInBackground.key)
private var locksInBackground = false
@State @State
private var path = NavigationPath() private var path = NavigationPath()
@ -42,14 +35,7 @@ public struct SettingsView: View {
public var body: some View { public var body: some View {
Form { Form {
Section { SettingsSection()
#if os(macOS)
confirmsQuitToggle
#endif
#if os(iOS)
lockInBackgroundToggle
#endif
}
} }
.themeForm() .themeForm()
.navigationTitle(Strings.Global.settings) .navigationTitle(Strings.Global.settings)
@ -59,13 +45,3 @@ public struct SettingsView: View {
#endif #endif
} }
} }
private extension SettingsView {
var confirmsQuitToggle: some View {
Toggle(Strings.Views.Settings.Rows.confirmQuit, isOn: $confirmsQuit)
}
var lockInBackgroundToggle: some View {
Toggle(Strings.Views.Settings.Rows.lockInBackground, isOn: $locksInBackground)
}
}