Skip to content

Commit d099600

Browse files
authored
Merge pull request #1639 from DimensionDev/feature/tablet_ui
update status media ui for tablet
2 parents 864da6b + ba54d2a commit d099600

File tree

25 files changed

+649
-648
lines changed

25 files changed

+649
-648
lines changed

app/src/main/java/dev/dimension/flare/ui/component/NavigationSuiteScaffold2.kt

Lines changed: 94 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ import dev.dimension.flare.R
8383
import dev.dimension.flare.data.model.BottomBarBehavior
8484
import dev.dimension.flare.data.model.BottomBarStyle
8585
import dev.dimension.flare.data.model.LocalAppearanceSettings
86+
import soup.compose.material.motion.animation.materialElevationScaleIn
87+
import soup.compose.material.motion.animation.materialElevationScaleOut
8688

8789
val LocalBottomBarHeight = androidx.compose.runtime.staticCompositionLocalOf<Dp> { 0.dp }
8890
val LocalBottomBarShowing = androidx.compose.runtime.staticCompositionLocalOf<Boolean> { false }
@@ -351,12 +353,47 @@ fun NavigationSuiteScaffold2(
351353
) {
352354
content.invoke()
353355
}
356+
357+
val isFloating =
358+
remember(bottomBarState) {
359+
when (bottomBarState) {
360+
BottomBarState.FloatingNormal -> true
361+
BottomBarState.FloatingMinimized -> true
362+
BottomBarState.FloatingHidden -> true
363+
BottomBarState.ClassicNormal -> false
364+
BottomBarState.ClassicHidden -> false
365+
}
366+
}
367+
val isHidden =
368+
remember(bottomBarState) {
369+
when (bottomBarState) {
370+
BottomBarState.FloatingNormal -> false
371+
BottomBarState.FloatingMinimized -> false
372+
BottomBarState.FloatingHidden -> true
373+
BottomBarState.ClassicNormal -> false
374+
BottomBarState.ClassicHidden -> true
375+
}
376+
}
354377
Column(
355378
modifier =
356379
Modifier
357380
.fillMaxWidth()
358381
.align(Alignment.BottomCenter)
359-
.animateContentSize(),
382+
.windowInsetsPadding(
383+
WindowInsets.systemBars.only(
384+
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom,
385+
),
386+
).let {
387+
if (!isHidden) {
388+
if (isFloating) {
389+
it.padding(bottom = 56.dp)
390+
} else {
391+
it.padding(bottom = 80.dp, end = 56.dp)
392+
}
393+
} else {
394+
it
395+
}
396+
}.animateContentSize(),
360397
horizontalAlignment = Alignment.CenterHorizontally,
361398
verticalArrangement = Arrangement.Bottom,
362399
) {
@@ -378,23 +415,29 @@ fun NavigationSuiteScaffold2(
378415
}
379416
},
380417
)
381-
androidx.compose.animation.AnimatedVisibility(
382-
layoutType == NavigationSuiteType.NavigationBar &&
383-
scope.itemList.any { item -> item.selected } &&
384-
(
385-
bottomBarState != BottomBarState.FloatingHidden &&
386-
bottomBarState != BottomBarState.ClassicHidden
387-
),
388-
enter = slideInVertically { it },
389-
exit = slideOutVertically { it },
390-
) {
391-
Box(
418+
}
419+
420+
androidx.compose.animation.AnimatedVisibility(
421+
layoutType == NavigationSuiteType.NavigationBar &&
422+
scope.itemList.any { item -> item.selected } &&
423+
(
424+
bottomBarState != BottomBarState.FloatingHidden &&
425+
bottomBarState != BottomBarState.ClassicHidden
426+
),
427+
enter = slideInVertically { it },
428+
exit = slideOutVertically { it },
429+
modifier =
430+
Modifier
431+
.fillMaxWidth()
432+
.align(Alignment.BottomCenter),
433+
) {
434+
Box(
392435
// horizontalArrangement = Arrangement.SpaceBetween,
393436
// verticalAlignment = Alignment.Bottom,
394-
contentAlignment = Alignment.BottomCenter,
395-
modifier =
396-
Modifier
397-
.fillMaxWidth(),
437+
// contentAlignment = Alignment.BottomCenter,
438+
modifier =
439+
Modifier
440+
.fillMaxWidth(),
398441
// .windowInsetsPadding(
399442
// WindowInsets.systemBars.only(
400443
// WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom,
@@ -404,43 +447,51 @@ fun NavigationSuiteScaffold2(
404447
// horizontal = 16.dp,
405448
// vertical = 8.dp,
406449
// ),
450+
) {
451+
SharedTransitionLayout(
452+
modifier = Modifier.align(Alignment.BottomStart),
407453
) {
408-
SharedTransitionLayout(
409-
modifier = Modifier.align(Alignment.BottomStart),
410-
) {
454+
AnimatedContent(
455+
bottomBarState,
456+
) { bottomBarState ->
457+
BottomBar(
458+
state = bottomBarState,
459+
provider = scope,
460+
animatedVisibilityScope = this@AnimatedContent,
461+
)
462+
}
463+
}
464+
androidx.compose.animation.AnimatedVisibility(
465+
showFab,
466+
modifier =
467+
Modifier.align(
468+
if (bottomBarStyle == BottomBarStyle.Classic) {
469+
Alignment.BottomEnd
470+
} else {
471+
Alignment.CenterEnd
472+
},
473+
),
474+
enter =
475+
materialElevationScaleIn(
476+
initialAlpha = 0f,
477+
),
478+
exit =
479+
materialElevationScaleOut(
480+
targetAlpha = 0f,
481+
),
482+
) {
483+
SharedTransitionLayout {
411484
AnimatedContent(
412485
bottomBarState,
413486
) { bottomBarState ->
414-
BottomBar(
487+
BottomFab(
415488
state = bottomBarState,
416489
provider = scope,
417490
animatedVisibilityScope = this@AnimatedContent,
491+
onFabClicked = onFabClicked,
418492
)
419493
}
420494
}
421-
if (showFab) {
422-
SharedTransitionLayout(
423-
modifier =
424-
Modifier.align(
425-
if (bottomBarStyle == BottomBarStyle.Classic) {
426-
Alignment.BottomEnd
427-
} else {
428-
Alignment.CenterEnd
429-
},
430-
),
431-
) {
432-
AnimatedContent(
433-
bottomBarState,
434-
) { bottomBarState ->
435-
BottomFab(
436-
state = bottomBarState,
437-
provider = scope,
438-
animatedVisibilityScope = this@AnimatedContent,
439-
onFabClicked = onFabClicked,
440-
)
441-
}
442-
}
443-
}
444495
}
445496
}
446497
}

app/src/main/java/dev/dimension/flare/ui/component/RefreshContainer.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fun RefreshContainer(
3030
onRefresh: () -> Unit,
3131
content: @Composable BoxScope.() -> Unit,
3232
modifier: Modifier = Modifier,
33+
contentAlignment: Alignment = Alignment.TopStart,
3334
indicatorPadding: PaddingValues = PaddingValues(0.dp),
3435
) {
3536
val hapticFeedback = LocalHapticFeedback.current
@@ -60,6 +61,7 @@ fun RefreshContainer(
6061
modifier = modifier,
6162
content = content,
6263
state = refreshState,
64+
contentAlignment = contentAlignment,
6365
indicator = {
6466
PullToRefreshDefaults.LoadingIndicator(
6567
modifier =

app/src/main/java/dev/dimension/flare/ui/component/TopLevelBackStack.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ internal class TopLevelBackStack<T : NavKey>(
2020
var topLevelKey by mutableStateOf(startKey)
2121
private set
2222

23+
var currentKey by mutableStateOf(startKey)
24+
private set
25+
2326
// Expose the back stack so it can be rendered by the NavDisplay
2427
val backStack = mutableStateListOf(startKey)
2528

2629
private fun updateBackStack() =
2730
backStack.apply {
2831
clear()
2932
addAll(topLevelStacks.flatMap { it.value })
33+
currentKey = last()
3034
}
3135

3236
fun addTopLevel(key: T) {

app/src/main/java/dev/dimension/flare/ui/screen/bluesky/BlueskyFeedScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ internal fun BlueskyFeedScreen(
197197

198198
StatusActionButton(
199199
icon = if (item.liked) FontAwesomeIcons.Solid.Heart else FontAwesomeIcons.Regular.Heart,
200-
digits = item.digits,
200+
number = item.likedCount,
201201
color = if (item.liked) Color.Red else LocalContentColor.current,
202202
onClicked = {
203203
if (item.liked) {

app/src/main/java/dev/dimension/flare/ui/screen/home/HomeScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ internal fun HomeScreen(afterInit: () -> Unit) {
163163
modifier = Modifier.fillMaxSize(),
164164
bottomBarAutoHideEnabled = state.navigationState.bottomBarAutoHideEnabled,
165165
layoutType = layoutType,
166-
showFab = userState.isSuccess && accountType !is AccountType.Guest,
166+
showFab = userState.isSuccess && accountType !is AccountType.Guest && topLevelBackStack.currentKey is Route.Home,
167167
onFabClicked = {
168168
navigate(Route.Compose.New(accountType))
169169
},

app/src/main/java/dev/dimension/flare/ui/screen/home/NotificationScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ internal fun NotificationScreen() {
188188
},
189189
scrollBehavior = topAppBarScrollBehavior,
190190
actions = {
191-
if (!windowInfo.windowSizeClass.isCompat() && state.notifications.size == 1) {
191+
if (!windowInfo.windowSizeClass.isCompat()) {
192192
state.supportedNotificationFilters.onSuccess { filters ->
193193
if (filters.size > 1) {
194194
NotificationFilterSelector(

app/src/main/java/dev/dimension/flare/ui/screen/media/MediaScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ internal fun MediaScreen(
150150
modifier =
151151
Modifier
152152
.fillMaxWidth()
153+
.systemBarsPadding()
153154
.align(Alignment.TopCenter),
154155
enter = slideInVertically { -it },
155156
exit = slideOutVertically { -it },

0 commit comments

Comments
 (0)