小编Jar*_*ojr的帖子

Jetpack Compose Navigation:如何将数组作为参数传递?

我有一个显示过滤器选项的过滤器对话框:

在此输入图像描述

当我单击“父平台”部分时,我将导航到带有PlatformsScreen两个参数的。第一个参数parent是 int ,第二个参数是 platform ,它是一个 int 数组:

sealed class Screen(val route: String, val arguments: List<NamedNavArgument>) {

    object PlatformScreen : Screen(PLATFORM_ROUTE,arguments = 
        listOf(navArgument("parent", builder = {type = NavType.IntType}),
        navArgument("platforms",builder = {type = NavType.IntArrayType})))
}


// click action
@Composable
fun FilterDialog(
    modifier: Modifier = Modifier,
    viewModel: FilterViewModel,
    navigateToPlatformScreen: (Int,Array<Int?>) -> Unit
) {
 val filterState by viewModel.filterState.collectAsState()
 Row(//other stuff
       .clickable {
                    navigateToPlatformScreen(filterState.parentPlatform?.id ?: -1,
                    filterState.platforms?.map { it?.id }?.toTypedArray() ?: arrayOf(-1))
                }
)
  //here is my filter bottom …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-jetpack-compose jetpack-compose-navigation

8
推荐指数
1
解决办法
6279
查看次数

Jetpack Compose 浮动操作按钮未显示

我有一个底部表单对话框。对于该对话框,我使用的是导航库ModalBottomSheetDialog中的Accompanist。在名为 的可组合乐趣对话框中PlatformsScreen,我有一个LazyColumn带有RadioButton. 每当选择任何单选按钮时,我都会将所选项目添加到selectedPlatforms其中mutableList

@Composable
fun PlatformsScreen(
    modifier: Modifier = Modifier,
    navController: NavController,
    viewModel: PlatformsScreenViewModel = hiltViewModel(),
) {
    // this is the platforms that I fetch from network
    val platforms = viewModel.platforms.observeAsState()

    val listState = rememberLazyListState()

    //this is the platforms that I selected from the platforms list
    val selectedPlatforms by rememberSaveable {
        mutableStateOf(mutableListOf<Platform>())
    }
    
    DefaultScreenUI(toolbar = {
        BottomSheetDialogToolbar(title = "Platforms")
    },
        floatingActionButton = {
            //This is …
Run Code Online (Sandbox Code Playgroud)

android kotlin bottom-sheet android-jetpack-compose

5
推荐指数
1
解决办法
3408
查看次数

Jetpack Compose Accompanist 导航:启动屏幕后出现空白屏幕

我有一个在应用程序启动时显示的启动屏幕。我正在使用SplashScreenAPI作为启动屏幕。我还使用伴奏导航库来通过动画进行导航。将伴奏版本从 0.24.7-alpha 更新到 0.24.8-beta后,我遇到了一个问题。问题是:

正如您所看到的,在显示初始屏幕后,屏幕会出现一秒钟的空白,然后导航到起始目的地。

这也是版本 0.24.7-alpha 的行为:

如果需要的话,这里还有代码:

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@AndroidEntryPoint
class AuthActivity : ComponentActivity() {

    private val splashViewModel: SplashViewModel by viewModels()
    private lateinit var splashScreen: SplashScreen

    override fun onCreate(savedInstanceState: Bundle?) {
        splashScreen = installSplashScreen()
        super.onCreate(savedInstanceState)
        splashScreen.setKeepOnScreenCondition {
            splashViewModel.isLoading.value
        }
        splashScreen.setOnExitAnimationListener {
            val startDestination = splashViewModel.navDestination.value.route
            if (startDestination == AUTH_GRAPH) {
                it.remove()
            } else {
                val intent = Intent(this@AuthActivity, MainActivity::class.java)
                startActivity(intent)
                finish()
            }
        }
        setContent {
            val errorMessage by splashViewModel.errorFlow.collectAsState()
            val widthSizeClass = calculateWindowSizeClass(this).widthSizeClass
            ProvideLocalWindowWidthSizeClass(widthSizeClass …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-architecture-navigation android-jetpack-compose jetpack-compose-accompanist

5
推荐指数
0
解决办法
2687
查看次数

Jetpack Compose:如何创建评级栏?

我正在尝试实施评级栏。我参考https://gist.github.com/vitorprado/0ae4ad60c296aefafba4a157bb165e60但我不明白这段代码中的任何内容。它有效,但当我使用此代码时,星星没有圆角。我想实现如下所示的东西:

android kotlin android-jetpack-compose

4
推荐指数
1
解决办法
5751
查看次数