From 17cc95188b1efc5c04949f717898aa6c31db1fa4 Mon Sep 17 00:00:00 2001 From: Avery Pace Date: Fri, 5 Nov 2021 21:04:03 -0400 Subject: [PATCH] Fix crash on physical device --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 34 +++++++++++++++++++ Toki Trainer/Views/ContentView.swift | 4 +-- Toki Trainer/Views/PartsOfSpeechView.swift | 9 +++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index cf492b1..fd3f778 100644 --- a/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,4 +3,38 @@ uuid = "2238B32A-BF80-4351-B121-F5E36A8C39FC" type = "1" version = "2.0"> + + + + + + + + + + diff --git a/Toki Trainer/Views/ContentView.swift b/Toki Trainer/Views/ContentView.swift index 6b5c904..474ae80 100644 --- a/Toki Trainer/Views/ContentView.swift +++ b/Toki Trainer/Views/ContentView.swift @@ -16,7 +16,7 @@ struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @ObservedObject var tokiDictViewModel = TokiDictionaryViewModel() - @State private var selectedPartOfSpeech: String? = nil + @State private var selectedPartOfSpeech: String? @State private var tokiInput: String = "" var body: some View { @@ -64,7 +64,7 @@ struct ContentView: View { .background(.thinMaterial) } .sheet(item: $selectedPartOfSpeech) { selectedPOS in - PartsOfSpeechView(selectedPartOfSpeech: selectedPOS, tokiDictViewModel: self.tokiDictViewModel) + PartsOfSpeechView(selectedPartOfSpeech: selectedPOS, partsOfSpeech: tokiDictViewModel.partsOfSpeech) } } } diff --git a/Toki Trainer/Views/PartsOfSpeechView.swift b/Toki Trainer/Views/PartsOfSpeechView.swift index 5046972..f65ed6f 100644 --- a/Toki Trainer/Views/PartsOfSpeechView.swift +++ b/Toki Trainer/Views/PartsOfSpeechView.swift @@ -10,7 +10,9 @@ import SwiftUI struct PartsOfSpeechView: View { var selectedPartOfSpeech: String? = nil - @ObservedObject var tokiDictViewModel: TokiDictionaryViewModel + @ObservedObject var tokiDictViewModel = TokiDictionaryViewModel() + + var partsOfSpeech: [TokiPartOfSpeech] // init(selectedPartOfSpeech: String) { // _selectedPartOfSpeech = State(initialValue: selectedPartOfSpeech) @@ -32,7 +34,7 @@ struct PartsOfSpeechView: View { Spacer() } //.background(.blue) - .background((selectedPartOfSpeech == pos.pos) ? Color(UIColor.systemGray4) : .white) + .background((selectedPartOfSpeech == pos.pos) ? Color(UIColor.systemGray4) : Color(UIColor.systemBackground)) .cornerRadius(5.0) .padding(2) } @@ -44,6 +46,7 @@ struct PartsOfSpeechView: View { struct PartsOfSpeechView_Previews: PreviewProvider { static var previews: some View { - PartsOfSpeechView(selectedPartOfSpeech: "sep", tokiDictViewModel: TokiDictionaryViewModel()) + PartsOfSpeechView(selectedPartOfSpeech: "sep", partsOfSpeech: [TokiPartOfSpeech(pos: "sep", definition: "test")]) + .preferredColorScheme(.dark) } }