theme: fix OEM skin edgecases
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
|
||||
package com.aurora.store.compose.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialExpressiveTheme
|
||||
@@ -14,8 +17,11 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.util.Preferences
|
||||
|
||||
@@ -46,5 +52,41 @@ fun AuroraTheme(content: @Composable () -> Unit) {
|
||||
else -> if (isSystemInDarkTheme()) darkScheme else lightScheme
|
||||
}
|
||||
|
||||
val darkTheme = when (themeStyle) {
|
||||
1 -> false
|
||||
2 -> true
|
||||
else -> isSystemInDarkTheme()
|
||||
}
|
||||
|
||||
/**
|
||||
* Side effect to update the system bars to be transparent and match the theme's light/dark mode.
|
||||
* This is necessary on OEM devices that don't properly support dynamic theming and may have issues with light/dark status bar icons.
|
||||
*/
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val activity = view.context.findActivity() ?: return@SideEffect
|
||||
val window = activity.window
|
||||
|
||||
// Transparent system bars
|
||||
window.statusBarColor = android.graphics.Color.TRANSPARENT
|
||||
window.navigationBarColor = android.graphics.Color.TRANSPARENT
|
||||
|
||||
// Control icon colors explicitly
|
||||
WindowCompat
|
||||
.getInsetsController(window, view)
|
||||
.apply {
|
||||
isAppearanceLightStatusBars = !darkTheme
|
||||
isAppearanceLightNavigationBars = !darkTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MaterialExpressiveTheme(colorScheme = colorScheme, content = content)
|
||||
}
|
||||
|
||||
tailrec fun Context.findActivity(): Activity? = when (this) {
|
||||
is Activity -> this
|
||||
is ContextWrapper -> baseContext.findActivity()
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -212,7 +213,10 @@ private fun ScreenContent(
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = { if (!packages.isNullOrEmpty()) SetupMenu() }
|
||||
actions = { if (!packages.isNullOrEmpty()) SetupMenu() },
|
||||
colors = SearchBarDefaults.appBarWithSearchColors(
|
||||
appBarContainerColor = Color.Transparent
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ private fun ScreenContentApp(
|
||||
}
|
||||
ScrollHint(
|
||||
listState = listState,
|
||||
bottomPadding = 5.dp,
|
||||
bottomPadding = 72.dp,
|
||||
modifier = Modifier.align(Alignment.BottomCenter)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@ import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -82,7 +84,11 @@ private fun ScreenContent(
|
||||
modifier = Modifier.height(64.dp),
|
||||
title = {
|
||||
PageIndicator(totalPages = pages.size, currentPage = pagerState.currentPage)
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = Color.Transparent,
|
||||
scrolledContainerColor = Color.Transparent
|
||||
)
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
package com.aurora.store.compose.ui.onboarding
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -50,7 +48,6 @@ private fun PageContent(
|
||||
permissions = permissions,
|
||||
onPermissionCallback = onPermissionCallback,
|
||||
header = {
|
||||
Surface(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(dimensionResource(R.dimen.padding_medium))
|
||||
) {
|
||||
@@ -68,7 +65,6 @@ private fun PageContent(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -101,7 +99,6 @@ private fun PageContent(onAboutAurora: () -> Unit = {}) {
|
||||
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.margin_xxsmall))
|
||||
) {
|
||||
stickyHeader {
|
||||
Surface(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(dimensionResource(R.dimen.padding_medium))
|
||||
) {
|
||||
@@ -119,7 +116,6 @@ private fun PageContent(onAboutAurora: () -> Unit = {}) {
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
items(items = links, key = { item -> item.id }) { link ->
|
||||
LinkListItem(
|
||||
|
||||
@@ -51,6 +51,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
@@ -210,7 +211,13 @@ private fun ScreenContent(
|
||||
)
|
||||
}
|
||||
|
||||
AppBarWithSearch(state = searchBarState, inputField = inputField)
|
||||
AppBarWithSearch(
|
||||
state = searchBarState,
|
||||
inputField = inputField,
|
||||
colors = SearchBarDefaults.appBarWithSearchColors(
|
||||
appBarContainerColor = Color.Transparent
|
||||
)
|
||||
)
|
||||
ExpandedDockedSearchBar(state = searchBarState, inputField = inputField) {
|
||||
suggestions.forEach { suggestion ->
|
||||
SearchSuggestionListItem(
|
||||
|
||||
Reference in New Issue
Block a user