Skip to content

Commit

Permalink
improved performance and character sheet back button
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Apr 26, 2024
1 parent eb1f62d commit 6967742
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ fun LazyListState.isScrollingUp(): Boolean {
@OptIn(ExperimentalMaterial3Api::class)
fun SheetState.isFullyExpandedOrTargeted(forceFullExpand: Boolean = false): Boolean {
val checkState = if (this.hasExpandedState) {
if (!this.hasPartiallyExpandedState) {
return false
}
SheetValue.Expanded
} else {
if (forceFullExpand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,16 @@ fun CollapsingToolbar(
},
actions = {
val mediumState by mediumStateFlow.collectAsStateWithLifecycle()
val isFavoriteBlocked by isFavoriteBlockedFlow.collectAsStateWithLifecycle()
val isFavorite by isFavoriteFlow.collectAsStateWithLifecycle()
var favoriteChanged by remember(isFavorite) { mutableStateOf<Boolean?>(null) }

AnimatedVisibility(
visible = mediumState.isSuccess,
enter = fadeIn(),
exit = fadeOut()
) {
val isFavoriteBlocked by isFavoriteBlockedFlow.collectAsStateWithLifecycle()
val isFavorite by isFavoriteFlow.collectAsStateWithLifecycle()
var favoriteChanged by remember(isFavorite) { mutableStateOf<Boolean?>(null) }

IconButton(
modifier = if (isCollapsed) {
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ fun CharacterDialog(component: CharacterComponent) {
) {
val image by component.image.collectAsStateWithLifecycle()
val state by component.state.collectAsStateWithLifecycle()
val isFavoriteBlocked by component.isFavoriteBlocked.collectAsStateWithLifecycle()
val isFavorite by component.isFavorite.collectAsStateWithLifecycle()
var favoriteChanged by remember(isFavorite) { mutableStateOf<Boolean?>(null) }

this@ModalBottomSheet.AnimatedVisibility(
modifier = Modifier.align(Alignment.CenterStart),
Expand Down Expand Up @@ -102,6 +99,10 @@ fun CharacterDialog(component: CharacterComponent) {
enter = fadeIn(),
exit = fadeOut()
) {
val isFavoriteBlocked by component.isFavoriteBlocked.collectAsStateWithLifecycle()
val isFavorite by component.isFavorite.collectAsStateWithLifecycle()
var favoriteChanged by remember(isFavorite) { mutableStateOf<Boolean?>(null) }

IconButton(
onClick = {
favoriteChanged = !(favoriteChanged ?: isFavorite)
Expand Down

0 comments on commit 6967742

Please sign in to comment.