Created
August 1, 2023 14:33
-
-
Save hieuwu/f39deaea525e04b25a969eaf0d1af41d to your computer and use it in GitHub Desktop.
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
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") | |
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun AddProductScreen( | |
modifier: Modifier = Modifier, | |
navController: NavController, | |
viewModel: AddProductViewModel = hiltViewModel(), | |
) { | |
Scaffold( | |
topBar = { | |
TopAppBar( | |
navigationIcon = { | |
IconButton(onClick = { | |
navController.navigateUp() | |
}) { | |
Icon( | |
imageVector = Icons.Filled.ArrowBack, | |
contentDescription = null, | |
tint = MaterialTheme.colorScheme.onPrimary | |
) | |
} | |
}, | |
backgroundColor = MaterialTheme.colorScheme.primary, | |
title = { | |
Text( | |
text = stringResource(R.string.add_product_text_screen_title), | |
color = MaterialTheme.colorScheme.onPrimary, | |
) | |
}, | |
) | |
} | |
) { padding -> | |
val navigateAddProductSuccess = | |
viewModel.navigateAddProductSuccess.collectAsState(initial = null).value | |
val isLoading = | |
viewModel.isLoading.collectAsState(initial = null).value | |
if (isLoading == true) { | |
LoadingScreen(message = "Adding Product", | |
onCancelSelected = { | |
navController.navigateUp() | |
}) | |
} else { | |
SuccessScreen( | |
message = "Product added", | |
onMoreAction = { | |
viewModel.onAddMoreProductSelected() | |
}, | |
onNavigateBack = { | |
navController.navigateUp() | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment