Skip to content

Commit 45fba1d

Browse files
committed
Addressed feedback
1 parent 68adc5b commit 45fba1d

4 files changed

Lines changed: 23 additions & 37 deletions

File tree

app/src/main/java/com/example/reply/MainActivity.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ import android.os.Bundle
1919
import androidx.activity.ComponentActivity
2020
import androidx.activity.compose.setContent
2121
import androidx.activity.enableEdgeToEdge
22+
import androidx.compose.foundation.layout.WindowInsets
23+
import androidx.compose.foundation.layout.asPaddingValues
24+
import androidx.compose.foundation.layout.calculateEndPadding
25+
import androidx.compose.foundation.layout.calculateStartPadding
26+
import androidx.compose.foundation.layout.padding
27+
import androidx.compose.foundation.layout.safeDrawing
2228
import androidx.compose.material3.Surface
2329
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
2430
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
2531
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
2632
import androidx.compose.runtime.Composable
33+
import androidx.compose.ui.Modifier
34+
import androidx.compose.ui.platform.LocalLayoutDirection
2735
import androidx.compose.ui.tooling.preview.Preview
2836
import com.example.reply.ui.ReplyApp
2937
import com.example.reply.ui.theme.ReplyTheme
@@ -37,7 +45,16 @@ class MainActivity : ComponentActivity() {
3745

3846
setContent {
3947
ReplyTheme {
40-
Surface {
48+
val layoutDirection = LocalLayoutDirection.current
49+
Surface(
50+
modifier = Modifier
51+
.padding(
52+
start = WindowInsets.safeDrawing.asPaddingValues()
53+
.calculateStartPadding(layoutDirection),
54+
end = WindowInsets.safeDrawing.asPaddingValues()
55+
.calculateEndPadding(layoutDirection)
56+
)
57+
) {
4158
val windowSize = calculateWindowSizeClass(this)
4259

4360
ReplyApp(

app/src/main/java/com/example/reply/ui/ReplyDetailsScreen.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import androidx.compose.foundation.layout.Row
2626
import androidx.compose.foundation.layout.Spacer
2727
import androidx.compose.foundation.layout.WindowInsets
2828
import androidx.compose.foundation.layout.asPaddingValues
29-
import androidx.compose.foundation.layout.calculateEndPadding
30-
import androidx.compose.foundation.layout.calculateStartPadding
3129
import androidx.compose.foundation.layout.fillMaxSize
3230
import androidx.compose.foundation.layout.fillMaxWidth
3331
import androidx.compose.foundation.layout.height
@@ -50,7 +48,6 @@ import androidx.compose.runtime.Composable
5048
import androidx.compose.ui.Alignment
5149
import androidx.compose.ui.Modifier
5250
import androidx.compose.ui.platform.LocalContext
53-
import androidx.compose.ui.platform.LocalLayoutDirection
5451
import androidx.compose.ui.platform.testTag
5552
import androidx.compose.ui.res.dimensionResource
5653
import androidx.compose.ui.res.stringResource
@@ -65,17 +62,13 @@ fun ReplyDetailsScreen(
6562
modifier: Modifier = Modifier,
6663
isFullScreen: Boolean = false
6764
) {
68-
val layoutDirection = LocalLayoutDirection.current
6965
BackHandler {
7066
onBackPressed()
7167
}
7268
Box(modifier = modifier) {
7369
LazyColumn(
7470
contentPadding = PaddingValues(
75-
top = WindowInsets.safeDrawing.asPaddingValues()
76-
.calculateTopPadding(),
77-
end = WindowInsets.safeDrawing.asPaddingValues()
78-
.calculateEndPadding(layoutDirection)
71+
top = WindowInsets.safeDrawing.asPaddingValues().calculateTopPadding(),
7972
),
8073
modifier = Modifier
8174
.testTag(stringResource(R.string.details_screen))

app/src/main/java/com/example/reply/ui/ReplyHomeScreen.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ fun ReplyHomeScreen(
104104
modifier = Modifier
105105
.width(dimensionResource(R.dimen.drawer_width))
106106
.background(MaterialTheme.colorScheme.inverseOnSurface),
107-
windowInsets = WindowInsets.safeDrawing.only(
108-
WindowInsetsSides.Top + WindowInsetsSides.Start
109-
),
107+
windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top),
110108
) {
111109
NavigationDrawerContent(
112110
selectedDestination = replyUiState.currentMailbox,

app/src/main/java/com/example/reply/ui/theme/Theme.kt

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ package com.example.reply.ui.theme
1818

1919
import android.app.Activity
2020
import android.os.Build
21-
import android.view.View
2221
import androidx.compose.foundation.isSystemInDarkTheme
23-
import androidx.compose.material3.ColorScheme
2422
import androidx.compose.material3.MaterialTheme
2523
import androidx.compose.material3.darkColorScheme
2624
import androidx.compose.material3.dynamicDarkColorScheme
2725
import androidx.compose.material3.dynamicLightColorScheme
2826
import androidx.compose.material3.lightColorScheme
2927
import androidx.compose.runtime.Composable
3028
import androidx.compose.runtime.SideEffect
31-
import androidx.compose.ui.graphics.Color
3229
import androidx.compose.ui.graphics.toArgb
3330
import androidx.compose.ui.platform.LocalContext
3431
import androidx.compose.ui.platform.LocalView
@@ -120,7 +117,9 @@ fun ReplyTheme(
120117
val view = LocalView.current
121118
if (!view.isInEditMode) {
122119
SideEffect {
123-
setUpEdgeToEdge(view, darkTheme, colorScheme)
120+
val window = (view.context as Activity).window
121+
window.statusBarColor = colorScheme.primary.toArgb()
122+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
124123
}
125124
}
126125

@@ -130,24 +129,3 @@ fun ReplyTheme(
130129
content = content
131130
)
132131
}
133-
134-
/**
135-
* Sets up edge-to-edge for the window of this [view]. The system icon colors are set to either
136-
* light or dark depending on whether the [darkTheme] is enabled or not.
137-
*/
138-
private fun setUpEdgeToEdge(view: View, darkTheme: Boolean, colorScheme: ColorScheme) {
139-
val window = (view.context as Activity).window
140-
WindowCompat.setDecorFitsSystemWindows(window, false)
141-
// window.statusBarColor = Color.Transparent.toArgb()
142-
window.statusBarColor = colorScheme.inverseOnSurface.toArgb()
143-
val navigationBarColor = when {
144-
Build.VERSION.SDK_INT >= 29 -> Color.Transparent.toArgb()
145-
Build.VERSION.SDK_INT >= 26 -> Color(0xFF, 0xFF, 0xFF, 0x63).toArgb()
146-
// Min sdk version for this app is 24, this block is for SDK versions 24 and 25
147-
else -> Color(0x00, 0x00, 0x00, 0x50).toArgb()
148-
}
149-
window.navigationBarColor = navigationBarColor
150-
val controller = WindowCompat.getInsetsController(window, view)
151-
controller.isAppearanceLightStatusBars = !darkTheme
152-
controller.isAppearanceLightNavigationBars = !darkTheme
153-
}

0 commit comments

Comments
 (0)