From b649cd9b56241a6883f2159f7974a9e8f3ad3ae1 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Thu, 28 Jan 2021 20:13:32 +0300 Subject: [PATCH] Migrate to 0.3.0-build146 (widgetsgallery) --- examples/widgetsgallery/build.gradle.kts | 5 ++-- .../compose/demo/widgets/ui/MainView.kt | 13 ++++++---- .../demo/widgets/ui/screens/AppBars.kt | 24 ++++++++++--------- .../demo/widgets/ui/screens/Buttons.kt | 17 +++++++------ .../compose/demo/widgets/ui/screens/Chips.kt | 5 ++-- .../demo/widgets/ui/screens/TextInputs.kt | 7 +++--- .../demo/widgets/ui/screens/Toggles.kt | 8 ++++--- .../demo/widgets/ui/screens/UICards.kt | 12 ++++++---- .../demo/widgets/ui/utils/ResizablePanel.kt | 1 + 9 files changed, 50 insertions(+), 42 deletions(-) diff --git a/examples/widgetsgallery/build.gradle.kts b/examples/widgetsgallery/build.gradle.kts index 946ae9688d..d3ed392005 100644 --- a/examples/widgetsgallery/build.gradle.kts +++ b/examples/widgetsgallery/build.gradle.kts @@ -9,9 +9,10 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135") + classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build146") classpath("com.android.tools.build:gradle:4.0.1") - classpath(kotlin("gradle-plugin", version = "1.4.21")) + // __KOTLIN_COMPOSE_VERSION__ + classpath(kotlin("gradle-plugin", version = "1.4.21-2")) } } diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt index e2f96b33e6..dbca876576 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt @@ -7,16 +7,20 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumnFor import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.* +import androidx.compose.material.AmbientContentColor +import androidx.compose.material.Text import androidx.compose.runtime.* -import androidx.compose.runtime.savedinstancestate.savedInstanceState +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.platform.AmbientDensity import androidx.compose.ui.selection.DisableSelection import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.* +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.TextUnit +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import org.jetbrains.compose.demo.widgets.platform.VerticalScrollbar import org.jetbrains.compose.demo.widgets.platform.pointerMoveFilter import org.jetbrains.compose.demo.widgets.theme.WidgetGalleryTheme @@ -24,7 +28,6 @@ import org.jetbrains.compose.demo.widgets.ui.utils.PanelState import org.jetbrains.compose.demo.widgets.ui.utils.ResizablePanel import org.jetbrains.compose.demo.widgets.ui.utils.VerticalSplittable import org.jetbrains.compose.demo.widgets.ui.utils.withoutWidthConstraints -import kotlin.ranges.coerceAtLeast @Composable fun MainView() { @@ -37,7 +40,7 @@ fun MainView() { @Composable fun WidgetsPanel() { - val widgetsTypeState = savedInstanceState { WidgetsType.sortedValues.first() } + val widgetsTypeState = rememberSaveable { mutableStateOf(WidgetsType.sortedValues.first()) } val panelState = remember { PanelState() } val animatedSize = if (panelState.splitter.isResizing) { diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt index a979c7e327..fb0325769e 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt @@ -19,7 +19,6 @@ import org.jetbrains.compose.demo.widgets.platform.Res import org.jetbrains.compose.demo.widgets.platform.imageResource import org.jetbrains.compose.demo.widgets.platform.vectorResource import org.jetbrains.compose.demo.widgets.theme.twitterColor -import org.jetbrains.compose.demo.widgets.theme.typography import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText import org.jetbrains.compose.demo.widgets.ui.utils.TitleText @@ -39,7 +38,7 @@ private fun TopAppBarsDemo() { elevation = 8.dp, navigationIcon = { IconButton(onClick = {}) { - Icon(Icons.Default.ArrowBack) + Icon(Icons.Default.ArrowBack, contentDescription = "ArrowBack") } } ) @@ -53,12 +52,12 @@ private fun TopAppBarsDemo() { elevation = 8.dp, navigationIcon = { IconButton(onClick = {}) { - Icon(vectorResource(Res.drawable.ic_instagram)) + Icon(vectorResource(Res.drawable.ic_instagram), contentDescription = "Instagram") } }, actions = { IconButton(onClick = {}) { - Icon(vectorResource(Res.drawable.ic_send)) + Icon(vectorResource(Res.drawable.ic_send), contentDescription = "Send") } } ) @@ -69,6 +68,7 @@ private fun TopAppBarsDemo() { title = { Icon( vectorResource(Res.drawable.ic_twitter), + contentDescription = "Twitter", tint = twitterColor, modifier = Modifier.fillMaxWidth() ) @@ -79,6 +79,7 @@ private fun TopAppBarsDemo() { navigationIcon = { Image( imageResource(Res.drawable.p6), + contentDescription = "", modifier = Modifier.padding(vertical = 4.dp, horizontal = 8.dp) .preferredSize(32.dp).clip(CircleShape) ) @@ -86,6 +87,7 @@ private fun TopAppBarsDemo() { actions = { Icon( Icons.Default.StarBorder, + contentDescription = "", modifier = Modifier.padding(horizontal = 8.dp) ) } @@ -102,7 +104,7 @@ private fun BottomAppBarDemo() { cutoutShape = CircleShape ) { IconButton(onClick = {}) { - Icon(Icons.Default.MoreHoriz) + Icon(Icons.Default.MoreHoriz, contentDescription = "") } TitleText(title = "Bottom App Bar") } @@ -115,19 +117,19 @@ private fun NavigationBarDemo() { val navItemState = remember { mutableStateOf(NavType.HOME) } BottomNavigation(backgroundColor = MaterialTheme.colors.surface) { BottomNavigationItem( - icon = { Icon(Icons.Outlined.Home) }, + icon = { Icon(Icons.Outlined.Home, contentDescription = "Home") }, selected = navItemState.value == NavType.HOME, onClick = { navItemState.value = NavType.HOME }, label = { Text(text = Res.string.spotify_nav_home) }, ) BottomNavigationItem( - icon = { Icon(Icons.Outlined.Search) }, + icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") }, selected = navItemState.value == NavType.SEARCH, onClick = { navItemState.value = NavType.SEARCH }, label = { Text(text = Res.string.spotify_nav_search) } ) BottomNavigationItem( - icon = { Icon(Icons.Outlined.LibraryMusic) }, + icon = { Icon(Icons.Outlined.LibraryMusic, contentDescription = "LibraryMusic") }, selected = navItemState.value == NavType.LIBRARY, onClick = { navItemState.value = NavType.LIBRARY }, label = { Text(text = Res.string.spotify_nav_library) } @@ -138,17 +140,17 @@ private fun NavigationBarDemo() { BottomNavigation { BottomNavigationItem( - icon = { Icon(Icons.Outlined.ReadMore) }, + icon = { Icon(Icons.Outlined.ReadMore, contentDescription = "ReadMore") }, selected = navItemState.value == NavType.HOME, onClick = { navItemState.value = NavType.HOME }, ) BottomNavigationItem( - icon = { Icon(Icons.Outlined.Search) }, + icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") }, selected = navItemState.value == NavType.SEARCH, onClick = { navItemState.value = NavType.SEARCH }, ) BottomNavigationItem( - icon = { Icon(Icons.Outlined.CleanHands) }, + icon = { Icon(Icons.Outlined.CleanHands, contentDescription = "CleanHands") }, selected = navItemState.value == NavType.LIBRARY, onClick = { navItemState.value = NavType.LIBRARY }, ) diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt index 3c59a82108..a7e5e295b5 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt @@ -12,9 +12,8 @@ import androidx.compose.material.icons.filled.FavoriteBorder import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.HorizontalGradient -import androidx.compose.ui.graphics.VerticalGradient import androidx.compose.ui.unit.dp import org.jetbrains.compose.demo.widgets.theme.purple import org.jetbrains.compose.demo.widgets.theme.purple200 @@ -38,7 +37,7 @@ fun Buttons() { Button( onClick = {}, modifier = Modifier.padding(8.dp), - elevation = ButtonConstants.defaultElevation() + elevation = ButtonDefaults.elevation() ) { Text(text = "Flat") } @@ -54,19 +53,19 @@ fun Buttons() { } Button(onClick = {}, modifier = Modifier.padding(8.dp)) { Row { - Icon(Icons.Default.FavoriteBorder, modifier = Modifier.padding(end = 4.dp)) + Icon(Icons.Default.FavoriteBorder, contentDescription = null, modifier = Modifier.padding(end = 4.dp)) Text(text = "Icon Button") } } Button(onClick = {}, modifier = Modifier.padding(8.dp)) { Text(text = "Icon Button") - Icon(Icons.Default.FavoriteBorder, modifier = Modifier.padding(start = 4.dp)) + Icon(Icons.Default.FavoriteBorder, contentDescription = null, modifier = Modifier.padding(start = 4.dp)) } //custom background buttons - val outlineButtonColor = ButtonConstants.defaultOutlinedButtonColors( + val outlineButtonColor = ButtonDefaults.outlinedButtonColors( contentColor = purple200, ) - val mainButtonColor = ButtonConstants.defaultButtonColors( + val mainButtonColor = ButtonDefaults.buttonColors( backgroundColor = purple, contentColor = MaterialTheme.colors.surface ) @@ -81,12 +80,12 @@ fun Buttons() { Text(text = "Custom colors") } - val horizontalGradient = HorizontalGradient( + val horizontalGradient = Brush.horizontalGradient( colors = listOf(MaterialTheme.colors.primary, MaterialTheme.colors.primaryVariant), 0f, 250f ) - val verticalGradient = VerticalGradient( + val verticalGradient = Brush.verticalGradient( colors = listOf(MaterialTheme.colors.primary, MaterialTheme.colors.primaryVariant), startY = 0f, endY = 100f diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt index 98166ab23e..526ae03c8b 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt @@ -3,7 +3,6 @@ package org.jetbrains.compose.demo.widgets.ui.screens import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button @@ -17,9 +16,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import org.jetbrains.compose.demo.widgets.platform.Res -import org.jetbrains.compose.demo.widgets.theme.typography -import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText import org.jetbrains.compose.demo.widgets.platform.imageResource +import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText @Composable fun Chips() { @@ -88,6 +86,7 @@ private fun CustomImageChip( Row(modifier = Modifier) { Image( imageResource(imageId), + contentDescription = null, modifier = Modifier.padding(8.dp).preferredSize(20.dp).clip(CircleShape) ) Text( diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt index 6995a64257..41634eceb4 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt @@ -17,7 +17,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.theme.typography @Composable fun TextInputs() { @@ -52,7 +51,7 @@ fun TextInputs() { OutlinedTextField( value = text, - leadingIcon = { Icon(Icons.Default.Email) }, + leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") }, modifier = Modifier.padding(8.dp).fillMaxWidth(), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), label = { Text(text = "Email address") }, @@ -63,8 +62,8 @@ fun TextInputs() { ) OutlinedTextField( value = text, - leadingIcon = { Icon(Icons.Default.Email) }, - trailingIcon = { Icon(Icons.Default.Edit) }, + leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") }, + trailingIcon = { Icon(Icons.Default.Edit, contentDescription = "Edit") }, modifier = Modifier.padding(8.dp).fillMaxWidth(), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), label = { Text(text = "Email address") }, diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt index 3fe981de23..4797a15dc7 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt @@ -1,12 +1,14 @@ package org.jetbrains.compose.demo.widgets.ui.screens import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.theme.typography @Composable fun Toggles() { @@ -21,7 +23,7 @@ fun Toggles() { var switched by remember { mutableStateOf(true) } Switch( checked = switched, - colors = SwitchConstants.defaultColors(checkedThumbColor = MaterialTheme.colors.primary), + colors = SwitchDefaults.colors(checkedThumbColor = MaterialTheme.colors.primary), modifier = Modifier.padding(8.dp), onCheckedChange = { switched = it } ) diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt index bf11733fff..cdfc20cb12 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt @@ -27,7 +27,7 @@ fun UICards() { Card( modifier = Modifier.padding(8.dp).fillMaxWidth(), backgroundColor = MaterialTheme.colors.primary, - shape = RoundedCornerShape(topLeft = 16.dp, bottomRight = 16.dp) + shape = RoundedCornerShape(topStart = 16.dp, bottomEnd = 16.dp) ) { Column { Text( @@ -53,6 +53,7 @@ fun UICards() { Row { Image( imageResource(Res.drawable.p3), + contentDescription = null, modifier = Modifier.preferredSize(60.dp) ) Text(text = item.title, modifier = Modifier.padding(16.dp)) @@ -75,7 +76,8 @@ fun UICards() { Divider(modifier = Modifier.padding(4.dp)) ListItem(text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, icon = { Image( - imageResource(Res.drawable.p3) + imageResource(Res.drawable.p3), + contentDescription = null ) }) Divider(modifier = Modifier.padding(4.dp)) @@ -83,7 +85,7 @@ fun UICards() { ListItem( text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, - icon = { Image(imageResource(Res.drawable.p1)) }, + icon = { Image(imageResource(Res.drawable.p1), contentDescription = null) }, overlineText = { Text("Overline text") }, singleLineSecondaryText = false ) @@ -91,8 +93,8 @@ fun UICards() { ListItem( text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, - icon = { Image(imageResource(Res.drawable.p2)) }, - trailing = { Icon(Icons.Default.ShoppingCart) }, + icon = { Image(imageResource(Res.drawable.p2), contentDescription = null) }, + trailing = { Icon(Icons.Default.ShoppingCart, contentDescription = null) }, singleLineSecondaryText = false ) Divider() diff --git a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt index 42818d8e38..826c1638f7 100644 --- a/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt +++ b/examples/widgetsgallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt @@ -55,6 +55,7 @@ fun ResizablePanel( Icon( if (state.isExpanded) Icons.Default.ArrowBack else Icons.Default.ArrowForward, + contentDescription = if (state.isExpanded) "Collapse" else "Expand", tint = AmbientContentColor.current, modifier = Modifier .size(24.dp)