mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Fix bottom chrome visibility in landscape split-screen with bottom nav.
This commit is contained in:
@@ -166,7 +166,7 @@ import org.thoughtcrime.securesms.window.AppPaneDragHandle
|
||||
import org.thoughtcrime.securesms.window.AppScaffold
|
||||
import org.thoughtcrime.securesms.window.AppScaffoldAnimationStateFactory
|
||||
import org.thoughtcrime.securesms.window.AppScaffoldNavigator
|
||||
import org.thoughtcrime.securesms.window.Navigation
|
||||
import org.thoughtcrime.securesms.window.NavigationType
|
||||
import org.thoughtcrime.securesms.window.isSplitPane
|
||||
import org.thoughtcrime.securesms.window.rememberThreePaneScaffoldNavigatorDelegate
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState
|
||||
@@ -349,14 +349,14 @@ class MainActivity : PassphraseRequiredActivity(), VoiceNoteMediaControllerOwner
|
||||
MainContainer {
|
||||
val wrappedNavigator = rememberNavigator(windowSizeClass, contentLayoutData, maxWidth)
|
||||
val listPaneWidth = contentLayoutData.rememberDefaultPanePreferredWidth(maxWidth)
|
||||
val navigation = Navigation.rememberNavigation()
|
||||
val navigationType = NavigationType.rememberNavigationType()
|
||||
|
||||
val anchors = remember(contentLayoutData, mainToolbarState) {
|
||||
val halfPartitionWidth = contentLayoutData.partitionWidth / 2
|
||||
|
||||
val detailOffset = when {
|
||||
mainToolbarState.mode == MainToolbarMode.SEARCH -> 0.dp
|
||||
navigation == Navigation.BAR -> 0.dp
|
||||
navigationType == NavigationType.BAR -> 0.dp
|
||||
else -> 80.dp
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.megaphone.Megaphone
|
||||
import org.thoughtcrime.securesms.megaphone.MegaphoneActionController
|
||||
import org.thoughtcrime.securesms.megaphone.Megaphones
|
||||
import org.thoughtcrime.securesms.window.NavigationType
|
||||
import org.thoughtcrime.securesms.window.isSplitPane
|
||||
|
||||
data class SnackbarState(
|
||||
@@ -78,13 +79,14 @@ fun MainBottomChrome(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
|
||||
val navigationType = NavigationType.rememberNavigationType()
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.animateContentSize()
|
||||
) {
|
||||
if (state.mainToolbarMode == MainToolbarMode.FULL && !windowSizeClass.isSplitPane()) {
|
||||
if (state.mainToolbarMode == MainToolbarMode.FULL && navigationType != NavigationType.RAIL) {
|
||||
Box(
|
||||
contentAlignment = Alignment.CenterEnd,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.signal.core.ui.compose.DayNightPreviews
|
||||
import org.signal.core.ui.compose.Previews
|
||||
import org.signal.core.ui.compose.theme.SignalTheme
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.window.Navigation
|
||||
import org.thoughtcrime.securesms.window.NavigationType
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private val ACTION_BUTTON_SIZE = 56.dp
|
||||
@@ -63,24 +63,24 @@ fun MainFloatingActionButtons(
|
||||
destination: MainNavigationListLocation,
|
||||
callback: MainFloatingActionButtonsCallback,
|
||||
modifier: Modifier = Modifier,
|
||||
navigation: Navigation = Navigation.rememberNavigation()
|
||||
navigationType: NavigationType = NavigationType.rememberNavigationType()
|
||||
) {
|
||||
val boxHeightDp = (ACTION_BUTTON_SIZE * 2 + ACTION_BUTTON_SPACING)
|
||||
val boxHeightPx = with(LocalDensity.current) {
|
||||
boxHeightDp.toPx().roundToInt()
|
||||
}
|
||||
|
||||
val primaryButtonAlignment = remember(navigation) {
|
||||
when (navigation) {
|
||||
Navigation.RAIL -> Alignment.TopCenter
|
||||
Navigation.BAR -> Alignment.BottomCenter
|
||||
val primaryButtonAlignment = remember(navigationType) {
|
||||
when (navigationType) {
|
||||
NavigationType.RAIL -> Alignment.TopCenter
|
||||
NavigationType.BAR -> Alignment.BottomCenter
|
||||
}
|
||||
}
|
||||
|
||||
val shadowElevation: Dp = remember(navigation) {
|
||||
when (navigation) {
|
||||
Navigation.RAIL -> 0.dp
|
||||
Navigation.BAR -> 4.dp
|
||||
val shadowElevation: Dp = remember(navigationType) {
|
||||
when (navigationType) {
|
||||
NavigationType.RAIL -> 0.dp
|
||||
NavigationType.BAR -> 4.dp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,20 +117,20 @@ private fun BoxScope.SecondaryActionButton(
|
||||
elevation: Dp,
|
||||
onCameraClick: (MainNavigationListLocation) -> Unit
|
||||
) {
|
||||
val navigation = Navigation.rememberNavigation()
|
||||
val secondaryButtonAlignment = remember(navigation) {
|
||||
when (navigation) {
|
||||
Navigation.RAIL -> Alignment.BottomCenter
|
||||
Navigation.BAR -> Alignment.TopCenter
|
||||
val navigationType = NavigationType.rememberNavigationType()
|
||||
val secondaryButtonAlignment = remember(navigationType) {
|
||||
when (navigationType) {
|
||||
NavigationType.RAIL -> Alignment.BottomCenter
|
||||
NavigationType.BAR -> Alignment.TopCenter
|
||||
}
|
||||
}
|
||||
|
||||
val offsetYProvider: (Int) -> Int = remember(navigation) {
|
||||
when (navigation) {
|
||||
Navigation.RAIL -> {
|
||||
val offsetYProvider: (Int) -> Int = remember(navigationType) {
|
||||
when (navigationType) {
|
||||
NavigationType.RAIL -> {
|
||||
{ it - boxHeightPx }
|
||||
}
|
||||
Navigation.BAR -> {
|
||||
NavigationType.BAR -> {
|
||||
{ boxHeightPx - it }
|
||||
}
|
||||
}
|
||||
@@ -146,9 +146,9 @@ private fun BoxScope.SecondaryActionButton(
|
||||
|
||||
CameraButton(
|
||||
colors = IconButtonDefaults.filledTonalIconButtonColors().copy(
|
||||
containerColor = when (navigation) {
|
||||
Navigation.RAIL -> MaterialTheme.colorScheme.surface
|
||||
Navigation.BAR -> SignalTheme.colors.colorSurface2
|
||||
containerColor = when (navigationType) {
|
||||
NavigationType.RAIL -> MaterialTheme.colorScheme.surface
|
||||
NavigationType.BAR -> SignalTheme.colors.colorSurface2
|
||||
},
|
||||
contentColor = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
@@ -266,7 +266,7 @@ private fun MainFloatingActionButtonsNavigationRailPreview() {
|
||||
MainFloatingActionButtons(
|
||||
destination = currentDestination,
|
||||
callback = callback,
|
||||
navigation = Navigation.RAIL
|
||||
navigationType = NavigationType.RAIL
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ private fun MainFloatingActionButtonsNavigationBarPreview() {
|
||||
MainFloatingActionButtons(
|
||||
destination = currentDestination,
|
||||
callback = callback,
|
||||
navigation = Navigation.BAR
|
||||
navigationType = NavigationType.BAR
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ import org.thoughtcrime.securesms.main.MainNavigationRail
|
||||
import org.thoughtcrime.securesms.main.MainNavigationState
|
||||
import kotlin.math.max
|
||||
|
||||
enum class Navigation {
|
||||
enum class NavigationType {
|
||||
RAIL,
|
||||
BAR;
|
||||
|
||||
companion object {
|
||||
@Composable
|
||||
fun rememberNavigation(): Navigation {
|
||||
fun rememberNavigationType(): NavigationType {
|
||||
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
|
||||
|
||||
return remember(windowSizeClass) {
|
||||
@@ -246,7 +246,7 @@ private fun ListAndNavigation(
|
||||
contentWindowInsets: WindowInsets,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val navigation = Navigation.rememberNavigation()
|
||||
val navigationType = NavigationType.rememberNavigationType()
|
||||
|
||||
Scaffold(
|
||||
containerColor = Color.Transparent,
|
||||
@@ -259,7 +259,7 @@ private fun ListAndNavigation(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
) {
|
||||
if (navigation == Navigation.RAIL) {
|
||||
if (navigationType == NavigationType.RAIL) {
|
||||
navRailContent()
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ private fun ListAndNavigation(
|
||||
listContent()
|
||||
}
|
||||
|
||||
if (navigation == Navigation.BAR) {
|
||||
if (navigationType == NavigationType.BAR) {
|
||||
bottomNavContent()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user