Unify macOS toggles in menu/settings (#864)

Show in both:

- Launch on login
- Keep in menu bar
This commit is contained in:
Davide 2024-11-13 22:04:34 +01:00 committed by GitHub
parent 91344c1294
commit 6495f51dc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 5 deletions

View File

@ -32,6 +32,9 @@ import SwiftUI
public struct AppMenu: View { public struct AppMenu: View {
@AppStorage(AppPreference.keepsInMenu.key)
private var keepsInMenu = true
@ObservedObject @ObservedObject
private var profileManager: ProfileManager private var profileManager: ProfileManager
@ -51,6 +54,7 @@ public struct AppMenu: View {
Divider() Divider()
showToggle showToggle
loginToggle loginToggle
keepToggle
Divider() Divider()
profilesList profilesList
Divider() Divider()
@ -71,7 +75,11 @@ private extension AppMenu {
} }
var loginToggle: some View { var loginToggle: some View {
Toggle(Strings.AppMenu.Items.launchOnLogin, isOn: $model.launchesOnLogin) Toggle(Strings.Views.Settings.launchesOnLogin, isOn: $model.launchesOnLogin)
}
var keepToggle: some View {
Toggle(Strings.Views.Settings.keepsInMenu, isOn: $keepsInMenu)
} }
var profilesList: some View { var profilesList: some View {

View File

@ -31,13 +31,16 @@ import SwiftUI
struct SettingsSectionGroup: View { struct SettingsSectionGroup: View {
@AppStorage(AppPreference.keepsInMenu.key) @AppStorage(AppPreference.keepsInMenu.key)
private var keepsInMenu = false private var keepsInMenu = true
@AppStorage(AppPreference.locksInBackground.key) @AppStorage(AppPreference.locksInBackground.key)
private var locksInBackground = false private var locksInBackground = false
let profileManager: ProfileManager let profileManager: ProfileManager
@StateObject
private var model = AppMenu.Model()
@State @State
private var isConfirmingEraseiCloud = false private var isConfirmingEraseiCloud = false
@ -49,6 +52,7 @@ struct SettingsSectionGroup: View {
lockInBackgroundToggle lockInBackgroundToggle
#endif #endif
#if os(macOS) #if os(macOS)
launchesOnLoginToggle
keepsInMenuToggle keepsInMenuToggle
#endif #endif
eraseCloudKitButton eraseCloudKitButton
@ -56,6 +60,11 @@ struct SettingsSectionGroup: View {
} }
private extension SettingsSectionGroup { private extension SettingsSectionGroup {
var launchesOnLoginToggle: some View {
Toggle(Strings.Views.Settings.launchesOnLogin, isOn: $model.launchesOnLogin)
.themeSectionWithSingleRow(footer: Strings.Views.Settings.LaunchesOnLogin.footer)
}
var keepsInMenuToggle: some View { var keepsInMenuToggle: some View {
Toggle(Strings.Views.Settings.keepsInMenu, isOn: $keepsInMenu) Toggle(Strings.Views.Settings.keepsInMenu, isOn: $keepsInMenu)
.themeSectionWithSingleRow(footer: Strings.Views.Settings.KeepsInMenu.footer) .themeSectionWithSingleRow(footer: Strings.Views.Settings.KeepsInMenu.footer)

View File

@ -32,8 +32,6 @@ public enum Strings {
} }
public enum AppMenu { public enum AppMenu {
public enum Items { public enum Items {
/// Launch on Login
public static let launchOnLogin = Strings.tr("Localizable", "app_menu.items.launch_on_login", fallback: "Launch on Login")
/// Quit %@ /// Quit %@
public static func quit(_ p1: Any) -> String { public static func quit(_ p1: Any) -> String {
return Strings.tr("Localizable", "app_menu.items.quit", String(describing: p1), fallback: "Quit %@") return Strings.tr("Localizable", "app_menu.items.quit", String(describing: p1), fallback: "Quit %@")
@ -772,6 +770,8 @@ public enum Strings {
public static let eraseIcloud = Strings.tr("Localizable", "views.settings.erase_icloud", fallback: "Erase iCloud store") public static let eraseIcloud = Strings.tr("Localizable", "views.settings.erase_icloud", fallback: "Erase iCloud store")
/// Keep in menu bar /// Keep in menu bar
public static let keepsInMenu = Strings.tr("Localizable", "views.settings.keeps_in_menu", fallback: "Keep in menu bar") public static let keepsInMenu = Strings.tr("Localizable", "views.settings.keeps_in_menu", fallback: "Keep in menu bar")
/// Launch on login
public static let launchesOnLogin = Strings.tr("Localizable", "views.settings.launches_on_login", fallback: "Launch on login")
/// Lock in background /// Lock in background
public static let locksInBackground = Strings.tr("Localizable", "views.settings.locks_in_background", fallback: "Lock in background") public static let locksInBackground = Strings.tr("Localizable", "views.settings.locks_in_background", fallback: "Lock in background")
public enum EraseIcloud { public enum EraseIcloud {
@ -782,6 +782,10 @@ public enum Strings {
/// Enable this to keep the app in the menu bar after closing it. /// Enable this to keep the app in the menu bar after closing it.
public static let footer = Strings.tr("Localizable", "views.settings.keeps_in_menu.footer", fallback: "Enable this to keep the app in the menu bar after closing it.") public static let footer = Strings.tr("Localizable", "views.settings.keeps_in_menu.footer", fallback: "Enable this to keep the app in the menu bar after closing it.")
} }
public enum LaunchesOnLogin {
/// Open the app in background after login.
public static let footer = Strings.tr("Localizable", "views.settings.launches_on_login.footer", fallback: "Open the app in background after login.")
}
public enum LocksInBackground { public enum LocksInBackground {
/// Lock the app with FaceID when sent to the background. /// Lock the app with FaceID when sent to the background.
public static let footer = Strings.tr("Localizable", "views.settings.locks_in_background.footer", fallback: "Lock the app with FaceID when sent to the background.") public static let footer = Strings.tr("Localizable", "views.settings.locks_in_background.footer", fallback: "Lock the app with FaceID when sent to the background.")

View File

@ -129,6 +129,8 @@
"views.profile.rows.add_module" = "Add module"; "views.profile.rows.add_module" = "Add module";
"views.profile.module_list.section.footer" = "Drag modules to rearrange them, as their order determines priority."; "views.profile.module_list.section.footer" = "Drag modules to rearrange them, as their order determines priority.";
"views.settings.launches_on_login" = "Launch on login";
"views.settings.launches_on_login.footer" = "Open the app in background after login.";
"views.settings.keeps_in_menu" = "Keep in menu bar"; "views.settings.keeps_in_menu" = "Keep in menu bar";
"views.settings.keeps_in_menu.footer" = "Enable this to keep the app in the menu bar after closing it."; "views.settings.keeps_in_menu.footer" = "Enable this to keep the app in the menu bar after closing it.";
"views.settings.locks_in_background" = "Lock in background"; "views.settings.locks_in_background" = "Lock in background";
@ -238,7 +240,6 @@
// MARK: - App menu // MARK: - App menu
"app_menu.items.launch_on_login" = "Launch on Login";
"app_menu.items.quit" = "Quit %@"; "app_menu.items.quit" = "Quit %@";
// MARK: - Theme // MARK: - Theme