mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-19 07:24:22 +01:00
Display cutout insets
# Conflicts: # app/src/main/java/no/nordicsemi/android/nrftoolbox/view/HomeView.kt # profile-parsers/src/main/java/no/nordicsemi/android/toolbox/profile/parser/battery/BatteryLevelParser.kt # profile/src/main/java/no/nordicsemi/android/toolbox/profile/ProfileScreen.kt
This commit is contained in:
committed by
himalia416
parent
e221b2cee2
commit
8af4e81fa7
@@ -31,10 +31,16 @@
|
|||||||
|
|
||||||
package no.nordicsemi.android.ui.view
|
package no.nordicsemi.android.ui.view
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||||
|
import androidx.compose.foundation.layout.displayCutout
|
||||||
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
|
import androidx.compose.foundation.layout.only
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.statusBars
|
||||||
|
import androidx.compose.foundation.layout.union
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Close
|
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -57,37 +63,6 @@ import no.nordicsemi.android.ui.R
|
|||||||
|
|
||||||
private const val TOP_APP_BAR_TITLE = "Nordic_Appbar"
|
private const val TOP_APP_BAR_TITLE = "Nordic_Appbar"
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
|
||||||
fun CloseIconAppBar(text: String, onClick: () -> Unit) {
|
|
||||||
TopAppBar(
|
|
||||||
title = { Text(text, maxLines = 1) },
|
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
|
||||||
scrolledContainerColor = MaterialTheme.colorScheme.primary,
|
|
||||||
containerColor = colorResource(id = R.color.appBarColor),
|
|
||||||
titleContentColor = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
),
|
|
||||||
navigationIcon = {
|
|
||||||
IconButton(onClick = { onClick() }) {
|
|
||||||
Icon(
|
|
||||||
Icons.Default.Close,
|
|
||||||
contentDescription = stringResource(id = R.string.close_app),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview
|
|
||||||
@Composable
|
|
||||||
private fun CloseIconAppBarPreview() {
|
|
||||||
NordicTheme {
|
|
||||||
CloseIconAppBar(TOP_APP_BAR_TITLE) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun LoggerBackIconAppBar(
|
fun LoggerBackIconAppBar(
|
||||||
@@ -104,6 +79,10 @@ fun LoggerBackIconAppBar(
|
|||||||
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
|
windowInsets = WindowInsets.displayCutout
|
||||||
|
.union(WindowInsets.statusBars)
|
||||||
|
.union(WindowInsets.navigationBars)
|
||||||
|
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = { onBackClick() }) {
|
IconButton(onClick = { onBackClick() }) {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -146,6 +125,10 @@ fun BackIconAppBar(text: String, onClick: () -> Unit) {
|
|||||||
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
|
windowInsets = WindowInsets.displayCutout
|
||||||
|
.union(WindowInsets.statusBars)
|
||||||
|
.union(WindowInsets.navigationBars)
|
||||||
|
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = { onClick() }) {
|
IconButton(onClick = { onClick() }) {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -183,6 +166,10 @@ fun LoggerIconAppBar(
|
|||||||
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
|
windowInsets = WindowInsets.displayCutout
|
||||||
|
.union(WindowInsets.statusBars)
|
||||||
|
.union(WindowInsets.navigationBars)
|
||||||
|
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = { onClick() }) {
|
IconButton(onClick = { onClick() }) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ internal fun ProfileAppBar(
|
|||||||
openLogger: () -> Unit
|
openLogger: () -> Unit
|
||||||
) {
|
) {
|
||||||
if (deviceName?.isNotBlank() == true) {
|
if (deviceName?.isNotBlank() == true) {
|
||||||
if (connectionState !is DeviceConnectionState.Disconnected)
|
if (connectionState !is DeviceConnectionState.Disconnected) {
|
||||||
LoggerIconAppBar(deviceName, navigateUp, disconnect, openLogger)
|
LoggerIconAppBar(deviceName, navigateUp, disconnect, openLogger)
|
||||||
else LoggerBackIconAppBar(deviceName, navigateUp) { openLogger() }
|
} else {
|
||||||
|
LoggerBackIconAppBar(deviceName, navigateUp) { openLogger() }
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
BackIconAppBar(title, navigateUp)
|
BackIconAppBar(title, navigateUp)
|
||||||
}
|
}
|
||||||
@@ -30,6 +32,13 @@ internal fun ProfileAppBar(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun ProfileAppBarPreview() {
|
private fun ProfileAppBarPreview() {
|
||||||
NordicTheme {
|
NordicTheme {
|
||||||
ProfileAppBar("DE", "nRF Toolbox", DeviceConnectionState.Connecting, {}, {}) {}
|
ProfileAppBar(
|
||||||
|
deviceName = "DE",
|
||||||
|
title = "nRF Toolbox",
|
||||||
|
connectionState = DeviceConnectionState.Connecting,
|
||||||
|
navigateUp = {},
|
||||||
|
disconnect = {},
|
||||||
|
openLogger = {},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user