This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsFragment : Fragment() { | |
private val viewModel: SettingsViewModel2 by viewModels() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
setInteractions() | |
observeViewState() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsViewModel( | |
settingsRepository: SettingsRepository | |
) : ViewModel() { | |
private var currentViewState = ViewState( | |
firstName = "", | |
lastName = "", | |
notificationsChecked = false, | |
notificationsEnabled = false | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class ViewState( | |
val firstName: String, | |
val lastName: String, | |
val notificationsChecked: Boolean, | |
val notificationsEnabled: Boolean | |
) | |
sealed class Interaction { | |
data class NotificationSwitchChanged(val enabled: Boolean) : Interaction() | |
data class FirstNameChange(val firstName: String) : Interaction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsFragment : Fragment() { | |
private val viewModel: SettingsViewModel by viewModels() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
setInteractions() | |
observeViewModel() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Settings( | |
val firstName: String, | |
val lastName: String, | |
val notificationsChecked: Boolean | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsRepository { | |
val settings: Settings get() = /* retrieving settings */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsViewModel( | |
settingsRepository: SettingsRepository | |
) : ViewModel() { | |
private val _firstName = MutableLiveData<String>() | |
val firstName: LiveData<String> = _firstName | |
private val _lastName = MutableLiveData<String>() | |
val lastName: LiveData<String> = _lastName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fragment : Fragment() { | |
@Inject | |
lateinit var viewModel: ViewModel | |
@Inject | |
lateinit var interactor: Interactor | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class ModelData( | |
val progressVisible: Boolean, | |
) | |
class ViewModel( | |
repository: Repository | |
) : ViewModel() { | |
private val _liveData = MutableLiveData<ModelData>() | |
val liveData: LiveData<ModelData> = _liveData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Interactor( | |
private val repository: Repository, | |
private val navigator: Navigator, | |
private val viewModel: ViewModel | |
) { | |
fun onInteraction(interaction: Interaction) { | |
when (interaction) { | |
is Interaction.BackButtonClick -> onBackButtonClicked() | |
is Interaction.SkipButtonClick -> onSkipButtonClicked() |
NewerOlder