Skip to content

Commit 8fa065c

Browse files
committed
#302 Update target sdk to 36
- Enable edge-to-edge display in `MainActivity`. - Update screen padding to use `WindowInsets.safeDrawing`. - Remove the wrapping `Scaffold` and `paddingValues` from `ComposeNewsApp`. - Bump `targetSdkVersion` and `compileSdkVersion` to 36.
1 parent 186a6ed commit 8fa065c

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:label="@string/app_name"
1818
android:supportsRtl="true"
1919
android:theme="@style/Theme.ComposeNews"
20-
tools:targetApi="31">
20+
tools:targetApi="36">
2121
<activity
2222
android:name="ir.composenews.ui.MainActivity"
2323
android:exported="true"

app/src/main/java/ir/composenews/ui/ComposeNewsApp.kt

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
package ir.composenews.ui
44

5-
import androidx.compose.foundation.layout.PaddingValues
6-
import androidx.compose.foundation.layout.padding
5+
import androidx.compose.foundation.layout.WindowInsets
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.foundation.layout.safeDrawing
8+
import androidx.compose.foundation.layout.windowInsetsPadding
79
import androidx.compose.material.icons.Icons
810
import androidx.compose.material.icons.filled.Favorite
911
import androidx.compose.material.icons.filled.Home
1012
import androidx.compose.material3.Icon
11-
import androidx.compose.material3.Scaffold
1213
import androidx.compose.material3.Text
1314
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
1415
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
@@ -34,23 +35,22 @@ fun ComposeNewsApp() {
3435
val items = rememberNavigationItems()
3536
var currentRoute by remember { mutableStateOf(Destinations.MarketListScreen.route) }
3637

37-
Scaffold { paddingValues ->
38-
NavigationSuiteScaffold(
39-
navigationSuiteItems = {
40-
items.forEach { item ->
41-
item(
42-
selected = item.route == currentRoute,
43-
onClick = { currentRoute = item.route },
44-
icon = { Icon(imageVector = item.icon, contentDescription = item.name) },
45-
label = { Text(text = item.name) },
46-
)
47-
}
48-
},
49-
layoutType = NavigationSuiteScaffoldDefaults.calculateFromAdaptiveInfo(currentWindowAdaptiveInfo()),
50-
) {
51-
val navigator = rememberListDetailPaneScaffoldNavigator<Any>()
52-
NavigationContent(currentRoute, paddingValues, navigator)
53-
}
38+
NavigationSuiteScaffold(
39+
navigationSuiteItems = {
40+
items.forEach { item ->
41+
item(
42+
selected = item.route == currentRoute,
43+
onClick = { currentRoute = item.route },
44+
icon = { Icon(imageVector = item.icon, contentDescription = item.name) },
45+
label = { Text(text = item.name) },
46+
)
47+
}
48+
},
49+
layoutType = NavigationSuiteScaffoldDefaults.calculateFromAdaptiveInfo(currentWindowAdaptiveInfo()),
50+
containerColor = androidx.compose.material3.MaterialTheme.colorScheme.background,
51+
) {
52+
val navigator = rememberListDetailPaneScaffoldNavigator<Any>()
53+
NavigationContent(currentRoute, navigator)
5454
}
5555
}
5656

@@ -75,16 +75,19 @@ private fun rememberNavigationItems(): ImmutableList<BottomNavItem> =
7575
@Composable
7676
private fun NavigationContent(
7777
currentRoute: String,
78-
paddingValues: PaddingValues,
7978
navigator: ThreePaneScaffoldNavigator<Any>,
8079
) {
80+
val modifier = Modifier
81+
.fillMaxSize()
82+
.windowInsetsPadding(WindowInsets.safeDrawing)
83+
8184
when (currentRoute) {
8285
Destinations.MarketListScreen.route -> {
83-
ListWithDetailScreen(Modifier.padding(paddingValues), navigator, showFavorite = false)
86+
ListWithDetailScreen(modifier, navigator, showFavorite = false)
8487
}
8588

8689
Destinations.FavoriteMarketScreen.route -> {
87-
ListWithDetailScreen(Modifier.padding(paddingValues), navigator, showFavorite = true)
90+
ListWithDetailScreen(modifier, navigator, showFavorite = true)
8891
}
8992
}
9093
}

app/src/main/java/ir/composenews/ui/MainActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ir.composenews.ui
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6+
import androidx.activity.enableEdgeToEdge
67
import androidx.compose.runtime.Composable
78
import androidx.compose.ui.tooling.preview.Preview
89
import dagger.hilt.android.AndroidEntryPoint
@@ -18,6 +19,8 @@ class MainActivity :
1819
override fun onCreate(savedInstanceState: Bundle?) {
1920
super.onCreate(savedInstanceState)
2021

22+
enableEdgeToEdge()
23+
2124
performPermission(
2225
PermissionType.POST_NOTIFICATIONS,
2326
this,

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ projectVersionName = "1.0.0"
44
projectVersionCode = "1"
55
projectMinSdkVersion = "23"
66
projectMinSdkVersionWear = "30"
7-
projectTargetSdkVersion = "35"
8-
projectCompileSdkVersion = "35"
7+
projectTargetSdkVersion = "36"
8+
projectCompileSdkVersion = "36"
99

1010
kotlin = "2.2.21"
1111
kotlinter = "5.4.2"

0 commit comments

Comments
 (0)