Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SystemUiController] Update SystemUiController samples #1259

Merged
merged 1 commit into from Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,7 +17,7 @@
package com.google.accompanist.sample.systemuicontroller

import android.os.Bundle
import android.view.ViewGroup
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
Expand All @@ -32,12 +32,15 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.Checkbox
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -55,6 +58,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogWindowProvider
Expand Down Expand Up @@ -86,9 +90,11 @@ class DialogSystemBarsColorSample : ComponentActivity() {
val dialogWindowProvider = LocalView.current.parent as DialogWindowProvider
// Setup the dialog to go edge-to-edge
SideEffect {
window.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
// Use SOFT_INPUT_ADJUST_RESIZE for API compatibility with IME insets
// See https://issuetracker.google.com/issues/176400965
@Suppress("DEPRECATION")
dialogWindowProvider.window.setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
)
WindowCompat.setDecorFitsSystemWindows(
dialogWindowProvider.window,
Expand Down Expand Up @@ -171,18 +177,21 @@ private fun Sample(parentSystemUiController: SystemUiController) {
Column(
Modifier
.fillMaxSize()
.systemBarsPadding()
.safeDrawingPadding()
) {
TopAppBar(
title = { Text(stringResource(R.string.system_ui_controller_title_color_dialog)) },
backgroundColor = MaterialTheme.colors.surface.copy(alpha = 0.5f),
elevation = 0.dp,
)
Spacer(modifier = Modifier.weight(1f))
var text by remember { mutableStateOf(TextFieldValue("Test for IME support")) }
TextField(value = text, onValueChange = { text = it })
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.background(MaterialTheme.colors.surface.copy(alpha = 0.5f))
.padding(vertical = 16.dp),
) {
Expand Down