File tree Expand file tree Collapse file tree 2 files changed +9
-20
lines changed Expand file tree Collapse file tree 2 files changed +9
-20
lines changed Original file line number Diff line number Diff line change @@ -15,35 +15,24 @@ struct AppSettings<T>: DynamicProperty where T: Equatable {
15
15
16
16
let keyPath : WritableKeyPath < SettingsData , T >
17
17
18
- @available ( * ,
19
- deprecated,
20
- message: """
21
- Use init(_ keyPath:) instead, otherwise the view will be reevaluated on every settings change.
22
- """
23
- )
24
- init ( ) where T == SettingsData {
25
- self . keyPath = \. self
26
- self . settings = . init( \. settings)
27
- }
28
-
29
18
init ( _ keyPath: WritableKeyPath < SettingsData , T > ) {
30
19
self . keyPath = keyPath
31
- let newKeyPath = ( \EnvironmentValues . settings) . appending ( path: keyPath)
32
- self . settings = . init ( newKeyPath )
20
+ let settingsKeyPath = ( \EnvironmentValues . settings) . appending ( path: keyPath)
21
+ self . settings = Environment ( settingsKeyPath )
33
22
}
34
23
35
24
var wrappedValue : T {
36
25
get {
37
- settings . wrappedValue
26
+ Settings . shared . preferences [ keyPath : keyPath ]
38
27
}
39
28
nonmutating set {
40
29
Settings . shared. preferences [ keyPath: keyPath] = newValue
41
30
}
42
31
}
43
32
44
33
var projectedValue : Binding < T > {
45
- . init {
46
- settings . wrappedValue
34
+ Binding {
35
+ Settings . shared . preferences [ keyPath : keyPath ]
47
36
} set: {
48
37
Settings . shared. preferences [ keyPath: keyPath] = $0
49
38
}
Original file line number Diff line number Diff line change @@ -47,20 +47,20 @@ struct ViewCommands: Commands {
47
47
48
48
Menu ( " Font Size " ) {
49
49
Button ( " Increase " ) {
50
- if ! ( editorFontSize >= 288 ) {
50
+ if editorFontSize < 288 {
51
51
editorFontSize += 1
52
52
}
53
- if ! ( terminalFontSize >= 288 ) {
53
+ if terminalFontSize < 288 {
54
54
terminalFontSize += 1
55
55
}
56
56
}
57
57
. keyboardShortcut ( " + " )
58
58
59
59
Button ( " Decrease " ) {
60
- if ! ( editorFontSize <= 1 ) {
60
+ if editorFontSize > 1 {
61
61
editorFontSize -= 1
62
62
}
63
- if ! ( terminalFontSize <= 1 ) {
63
+ if terminalFontSize > 1 {
64
64
terminalFontSize -= 1
65
65
}
66
66
}
You can’t perform that action at this time.
0 commit comments