@@ -11,6 +11,11 @@ import SwiftUI
1111struct SettingsView : View {
1212
1313 @EnvironmentObject var settings : Settings
14+
15+ @Environment ( \. themePrimaryColor) var themePrimaryColor
16+ @Environment ( \. themeTextColor) var themeTextColor
17+ @Environment ( \. themeShadowColor) var themeShadowColor
18+
1419 @ObservedObject var viewModel : SettingsViewModel
1520
1621 @State private var selectedTheme = 0
@@ -30,6 +35,7 @@ struct SettingsView: View {
3035 Spacer ( )
3136 Text ( " Settings " )
3237 . font ( . largeTitle)
38+ . foregroundColor ( themeTextColor)
3339 Spacer ( )
3440 }
3541 . padding ( . top, 16 )
@@ -45,7 +51,10 @@ struct SettingsView: View {
4551 set: {
4652 selectedAppTheme = $0
4753 settings. snipAppTheme = SnipAppTheme . allCases [ $0]
48- } ) , label: Text ( " Application Theme " ) ) {
54+ } ) , label:
55+ Text ( " Application Theme " )
56+ . foregroundColor ( themeTextColor)
57+ ) {
4958 ForEach ( 0 ..< SnipAppTheme . allCases. count) { index in
5059 Text ( SnipAppTheme . allCases [ index] . rawValue) . tag ( index)
5160 }
@@ -66,7 +75,10 @@ struct SettingsView: View {
6675 set: {
6776 selectedTheme = $0
6877 settings. codeViewTheme = CodeViewTheme . list [ $0]
69- } ) , label: Text ( " CodeView Theme " ) ) {
78+ } ) , label:
79+ Text ( " CodeView Theme " )
80+ . foregroundColor ( themeTextColor)
81+ ) {
7082 ForEach ( 0 ..< CodeViewTheme . list. count) {
7183 Text ( CodeViewTheme . list [ $0] . rawValue)
7284 }
@@ -98,7 +110,7 @@ struct SettingsView: View {
98110
99111 HStack {
100112 Text ( " CodeView Text Size " )
101- . foregroundColor ( . text )
113+ . foregroundColor ( themeTextColor )
102114 Spacer ( )
103115 Slider ( value: Binding < Float > (
104116 get: {
@@ -127,7 +139,7 @@ struct SettingsView: View {
127139 Spacer ( )
128140 Button ( action: {
129141 withAnimation ( . spring( response: 0.4 , dampingFraction: 0.8 , blendDuration: 0.3 ) ) { ( ) -> ( ) in
130- settings . isSettingsOpened . toggle ( )
142+ viewModel . isVisible = false
131143 }
132144 } ) {
133145 Text ( " Close " )
@@ -145,7 +157,7 @@ struct SettingsView: View {
145157 . frame ( width: viewModel. size. width / 2.5 ,
146158 height: viewModel. size. height / 1.5 ,
147159 alignment: . center)
148- . background ( ( settings . snipAppTheme == . auto ? Color . primary : Color . primaryTheme ) )
160+ . background ( themePrimaryColor )
149161 . cornerRadius ( 4.0 )
150162 . offset ( x: 0 ,
151163 y: viewModel. isVisible ? ( ( viewModel. size. height / 2 ) - ( ( viewModel. size. height / 1.5 ) / 1.5 ) ) : 10000 )
@@ -155,25 +167,25 @@ struct SettingsView: View {
155167 }
156168
157169 var backgroundView : some View {
158- viewModel. isVisible ? Color . shadow : Color . clear
170+ viewModel. isVisible ? themeShadowColor : Color . clear
159171 }
160172}
161173
162174final class SettingsViewModel : ObservableObject {
163175
164- var isVisible : Bool
176+ @ Binding var isVisible : Bool
165177 var size : CGSize
166178
167- init ( isVisible: Bool , readerSize: CGSize ) {
168- self . isVisible = isVisible
179+ init ( isVisible: Binding < Bool > , readerSize: CGSize ) {
180+ self . _isVisible = isVisible
169181 self . size = readerSize
170182 }
171183
172184}
173185
174186struct SettingsView_Previews : PreviewProvider {
175187 static var previews : some View {
176- SettingsView ( viewModel: SettingsViewModel ( isVisible: true ,
188+ SettingsView ( viewModel: SettingsViewModel ( isVisible: . constant ( true ) ,
177189 readerSize: CGSize ( width: 400 , height: 300 ) ) )
178190 }
179191}
0 commit comments