Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation drawer examples #380

Merged
merged 20 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor, new region tags
  • Loading branch information
jakeroseman committed Oct 14, 2024
commit 1f7b7939c6502d021f105f682fd8261d20a605c7
Empty file.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.Help
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.DismissibleDrawerSheet
import androidx.compose.material3.DismissibleNavigationDrawer
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
Expand All @@ -25,30 +29,28 @@ import kotlinx.coroutines.launch

@Composable
fun NavigationDrawerExamples() {
MaterialTheme {
DismissibleDrawerExample { innerPadding ->
Box(modifier = Modifier.padding(innerPadding)) {
Text(
"Swipe from left edge or use menu icon to open the dismissible drawer",
modifier = Modifier.padding(16.dp)
)
}
DismissibleDrawerExample { innerPadding ->
Box(modifier = Modifier.padding(innerPadding)) {
Text(
"Swipe from left edge or use menu icon to open the dismissible drawer",
modifier = Modifier.padding(16.dp)
)
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
// [START android_compose_components_dismissibledrawerexample]
// [START android_compose_components_drawerexample]
@Composable
fun DismissibleDrawerExample(
content: @Composable (PaddingValues) -> Unit
) {
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
val scope = rememberCoroutineScope()

DismissibleNavigationDrawer (
ModalNavigationDrawer (
drawerContent = {
DismissibleDrawerSheet {
ModalDrawerSheet {
Spacer(Modifier.height(12.dp))
Text("Drawer Title", modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.titleLarge)
HorizontalDivider()
Expand Down Expand Up @@ -108,7 +110,7 @@ fun DismissibleDrawerExample(
}
}
}
// [END android_compose_components_dismissibledrawerexample]
// [END android_compose_components_drawerexample]

@Preview
@Composable
Expand Down
Loading