Skip to content

Commit

Permalink
refactor(ui): new MainViewModel
Browse files Browse the repository at this point in the history
ViewModel in a lifecycle component that can help share necessary live data among Activities.
  • Loading branch information
WhiredPlanck committed Aug 6, 2022
1 parent 63fd86b commit 305bf2b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/com/osfans/trime/ui/main/MainViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.osfans.trime.ui.main

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class MainViewModel : ViewModel() {

val toolbarTitle = MutableLiveData<String>()

val topOptionsMenu = MutableLiveData<Boolean>()

fun setToolbarTitle(title: String) {
toolbarTitle.value = title
}

fun enableTopOptionsMenu() {
topOptionsMenu.value = true
}

fun disableTopOptionsMenu() {
topOptionsMenu.value = false
}
}

0 comments on commit 305bf2b

Please sign in to comment.