bryankeltonadams
10/03/2023, 8:49 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:06 PMbryankeltonadams
10/03/2023, 9:07 PM@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private var backPressedTime = System.currentTimeMillis()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
FishbowlApp()
}
// FishbowlDriveTheme {
// FishbowlApp()
// }
}
}
@Composable
fun FishbowlApp(
viewModel: FishbowlAppViewModel = hiltViewModel(),
appState: FishbowlAppState = rememberFishbowlAppState(
drawerState = drawerStateWithKeyboardHiding(),
clearSession = viewModel::clearSession,
),
) {
val textFieldValue = remember { mutableStateOf("") }
Scaffold(
modifier = Modifier
.fillMaxSize(),
containerColor = Color.Red
) { paddingValues ->
TextField(
value = textFieldValue.value,
onValueChange = { textFieldValue.value = it },
modifier = Modifier.padding(paddingValues)
)
}
}
Zach Klippenstein (he/him) [MOD]
10/03/2023, 9:07 PMbryankeltonadams
10/03/2023, 9:07 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:08 PMbryankeltonadams
10/03/2023, 9:08 PM<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It seems when I change android:theme to Material.Dark it will flash black instead of white.
But my main app is wrapped in a Material Theme like this
setContent {
MaterialTheme {
Scaffold(containerColor = Color.Red) { paddingValues ->
val textFieldValue = remember { mutableStateOf("") }
TextField(value = textFieldValue.value, onValueChange = {
textFieldValue.value = it
}, modifier = Modifier.padding(paddingValues))
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="<http://schemas.android.com/apk/res/android>"
xmlns:tools="<http://schemas.android.com/tools>">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Test"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.bryankeltonadams.test
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import com.bryankeltonadams.test.ui.theme.TestTheme
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
// A surface container using the 'background' color from the theme
Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = Color.Red
) { paddingValues ->
val textFieldValue = remember { mutableStateOf("") }
TextField(
value = textFieldValue.value,
onValueChange = { textFieldValue.value = it },
modifier = Modifier.padding(paddingValues)
)
}
}
}
}
}
Zach Klippenstein (he/him) [MOD]
10/03/2023, 9:17 PMWindowCompat.setDecorFitsSystemWindows(window, false)
in your onCreate
and then pass Modifier.imePadding()
to your Scaffold
bryankeltonadams
10/03/2023, 9:23 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:24 PMbryankeltonadams
10/03/2023, 9:27 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:28 PMbryankeltonadams
10/03/2023, 9:29 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:29 PMbryankeltonadams
10/03/2023, 9:31 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:31 PMbryankeltonadams
10/03/2023, 9:33 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:41 PMbryankeltonadams
10/03/2023, 9:41 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:42 PMbryankeltonadams
10/03/2023, 9:42 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:42 PMbryankeltonadams
10/03/2023, 9:42 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:43 PMbryankeltonadams
10/03/2023, 9:44 PMZach Klippenstein (he/him) [MOD]
10/03/2023, 9:44 PMbryankeltonadams
10/03/2023, 9:46 PMif (!view.isInEditMode) {
SideEffect {
val activity = view.context as Activity
activity.window.statusBarColor = colors.backgroundPrimary.toArgb()
WindowCompat.getInsetsController(activity.window, view).isAppearanceLightStatusBars =
!darkTheme
WindowCompat.getInsetsController(
activity.window,
view
).isAppearanceLightNavigationBars = !darkTheme
}
}
which has to do with some WindowCompat stuff as well. should I clump the setDecorFitsSystemWindows in there as well, or do you think this stuff is inappropriate to be in the Theme.kt in the first place and should be moved to MainActivity. or are both fine where they are in different places?Zach Klippenstein (he/him) [MOD]
10/03/2023, 10:00 PMSideEffect
– it will run on every recomposition. Instead use a DisposableEffect
to only run it oncebryankeltonadams
10/03/2023, 10:01 PMStylianos Gakis
10/04/2023, 6:29 AMZoltan Demant
10/04/2023, 1:17 PMsetupEdgeToEdge
the precursor to enableEdgeToEdge
? Sounds like it, but no mention in the changelog afaik blob thinking upside downIan Lake
10/04/2023, 1:25 PMenableEdgeToEdge
in one of the later alphas (but you're right that rename missed the release notes)Zach Klippenstein (he/him) [MOD]
10/04/2023, 3:02 PMZoltan Demant
10/05/2023, 3:36 AMComponentActivity.setUpEdgeToEdge()
has been added to easily set up the edge-to-edge display in a backward-compatible manner.
😄bryankeltonadams
10/30/2023, 12:09 AMStylianos Gakis
10/30/2023, 12:19 PMColton Idle
10/30/2023, 3:41 PMbryankeltonadams
10/30/2023, 4:01 PMIan Lake
10/30/2023, 4:42 PMNavigationBar
that supports window insets by default (note the windowInsets
parameters): https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#NavigationBar(androidx.comp[…]ndowInsets,kotlin.Function1)bryankeltonadams
10/30/2023, 4:54 PMIan Lake
10/30/2023, 4:55 PMNavigationBar
does - insets in the buttons, but lets the background fill the inset area entirely)bryankeltonadams
10/30/2023, 5:00 PMoverride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
enableEdgeToEdge()
setContent {
FishbowlDriveTheme {
FishbowlApp()
}
}
Scaffold(bottomBar = {
NavigationBar {
Button(modifier = Modifier.fillMaxWidth(), onClick = onSeeResults) {
Text(text = stringResource(id = R.string.inventory_filter_see_results))
}
}
// FbBottomPrimaryActionBar(
// title = stringResource(id = R.string.inventory_filter_see_results),
// onClick = onSeeResults,
// )
},
Stylianos Gakis
10/30/2023, 9:20 PMbryankeltonadams
10/30/2023, 9:24 PM