Skip to content

Instantly share code, notes, and snippets.

@shohiebsense
Last active April 14, 2022 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shohiebsense/b3a0ffa81e38f092c95b1e37414cca41 to your computer and use it in GitHub Desktop.
Save shohiebsense/b3a0ffa81e38f092c95b1e37414cca41 to your computer and use it in GitHub Desktop.
Animated Popup Message
@ExperimentalAnimationApi
@Composable
fun EdufundBackConfirmationDialog(
componentParameter: ComponentParameter,
isDialogTypeBackConfirmation: Boolean,
title: String,
desc: String,
onYesClicked: () -> Unit,
onDismiss: () -> Unit,
testTag: String
) {
val isDialogShowing = remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
if (isDialogTypeBackConfirmation) {
Dialog(
onDismissRequest = {
dismissDialog(scope, isDialogShowing = isDialogShowing, onDismiss = onDismiss)
}
) {
LaunchedEffect(Unit) {
delay(150L)
isDialogShowing.value = true
}
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
AnimatedVisibility(
isDialogShowing.value,
enter = scaleIn() + expandIn(expandFrom = Alignment.Center),
exit = fadeOut() + shrinkOut(shrinkTowards = Alignment.Center) + scaleOut(),
) {
Column(
modifier = Modifier
.clip(Shapes.medium)
.background(Edufund_Background_Color_List[componentParameter.backgroundColorIndex])
) {
EdufundSmallSpacer()
EdufundDialogTitleText(
componentParameter = componentParameter,
text = title,
color = Edufund_Dialog_Title_Color_List[componentParameter.backgroundColorIndex],
fontSize = 16.sp,
textAlign = TextAlign.Start,
)
EdufundSmallSpacer()
EdufundBasicDialogDescriptionText(
componentParameter = componentParameter,
desc = desc,
)
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.defaultHorizontalPadding()
.fillMaxWidth()
) {
EdufundClickableText(
modifier = Modifier
.testTag(testTag)
.weight(0.5f)
.padding(vertical = CommonSpacerList[SpacerIndex.BIGGER]),
componentParameter = componentParameter,
onClick = {
onYesClicked()
},
text = stringResource(id = R.string.ya_keluar),
color = Edufund_Yes_Text_Back_Dialog_Color_List[componentParameter.backgroundColorIndex],
)
EdufundButton(
modifier = Modifier
.testTag(testTag)
.weight(0.5f)
.padding(vertical = CommonSpacerList[SpacerIndex.BIGGER]),
componentParameter = componentParameter,
onClick = {
dismissDialog(
scope,
isDialogShowing = isDialogShowing,
onDismiss = onDismiss
)
},
label = stringResource(id = R.string.tidak_lanjutkan),
buttonBackgroundColor = Edufund_Orange,
)
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment