UI update for advanced search options, search button
This commit is contained in:
parent
da83c34090
commit
5a5e56cb66
@ -150,6 +150,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Search for:" : {
|
||||
"localizations" : {
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Options de recherche"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Words" : {
|
||||
|
||||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
|
@ -17,14 +17,16 @@ struct DictionaryView: View {
|
||||
|
||||
@State private var tokiInput: String = ""
|
||||
@State private var selectedPartOfSpeech: String?
|
||||
@State private var advancedSearchEnabled = false
|
||||
@State var searchMode: SearchMode = .Dictionary
|
||||
|
||||
@FocusState private var searchInputIsForuced: Bool
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
TextField("Search", text: $tokiInput)
|
||||
.multilineTextAlignment(.center)
|
||||
//.multilineTextAlignment(.center)
|
||||
.textInputAutocapitalization(.never)
|
||||
.disableAutocorrection(true)
|
||||
.padding(8)
|
||||
@ -32,8 +34,29 @@ struct DictionaryView: View {
|
||||
filterByInput()
|
||||
//tokiDictViewModel.filterDictionaryEnglishMode(tokiInput)
|
||||
}
|
||||
Button {
|
||||
hideKeyboard()
|
||||
filterByInput()
|
||||
} label: {
|
||||
Image(systemName: "magnifyingglass")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
Button(action: {
|
||||
withAnimation {
|
||||
advancedSearchEnabled.toggle()
|
||||
}
|
||||
}, label: {
|
||||
Image(systemName: "slider.horizontal.2.square.on.square")
|
||||
})
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
.padding([.top, .leading, .trailing], 8)
|
||||
if advancedSearchEnabled == true {
|
||||
VStack {
|
||||
Text("Search for:")
|
||||
Picker("Language", selection: $searchMode) {
|
||||
Text("Dictionary").tag(SearchMode.Dictionary)
|
||||
Text("Words").tag(SearchMode.Dictionary)
|
||||
Text("Definitions").tag(SearchMode.Definitions)
|
||||
}
|
||||
.pickerStyle(SegmentedPickerStyle())
|
||||
@ -45,6 +68,9 @@ struct DictionaryView: View {
|
||||
}
|
||||
filterByInput()
|
||||
}
|
||||
}
|
||||
.padding([.leading, .trailing], 8)
|
||||
}
|
||||
List(tokiDictViewModel.dictionary, id: \.word) { entry in
|
||||
TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
|
||||
}
|
||||
@ -70,6 +96,16 @@ struct DictionaryView: View {
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func searchOptionsButtonStyle(toggle: Binding<Bool>) -> any PrimitiveButtonStyle {
|
||||
if toggle.wrappedValue == true {
|
||||
BorderedButtonStyle()
|
||||
} else {
|
||||
BorderlessButtonStyle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct DictionaryView_Previews: PreviewProvider {
|
||||
|
||||
|
@ -15,22 +15,24 @@ struct TranslatorView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
// Button(action: changeTranslationDirection) {
|
||||
// #warning("This needs to actually switch how the lookup happens")
|
||||
// if translateToTokiPona == true {
|
||||
// LanguageDirectionView(from: "English", to: "Toki Pona", fromColor: .blue, toColor: .cyan)
|
||||
// } else {
|
||||
// LanguageDirectionView(from: "Toki Pona", to: "English", fromColor: .cyan, toColor: .blue)
|
||||
// }
|
||||
// }
|
||||
HStack {
|
||||
TextField("Enter Toki Pona Word or Phrase", text: $tokiInput)
|
||||
.multilineTextAlignment(.center)
|
||||
.textInputAutocapitalization(.never)
|
||||
.disableAutocorrection(true)
|
||||
.padding(8)
|
||||
.onSubmit {
|
||||
tokiDictViewModel.translatePhrase(tokiInput)
|
||||
}
|
||||
Button {
|
||||
hideKeyboard()
|
||||
tokiDictViewModel.translatePhrase(tokiInput)
|
||||
} label: {
|
||||
Image(systemName: "magnifyingglass")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
.padding([.top, .leading, .trailing], 8)
|
||||
|
||||
if tokiInput.count == 0 {
|
||||
List(tokiDictViewModel.dictionary, id: \.word) { entry in
|
||||
TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
|
||||
|
Loading…
Reference in New Issue
Block a user