Skip to content

Commit

Permalink
Merge Settings into About on iOS (#670)
Browse files Browse the repository at this point in the history
Closes #669
  • Loading branch information
keeshux authored Oct 3, 2024
1 parent e8d5f24 commit 63b0199
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct AboutView: View {

var body: some View {
listView
.navigationTitle(Strings.Views.About.title)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import SwiftUI
extension AboutView {
var listView: some View {
List {
SettingsSection()
Section {
// TODO: #585, donations
// donateLink
Expand All @@ -45,6 +46,7 @@ extension AboutView {
.withTrailingText(BundleConfiguration.mainVersionString)
}
}
.navigationTitle(Strings.Global.settings)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension AboutView {
Text(BundleConfiguration.mainVersionString)
.padding(.bottom)
}
.navigationTitle(Strings.Views.About.title)
}
}

Expand Down
11 changes: 4 additions & 7 deletions Passepartout/Library/Sources/AppUI/Views/App/AppToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct AppToolbar: ToolbarContent {
}
} else {
ToolbarItem(placement: .navigation) {
moreMenu
moreButton
}
ToolbarItemGroup(placement: .primaryAction) {
addProfileMenu
Expand All @@ -77,12 +77,9 @@ private extension AppToolbar {
)
}

var moreMenu: some View {
Menu {
settingsButton
aboutButton
} label: {
ThemeImage(.moreDetails)
var moreButton: some View {
Button(action: onAbout) {
ThemeImageLabel(Strings.Global.about, .moreDetails)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,10 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//

import CommonLibrary
import SwiftUI

public struct SettingsView: View {

@AppStorage(AppPreference.confirmsQuit.key)
private var confirmsQuit = true

@AppStorage(AppPreference.locksInBackground.key)
private var locksInBackground = false

@State
private var path = NavigationPath()

Expand All @@ -42,14 +35,7 @@ public struct SettingsView: View {

public var body: some View {
Form {
Section {
#if os(macOS)
confirmsQuitToggle
#endif
#if os(iOS)
lockInBackgroundToggle
#endif
}
SettingsSection()
}
.themeForm()
.navigationTitle(Strings.Global.settings)
Expand All @@ -59,13 +45,3 @@ public struct SettingsView: View {
#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)
}
}

0 comments on commit 63b0199

Please sign in to comment.