Last active
January 31, 2020 08:36
-
-
Save fluxtah/7dd65c61842a588cca245b366092046e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Composable | |
fun CardDesignerScreen(repository: MemoryCardRepository = get(), cardUuid: String? = null) { | |
val state = remember { CardDesignerState() } | |
if (cardUuid != null && cardUuid.isNotEmpty()) { | |
observe({ repository.getCard(cardUuid) }) { | |
state.card = it | |
state.loadingState = LoadingState.Loaded | |
} | |
} | |
val onCardSaved = { | |
runBlocking { | |
repository.saveCard(state.card) | |
goto(Destination.HomeScreen) | |
} | |
} | |
MemsetMainTemplate { | |
when (state.loadingState) { | |
LoadingState.Loaded -> CardEditorContent(state, onCardSaved) | |
LoadingState.Loading -> CardEditorLoading() | |
LoadingState.Error -> CardEditorLoadingError() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment