Skip to content

Commit

Permalink
beans-to-values.5 : Create copies in PreferencesView
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan McGregor authored and dmcg committed Jun 23, 2021
1 parent e3524a3 commit 79447f9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/travelator/mobile/PreferencesView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package travelator.mobile
import java.util.*

class PreferencesView(
private val preferences: UserPreferences
private var preferences: UserPreferences
) : View() {
private val greetingPicker = GreetingPicker()
private val localePicker = LocalePicker()
Expand All @@ -18,15 +18,28 @@ class PreferencesView(
}

protected fun onGreetingChange() {
preferences.greeting = greetingPicker.greeting
preferences = UserPreferences(
greetingPicker.greeting,
preferences.locale,
preferences.currency
)
}


protected fun onLocaleChange() {
preferences.locale = localePicker.locale
preferences = UserPreferences(
preferences.greeting,
localePicker.locale,
preferences.currency
)
}

protected fun onCurrencyChange() {
preferences.currency = currencyPicker.currency
preferences = UserPreferences(
preferences.greeting,
preferences.locale,
currencyPicker.currency
)
}
}

Expand Down

0 comments on commit 79447f9

Please sign in to comment.