为什么paddingvalue在JetPack中不工作
我的底部逐步效果具有paddingvalue。我在应用程序中有一个飞溅屏幕,之后,我有房屋屏幕屏幕。当我想导航尚未显示底部导航到显示它的屏幕的屏幕时,我的应用程序会刷新。我该如何修复?
MyKuyaClientTheme(darkTheme = false) {
if (BuildConfig.FLAVOR == "development" || BuildConfig.FLAVOR == "staging") {
SensorListenerCompose {
clientNavigator.navigate(LoggerDestination.route())
}
}
SystemBroadcastReceiver(Constants.UPDATE_UNRATED_JOBS) { intent ->
intent?.let {
val request = it.getParcelableArrayExtra("unratedjobs")?.get(0) as Request
val isInRatingJobs = it.getBooleanExtra("inratingjob", false)
if (!isInRatingJobs)
clientNavigator.navigate(
JobRatingDestination.createJobRatingRoute(
Gson().toJson(request)
)
)
}
}
Surface(
color = AppColor.ThemeColor.BACKGROUND,
modifier = Modifier
.fillMaxSize()
) {
Box(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxSize()) {
ConnectivityStatus()
**ClientScaffold(clientNavigator)**
}
val gpsEnable by locationHelper.gpsProviderState
if (!gpsEnable) {
MakeSureLocEnable(this@MainActivity)
}
}
}
}
fun ClientScaffold(clientNavigator: ClientNavigator?) {
var showBottomBar by rememberSaveable { mutableStateOf(false) }
val systemUiController = rememberSystemUiController()
val sheetState =
rememberModalBottomSheetState(ModalBottomSheetValue.Hidden, SwipeableDefaults.AnimationSpec)
val bottomSheetNavigator = rememberBottomSheetNavigatorFix(sheetState)
val navController = rememberNavController()
navController.navigatorProvider += bottomSheetNavigator
systemUiController.setStatusBarColor(color = Color.Transparent)
LaunchedEffect(navController) {
clientNavigator?.destinations?.collectLatest { event ->
when (event) {
is NavigatorEvent.NavigateUp -> {
sheetState.hide()
navController.navigateUp()
}
is NavigatorEvent.PopBackStack -> {
sheetState.hide()
navController.popBackStack()
}
is NavigatorEvent.Directions -> {
navController.navigate(
event.destination,
event.builder
)
}
}
}
}
ModalBottomSheetLayout(
bottomSheetNavigator = bottomSheetNavigator,
sheetShape = RoundedCornerShape(16.dp),
) {
Scaffold(
bottomBar = {
MyKuyaBottomNavigation(navController)
},
content = { paddingValues ->
NavHost(
navController = navController,
startDestination = SplashDestination.route(),
**modifier = Modifier.padding(paddingValues = paddingValues),**
) {
addComposableDestinations(navController)
}
}
)
}
}
我认为这与更改PaddingValue值有关
I have a BottomNavigation that has paddingValue. I have a splash screen in the app and after that, I have HomeScreen HomeScreen. When I want to navigate a screen that has not shown bottom navigation to a screen that shows it, My app is refreshed. how can i fix it?
MyKuyaClientTheme(darkTheme = false) {
if (BuildConfig.FLAVOR == "development" || BuildConfig.FLAVOR == "staging") {
SensorListenerCompose {
clientNavigator.navigate(LoggerDestination.route())
}
}
SystemBroadcastReceiver(Constants.UPDATE_UNRATED_JOBS) { intent ->
intent?.let {
val request = it.getParcelableArrayExtra("unratedjobs")?.get(0) as Request
val isInRatingJobs = it.getBooleanExtra("inratingjob", false)
if (!isInRatingJobs)
clientNavigator.navigate(
JobRatingDestination.createJobRatingRoute(
Gson().toJson(request)
)
)
}
}
Surface(
color = AppColor.ThemeColor.BACKGROUND,
modifier = Modifier
.fillMaxSize()
) {
Box(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxSize()) {
ConnectivityStatus()
**ClientScaffold(clientNavigator)**
}
val gpsEnable by locationHelper.gpsProviderState
if (!gpsEnable) {
MakeSureLocEnable(this@MainActivity)
}
}
}
}
fun ClientScaffold(clientNavigator: ClientNavigator?) {
var showBottomBar by rememberSaveable { mutableStateOf(false) }
val systemUiController = rememberSystemUiController()
val sheetState =
rememberModalBottomSheetState(ModalBottomSheetValue.Hidden, SwipeableDefaults.AnimationSpec)
val bottomSheetNavigator = rememberBottomSheetNavigatorFix(sheetState)
val navController = rememberNavController()
navController.navigatorProvider += bottomSheetNavigator
systemUiController.setStatusBarColor(color = Color.Transparent)
LaunchedEffect(navController) {
clientNavigator?.destinations?.collectLatest { event ->
when (event) {
is NavigatorEvent.NavigateUp -> {
sheetState.hide()
navController.navigateUp()
}
is NavigatorEvent.PopBackStack -> {
sheetState.hide()
navController.popBackStack()
}
is NavigatorEvent.Directions -> {
navController.navigate(
event.destination,
event.builder
)
}
}
}
}
ModalBottomSheetLayout(
bottomSheetNavigator = bottomSheetNavigator,
sheetShape = RoundedCornerShape(16.dp),
) {
Scaffold(
bottomBar = {
MyKuyaBottomNavigation(navController)
},
content = { paddingValues ->
NavHost(
navController = navController,
startDestination = SplashDestination.route(),
**modifier = Modifier.padding(paddingValues = paddingValues),**
) {
addComposableDestinations(navController)
}
}
)
}
}
I think it's to do with changing the paddingValue value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论