Settings.swift (1543B)
1 // 2 // Settings.swift 3 // captainsLog 4 // 5 // Created by Benjamin Welner on 10/18/19. 6 // Copyright © 2019 FIGBERT Industries. All rights reserved. 7 // 8 9 import SwiftUI 10 11 struct Settings: View { 12 @EnvironmentObject var globalVars: GlobalVars 13 14 var body: some View { 15 Form { 16 Section(header: Text("Save")) { 17 Toggle(isOn: $globalVars.saveLocally) { 18 Text("Save on device") 19 } 20 Toggle(isOn: $globalVars.saveICloud) { 21 Text("Save to iCloud") 22 } 23 } 24 Section(header: Text("Name")) { 25 TextField("Name", text: $globalVars.name) 26 } 27 Section(header: Text("Prompt")) { 28 Picker("Date format", selection: $globalVars.currentDateFormat) { 29 ForEach(0 ..< globalVars.dateFormats.count, id: \.self) { 30 Text("\(self.globalVars.dateFormats[$0])") 31 } 32 } 33 Picker("Intro message", selection: $globalVars.currentMessage) { 34 ForEach(0 ..< globalVars.messages.count, id: \.self) { 35 Text("\(self.globalVars.messages[$0])") 36 } 37 } 38 } 39 } 40 .navigationBarTitle( 41 Text("Settings"), 42 displayMode: .inline 43 ) 44 } 45 } 46 47 struct Settings_Previews: PreviewProvider { 48 static var previews: some View { 49 Settings().environmentObject(GlobalVars()) 50 } 51 }