mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Remove unnecessary dictionary in favor of tuple (#1192)
The dictionary for the detected and selected language when posting is replaced with a named tuple to include named values that are checked at compile time. This removes a source of error while still being expressive. Signed-off-by: Paul Schuetz <pa.schuetz@web.de>
This commit is contained in:
parent
b3919702e0
commit
156279faac
2 changed files with 3 additions and 6 deletions
|
@ -170,10 +170,8 @@ public struct StatusEditorView: View {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var languageConfirmationDialog: some View {
|
private var languageConfirmationDialog: some View {
|
||||||
if let dialogVals = viewModel.languageConfirmationDialogLanguages,
|
if let (detected: detected, selected: selected) = viewModel.languageConfirmationDialogLanguages,
|
||||||
let detected = dialogVals["detected"],
|
|
||||||
let detectedLong = Locale.current.localizedString(forLanguageCode: detected),
|
let detectedLong = Locale.current.localizedString(forLanguageCode: detected),
|
||||||
let selected = dialogVals["selected"],
|
|
||||||
let selectedLong = Locale.current.localizedString(forLanguageCode: selected)
|
let selectedLong = Locale.current.localizedString(forLanguageCode: selected)
|
||||||
{
|
{
|
||||||
Button("status.editor.language-select.confirmation.detected-\(detectedLong)") {
|
Button("status.editor.language-select.confirmation.detected-\(detectedLong)") {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
||||||
var currentAccount: Account?
|
var currentAccount: Account?
|
||||||
var theme: Theme?
|
var theme: Theme?
|
||||||
var preferences: UserPreferences?
|
var preferences: UserPreferences?
|
||||||
var languageConfirmationDialogLanguages: [String: String]?
|
var languageConfirmationDialogLanguages: (detected: String, selected: String)?
|
||||||
|
|
||||||
var textView: UITextView? {
|
var textView: UITextView? {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -151,8 +151,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
||||||
selectedLanguage != "",
|
selectedLanguage != "",
|
||||||
selectedLanguage != detectedLang
|
selectedLanguage != detectedLang
|
||||||
{
|
{
|
||||||
languageConfirmationDialogLanguages = ["detected": detectedLang,
|
languageConfirmationDialogLanguages = (detected: detectedLang, selected: selectedLanguage)
|
||||||
"selected": selectedLanguage]
|
|
||||||
} else {
|
} else {
|
||||||
languageConfirmationDialogLanguages = nil
|
languageConfirmationDialogLanguages = nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue