@@ -54,34 +54,6 @@ struct ImportExportSettingsView: View {
5454 }
5555 }
5656
57- // MARK: - iCloud Section
58-
59- Section ( " iCloud Import " ) {
60- Button ( action: {
61- viewModel. importFromiCloud ( )
62- } ) {
63- HStack {
64- Image ( systemName: " icloud.and.arrow.down " )
65- . foregroundColor ( . green)
66- Text ( " Import Settings from iCloud " )
67- }
68- }
69- . buttonStyle ( . plain)
70- }
71-
72- Section ( " iCloud Export " ) {
73- Button ( action: {
74- viewModel. exportToiCloud ( )
75- } ) {
76- HStack {
77- Image ( systemName: " icloud.and.arrow.up " )
78- . foregroundColor ( . blue)
79- Text ( " Export All Settings to iCloud " )
80- }
81- }
82- . buttonStyle ( . plain)
83- }
84-
8557 // MARK: - Status Message
8658
8759 if !viewModel. qrCodeErrorMessage. isEmpty {
@@ -148,168 +120,6 @@ struct ImportExportSettingsView: View {
148120 . sheet ( isPresented: $viewModel. showImportConfirmation) {
149121 ImportConfirmationView ( viewModel: viewModel)
150122 }
151- . sheet ( isPresented: $viewModel. showExportSuccessAlert) {
152- ExportSuccessView ( viewModel: viewModel)
153- }
154- . sheet ( isPresented: $viewModel. showImportNotFoundAlert) {
155- ImportNotFoundView ( viewModel: viewModel)
156- }
157- }
158- }
159-
160- struct ImportNotFoundView : View {
161- @ObservedObject var viewModel : ImportExportSettingsViewModel
162-
163- var body : some View {
164- NavigationView {
165- VStack ( spacing: 20 ) {
166- // Header
167- VStack ( spacing: 12 ) {
168- Image ( systemName: " icloud.slash " )
169- . font ( . system( size: 60 ) )
170- . foregroundColor ( . orange)
171-
172- Text ( " No Settings Found " )
173- . font ( . title2)
174- . fontWeight ( . semibold)
175-
176- Text ( viewModel. importNotFoundMessage)
177- . font ( . subheadline)
178- . foregroundColor ( . secondary)
179- . multilineTextAlignment ( . center)
180- . padding ( . horizontal)
181- }
182- . padding ( . top, 30 )
183-
184- Spacer ( )
185-
186- // Done Button
187- Button ( action: {
188- viewModel. showImportNotFoundAlert = false
189- } ) {
190- HStack {
191- Image ( systemName: " xmark " )
192- Text ( " OK " )
193- }
194- . font ( . headline)
195- . foregroundColor ( . white)
196- . frame ( maxWidth: . infinity)
197- . padding ( )
198- . background ( Color . blue)
199- . cornerRadius ( 12 )
200- }
201- . padding ( . horizontal)
202- . padding ( . bottom, 20 )
203- }
204- . navigationBarHidden ( true )
205- }
206- }
207- }
208-
209- struct ExportSuccessView : View {
210- @ObservedObject var viewModel : ImportExportSettingsViewModel
211-
212- var body : some View {
213- NavigationView {
214- VStack ( spacing: 20 ) {
215- // Header
216- VStack ( spacing: 12 ) {
217- Image ( systemName: " checkmark.icloud.fill " )
218- . font ( . system( size: 60 ) )
219- . foregroundColor ( . green)
220-
221- Text ( " Export Successful " )
222- . font ( . title2)
223- . fontWeight ( . semibold)
224-
225- Text ( viewModel. exportSuccessMessage)
226- . font ( . subheadline)
227- . foregroundColor ( . secondary)
228- . multilineTextAlignment ( . center)
229- }
230- . padding ( . top, 30 )
231-
232- // Exported Settings Details
233- if !viewModel. exportSuccessDetails. isEmpty {
234- VStack ( alignment: . leading, spacing: 16 ) {
235- Text ( " Exported Settings " )
236- . font ( . headline)
237- . padding ( . horizontal)
238-
239- VStack ( spacing: 12 ) {
240- ForEach ( viewModel. exportSuccessDetails, id: \. self) { detail in
241- HStack ( spacing: 12 ) {
242- Image ( systemName: iconForDetail ( detail) )
243- . font ( . title2)
244- . foregroundColor ( colorForDetail ( detail) )
245- . frame ( width: 30 )
246-
247- Text ( detail)
248- . font ( . subheadline)
249- . lineLimit ( 2 )
250-
251- Spacer ( )
252-
253- Image ( systemName: " checkmark.circle.fill " )
254- . foregroundColor ( . green)
255- }
256- . padding ( )
257- . background ( Color ( . systemGray6) )
258- . cornerRadius ( 10 )
259- }
260- }
261- . padding ( . horizontal)
262- }
263- }
264-
265- Spacer ( )
266-
267- // Done Button
268- Button ( action: {
269- viewModel. showExportSuccessAlert = false
270- } ) {
271- HStack {
272- Image ( systemName: " checkmark " )
273- Text ( " Done " )
274- }
275- . font ( . headline)
276- . foregroundColor ( . white)
277- . frame ( maxWidth: . infinity)
278- . padding ( )
279- . background ( Color . blue)
280- . cornerRadius ( 12 )
281- }
282- . padding ( . horizontal)
283- . padding ( . bottom, 20 )
284- }
285- . navigationBarHidden ( true )
286- }
287- }
288-
289- private func iconForDetail( _ detail: String ) -> String {
290- if detail. lowercased ( ) . contains ( " nightscout " ) {
291- return " network "
292- } else if detail. lowercased ( ) . contains ( " dexcom " ) {
293- return " person.circle "
294- } else if detail. lowercased ( ) . contains ( " remote " ) {
295- return " antenna.radiowaves.left.and.right "
296- } else if detail. lowercased ( ) . contains ( " alarm " ) {
297- return " bell "
298- }
299- return " gear "
300- }
301-
302- private func colorForDetail( _ detail: String ) -> Color {
303- if detail. lowercased ( ) . contains ( " nightscout " ) {
304- return . blue
305- } else if detail. lowercased ( ) . contains ( " dexcom " ) {
306- return . green
307- } else if detail. lowercased ( ) . contains ( " remote " ) {
308- return . orange
309- } else if detail. lowercased ( ) . contains ( " alarm " ) {
310- return . red
311- }
312- return . gray
313123 }
314124}
315125
0 commit comments