Skip to content

Instantly share code, notes, and snippets.

@laurentyhuel
Created May 9, 2022 08:29
Show Gist options
  • Save laurentyhuel/dc173f06394fc1bcdf831ac91fcb58ba to your computer and use it in GitHub Desktop.
Save laurentyhuel/dc173f06394fc1bcdf831ac91fcb58ba to your computer and use it in GitHub Desktop.
2x screen SharedViewModel
class CustomerDisplayViewModel : ViewModel() {
enum class CustomerDisplayState(val flipperViewIndex: Int) {
DEFAULT(0), CART(1), CONFIRM_PRINT(2)
}
val stateLiveData = MutableLiveData<CustomerDisplayState>()
val cartLiveData = MutableLiveData<OrderCartPresentationModel>()
var confirmPrintReceiptListener: ConfirmPrintReceiptDialogFragment.ConfirmPrintReceiptListener? = null
var isCustomerDisplayAvailable = false
fun changeState(newState: CustomerDisplayState) {
if(stateLiveData.value == newState){
return
}
stateLiveData.postValue(newState)
}
[...]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment