Add dictionary view and change how phrase lookup works
This commit is contained in:
34
Toki Trainer/Views/DictionaryView.swift
Normal file
34
Toki Trainer/Views/DictionaryView.swift
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// DictionaryView.swift
|
||||
// Toki Trainer
|
||||
//
|
||||
// Created by maddiefuzz on 10/4/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct DictionaryView: View {
|
||||
@ObservedObject var tokiDictViewModel = TokiDictionaryViewModel()
|
||||
|
||||
@State var tokiInput: String = ""
|
||||
@State var selectedPartOfSpeech: String?
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
TextField("Search", text: $tokiInput)
|
||||
.multilineTextAlignment(.center)
|
||||
.textInputAutocapitalization(.never)
|
||||
.disableAutocorrection(true)
|
||||
.padding(8)
|
||||
.onSubmit {
|
||||
tokiDictViewModel.filterDictionary(tokiInput)
|
||||
}
|
||||
List(tokiDictViewModel.dictionary, id: \.word) { entry in
|
||||
TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
|
||||
}
|
||||
.onChange(of: tokiInput) { newValue in
|
||||
tokiDictViewModel.filterDictionary(newValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user