More robust dictionary search feature, styling tweaks for widgets
This commit is contained in:
@@ -40,6 +40,32 @@ class TokiDictionaryViewModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func filterDictionaryEnglishMode(_ input: String) {
|
||||
dictionary = []
|
||||
|
||||
for value in fullDictionary {
|
||||
|
||||
var entryMatch = false
|
||||
|
||||
// Check if word matches toki pona form, even partially
|
||||
if value.word.hasPrefix(input) {
|
||||
entryMatch = true
|
||||
}
|
||||
|
||||
// Check if any part of the word definitions match in English, even partially
|
||||
for definition in value.definitions {
|
||||
if definition.definition.contains(input) {
|
||||
entryMatch = true
|
||||
}
|
||||
}
|
||||
|
||||
// Add to dictionary
|
||||
if entryMatch == true {
|
||||
dictionary.append(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func translatePhrase(_ input: String) {
|
||||
dictionary = []
|
||||
translatedDictionary = []
|
||||
|
Reference in New Issue
Block a user