mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-04 20:34:14 +01:00
Fix edge-to-edge issue with forward sheet.
This commit is contained in:
+9
-9
@@ -22,10 +22,12 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalResources
|
||||
@@ -132,7 +134,9 @@ class MultiselectForwardFragment :
|
||||
private var dismissibleDialog: SimpleProgressDialog.DismissibleDialog? = null
|
||||
private var handler: Handler? = null
|
||||
|
||||
/** Height of the bottom bar's content, excluding any window inset padding it applies. */
|
||||
private var bottomBarHeightPx by mutableIntStateOf(0)
|
||||
private var isBottomBarVisible by mutableStateOf(false)
|
||||
|
||||
private val args: MultiselectForwardFragmentArgs by lazy {
|
||||
requireArguments().getParcelableCompat(ARGS, MultiselectForwardFragmentArgs::class.java)!!
|
||||
@@ -157,7 +161,7 @@ class MultiselectForwardFragment :
|
||||
mapStateToConfiguration = this@MultiselectForwardFragment::getConfiguration,
|
||||
contactSearchCallbacks = remember { SearchCallbacks() },
|
||||
additionalEntries = findListener<SearchConfigurationProvider>()?.getAdditionalEntries() ?: persistentHashMapOf(),
|
||||
bottomContentPadding = with(LocalDensity.current) { bottomBarHeightPx.toDp() }
|
||||
bottomContentPadding = with(LocalDensity.current) { (if (isBottomBarVisible) bottomBarHeightPx else 0).toDp() }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -203,9 +207,8 @@ class MultiselectForwardFragment :
|
||||
isSplitPane = isSplitPane,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
// Bottom-sheet hosts already clear the navigation bar via BottomSheetBehavior's
|
||||
// edge-to-edge padding; padding again here would double up.
|
||||
.then(if (args.isWrappedInBottomSheet) Modifier else Modifier.navigationBarsPadding())
|
||||
.navigationBarsPadding()
|
||||
.onSizeChanged { bottomBarHeightPx = it.height }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -217,10 +220,6 @@ class MultiselectForwardFragment :
|
||||
|
||||
bottomBar.visible = false
|
||||
|
||||
bottomBar.addOnLayoutChangeListener { _, _, top, _, bottom, _, _, _, _ ->
|
||||
bottomBarHeightPx = if (bottomBar.isVisible) bottom - top else 0
|
||||
}
|
||||
|
||||
container.addView(bottomBar)
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
@@ -247,13 +246,14 @@ class MultiselectForwardFragment :
|
||||
if (contactSelection.isNotEmpty() && !bottomBar.isVisible) {
|
||||
bottomBar.animation = AnimationUtils.loadAnimation(requireContext(), R.anim.slide_fade_from_bottom)
|
||||
bottomBar.visible = true
|
||||
isBottomBarVisible = true
|
||||
if (args.forceDisableAddMessage) {
|
||||
ViewUtil.hideKeyboard(requireContext(), bottomBar)
|
||||
}
|
||||
} else if (contactSelection.isEmpty() && bottomBar.isVisible) {
|
||||
bottomBar.animation = AnimationUtils.loadAnimation(requireContext(), R.anim.slide_fade_to_bottom)
|
||||
bottomBar.visible = false
|
||||
bottomBarHeightPx = 0
|
||||
isBottomBarVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user