diff --git a/Genius/Localization/Localizable.xcstrings b/Genius/Localization/Localizable.xcstrings index 7fe0b7a..b5e17ec 100644 --- a/Genius/Localization/Localizable.xcstrings +++ b/Genius/Localization/Localizable.xcstrings @@ -39,6 +39,7 @@ } }, "Home" : { + "extractionState" : "manual", "localizations" : { "de" : { "stringUnit" : { diff --git a/Genius/Views/Common/TabContentBuilder.swift b/Genius/Views/Common/TabContentBuilder.swift index 430f3c5..7d5eb12 100644 --- a/Genius/Views/Common/TabContentBuilder.swift +++ b/Genius/Views/Common/TabContentBuilder.swift @@ -11,4 +11,8 @@ enum TabContentBuilder { static func buildBlock(_ tabs: TabLegacy...) -> [TabLegacy] { tabs } + + static func buildBlock(_ tabs: [TabLegacy]) -> [TabLegacy] { + tabs + } } diff --git a/Genius/Views/ContentView.swift b/Genius/Views/ContentView.swift index 47046cb..7ba9fc3 100644 --- a/Genius/Views/ContentView.swift +++ b/Genius/Views/ContentView.swift @@ -16,33 +16,23 @@ struct ContentView: View { var body: some View { if #available(macOS 15, *) { TabView { - Tab("Home") { - HomeView() - } - Tab("System Information", variesByInterfaceMode: true, viewInvalidator: interfaceMode) { - SystemInformationView() - } - Tab("Maintenance") { - MaintenanceView() - } - Tab("Settings") { - SettingsView() + ForEach(ContentViewTabs.allCases) { tab in + Tab( + tab.localizedStringKey, + variesByInterfaceMode: tab.variesByInterfaceMode, + viewInvalidator: tab.variesByInterfaceMode ? interfaceMode : nil + ) { tab.content } } } .frame(minWidth: 686, minHeight: 256) } else { TabViewLegacy(entireWindow: true) { - TabLegacy("Home") { - HomeView() - } - TabLegacy("System Information", variesByInterfaceMode: true, viewInvalidator: interfaceMode) { - SystemInformationView() - } - TabLegacy("Maintenance") { - MaintenanceView() - } - TabLegacy("Settings") { - SettingsView() + ContentViewTabs.allCases.map { tab in + TabLegacy( + tab.localizedStringKey, + variesByInterfaceMode: tab.variesByInterfaceMode, + viewInvalidator: tab.variesByInterfaceMode ? interfaceMode : nil + ) { tab.content } } } .frame(minWidth: 686, minHeight: 256) diff --git a/Genius/Views/Types/ContentViewTabs.swift b/Genius/Views/Types/ContentViewTabs.swift new file mode 100644 index 0000000..4c4fdaa --- /dev/null +++ b/Genius/Views/Types/ContentViewTabs.swift @@ -0,0 +1,35 @@ +// +// ContentViewTabs.swift +// Genius +// +// Created by F1248. +// + +import SwiftUICore + +enum ContentViewTabs: String, CaseIterable, Identifiable { + + case home = "Home" + case systemInformation = "System Information" + case maintenance = "Maintenance" + case settings = "Settings" + + var id: Self { self } + var localizedStringKey: LocalizedStringKey { LocalizedStringKey(rawValue) } + + var content: AnyView { + switch self { + case .home: AnyView(HomeView()) + case .systemInformation: AnyView(SystemInformationView()) + case .maintenance: AnyView(MaintenanceView()) + case .settings: AnyView(SettingsView()) + } + } + + var variesByInterfaceMode: Bool { + switch self { + case .systemInformation: true + default: false + } + } +}