Fix PullDownScaffold IME behavior
This commit is contained in:
parent
d0328da2f9
commit
466b7c2384
@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.systemBarsPadding
|
import androidx.compose.foundation.layout.systemBarsPadding
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
@ -23,6 +24,7 @@ import com.afollestad.materialdialogs.MaterialDialog
|
|||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
import com.afollestad.materialdialogs.callbacks.onDismiss
|
import com.afollestad.materialdialogs.callbacks.onDismiss
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
import com.android.launcher3.GestureNavContract
|
||||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||||
import de.mm20.launcher2.icons.DynamicIconController
|
import de.mm20.launcher2.icons.DynamicIconController
|
||||||
import de.mm20.launcher2.ui.R
|
import de.mm20.launcher2.ui.R
|
||||||
@ -31,6 +33,8 @@ import de.mm20.launcher2.ui.base.ProvideSettings
|
|||||||
import de.mm20.launcher2.ui.component.NavBarEffects
|
import de.mm20.launcher2.ui.component.NavBarEffects
|
||||||
import de.mm20.launcher2.ui.launcher.modals.EditFavoritesView
|
import de.mm20.launcher2.ui.launcher.modals.EditFavoritesView
|
||||||
import de.mm20.launcher2.ui.launcher.modals.HiddenItemsSheet
|
import de.mm20.launcher2.ui.launcher.modals.HiddenItemsSheet
|
||||||
|
import de.mm20.launcher2.ui.launcher.transitions.HomeTransitionManager
|
||||||
|
import de.mm20.launcher2.ui.launcher.transitions.LocalHomeTransitionManager
|
||||||
import de.mm20.launcher2.ui.theme.LauncherTheme
|
import de.mm20.launcher2.ui.theme.LauncherTheme
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
|
|
||||||
@ -39,6 +43,8 @@ class LauncherActivity : BaseActivity() {
|
|||||||
|
|
||||||
private val viewModel: LauncherActivityVM by viewModels()
|
private val viewModel: LauncherActivityVM by viewModels()
|
||||||
|
|
||||||
|
private val homeTransitionManager = HomeTransitionManager()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@ -47,44 +53,47 @@ class LauncherActivity : BaseActivity() {
|
|||||||
viewModel.setDarkMode(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES)
|
viewModel.setDarkMode(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
LauncherTheme {
|
CompositionLocalProvider(
|
||||||
ProvideSettings {
|
LocalHomeTransitionManager provides homeTransitionManager
|
||||||
val lightStatus by viewModel.lightStatusBar.observeAsState(false)
|
) {
|
||||||
val lightNav by viewModel.lightNavBar.observeAsState(false)
|
LauncherTheme {
|
||||||
val hideStatus by viewModel.hideStatusBar.observeAsState(false)
|
ProvideSettings {
|
||||||
val hideNav by viewModel.hideNavBar.observeAsState(false)
|
val lightStatus by viewModel.lightStatusBar.observeAsState(false)
|
||||||
val dimBackground by viewModel.dimBackground.observeAsState(false)
|
val lightNav by viewModel.lightNavBar.observeAsState(false)
|
||||||
|
val hideStatus by viewModel.hideStatusBar.observeAsState(false)
|
||||||
|
val hideNav by viewModel.hideNavBar.observeAsState(false)
|
||||||
|
val dimBackground by viewModel.dimBackground.observeAsState(false)
|
||||||
|
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
|
|
||||||
LaunchedEffect(hideStatus) {
|
LaunchedEffect(hideStatus) {
|
||||||
systemUiController.isStatusBarVisible = !hideStatus
|
systemUiController.isStatusBarVisible = !hideStatus
|
||||||
}
|
}
|
||||||
LaunchedEffect(hideNav) {
|
LaunchedEffect(hideNav) {
|
||||||
systemUiController.isNavigationBarVisible = !hideNav
|
systemUiController.isNavigationBarVisible = !hideNav
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(if (dimBackground) Color.Black.copy(alpha = 0.30f) else Color.Transparent),
|
|
||||||
contentAlignment = Alignment.BottomCenter
|
|
||||||
) {
|
|
||||||
NavBarEffects(modifier = Modifier.fillMaxSize())
|
|
||||||
PagerScaffold(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.systemBarsPadding()
|
.background(if (dimBackground) Color.Black.copy(alpha = 0.30f) else Color.Transparent),
|
||||||
.imePadding(),
|
contentAlignment = Alignment.BottomCenter
|
||||||
darkStatusBarIcons = lightStatus,
|
) {
|
||||||
darkNavBarIcons = lightNav,
|
NavBarEffects(modifier = Modifier.fillMaxSize())
|
||||||
)
|
PagerScaffold(
|
||||||
}
|
modifier = Modifier
|
||||||
val showHiddenItems by viewModel.isHiddenItemsShown.observeAsState(false)
|
.fillMaxSize()
|
||||||
if (showHiddenItems) {
|
.systemBarsPadding(),
|
||||||
HiddenItemsSheet(onDismiss = {
|
darkStatusBarIcons = lightStatus,
|
||||||
viewModel.hideHiddenItems()
|
darkNavBarIcons = lightNav,
|
||||||
})
|
)
|
||||||
|
}
|
||||||
|
val showHiddenItems by viewModel.isHiddenItemsShown.observeAsState(false)
|
||||||
|
if (showHiddenItems) {
|
||||||
|
HiddenItemsSheet(onDismiss = {
|
||||||
|
viewModel.hideHiddenItems()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +144,11 @@ class LauncherActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
onBackPressed()
|
val navContract = intent?.let { GestureNavContract.fromIntent(it) }
|
||||||
|
if (navContract != null) {
|
||||||
|
homeTransitionManager.resolve(navContract)
|
||||||
|
} else {
|
||||||
|
onBackPressed()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,10 +7,7 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
import androidx.compose.animation.slideIn
|
import androidx.compose.animation.slideIn
|
||||||
import androidx.compose.animation.slideOut
|
import androidx.compose.animation.slideOut
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.offset
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@ -157,7 +154,8 @@ fun PagerScaffold(
|
|||||||
size = it
|
size = it
|
||||||
}
|
}
|
||||||
.verticalScroll(searchScrollState, reverseScrolling = true)
|
.verticalScroll(searchScrollState, reverseScrolling = true)
|
||||||
.padding(start = 8.dp, end = 8.dp, top = 8.dp, bottom = 56.dp)
|
.imePadding()
|
||||||
|
.padding(start = 8.dp, end = 8.dp, top = 8.dp, bottom = 64.dp)
|
||||||
.padding(bottom = webSearchPadding),
|
.padding(bottom = webSearchPadding),
|
||||||
reverse = true,
|
reverse = true,
|
||||||
)
|
)
|
||||||
@ -223,6 +221,7 @@ fun PagerScaffold(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
.padding(start = 8.dp, end = 8.dp, bottom = 8.dp)
|
.padding(start = 8.dp, end = 8.dp, bottom = 8.dp)
|
||||||
|
.imePadding()
|
||||||
.offset(y = widgetEditModeOffset),
|
.offset(y = widgetEditModeOffset),
|
||||||
level = searchBarLevel, focused = focusSearchBar, onFocusChange = {
|
level = searchBarLevel, focused = focusSearchBar, onFocusChange = {
|
||||||
if (it) viewModel.openSearch()
|
if (it) viewModel.openSearch()
|
||||||
|
|||||||
@ -235,6 +235,7 @@ fun PullDownScaffold(
|
|||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.padding(top = 56.dp)
|
.padding(top = 56.dp)
|
||||||
.padding(top = webSearchPadding)
|
.padding(top = webSearchPadding)
|
||||||
|
.imePadding()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user