Skip to content

Commit faeb761

Browse files
committed
Merge branch 'nav-cujs' of https://github.com/android/snippets into nav-cujs
Merging
2 parents 0094032 + 0683086 commit faeb761

File tree

1 file changed

+29
-15
lines changed
  • compose/snippets/src/main/java/com/example/compose/snippets/components

1 file changed

+29
-15
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/components/Navigation.kt

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,53 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.example.compose.snippets.components
218

319
import androidx.compose.foundation.layout.Box
420
import androidx.compose.foundation.layout.fillMaxSize
21+
import androidx.compose.foundation.layout.padding
522
import androidx.compose.material.icons.Icons
623
import androidx.compose.material.icons.filled.Album
724
import androidx.compose.material.icons.filled.MusicNote
825
import androidx.compose.material.icons.filled.PlaylistAddCircle
26+
import androidx.compose.material3.ExperimentalMaterial3Api
927
import androidx.compose.material3.Icon
1028
import androidx.compose.material3.NavigationBar
1129
import androidx.compose.material3.NavigationBarDefaults
1230
import androidx.compose.material3.NavigationBarItem
31+
import androidx.compose.material3.NavigationRail
32+
import androidx.compose.material3.NavigationRailItem
33+
import androidx.compose.material3.PrimaryTabRow
1334
import androidx.compose.material3.Scaffold
35+
import androidx.compose.material3.Tab
1436
import androidx.compose.material3.Text
1537
import androidx.compose.runtime.Composable
38+
import androidx.compose.runtime.getValue
39+
import androidx.compose.runtime.mutableIntStateOf
1640
import androidx.compose.runtime.saveable.rememberSaveable
41+
import androidx.compose.runtime.setValue
1742
import androidx.compose.ui.Alignment
1843
import androidx.compose.ui.Modifier
1944
import androidx.compose.ui.graphics.vector.ImageVector
45+
import androidx.compose.ui.text.style.TextOverflow
2046
import androidx.compose.ui.tooling.preview.Preview
2147
import androidx.navigation.NavHostController
2248
import androidx.navigation.compose.NavHost
2349
import androidx.navigation.compose.composable
2450
import androidx.navigation.compose.rememberNavController
25-
import androidx.compose.runtime.mutableIntStateOf
26-
import androidx.compose.runtime.getValue
27-
import androidx.compose.runtime.setValue
28-
import androidx.compose.material3.NavigationRail
29-
import androidx.compose.material3.NavigationRailItem
30-
import androidx.compose.foundation.layout.padding
31-
import androidx.compose.material3.ExperimentalMaterial3Api
32-
import androidx.compose.material3.PrimaryTabRow
33-
import androidx.compose.material3.Tab
34-
import androidx.compose.ui.text.style.TextOverflow
3551

3652
@Composable
3753
fun SongsScreen(modifier: Modifier = Modifier) {
@@ -140,8 +156,8 @@ fun NavigationRailExample(modifier: Modifier = Modifier) {
140156
val startDestination = Destination.SONGS
141157
var selectedDestination by rememberSaveable { mutableIntStateOf(startDestination.ordinal) }
142158

143-
Scaffold (modifier = modifier) { contentPadding ->
144-
NavigationRail (modifier = Modifier.padding(contentPadding)) {
159+
Scaffold(modifier = modifier) { contentPadding ->
160+
NavigationRail(modifier = Modifier.padding(contentPadding)) {
145161
Destination.entries.forEachIndexed { index, destination ->
146162
NavigationRailItem(
147163
selected = selectedDestination == index,
@@ -173,7 +189,7 @@ fun NavigationTabExample(modifier: Modifier = Modifier) {
173189
val startDestination = Destination.SONGS
174190
var selectedDestination by rememberSaveable { mutableIntStateOf(startDestination.ordinal) }
175191

176-
Scaffold (modifier = modifier) { contentPadding ->
192+
Scaffold(modifier = modifier) { contentPadding ->
177193
PrimaryTabRow(selectedTabIndex = selectedDestination, modifier = Modifier.padding(contentPadding)) {
178194
Destination.entries.forEachIndexed { index, destination ->
179195
Tab(
@@ -196,5 +212,3 @@ fun NavigationTabExample(modifier: Modifier = Modifier) {
196212
}
197213
}
198214
// [END android_compose_components_navigationtabexample]
199-
200-

0 commit comments

Comments
 (0)