Revert "Bring back tag expand / collapse shared element transition"

This reverts commit cd803974de86f4bf94b1d39e4d95687b80a721d9.

Close #1145
This commit is contained in:
MM20 2024-11-23 22:28:50 +01:00
parent cc26217594
commit 25551859c5
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -55,107 +55,172 @@ fun FavoritesTagSelector(
) { ) {
val sheetManager = LocalBottomSheetManager.current val sheetManager = LocalBottomSheetManager.current
SharedTransitionScope { AnimatedContent(
AnimatedContent( modifier = Modifier
modifier = it .fillMaxWidth()
.fillMaxWidth() .padding(
.padding( top = if (reverse) 8.dp else 4.dp,
top = if (reverse) 8.dp else 4.dp, bottom = if (reverse) 4.dp else 8.dp,
bottom = if (reverse) 4.dp else 8.dp, end = if (editButton) 8.dp else 0.dp
end = if (editButton) 8.dp else 0.dp ),
), targetState = expanded,
targetState = expanded, ) {
) { if (!it) {
if (!it) { val canScroll by remember {
val canScroll by remember { derivedStateOf { scrollState.canScrollForward || scrollState.canScrollBackward }
derivedStateOf { scrollState.canScrollForward || scrollState.canScrollBackward } }
} Row {
Row { Row(
Row( modifier = Modifier
.weight(1f)
.consumeAllScrolling()
.horizontalScroll(scrollState)
.padding(end = 12.dp),
) {
FilterChip(
modifier = Modifier modifier = Modifier
.weight(1f) .padding(start = 16.dp),
.consumeAllScrolling() selected = selectedTag == null,
.horizontalScroll(scrollState) onClick = { onSelectTag(null) },
.padding(end = 12.dp), leadingIcon = if (compact) null else {
) { {
FilterChip( Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
}
},
label = {
if (compact) {
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
} else {
Text(stringResource(R.string.favorites))
}
}
)
for (tag in tags) {
TagChip(
modifier = Modifier modifier = Modifier
.padding(start = 16.dp) .padding(start = 8.dp),
.sharedBounds( tag = tag,
rememberSharedContentState("favorites"), selected = selectedTag == tag.tag,
this@AnimatedContent onClick = {
), if (selectedTag == tag.tag) {
selected = selectedTag == null, onSelectTag(null)
onClick = { onSelectTag(null) }, } else {
leadingIcon = if (compact) null else { onSelectTag(tag.tag)
{
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
} }
}, },
label = { compact = compact,
if (compact) { onLongClick = {
Icon( sheetManager.showEditTagSheet(tag.tag)
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
} else {
Text(stringResource(R.string.favorites))
}
} }
) )
for (tag in tags) { }
TagChip( if (canScroll) {
modifier = Modifier val rot by transition.animateFloat {
.padding(start = 8.dp) if (it == EnterExitState.Visible) 0f else 180f
.sharedBounds(
rememberSharedContentState("tag-${tag.tag}"),
this@AnimatedContent
),
tag = tag,
selected = selectedTag == tag.tag,
onClick = {
if (selectedTag == tag.tag) {
onSelectTag(null)
} else {
onSelectTag(tag.tag)
}
},
compact = compact,
onLongClick = {
sheetManager.showEditTagSheet(tag.tag)
}
)
} }
if (canScroll) { IconButton(
val rot by transition.animateFloat { modifier = Modifier
if (it == EnterExitState.Visible) 0f else 180f .rotate(rot),
} onClick = { onExpand(true) }) {
IconButton( Icon(Icons.Rounded.ExpandMore, null)
modifier = Modifier
.rotate(rot)
.sharedBounds(
rememberSharedContentState("expand"),
this@AnimatedContent
),
onClick = { onExpand(true) }) {
Icon(Icons.Rounded.ExpandMore, null)
}
} }
}
} }
if (editButton) {
SmallFloatingActionButton(
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
onClick = { sheetManager.showEditFavoritesSheet() }
) {
Icon(
imageVector = Icons.Rounded.Edit,
contentDescription = null
)
}
}
}
} else {
Row(
verticalAlignment = if (reverse) Alignment.Top else Alignment.Bottom,
) {
FlowRow(
modifier = Modifier
.weight(1f)
.padding(end = 12.dp, start = 16.dp),
) {
FilterChip(
modifier = Modifier
.padding(end = 8.dp),
selected = selectedTag == null,
onClick = { onSelectTag(null) },
leadingIcon = if (compact) null else {
{
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
}
},
label = {
if (compact) {
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
} else {
Text(stringResource(R.string.favorites))
}
}
)
for (tag in tags) {
TagChip(
modifier = Modifier
.padding(end = 8.dp),
tag = tag,
compact = compact,
selected = selectedTag == tag.tag,
onClick = {
if (selectedTag == tag.tag) {
onSelectTag(null)
} else {
onSelectTag(tag.tag)
}
},
onLongClick = {
sheetManager.showEditTagSheet(tag.tag)
}
)
}
}
Column(
modifier = Modifier.fillMaxHeight(),
verticalArrangement = if (reverse) Arrangement.TopReversed else Arrangement.Bottom,
) {
val rot by transition.animateFloat {
if (it == EnterExitState.Visible) 0f else 180f
}
IconButton(
modifier = Modifier
.rotate(rot),
onClick = { onExpand(false) }
) {
Icon(Icons.Rounded.ExpandLess, null)
}
if (editButton) { if (editButton) {
SmallFloatingActionButton( SmallFloatingActionButton(
modifier = Modifier
.sharedBounds(
rememberSharedContentState("edit"),
this@AnimatedContent
),
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(), elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
onClick = { sheetManager.showEditFavoritesSheet() } onClick = { sheetManager.showEditFavoritesSheet() }
) { ) {
@ -166,107 +231,6 @@ fun FavoritesTagSelector(
} }
} }
} }
} else {
Row(
verticalAlignment = if (reverse) Alignment.Top else Alignment.Bottom,
) {
FlowRow(
modifier = Modifier
.weight(1f)
.padding(end = 12.dp, start = 16.dp),
) {
FilterChip(
modifier = Modifier
.padding(end = 8.dp)
.sharedBounds(
rememberSharedContentState("favorites"),
this@AnimatedContent
),
selected = selectedTag == null,
onClick = { onSelectTag(null) },
leadingIcon = if (compact) null else {
{
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
}
},
label = {
if (compact) {
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
modifier = Modifier.size(FilterChipDefaults.IconSize),
)
} else {
Text(stringResource(R.string.favorites))
}
}
)
for (tag in tags) {
TagChip(
modifier = Modifier
.padding(end = 8.dp)
.sharedBounds(
rememberSharedContentState("tag-${tag.tag}"),
this@AnimatedContent
),
tag = tag,
compact = compact,
selected = selectedTag == tag.tag,
onClick = {
if (selectedTag == tag.tag) {
onSelectTag(null)
} else {
onSelectTag(tag.tag)
}
},
onLongClick = {
sheetManager.showEditTagSheet(tag.tag)
}
)
}
}
Column(
modifier = Modifier.fillMaxHeight(),
verticalArrangement = if (reverse) Arrangement.TopReversed else Arrangement.Bottom,
) {
val rot by transition.animateFloat {
if (it == EnterExitState.Visible) 0f else 180f
}
IconButton(
modifier = Modifier
.rotate(rot)
.sharedBounds(
rememberSharedContentState("expand"),
this@AnimatedContent
),
onClick = { onExpand(false) }
) {
Icon(Icons.Rounded.ExpandLess, null)
}
if (editButton) {
SmallFloatingActionButton(
modifier = Modifier
.sharedBounds(
rememberSharedContentState("edit"),
this@AnimatedContent
),
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
onClick = { sheetManager.showEditFavoritesSheet() }
) {
Icon(
imageVector = Icons.Rounded.Edit,
contentDescription = null
)
}
}
}
}
} }
} }
} }