35 lines
1005 B
Swift
35 lines
1005 B
Swift
//
|
|
// 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)
|
|
}
|
|
}
|
|
}
|
|
}
|