为什么paddingvalue在JetPack中不工作

发布于 2025-01-24 08:22:56 字数 3732 浏览 0 评论 0原文

我的底部逐步效果具有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文