UI update for advanced search options, search button
This commit is contained in:
		@@ -150,6 +150,19 @@
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "Search for:" : {
 | 
				
			||||||
 | 
					      "localizations" : {
 | 
				
			||||||
 | 
					        "fr" : {
 | 
				
			||||||
 | 
					          "stringUnit" : {
 | 
				
			||||||
 | 
					            "state" : "translated",
 | 
				
			||||||
 | 
					            "value" : "Options de recherche"
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "Words" : {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "version" : "1.0"
 | 
					  "version" : "1.0"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,14 +17,16 @@ struct DictionaryView: View {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    @State private var tokiInput: String = ""
 | 
					    @State private var tokiInput: String = ""
 | 
				
			||||||
    @State private var selectedPartOfSpeech: String?
 | 
					    @State private var selectedPartOfSpeech: String?
 | 
				
			||||||
 | 
					    @State private var advancedSearchEnabled = false
 | 
				
			||||||
    @State var searchMode: SearchMode = .Dictionary
 | 
					    @State var searchMode: SearchMode = .Dictionary
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    @FocusState private var searchInputIsForuced: Bool
 | 
					    @FocusState private var searchInputIsForuced: Bool
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var body: some View {
 | 
					    var body: some View {
 | 
				
			||||||
        VStack {
 | 
					        VStack {
 | 
				
			||||||
 | 
					            HStack {
 | 
				
			||||||
                TextField("Search", text: $tokiInput)
 | 
					                TextField("Search", text: $tokiInput)
 | 
				
			||||||
                .multilineTextAlignment(.center)
 | 
					                    //.multilineTextAlignment(.center)
 | 
				
			||||||
                    .textInputAutocapitalization(.never)
 | 
					                    .textInputAutocapitalization(.never)
 | 
				
			||||||
                    .disableAutocorrection(true)
 | 
					                    .disableAutocorrection(true)
 | 
				
			||||||
                    .padding(8)
 | 
					                    .padding(8)
 | 
				
			||||||
@@ -32,8 +34,29 @@ struct DictionaryView: View {
 | 
				
			|||||||
                        filterByInput()
 | 
					                        filterByInput()
 | 
				
			||||||
                        //tokiDictViewModel.filterDictionaryEnglishMode(tokiInput)
 | 
					                        //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) {
 | 
					                    Picker("Language", selection: $searchMode) {
 | 
				
			||||||
                Text("Dictionary").tag(SearchMode.Dictionary)
 | 
					                        Text("Words").tag(SearchMode.Dictionary)
 | 
				
			||||||
                        Text("Definitions").tag(SearchMode.Definitions)
 | 
					                        Text("Definitions").tag(SearchMode.Definitions)
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    .pickerStyle(SegmentedPickerStyle())
 | 
					                    .pickerStyle(SegmentedPickerStyle())
 | 
				
			||||||
@@ -45,6 +68,9 @@ struct DictionaryView: View {
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        filterByInput()
 | 
					                        filterByInput()
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                .padding([.leading, .trailing], 8)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            List(tokiDictViewModel.dictionary, id: \.word) { entry in
 | 
					            List(tokiDictViewModel.dictionary, id: \.word) { entry in
 | 
				
			||||||
                TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
 | 
					                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 {
 | 
					struct DictionaryView_Previews: PreviewProvider {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,22 +15,24 @@ struct TranslatorView: View {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    var body: some View {
 | 
					    var body: some View {
 | 
				
			||||||
        VStack {
 | 
					        VStack {
 | 
				
			||||||
//            Button(action: changeTranslationDirection) {
 | 
					            HStack {
 | 
				
			||||||
//                #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)
 | 
					 | 
				
			||||||
//                }
 | 
					 | 
				
			||||||
//            }
 | 
					 | 
				
			||||||
                TextField("Enter Toki Pona Word or Phrase", text: $tokiInput)
 | 
					                TextField("Enter Toki Pona Word or Phrase", text: $tokiInput)
 | 
				
			||||||
                .multilineTextAlignment(.center)
 | 
					 | 
				
			||||||
                    .textInputAutocapitalization(.never)
 | 
					                    .textInputAutocapitalization(.never)
 | 
				
			||||||
                    .disableAutocorrection(true)
 | 
					                    .disableAutocorrection(true)
 | 
				
			||||||
                    .padding(8)
 | 
					                    .padding(8)
 | 
				
			||||||
                    .onSubmit {
 | 
					                    .onSubmit {
 | 
				
			||||||
                        tokiDictViewModel.translatePhrase(tokiInput)
 | 
					                        tokiDictViewModel.translatePhrase(tokiInput)
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                Button {
 | 
				
			||||||
 | 
					                    hideKeyboard()
 | 
				
			||||||
 | 
					                    tokiDictViewModel.translatePhrase(tokiInput)
 | 
				
			||||||
 | 
					                } label: {
 | 
				
			||||||
 | 
					                    Image(systemName: "magnifyingglass")
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                .buttonStyle(.borderedProminent)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            .padding([.top, .leading, .trailing], 8)
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            if tokiInput.count == 0 {
 | 
					            if tokiInput.count == 0 {
 | 
				
			||||||
                List(tokiDictViewModel.dictionary, id: \.word) { entry in
 | 
					                List(tokiDictViewModel.dictionary, id: \.word) { entry in
 | 
				
			||||||
                    TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
 | 
					                    TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user