Skip to content

Commit 39fc8a7

Browse files
Fixing Theme not updating on click (#1255)
Updating themModel to be @StateObject
1 parent f20f9dc commit 39fc8a7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

CodeEdit/Features/CodeFile/CodeFileView.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ struct CodeFileView: View {
2626
@Environment(\.colorScheme)
2727
private var colorScheme
2828

29+
@StateObject
30+
private var themeModel: ThemeModel = .shared
31+
2932
private var cancellables = [AnyCancellable]()
3033

3134
private let isEditable: Bool
@@ -99,15 +102,15 @@ struct CodeFileView: View {
99102
)
100103
// minHeight zero fixes a bug where the app would freeze if the contents of the file are empty.
101104
.frame(minHeight: .zero, maxHeight: .infinity)
102-
.onChange(of: ThemeModel.shared.selectedTheme) { newValue in
105+
.onChange(of: themeModel.selectedTheme) { newValue in
103106
guard let theme = newValue else { return }
104107
self.selectedTheme = theme
105108
}
106109
.onChange(of: colorScheme) { newValue in
107110
if matchAppearance {
108-
ThemeModel.shared.selectedTheme = newValue == .dark
109-
? ThemeModel.shared.selectedDarkTheme!
110-
: ThemeModel.shared.selectedLightTheme!
111+
themeModel.selectedTheme = newValue == .dark
112+
? themeModel.selectedDarkTheme
113+
: themeModel.selectedLightTheme
111114
}
112115
}
113116
.onChange(of: settingsFont) { _ in

0 commit comments

Comments
 (0)