fun StartNotificationsScreen()

in shared/src/commonMain/kotlin/org/jetbrains/kotlinconf/screens/StartNotificationsScreen.kt [38:102]


fun StartNotificationsScreen(
    onDone: () -> Unit,
    viewModel: StartNotificationsViewModel = koinViewModel(),
) {
    val notificationSettings = viewModel.notificationSettings.collectAsStateWithLifecycle().value

    LaunchedEffect(Unit) {
        viewModel.permissionHandlingDone.collect { done ->
            if (done) onDone()
        }
    }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(color = KotlinConfTheme.colors.mainBackground)
            .windowInsetsPadding(WindowInsets.safeDrawing)
    ) {
        Column(
            verticalArrangement = Arrangement.spacedBy(24.dp),
            modifier = Modifier
                .verticalScroll(rememberScrollState())
                .padding(horizontal = 12.dp, vertical = 16.dp)
                .weight(1f)
        ) {
            Image(
                imageVector = vectorResource(Res.drawable.kodee_notifications),
                contentDescription = null,
                modifier = Modifier.fillMaxWidth()
                    .size(160.dp)
            )
            Text(
                stringResource(Res.string.notifications_title),
                style = KotlinConfTheme.typography.h1,
                modifier = Modifier.semantics {
                    heading()
                }
            )
            Text(
                stringResource(Res.string.notifications_description),
                color = KotlinConfTheme.colors.longText,
            )
            if (notificationSettings != null) {
                NotificationSettings(
                    notificationSettings = notificationSettings,
                    onChangeSettings = { viewModel.setNotificationSettings(it) }
                )
            }
        }

        Row(
            horizontalArrangement = Arrangement.spacedBy(16.dp),
            modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp)
        ) {
            Button(
                label = stringResource(Res.string.notifications_lets_get_started),
                onClick = {
                    viewModel.requestNotificationPermissions()
                },
                modifier = Modifier.weight(1f),
                primary = true,
            )
        }
    }
}