Skip to content

Commit

Permalink
Fix/settings statusbar padding (#853)
Browse files Browse the repository at this point in the history
**Background**

On settings/options screen Composable doesn't have `statusBarsPaddings`

**Changes**

- Added `SafeStatusBarBox` to handle both overscroll effect and
different colors for status bar, background content

**Test plan**

- Open options screen
- Scroll down
- See there's now status bar on top
  • Loading branch information
makeevrserg authored May 13, 2024
1 parent 5db6491 commit 48731f1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [FIX] Wrong error display on categories screen when no internet connection
- [FIX] Using third-party Github Action Setup Android SDK for baseline profile generation
- [FIX] Manifest dev catalog flag on installed apps
- [FIX] Settings status bar overflow content
- [FIX] Fix TopBar above system bar in file manager file edit screen
- [Feature] Add not connected, empty and syncing states to emulation button on key screen
- [Feature] Check app exist on apps catalog manifest loading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package com.flipperdevices.settings.impl.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.flipperdevices.core.ui.ktx.OrangeAppBar
Expand Down Expand Up @@ -47,45 +52,75 @@ fun ComposableSettings(
val exportState by settingsViewModel.getExportState().collectAsState()
val notificationState by notificationViewModel.getNotificationToggleState().collectAsState()

Column(
SafeStatusBarBox(modifier = modifier) {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.background(LocalPallet.current.background),
verticalArrangement = Arrangement.spacedBy(14.dp)
) {
OrangeAppBar(R.string.options, onBack = onBack)
AppCategory(
theme = settings.selectedTheme,
onSelectTheme = settingsViewModel::onChangeSelectedTheme,
notificationState = notificationState,
onChangeNotificationState = notificationViewModel::switchToggle
)
if (settings.expertMode) {
DebugCategory(
settings = settings,
onSwitchDebug = settingsViewModel::onSwitchDebug,
onAction = onDebugAction,
onDebugSettingSwitch = debugViewModel::onSwitch
)
}
ExperimentalCategory(
settings = settings,
onSwitchExperimental = settingsViewModel::onSwitchExperimental,
onOpenFM = { onOpen(SettingsNavigationConfig.FileManager) }
)
ExportKeysCategory(
exportState = exportState,
onExport = { settingsViewModel.onMakeExport(context) }
)
OtherSettingsCategory(
s2rInitialized = s2rInitialized,
onReportBug = { onOpen(SettingsNavigationConfig.Shake2Report) }
)
@Suppress("ViewModelForwarding")
VersionCategory(
onActivateExpertMode = settingsViewModel::onExpertModeActivate,
versionViewModel = versionViewModel
)
}
}
}

@Composable
private fun SafeStatusBarBox(
modifier: Modifier = Modifier,
statusBarColor: Color = LocalPallet.current.accent,
backgroundColor: Color = LocalPallet.current.background,
content: @Composable () -> Unit
) {
Box(
modifier = modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.background(LocalPallet.current.background),
verticalArrangement = Arrangement.spacedBy(14.dp)
.background(statusBarColor)
.statusBarsPadding()
.background(backgroundColor)
) {
OrangeAppBar(R.string.options, onBack = onBack)
AppCategory(
theme = settings.selectedTheme,
onSelectTheme = settingsViewModel::onChangeSelectedTheme,
notificationState = notificationState,
onChangeNotificationState = notificationViewModel::switchToggle
)
if (settings.expertMode) {
DebugCategory(
settings = settings,
onSwitchDebug = settingsViewModel::onSwitchDebug,
onAction = onDebugAction,
onDebugSettingSwitch = debugViewModel::onSwitch
// Used to fill overflow color on top of StatusBars
if (statusBarColor != backgroundColor) {
Box(
modifier = Modifier
.background(statusBarColor)
.statusBarsPadding()
.fillMaxWidth()
.padding(vertical = 20.dp)
)
}
ExperimentalCategory(
settings = settings,
onSwitchExperimental = settingsViewModel::onSwitchExperimental,
onOpenFM = { onOpen(SettingsNavigationConfig.FileManager) }
)
ExportKeysCategory(
exportState = exportState,
onExport = { settingsViewModel.onMakeExport(context) }
)
OtherSettingsCategory(
s2rInitialized = s2rInitialized,
onReportBug = { onOpen(SettingsNavigationConfig.Shake2Report) }
)
@Suppress("ViewModelForwarding")
VersionCategory(
onActivateExpertMode = settingsViewModel::onExpertModeActivate,
versionViewModel = versionViewModel
)
content.invoke()
}
}

0 comments on commit 48731f1

Please sign in to comment.