change(ios): apply suggestions from review

This commit is contained in:
Joshua Horton 2026-07-09 10:37:42 -05:00
parent 86cf687519
commit f1a6f6efdf
2 changed files with 18 additions and 17 deletions

View file

@ -105,21 +105,26 @@ class LanguageSettingsViewController: UITableViewController {
}
}
func refreshSwitchVisibility() {
let userDefaults = Storage.active.userDefaults
let mayCorrect = userDefaults.correctSettingForLanguage(languageID: self.language.id)
self.doCorrectionsSwitch?.isHidden = !mayCorrect
self.doCorrectionsLabel?.isEnabled = mayCorrect
let mayAutoCorrect = userDefaults.autocorrectSettingForLanguage(languageID: self.language.id)
self.doAutocorrectionsSwitch?.isHidden = !(mayCorrect && mayAutoCorrect)
self.doAutocorrectionsLabel?.isEnabled = mayCorrect && mayAutoCorrect
self.correctionsCell?.isUserInteractionEnabled = mayCorrect
}
@objc
func predictionSwitchValueChanged(source: UISwitch) {
let value = source.isOn;
let userDefaults = Storage.active.userDefaults
userDefaults.set(predictSetting: value, forLanguageID: self.language.id)
// Reactively set the corrections switch interactivity state.
self.doCorrectionsSwitch?.isHidden = !value
self.doCorrectionsLabel?.isEnabled = value
let mayCorrect = userDefaults.autocorrectSettingForLanguage(languageID: self.language.id)
self.doAutocorrectionsSwitch?.isHidden = !(value && mayCorrect)
self.doAutocorrectionsLabel?.isEnabled = value && mayCorrect
self.correctionsCell?.isUserInteractionEnabled = value
refreshSwitchVisibility()
refreshModelIfNeeded()
}
@ -129,11 +134,7 @@ class LanguageSettingsViewController: UITableViewController {
let userDefaults = Storage.active.userDefaults
userDefaults.set(correctSetting: value, forLanguageID: self.language.id)
// This may only be triggered if the predict toggle is on,
// so we can rely on just the input value.
self.doAutocorrectionsSwitch?.isHidden = !value
self.doAutocorrectionsLabel?.isEnabled = value
refreshSwitchVisibility()
refreshModelIfNeeded()
}

View file

@ -152,13 +152,13 @@
"menu-langsettings-title" = "%@ Settings";
/* Label for the toggle that enables corrections that is displayed within a language-specific settings menu */
"menu-langsettings-toggle-correct" = "Enable corrections";
"menu-langsettings-toggle-correct" = "Offer corrections";
/* Label for the toggle that enables auto-corrections that is displayed within a language-specific settings menu */
"menu-langsettings-toggle-autocorrect" = "Enable autocorrections";
"menu-langsettings-toggle-autocorrect" = "Apply corrections automatically";
/* Label for the toggle that enables predictions that is displayed within a language-specific settings menu */
"menu-langsettings-toggle-predict" = "Enable predictions";
"menu-langsettings-toggle-predict" = "Offer word completions";
/* Help message for a prompt that appears for confirming a lexical model download: language (1): lexical model (dictionary) name (2) */
"menu-lexical-model-install-message" = "Would you like to install this dictionary?";