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+
117package com.example.compose.snippets.components
218
319import androidx.compose.foundation.layout.Box
420import androidx.compose.foundation.layout.fillMaxSize
21+ import androidx.compose.foundation.layout.padding
522import androidx.compose.material.icons.Icons
623import androidx.compose.material.icons.filled.Album
724import androidx.compose.material.icons.filled.MusicNote
825import androidx.compose.material.icons.filled.PlaylistAddCircle
26+ import androidx.compose.material3.ExperimentalMaterial3Api
927import androidx.compose.material3.Icon
1028import androidx.compose.material3.NavigationBar
1129import androidx.compose.material3.NavigationBarDefaults
1230import androidx.compose.material3.NavigationBarItem
31+ import androidx.compose.material3.NavigationRail
32+ import androidx.compose.material3.NavigationRailItem
33+ import androidx.compose.material3.PrimaryTabRow
1334import androidx.compose.material3.Scaffold
35+ import androidx.compose.material3.Tab
1436import androidx.compose.material3.Text
1537import androidx.compose.runtime.Composable
38+ import androidx.compose.runtime.getValue
39+ import androidx.compose.runtime.mutableIntStateOf
1640import androidx.compose.runtime.saveable.rememberSaveable
41+ import androidx.compose.runtime.setValue
1742import androidx.compose.ui.Alignment
1843import androidx.compose.ui.Modifier
1944import androidx.compose.ui.graphics.vector.ImageVector
45+ import androidx.compose.ui.text.style.TextOverflow
2046import androidx.compose.ui.tooling.preview.Preview
2147import androidx.navigation.NavHostController
2248import androidx.navigation.compose.NavHost
2349import androidx.navigation.compose.composable
2450import 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
3753fun 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