Fix crash
This commit is contained in:
parent
dbd37b1aeb
commit
43c295c832
@ -20,13 +20,13 @@ import androidx.compose.foundation.layout.fillMaxHeight
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.imePadding
|
|
||||||
import androidx.compose.foundation.layout.offset
|
import androidx.compose.foundation.layout.offset
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredWidth
|
import androidx.compose.foundation.layout.requiredWidth
|
||||||
import androidx.compose.foundation.layout.safeDrawing
|
import androidx.compose.foundation.layout.safeDrawing
|
||||||
import androidx.compose.foundation.layout.systemBarsPadding
|
import androidx.compose.foundation.layout.systemBarsPadding
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
|
import androidx.compose.foundation.layout.wrapContentHeight
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
import androidx.compose.foundation.pager.PagerDefaults
|
import androidx.compose.foundation.pager.PagerDefaults
|
||||||
@ -84,6 +84,7 @@ import de.mm20.launcher2.ui.launcher.widgets.clock.ClockWidget
|
|||||||
import de.mm20.launcher2.ui.locals.LocalPreferDarkContentOverWallpaper
|
import de.mm20.launcher2.ui.locals.LocalPreferDarkContentOverWallpaper
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PagerScaffold(
|
fun PagerScaffold(
|
||||||
@ -228,7 +229,7 @@ fun PagerScaffold(
|
|||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val `handleBackOrHomeEvent` = {
|
val handleBackOrHomeEvent = {
|
||||||
when {
|
when {
|
||||||
isSearchOpen -> {
|
isSearchOpen -> {
|
||||||
viewModel.closeSearch()
|
viewModel.closeSearch()
|
||||||
@ -250,12 +251,13 @@ fun PagerScaffold(
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BackHandler {
|
BackHandler {
|
||||||
`handleBackOrHomeEvent`()
|
handleBackOrHomeEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val keyboardController = LocalSoftwareKeyboardController.current
|
val keyboardController = LocalSoftwareKeyboardController.current
|
||||||
@ -275,12 +277,15 @@ fun PagerScaffold(
|
|||||||
}
|
}
|
||||||
return super.onPreScroll(available, source)
|
return super.onPreScroll(available, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPostScroll(
|
override fun onPostScroll(
|
||||||
consumed: Offset,
|
consumed: Offset,
|
||||||
available: Offset,
|
available: Offset,
|
||||||
source: NestedScrollSource
|
source: NestedScrollSource
|
||||||
): Offset {
|
): Offset {
|
||||||
if (source == NestedScrollSource.Drag && !isWidgetEditMode) gestureManager.dispatchDrag(available)
|
if (source == NestedScrollSource.Drag && !isWidgetEditMode) gestureManager.dispatchDrag(
|
||||||
|
available
|
||||||
|
)
|
||||||
val deltaSearchBarOffset =
|
val deltaSearchBarOffset =
|
||||||
consumed.y * if (isSearchOpen && reverseSearchResults) 1 else -1
|
consumed.y * if (isSearchOpen && reverseSearchResults) 1 else -1
|
||||||
searchBarOffset.value =
|
searchBarOffset.value =
|
||||||
@ -320,7 +325,6 @@ fun PagerScaffold(
|
|||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.nestedScroll(nestedScrollConnection)
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
@ -350,7 +354,7 @@ fun PagerScaffold(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
// FIXME: Workaround https://issuetracker.google.com/issues/276738324
|
// FIXME: Workaround https://issuetracker.google.com/issues/276738324
|
||||||
pageNestedScrollConnection = remember { object: NestedScrollConnection {} }
|
pageNestedScrollConnection = nestedScrollConnection
|
||||||
) {
|
) {
|
||||||
when (it) {
|
when (it) {
|
||||||
0 -> {
|
0 -> {
|
||||||
@ -522,16 +526,25 @@ fun PagerScaffold(
|
|||||||
LauncherSearchBar(
|
LauncherSearchBar(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(if (bottomSearchBar) Alignment.BottomCenter else Alignment.TopCenter)
|
.align(if (bottomSearchBar) Alignment.BottomCenter else Alignment.TopCenter)
|
||||||
.padding(8.dp)
|
.fillMaxWidth()
|
||||||
|
.wrapContentHeight()
|
||||||
.windowInsetsPadding(WindowInsets.safeDrawing)
|
.windowInsetsPadding(WindowInsets.safeDrawing)
|
||||||
.imePadding()
|
.padding(8.dp)
|
||||||
.offset {
|
.offset {
|
||||||
IntOffset(
|
IntOffset(
|
||||||
0,
|
0,
|
||||||
if (focusSearchBar || fixedSearchBar) 0 else searchBarOffset.value.toInt() * if (bottomSearchBar) 1 else -1
|
if (focusSearchBar || fixedSearchBar) 0 else searchBarOffset.value.toInt() * if (bottomSearchBar) 1 else -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.offset(y = widgetEditModeOffset),
|
.offset {
|
||||||
|
IntOffset(
|
||||||
|
0,
|
||||||
|
with(density) {
|
||||||
|
widgetEditModeOffset
|
||||||
|
.toPx()
|
||||||
|
.roundToInt()
|
||||||
|
})
|
||||||
|
},
|
||||||
level = { searchBarLevel },
|
level = { searchBarLevel },
|
||||||
focused = focusSearchBar,
|
focused = focusSearchBar,
|
||||||
onFocusChange = {
|
onFocusChange = {
|
||||||
|
|||||||
@ -207,8 +207,10 @@ abstract class SharedLauncherActivity(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
scaleX = enterTransitionProgress.value
|
scaleX =
|
||||||
scaleY = enterTransitionProgress.value
|
0.5f + enterTransitionProgress.value * 0.5f
|
||||||
|
scaleY =
|
||||||
|
0.5f + enterTransitionProgress.value * 0.5f
|
||||||
alpha = enterTransitionProgress.value
|
alpha = enterTransitionProgress.value
|
||||||
},
|
},
|
||||||
darkStatusBarIcons = lightStatus,
|
darkStatusBarIcons = lightStatus,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user