Skip to content

Instantly share code, notes, and snippets.

View lbenevento's full-sized avatar

Lorenzo Benevento lbenevento

  • dDevs
  • Perugia
View GitHub Profile
YourAppTheme {
val coroutineScope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState(
initialvalue = ModalBottomSheetValue.Hidden
)
ModalBottomSheetLayout(
sheetContent = { YourSheetContent() },
sheetState = sheetState
) {
@lbenevento
lbenevento / build.gradle
Last active September 5, 2021 22:28
accompanist-insets_gradle-setup
// Accompanist Insets
implementation 'com.google.accompanist:accompanist-insets:0.17.0'
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
//...
}
@lbenevento
lbenevento / themes_transparent_statusbar.xml
Last active September 6, 2021 09:55
Code to make the StatusBar transparent in Android using theme.xml.
<!-- Status bar color. -->
<item name="android:statusBarColor">@android:color/transparent</item>
// System UI Controller
implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0"
fun YourTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val systemUiController = rememberSystemUiController()
systemUiController.setStatusBarColor(Color.Transparent)
MaterialTheme(
content = content
)
ModalBottomSheetLayout(
sheetContent = { SheetContent() },
sheetState = sheetState
) {
Column {
Spacer(modifier = Modifier
.background(MaterialTheme.colors.primary)
.statusBarsHeight()
.fillMaxWidth()
)
setContent {
ModalBottomSheetTheme {
ProvideWindowInsets {
Content()
}
}
}
<!-- Navigation bar color -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar">true</item> // Requires API level 27
systemUiController.setNavigationBarColor(
color = Color.Transparent,
darkIcons = true,
navigationBarContrastEnforced = false
)