mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-02 06:33:38 +01:00
Add missing remember keys for pane anchors and preferred width to fix stale layout on resize.
This commit is contained in:
committed by
Alex Hart
parent
a00978d96e
commit
51bd2d51c6
@@ -44,7 +44,6 @@ import androidx.compose.foundation.layout.systemBarsPadding
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.layout.PaneAdaptedValue
|
||||
import androidx.compose.material3.adaptive.layout.PaneExpansionAnchor
|
||||
import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldRole
|
||||
@@ -431,7 +430,6 @@ class MainActivity :
|
||||
}
|
||||
|
||||
val isSplitPane = LocalResources.current.rememberIsSplitPane()
|
||||
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
|
||||
val contentLayoutData = MainContentLayoutData.rememberContentLayoutData(mainToolbarState.mode)
|
||||
|
||||
MainContainer {
|
||||
@@ -439,7 +437,7 @@ class MainActivity :
|
||||
val listPaneWidth = contentLayoutData.rememberDefaultPanePreferredWidth(maxWidth)
|
||||
val navigationType = NavigationType.rememberNavigationType()
|
||||
|
||||
val anchors = remember(contentLayoutData, mainToolbarState) {
|
||||
val anchors = remember(contentLayoutData, mainToolbarState, listPaneWidth, navigationType) {
|
||||
val halfPartitionWidth = contentLayoutData.partitionWidth / 2
|
||||
|
||||
val detailOffset = when {
|
||||
@@ -467,7 +465,7 @@ class MainActivity :
|
||||
anchors.indexOf(paneExpansionState.currentAnchor)
|
||||
}
|
||||
|
||||
LaunchedEffect(windowSizeClass) {
|
||||
LaunchedEffect(anchors) {
|
||||
val index = when {
|
||||
paneAnchorIndex < 0 -> 1
|
||||
paneAnchorIndex > anchors.lastIndex -> anchors.lastIndex
|
||||
|
||||
@@ -58,7 +58,7 @@ data class MainContentLayoutData(
|
||||
val isSplitPane = LocalResources.current.rememberIsSplitPane()
|
||||
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
|
||||
|
||||
return remember(maxWidth, windowSizeClass) {
|
||||
return remember(maxWidth, windowSizeClass, isSplitPane) {
|
||||
when {
|
||||
!isSplitPane -> maxWidth
|
||||
windowSizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND) -> 416.dp
|
||||
|
||||
@@ -120,7 +120,7 @@ class MainNavigationViewModel(
|
||||
* where the user can change configurations (such as opening a foldable) and we will restore state and errantly
|
||||
* take them back into a PRIMARY pane. This boolean helps avoid these cases.
|
||||
*/
|
||||
private var lockPaneToSecondary: Boolean by savedStateHandle.delegate(LOCK_PANE_TO_SECONDARY, false)
|
||||
private var lockPaneToSecondary: Boolean by savedStateHandle.delegate(LOCK_PANE_TO_SECONDARY, true)
|
||||
|
||||
val snackbarRegistry = SnackbarStateConsumerRegistry()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user