Skip to content

Commit 5cb2216

Browse files
committed
Merge branch 'navigation-drawer' of https://github.com/android/snippets into navigation-drawer
2 parents 3ec4192 + 9fcc09b commit 5cb2216

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2024 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.animation.AnimatedVisibility
@@ -27,17 +43,17 @@ import androidx.compose.ui.text.style.TextAlign
2743
import androidx.compose.ui.tooling.preview.Preview
2844
import androidx.compose.ui.unit.dp
2945

30-
enum class ExampleStrings(val description: String){
46+
enum class ExampleStrings(val description: String) {
3147
SIMPLE("simple navigation drawer example"),
3248
NESTED("navigation drawer with nested items")
3349
}
3450

3551
@Composable
36-
fun NavigationDrawerExamples(){
52+
fun NavigationDrawerExamples() {
3753
var currentExample by remember { mutableStateOf<ExampleStrings?>(null) }
3854

39-
if (currentExample == null){
40-
Column(){
55+
if (currentExample == null) {
56+
Column() {
4157
Text(
4258
text = "Select which example you'd like to see.",
4359
textAlign = TextAlign.Center,
@@ -46,16 +62,16 @@ fun NavigationDrawerExamples(){
4662
.padding(16.dp)
4763
)
4864

49-
Button(onClick = {currentExample = ExampleStrings.SIMPLE}){
65+
Button(onClick = { currentExample = ExampleStrings.SIMPLE }) {
5066
Text("Simple navigation drawer.")
5167
}
52-
Button(onClick = {currentExample = ExampleStrings.NESTED}){
68+
Button(onClick = { currentExample = ExampleStrings.NESTED }) {
5369
Text("Navigation drawer with nested items.")
5470
}
5571
}
5672
}
5773

58-
Column(modifier = Modifier.fillMaxSize()){
74+
Column(modifier = Modifier.fillMaxSize()) {
5975
Text(
6076
text = "Swipe from left to open the ${currentExample!!.description}.",
6177
textAlign = TextAlign.Center,
@@ -65,7 +81,7 @@ fun NavigationDrawerExamples(){
6581
)
6682
}
6783

68-
when (currentExample){
84+
when (currentExample) {
6985
null,
7086
ExampleStrings.SIMPLE -> SimpleNavigationDrawerExample()
7187
ExampleStrings.NESTED -> NestedNavigationDrawerExample()
@@ -74,7 +90,7 @@ fun NavigationDrawerExamples(){
7490

7591
@Preview
7692
@Composable
77-
private fun NavigationDrawerExamplesPreview(){
93+
private fun NavigationDrawerExamplesPreview() {
7894
NavigationDrawerExamples()
7995
}
8096

@@ -104,7 +120,7 @@ fun SimpleNavigationDrawerExample() {
104120

105121
@Preview
106122
@Composable
107-
private fun SimpleNavigationDrawerExamplePreview(){
123+
private fun SimpleNavigationDrawerExamplePreview() {
108124
SimpleNavigationDrawerExample()
109125
}
110126

@@ -188,6 +204,6 @@ fun NestedNavigationDrawerExample() {
188204

189205
@Preview
190206
@Composable
191-
private fun NestedNavigationDrawerExamplePreview(){
207+
private fun NestedNavigationDrawerExamplePreview() {
192208
NestedNavigationDrawerExample()
193209
}

0 commit comments

Comments
 (0)