Skip to content

Commit

Permalink
Merge branch 'deployment-target-macOS-13' into deployment-target-macO…
Browse files Browse the repository at this point in the history
…S-14
  • Loading branch information
F1248 committed Sep 19, 2024
2 parents f12bde3 + 96a3172 commit a1588c1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
9 changes: 7 additions & 2 deletions Genius/Views/Common/TabLegacy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ struct TabLegacy: Hashable, Identifiable {
let title: Text
let content: AnyView

init(_ titleKey: LocalizedStringKey, tableName: String? = nil, content: () -> any View) {
self.title = Text(titleKey, tableName: tableName)
init(
_ titleKey: LocalizedStringKey,
variesByInterfaceMode: Bool = false,
viewInvalidator _: Any? = nil,
content: () -> any View
) {
self.title = Text(titleKey, variesByInterfaceMode: variesByInterfaceMode)
self.content = AnyView(content())
}

Expand Down
4 changes: 2 additions & 2 deletions Genius/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ContentView: View {
Tab("Home") {
HomeView()
}
Tab("System Information", tableName: interfaceMode.localizationTable) {
Tab("System Information", variesByInterfaceMode: true, viewInvalidator: interfaceMode) {
SystemInformationView()
}
Tab("Maintenance") {
Expand All @@ -35,7 +35,7 @@ struct ContentView: View {
TabLegacy("Home") {
HomeView()
}
TabLegacy("System Information", tableName: interfaceMode.localizationTable) {
TabLegacy("System Information", variesByInterfaceMode: true, viewInvalidator: interfaceMode) {
SystemInformationView()
}
TabLegacy("Maintenance") {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ import SwiftUICore
@available(macOS 15, *)
extension Tab where Value == Never, Content: View, Label == SwiftUI.Label<Text, EmptyView> {

init(_ titleKey: LocalizedStringKey, tableName: String? = nil, content: () -> Content) {
init(
_ titleKey: LocalizedStringKey,
variesByInterfaceMode: Bool = false,
viewInvalidator _: Any? = nil,
content: () -> Content
) {
self.init(content: content) {
Label {
Text(titleKey, tableName: tableName)
Text(titleKey, variesByInterfaceMode: variesByInterfaceMode)
} icon: {
EmptyView()
}
Expand Down
18 changes: 18 additions & 0 deletions Genius/Views/Extensions/Text.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Text.swift
// Genius
//
// Created by F1248.
//

import SwiftUI
import SwiftUICore

extension Text {

init(_ key: LocalizedStringKey, variesByInterfaceMode: Bool) {
@AppStorage("interfaceMode")
var interfaceMode = Settings.InterfaceMode()
self.init(key, tableName: variesByInterfaceMode ? interfaceMode.localizationTable : nil)
}
}
5 changes: 1 addition & 4 deletions Genius/Views/SystemInformation/SystemInformationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import SwiftUICore

struct SystemInformationView: View {

@AppStorage("interfaceMode")
var interfaceMode = Settings.InterfaceMode()

var body: some View {
VStack {
Text("System Information", tableName: interfaceMode.localizationTable)
Text("System Information", variesByInterfaceMode: true)
.font(.largeTitle)
.padding()
}
Expand Down

0 comments on commit a1588c1

Please sign in to comment.