Removed animateContentSize(caused bugs) (v1.0.1)
This commit is contained in:
parent
b2df80daea
commit
b5d99916a1
2 changed files with 24 additions and 28 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
package ua.acclorite.book_story.presentation.components.custom_dialog
|
package ua.acclorite.book_story.presentation.components.custom_dialog
|
||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
|
||||||
import androidx.compose.animation.core.Spring
|
|
||||||
import androidx.compose.animation.core.spring
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
|
|
@ -77,6 +74,16 @@ fun CustomDialogWithContent(
|
||||||
var actionClicked by remember { mutableStateOf(false) }
|
var actionClicked by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
BasicAlertDialog(
|
BasicAlertDialog(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.navigationBarsPadding()
|
||||||
|
.statusBarsPadding()
|
||||||
|
.clip(MaterialTheme.shapes.extraLarge)
|
||||||
|
.background(
|
||||||
|
MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||||
|
MaterialTheme.shapes.extraLarge
|
||||||
|
)
|
||||||
|
.padding(top = 24.dp, bottom = 12.dp),
|
||||||
onDismissRequest = { onDismiss() },
|
onDismissRequest = { onDismiss() },
|
||||||
properties = DialogProperties(
|
properties = DialogProperties(
|
||||||
dismissOnBackPress = !actionClicked,
|
dismissOnBackPress = !actionClicked,
|
||||||
|
|
@ -86,16 +93,7 @@ fun CustomDialogWithContent(
|
||||||
(LocalView.current.parent as DialogWindowProvider).window.setDimAmount(
|
(LocalView.current.parent as DialogWindowProvider).window.setDimAmount(
|
||||||
backgroundTransparency
|
backgroundTransparency
|
||||||
)
|
)
|
||||||
Column(
|
Column {
|
||||||
modifier = modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.navigationBarsPadding()
|
|
||||||
.statusBarsPadding()
|
|
||||||
.clip(MaterialTheme.shapes.extraLarge)
|
|
||||||
.background(MaterialTheme.colorScheme.surfaceContainerHigh)
|
|
||||||
.animateContentSize(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
|
|
||||||
.padding(top = 24.dp, bottom = 12.dp)
|
|
||||||
) {
|
|
||||||
if (drawableIcon != null) {
|
if (drawableIcon != null) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = drawableIcon,
|
painter = drawableIcon,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package ua.acclorite.book_story.presentation.components.custom_dialog
|
package ua.acclorite.book_story.presentation.components.custom_dialog
|
||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
|
||||||
import androidx.compose.animation.core.Spring
|
|
||||||
import androidx.compose.animation.core.spring
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
|
@ -59,7 +57,7 @@ import ua.acclorite.book_story.R
|
||||||
* @param withDivider Should divider be shown or not.
|
* @param withDivider Should divider be shown or not.
|
||||||
* @param items The items of this dialog, use items(..) { .. } or item { .. }.
|
* @param items The items of this dialog, use items(..) { .. } or item { .. }.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun CustomDialogWithLazyColumn(
|
fun CustomDialogWithLazyColumn(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -78,6 +76,16 @@ fun CustomDialogWithLazyColumn(
|
||||||
) {
|
) {
|
||||||
var actionClicked by remember { mutableStateOf(false) }
|
var actionClicked by remember { mutableStateOf(false) }
|
||||||
BasicAlertDialog(
|
BasicAlertDialog(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.navigationBarsPadding()
|
||||||
|
.statusBarsPadding()
|
||||||
|
.clip(MaterialTheme.shapes.extraLarge)
|
||||||
|
.background(
|
||||||
|
MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||||
|
MaterialTheme.shapes.extraLarge
|
||||||
|
)
|
||||||
|
.padding(top = 24.dp, bottom = 12.dp),
|
||||||
onDismissRequest = { onDismiss() },
|
onDismissRequest = { onDismiss() },
|
||||||
properties = DialogProperties(
|
properties = DialogProperties(
|
||||||
dismissOnBackPress = !actionClicked,
|
dismissOnBackPress = !actionClicked,
|
||||||
|
|
@ -87,16 +95,7 @@ fun CustomDialogWithLazyColumn(
|
||||||
(LocalView.current.parent as DialogWindowProvider).window.setDimAmount(
|
(LocalView.current.parent as DialogWindowProvider).window.setDimAmount(
|
||||||
backgroundTransparency
|
backgroundTransparency
|
||||||
)
|
)
|
||||||
Column(
|
Column {
|
||||||
modifier = modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.navigationBarsPadding()
|
|
||||||
.statusBarsPadding()
|
|
||||||
.clip(MaterialTheme.shapes.extraLarge)
|
|
||||||
.background(MaterialTheme.colorScheme.surfaceContainerHigh)
|
|
||||||
.animateContentSize(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
|
|
||||||
.padding(top = 24.dp, bottom = 12.dp)
|
|
||||||
) {
|
|
||||||
if (drawableIcon != null) {
|
if (drawableIcon != null) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = drawableIcon,
|
painter = drawableIcon,
|
||||||
|
|
@ -161,7 +160,6 @@ fun CustomDialogWithLazyColumn(
|
||||||
item {
|
item {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.animateItem()
|
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue