Skip to content

Commit

Permalink
Adding start-end comments, addressing small issues from PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeroseman committed Aug 17, 2023
1 parent 292af0f commit 262970a
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 95 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.compose.snippets.LandingScreen.LandingScreen
import com.example.compose.snippets.animations.AnimationExamplesScreen
import com.example.compose.snippets.graphics.BrushExamplesScreen
import com.example.compose.snippets.images.ImageExamplesScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Preview
@Composable
fun AppBarExamples() {
var selection by remember { mutableStateOf("none") }
Expand Down Expand Up @@ -110,6 +112,7 @@ fun AppBarOptions(
}
}

@Preview
@Composable
fun BottomAppBarExample() {
Scaffold(
Expand Down Expand Up @@ -158,6 +161,7 @@ fun BottomAppBarExample() {
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun SmallTopAppBarExample() {
Scaffold(
Expand All @@ -178,6 +182,7 @@ fun SmallTopAppBarExample() {
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun CenterAlignedTopAppBarExample() {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
Expand Down Expand Up @@ -223,6 +228,7 @@ fun CenterAlignedTopAppBarExample() {
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun MediumTopAppBarExample() {
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
Expand Down Expand Up @@ -267,6 +273,7 @@ fun MediumTopAppBarExample() {
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun LargeTopAppBarExample() {
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,43 @@ fun ButtonExamples() {
}
}

// [START android_compose_components_filledbutton]
@Composable
fun FilledButtonExample(onClick: () -> Unit) {
Button(onClick = { onClick() }) {
Text("Filled")
}
}
// [END android_compose_components_filledbutton]

// [START android_compose_components_filledtonalbutton]
@Composable
fun FilledTonalButtonExample(onClick: () -> Unit) {
FilledTonalButton(onClick = { onClick() }) {
Text("Tonal")
}
}
// [END android_compose_components_filledtonalbutton]

// [START android_compose_components_elevatedbutton]
@Composable
fun ElevatedButtonExample(onClick: () -> Unit) {
ElevatedButton(onClick = { onClick() }) {
Text("Elevated")
}
}
// [END android_compose_components_filledtonalbutton]

// [START android_compose_components_outlinedbutton]
@Composable
fun OutlinedButtonExample(onClick: () -> Unit) {
OutlinedButton(onClick = { onClick() }) {
Text("Outlined")
}
}
// [END android_compose_components_outlinedbutton]

// [START android_compose_components_textbutton]
@Composable
fun TextButtonExample(onClick: () -> Unit) {
TextButton(
Expand All @@ -90,3 +99,4 @@ fun TextButtonExample(onClick: () -> Unit) {
Text("Text Button")
}
}
// [END android_compose_components_textbutton]
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
Expand All @@ -54,6 +55,7 @@ fun CardExamples() {
}
}

// [START android_compose_components_customcard]
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CustomCardExample(event: () -> Unit) {
Expand All @@ -78,8 +80,10 @@ fun CustomCardExample(event: () -> Unit) {
)
}
}
// [END android_compose_components_customcard]

@OptIn(ExperimentalMaterial3Api::class)
// [START android_compose_components_elevatedcard]
@Preview
@Composable
fun ElevatedCardExample() {
ElevatedCard(
Expand All @@ -97,8 +101,10 @@ fun ElevatedCardExample() {
)
}
}
// [END android_compose_components_elevatedcard]

@OptIn(ExperimentalMaterial3Api::class)
// [START android_compose_components_filledcard]
@Preview
@Composable
fun FilledCardExample() {
Card(
Expand All @@ -116,8 +122,10 @@ fun FilledCardExample() {
)
}
}
// [END android_compose_components_filledcard]

@OptIn(ExperimentalMaterial3Api::class)
// [START android_compose_components_outlinedcard]
@Preview
@Composable
fun OutlinedCardExample() {
OutlinedCard(
Expand All @@ -136,3 +144,5 @@ fun OutlinedCardExample() {
)
}
}
// [END android_compose_components_outlinedcard]

Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun ChipExamples() {
Column(
Expand All @@ -67,6 +68,8 @@ fun ChipExamples() {
}
}

// [START android_compose_components_assistchip]
@Preview
@Composable
fun AssistChipExample() {
AssistChip(
Expand All @@ -81,8 +84,11 @@ fun AssistChipExample() {
}
)
}
// [END android_compose_components_assistchip]

// [START android_compose_components_filterchip]
@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun FilterChipExample() {
var selected by remember { mutableStateOf(false) }
Expand All @@ -106,9 +112,12 @@ fun FilterChipExample() {
},
)
}
// [END android_compose_components_filterchip]


// You could set this up similarly to the filter chip above and have it toggleable, but this is
// an example of a chip that can dismiss with a click.
// [START android_compose_components_inputchip]
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun InputChipExample(
Expand Down Expand Up @@ -141,11 +150,15 @@ fun InputChipExample(
},
)
}
// [END android_compose_components_inputchip]

// [START android_compose_components_suggestionchip]
@Preview
@Composable
fun SuggestionChipExample() {
SuggestionChip(
onClick = { Log.d("Suggestion chip", "hello world") },
label = { Text("Suggestion chip") }
)
}
// [END android_compose_components_suggestionchip]
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.example.compose.snippets.R

@Preview
@Composable
fun DialogExamples() {
val openMinimalDialog = remember { mutableStateOf(false) }
Expand Down Expand Up @@ -128,6 +130,7 @@ fun DialogExamples() {
}
}

// [START android_compose_components_minimaldialog]
@Composable
fun MinimalDialog(onDismissRequest: () -> Unit) {
Dialog(onDismissRequest = { onDismissRequest() }) {
Expand All @@ -148,7 +151,9 @@ fun MinimalDialog(onDismissRequest: () -> Unit) {
}
}
}
// [END android_compose_components_minimaldialog]

// [START android_compose_components_dialogwithimage]
@Composable
fun DialogWithImage(
onDismissRequest: () -> Unit,
Expand Down Expand Up @@ -204,7 +209,9 @@ fun DialogWithImage(
}
}
}
// [END android_compose_components_dialogwithimage]

// [START android_compose_components_alertdialog]
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AlertDialogExample(
Expand Down Expand Up @@ -247,7 +254,9 @@ fun AlertDialogExample(
}
)
}
// [END android_compose_components_alertdialog]

// [START android_compose_components_fullscreendialog]
@Composable
fun FullScreenDialog(onDismissRequest: () -> Unit) {
Dialog(
Expand Down Expand Up @@ -279,3 +288,5 @@ fun FullScreenDialog(onDismissRequest: () -> Unit) {
}
}
}
// [END android_compose_components_fullscreendialog]

Loading

0 comments on commit 262970a

Please sign in to comment.