Skip to content

Instantly share code, notes, and snippets.

@laurentyhuel
Last active March 21, 2022 15:22
Show Gist options
  • Save laurentyhuel/1f9786092b4a73dfca71da38960a8811 to your computer and use it in GitHub Desktop.
Save laurentyhuel/1f9786092b4a73dfca71da38960a8811 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