Skip to content

Commit 3f4859c

Browse files
authored
🐞 Improved settings window managment (#916)
* ✨ New settings window management * πŸš› Tab -> SettingsTab
1 parent 437de13 commit 3f4859c

10 files changed

Lines changed: 223 additions & 212 deletions

β€ŽLoop/App/AppDelegate.swiftβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
2727
}
2828

2929
if !launchedAsLoginItem {
30-
LuminareManager.shared.showWindow(nil)
30+
SettingsWindowManager.shared.show()
3131
} else {
3232
// Dock icon is usually handled by LuminareManager, but in this case, it is manually set
3333
if !Defaults[.showDockIcon] {
@@ -74,12 +74,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
7474
}
7575

7676
func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
77-
LuminareManager.shared.close()
77+
SettingsWindowManager.shared.close()
7878
return false
7979
}
8080

8181
func applicationShouldHandleReopen(_: NSApplication, hasVisibleWindows _: Bool) -> Bool {
82-
LuminareManager.shared.showWindow(self)
82+
SettingsWindowManager.shared.show()
8383
return true
8484
}
8585

β€ŽLoop/App/LoopApp.swiftβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct LoopApp: App {
5555
}
5656

5757
Button("Settings…") {
58-
LuminareManager.shared.showWindow(self)
58+
SettingsWindowManager.shared.show()
5959
}
6060
.keyboardShortcut(",", modifiers: .command)
6161

β€ŽLoop/Settings Window/Loop/ExcludedAppsConfiguration.swiftβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct ExcludedAppsConfigurationView: View {
5757

5858
func showAppChooser() {
5959
Task { @MainActor in
60-
guard let window = LuminareManager.shared.window else { return }
60+
guard let window = SettingsWindowManager.shared.window else { return }
6161

6262
let panel = NSOpenPanel()
6363
panel.worksWhenModal = true

β€ŽLoop/Settings Window/LuminareManager.swiftβ€Ž

Lines changed: 0 additions & 198 deletions
This file was deleted.

Loop/Settings Window/LuminareContentView.swift renamed to Loop/Settings Window/SettingsContentView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// LuminareContentView.swift
2+
// SettingsContentView.swift
33
// Loop
44
//
55
// Created by Kai Azim on 2025-10-18.
@@ -8,8 +8,8 @@
88
import Luminare
99
import SwiftUI
1010

11-
struct LuminareContentView: View {
12-
@ObservedObject var model: LuminareManager
11+
struct SettingsContentView: View {
12+
@ObservedObject var model: SettingsWindowManager
1313
@ObservedObject private var accentColorController: AccentColorController = .shared
1414

1515
@Environment(\.luminareAnimation) private var animation
@@ -18,9 +18,9 @@ struct LuminareContentView: View {
1818
var body: some View {
1919
LuminareDividedStack {
2020
LuminareSidebar {
21-
LuminareSidebarSection("Theming", selection: $model.currentTab, items: Tab.themingTabs)
22-
LuminareSidebarSection("Settings", selection: $model.currentTab, items: Tab.settingsTabs)
23-
LuminareSidebarSection("\(Bundle.main.appName)", selection: $model.currentTab, items: Tab.loopTabs)
21+
LuminareSidebarSection("Theming", selection: $model.currentTab, items: SettingsTab.themingTabs)
22+
LuminareSidebarSection("Settings", selection: $model.currentTab, items: SettingsTab.settingsTabs)
23+
LuminareSidebarSection("\(Bundle.main.appName)", selection: $model.currentTab, items: SettingsTab.loopTabs)
2424
}
2525
.frame(width: 260)
2626
.padding(.top, titleBarHeight)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// SettingsTab.swift
3+
// Loop
4+
//
5+
// Created by Kai Azim on 2025-12-06.
6+
//
7+
8+
import Luminare
9+
import SwiftUI
10+
11+
enum SettingsTab: LuminareTabItem, CaseIterable {
12+
var id: String { title }
13+
14+
case icon
15+
case accentColor
16+
case radialMenu
17+
case preview
18+
19+
case behavior
20+
case keybinds
21+
22+
case advanced
23+
case excludedApps
24+
case about
25+
26+
var title: String {
27+
switch self {
28+
case .icon: .init(localized: "Settings tab: Icon", defaultValue: "Icon")
29+
case .accentColor: .init(localized: "Settings tab: Accent Color", defaultValue: "Accent Color")
30+
case .radialMenu: .init(localized: "Settings tab: Radial Menu", defaultValue: "Radial Menu")
31+
case .preview: .init(localized: "Settings tab: Preview", defaultValue: "Preview")
32+
case .behavior: .init(localized: "Settings tab: Behavior", defaultValue: "Behavior")
33+
case .keybinds: .init(localized: "Settings tab: Keybindings", defaultValue: "Keybinds")
34+
case .advanced: .init(localized: "Settings tab: Advanced", defaultValue: "Advanced")
35+
case .excludedApps: .init(localized: "Settings tab: Excluded Apps", defaultValue: "Excluded Apps")
36+
case .about: .init(localized: "Settings tab: About", defaultValue: "About")
37+
}
38+
}
39+
40+
var image: Image {
41+
switch self {
42+
case .icon: Image(.squareSparkle)
43+
case .accentColor: Image(.paintbrush)
44+
case .radialMenu: Image(.loop)
45+
case .preview: Image(.sidebarRight2)
46+
case .behavior: Image(.gear)
47+
case .keybinds: Image(.command)
48+
case .advanced: Image(.faceNerdSmile)
49+
case .excludedApps: Image(.windowLock)
50+
case .about: Image(.msgSmile2)
51+
}
52+
}
53+
54+
var showIndicator: Bool {
55+
switch self {
56+
case .about: Updater.shared.updateState == .available
57+
default: false
58+
}
59+
}
60+
61+
@ViewBuilder func view() -> some View {
62+
switch self {
63+
case .icon: IconConfigurationView()
64+
case .accentColor: AccentColorConfigurationView()
65+
case .radialMenu: RadialMenuConfigurationView()
66+
case .preview: PreviewConfigurationView()
67+
case .behavior: BehaviorConfigurationView()
68+
case .keybinds: KeybindsConfigurationView()
69+
case .advanced: AdvancedConfigurationView()
70+
case .excludedApps: ExcludedAppsConfigurationView()
71+
case .about: AboutConfigurationView()
72+
}
73+
}
74+
75+
static let themingTabs: [Self] = [.icon, .accentColor, .radialMenu, .preview]
76+
static let settingsTabs: [Self] = [.behavior, .keybinds]
77+
static let loopTabs: [Self] = [.advanced, .excludedApps, .about]
78+
}

0 commit comments

Comments
Β (0)