From 89d1c94a7b754d5b9a32b116a5ef2bcb5d4a9155 Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Thu, 10 Feb 2022 22:18:17 -0500 Subject: [PATCH 1/6] Added a stepper and a slider --- .../presentation/MainActivity.kt | 39 +++++++++++ .../presentation/navigation/Screen.kt | 3 + .../presentation/ui/landing/LandingScreen.kt | 18 ++++- .../presentation/ui/slider/SliderScreen.kt | 33 +++++++++ .../presentation/ui/stepper/StepperScreen.kt | 33 +++++++++ .../ui/valuedisplay/ValueDisplayScreen.kt | 68 +++++++++++++++++++ .../app/src/main/res/values/strings.xml | 3 + ComposeAdvanced/build.gradle | 2 +- 8 files changed, 196 insertions(+), 3 deletions(-) create mode 100644 ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt create mode 100644 ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt create mode 100644 ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt index 98ab07079..6fe4f3c1f 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.lifecycle.viewmodel.compose.viewModel @@ -49,6 +50,9 @@ import com.example.android.wearable.composeadvanced.presentation.theme.WearAppTh import com.example.android.wearable.composeadvanced.presentation.ui.ScalingLazyListStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.ScrollStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.landing.LandingScreen +import com.example.android.wearable.composeadvanced.presentation.ui.slider.SliderScreen +import com.example.android.wearable.composeadvanced.presentation.ui.stepper.StepperScreen +import com.example.android.wearable.composeadvanced.presentation.ui.valuedisplay.ValueDisplayScreen import com.example.android.wearable.composeadvanced.presentation.ui.watch.WatchDetailScreen import com.example.android.wearable.composeadvanced.presentation.ui.watchlist.WatchListScreen @@ -113,6 +117,8 @@ fun WearApp(watchRepository: WatchRepository) { currentBackStackEntry?.arguments?.getSerializable(SCROLL_TYPE_NAV_ARGUMENT) ?: DestinationScrollType.NONE + var displayValue by remember { mutableStateOf(2) } + Scaffold( timeText = { // Scaffold places time at top of screen to follow Material Design guidelines. @@ -184,6 +190,9 @@ fun WearApp(watchRepository: WatchRepository) { onClickWatchList = { swipeDismissableNavController.navigate(Screen.WatchList.route) }, + onClickValueDisplay = { + swipeDismissableNavController.navigate(Screen.ValueDisplay.route) + }, proceedingTimeTextEnabled = showProceedingTextBeforeTime, onClickProceedingTimeText = { showProceedingTextBeforeTime = !showProceedingTextBeforeTime @@ -191,6 +200,36 @@ fun WearApp(watchRepository: WatchRepository) { ) } + composable(Screen.ValueDisplay.route) { + ValueDisplayScreen( + value = displayValue, + onClickStepper = { + swipeDismissableNavController.navigate(Screen.StepperDisplay.route) + }, + onClickSlider = { + swipeDismissableNavController.navigate(Screen.SliderDisplay.route) + } + ) + } + + composable(Screen.StepperDisplay.route) { + StepperScreen( + displayValue = displayValue, + onValueChange = { + displayValue = it + } + ) + } + + composable(Screen.SliderDisplay.route) { + SliderScreen( + displayValue = displayValue, + onValueChange = { + displayValue = it + } + ) + } + composable( route = Screen.WatchList.route, arguments = listOf( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt index 80b82c42e..d43bd4e4e 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt @@ -32,4 +32,7 @@ sealed class Screen( object Landing : Screen("landing") object WatchList : Screen("watchList") object WatchDetail : Screen("watchDetail") + object ValueDisplay : Screen("valueDisplay") + object StepperDisplay: Screen("stepper") + object SliderDisplay: Screen("slider") } diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt index 8c7e6e321..5bf0c684f 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt @@ -45,8 +45,8 @@ import androidx.wear.compose.material.ToggleChip import com.example.android.wearable.composeadvanced.R /** - * Simple landing page with two actions, view a list of watches or toggle on/off text before the - * time. + * Simple landing page with three actions, view a list of watches, toggle on/off text before the + * time or display a value using a Stepper or a Slider. * * A text label indicates the screen shape and places it at the bottom of the screen. * If it's a round device, it will curve the text along the bottom curve. Otherwise, for a square @@ -55,6 +55,7 @@ import com.example.android.wearable.composeadvanced.R @Composable fun LandingScreen( onClickWatchList: () -> Unit, + onClickValueDisplay: () -> Unit, proceedingTimeTextEnabled: Boolean, onClickProceedingTimeText: (Boolean) -> Unit, ) { @@ -93,6 +94,19 @@ fun LandingScreen( ) } ) + + Spacer(modifier = Modifier.size(4.dp)) + + CompactChip( + onClick = onClickValueDisplay, + label = { + Text( + stringResource(R.string.value_display_label), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + ) } // Places curved text at the bottom of round devices and straight text at the bottom of diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt new file mode 100644 index 000000000..7d2e5d08d --- /dev/null +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt @@ -0,0 +1,33 @@ +package com.example.android.wearable.composeadvanced.presentation.ui.slider + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.wear.compose.material.InlineSlider + +/** + * Displays a Slider + */ +@Composable +fun SliderScreen( + displayValue: Int, + onValueChange: (Int) -> Unit +) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(top = 10.dp), + verticalArrangement = Arrangement.Center + ) { + InlineSlider( + value = displayValue, + onValueChange = onValueChange, + valueProgression = 0..10, + segmented = true + ) + } +} diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt new file mode 100644 index 000000000..1c83d0ac8 --- /dev/null +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt @@ -0,0 +1,33 @@ +package com.example.android.wearable.composeadvanced.presentation.ui.stepper + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.wear.compose.material.Stepper +import androidx.wear.compose.material.Text + +/** + * Displays a Stepper + */ +@Composable +fun StepperScreen( + displayValue: Int, + onValueChange: (Int) -> Unit +) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(top = 10.dp), + verticalArrangement = Arrangement.Center + ) { + Stepper( + value = displayValue, + onValueChange = onValueChange, + valueProgression = 1..10 + ) { Text("Value: $displayValue") } + } +} diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt new file mode 100644 index 000000000..b2734d01f --- /dev/null +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt @@ -0,0 +1,68 @@ +package com.example.android.wearable.composeadvanced.presentation.ui.valuedisplay + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.wear.compose.material.CompactChip +import androidx.wear.compose.material.Text +import com.example.android.wearable.composeadvanced.R + +/** + * Displays a value by using a Stepper or a Slider + */ +@Composable +fun ValueDisplayScreen( + value: Int, + onClickStepper: () -> Unit, + onClickSlider: () -> Unit +) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(top = 10.dp), + verticalArrangement = Arrangement.Center + ) { + Text( + modifier = Modifier.fillMaxWidth(1f), + text = "$value", + textAlign = TextAlign.Center + ) + + Spacer(modifier = Modifier.size(4.dp)) + + CompactChip( + onClick = onClickStepper, + label = { + Text( + stringResource(R.string.stepper_label), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + ) + + Spacer(modifier = Modifier.size(4.dp)) + + CompactChip( + onClick = onClickSlider, + label = { + Text( + stringResource(R.string.slider_label), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + ) + + } +} diff --git a/ComposeAdvanced/app/src/main/res/values/strings.xml b/ComposeAdvanced/app/src/main/res/values/strings.xml index bf009152c..912a31a6f 100644 --- a/ComposeAdvanced/app/src/main/res/values/strings.xml +++ b/ComposeAdvanced/app/src/main/res/values/strings.xml @@ -25,4 +25,7 @@ Vignette Invalid Watch Leading Text... + Stepper + Slider + Value Display diff --git a/ComposeAdvanced/build.gradle b/ComposeAdvanced/build.gradle index 27b51487f..80f2def4a 100644 --- a/ComposeAdvanced/build.gradle +++ b/ComposeAdvanced/build.gradle @@ -20,7 +20,7 @@ buildscript { activity_compose_version = '1.4.0' compose_version = '1.2.0-alpha02' lifecycle_version = '2.4.0' - wear_compose_version = '1.0.0-alpha15' + wear_compose_version = '1.0.0-alpha16' junit_version = '4.13.2' androidx_test_ext_junit_version = '1.1.3' From a86e562945e65529d90f29250ff2bc9782fe2c3e Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Tue, 15 Feb 2022 10:05:43 -0500 Subject: [PATCH 2/6] Updated horizontal padding for ValueDisplayScreen --- .../composeadvanced/presentation/ui/slider/SliderScreen.kt | 3 ++- .../composeadvanced/presentation/ui/stepper/StepperScreen.kt | 3 ++- .../presentation/ui/valuedisplay/ValueDisplayScreen.kt | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt index 7d2e5d08d..3994122f1 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt @@ -10,7 +10,8 @@ import androidx.compose.ui.unit.dp import androidx.wear.compose.material.InlineSlider /** - * Displays a Slider + * Displays a Slider, which allows users to make a selection from a range of values. + * https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#InlineSlider(kotlin.Float,kotlin.Function1,kotlin.Int,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.ranges.ClosedFloatingPointRange,kotlin.Boolean,kotlin.Function0,kotlin.Function0,androidx.wear.compose.material.InlineSliderColors) */ @Composable fun SliderScreen( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt index 1c83d0ac8..8bf1a0b2d 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt @@ -11,7 +11,8 @@ import androidx.wear.compose.material.Stepper import androidx.wear.compose.material.Text /** - * Displays a Stepper + * Displays a Stepper, which allows users to make a selection from a range of values. + * https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#Stepper(kotlin.Int,kotlin.Function1,androidx.compose.ui.Modifier,kotlin.ranges.IntProgression,kotlin.Function0,kotlin.Function0,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1) */ @Composable fun StepperScreen( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt index b2734d01f..4c01fa422 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt @@ -29,7 +29,8 @@ fun ValueDisplayScreen( Column( modifier = Modifier .fillMaxSize() - .padding(top = 10.dp), + .padding(top = 10.dp) + .padding(horizontal = 10.dp), verticalArrangement = Arrangement.Center ) { Text( From b384e6b16429cebe392841b097c4816c265e39e9 Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Wed, 16 Feb 2022 18:45:03 -0500 Subject: [PATCH 3/6] Updated valueProgression for slider and renamed variables --- .../presentation/MainActivity.kt | 34 +++++++++--------- .../presentation/navigation/Screen.kt | 6 ++-- .../presentation/ui/landing/LandingScreen.kt | 14 +++----- .../SliderScreen.kt | 19 ++++++++-- .../StepperScreen.kt | 17 ++++++++- .../UserInputComponentsScreen.kt} | 36 +++++++++++++------ .../app/src/main/res/values/strings.xml | 2 +- 7 files changed, 85 insertions(+), 43 deletions(-) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{slider => userInputComponents}/SliderScreen.kt (64%) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{stepper => userInputComponents}/StepperScreen.kt (67%) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{valuedisplay/ValueDisplayScreen.kt => userInputComponents/UserInputComponentsScreen.kt} (63%) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt index 6fe4f3c1f..54053d5cb 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt @@ -50,9 +50,9 @@ import com.example.android.wearable.composeadvanced.presentation.theme.WearAppTh import com.example.android.wearable.composeadvanced.presentation.ui.ScalingLazyListStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.ScrollStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.landing.LandingScreen -import com.example.android.wearable.composeadvanced.presentation.ui.slider.SliderScreen -import com.example.android.wearable.composeadvanced.presentation.ui.stepper.StepperScreen -import com.example.android.wearable.composeadvanced.presentation.ui.valuedisplay.ValueDisplayScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.SliderScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.StepperScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.UserInputComponentsScreen import com.example.android.wearable.composeadvanced.presentation.ui.watch.WatchDetailScreen import com.example.android.wearable.composeadvanced.presentation.ui.watchlist.WatchListScreen @@ -117,7 +117,7 @@ fun WearApp(watchRepository: WatchRepository) { currentBackStackEntry?.arguments?.getSerializable(SCROLL_TYPE_NAV_ARGUMENT) ?: DestinationScrollType.NONE - var displayValue by remember { mutableStateOf(2) } + var displayValueForUserInput by remember { mutableStateOf(2) } Scaffold( timeText = { @@ -190,8 +190,8 @@ fun WearApp(watchRepository: WatchRepository) { onClickWatchList = { swipeDismissableNavController.navigate(Screen.WatchList.route) }, - onClickValueDisplay = { - swipeDismissableNavController.navigate(Screen.ValueDisplay.route) + onClickDemoUserInputComponents = { + swipeDismissableNavController.navigate(Screen.UserInputComponents.route) }, proceedingTimeTextEnabled = showProceedingTextBeforeTime, onClickProceedingTimeText = { @@ -200,32 +200,32 @@ fun WearApp(watchRepository: WatchRepository) { ) } - composable(Screen.ValueDisplay.route) { - ValueDisplayScreen( - value = displayValue, + composable(Screen.UserInputComponents.route) { + UserInputComponentsScreen( + value = displayValueForUserInput, onClickStepper = { - swipeDismissableNavController.navigate(Screen.StepperDisplay.route) + swipeDismissableNavController.navigate(Screen.Stepper.route) }, onClickSlider = { - swipeDismissableNavController.navigate(Screen.SliderDisplay.route) + swipeDismissableNavController.navigate(Screen.Slider.route) } ) } - composable(Screen.StepperDisplay.route) { + composable(Screen.Stepper.route) { StepperScreen( - displayValue = displayValue, + displayValue = displayValueForUserInput, onValueChange = { - displayValue = it + displayValueForUserInput = it } ) } - composable(Screen.SliderDisplay.route) { + composable(Screen.Slider.route) { SliderScreen( - displayValue = displayValue, + displayValue = displayValueForUserInput, onValueChange = { - displayValue = it + displayValueForUserInput = it } ) } diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt index d43bd4e4e..a281492e7 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt @@ -32,7 +32,7 @@ sealed class Screen( object Landing : Screen("landing") object WatchList : Screen("watchList") object WatchDetail : Screen("watchDetail") - object ValueDisplay : Screen("valueDisplay") - object StepperDisplay: Screen("stepper") - object SliderDisplay: Screen("slider") + object UserInputComponents : Screen("userInputComponents") + object Stepper: Screen("stepper") + object Slider: Screen("slider") } diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt index 5bf0c684f..877509038 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt @@ -46,7 +46,7 @@ import com.example.android.wearable.composeadvanced.R /** * Simple landing page with three actions, view a list of watches, toggle on/off text before the - * time or display a value using a Stepper or a Slider. + * time or view a demo of different user input components. * * A text label indicates the screen shape and places it at the bottom of the screen. * If it's a round device, it will curve the text along the bottom curve. Otherwise, for a square @@ -55,7 +55,7 @@ import com.example.android.wearable.composeadvanced.R @Composable fun LandingScreen( onClickWatchList: () -> Unit, - onClickValueDisplay: () -> Unit, + onClickDemoUserInputComponents: () -> Unit, proceedingTimeTextEnabled: Boolean, onClickProceedingTimeText: (Boolean) -> Unit, ) { @@ -67,7 +67,7 @@ fun LandingScreen( modifier = Modifier .fillMaxSize() .padding(horizontal = 10.dp), - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterVertically) ) { CompactChip( onClick = onClickWatchList, @@ -80,8 +80,6 @@ fun LandingScreen( } ) - Spacer(modifier = Modifier.size(4.dp)) - ToggleChip( modifier = Modifier.height(32.dp), checked = proceedingTimeTextEnabled, @@ -95,13 +93,11 @@ fun LandingScreen( } ) - Spacer(modifier = Modifier.size(4.dp)) - CompactChip( - onClick = onClickValueDisplay, + onClick = onClickDemoUserInputComponents, label = { Text( - stringResource(R.string.value_display_label), + stringResource(R.string.user_input_components_label), maxLines = 1, overflow = TextOverflow.Ellipsis ) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt similarity index 64% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt index 3994122f1..4fa7a2c6f 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/slider/SliderScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt @@ -1,4 +1,19 @@ -package com.example.android.wearable.composeadvanced.presentation.ui.slider +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -27,7 +42,7 @@ fun SliderScreen( InlineSlider( value = displayValue, onValueChange = onValueChange, - valueProgression = 0..10, + valueProgression = 1..10, segmented = true ) } diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt similarity index 67% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt index 8bf1a0b2d..592abfc06 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/stepper/StepperScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt @@ -1,4 +1,19 @@ -package com.example.android.wearable.composeadvanced.presentation.ui.stepper +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt similarity index 63% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt index 4c01fa422..882c6f9f7 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/valuedisplay/ValueDisplayScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt @@ -1,13 +1,27 @@ -package com.example.android.wearable.composeadvanced.presentation.ui.valuedisplay +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -21,7 +35,7 @@ import com.example.android.wearable.composeadvanced.R * Displays a value by using a Stepper or a Slider */ @Composable -fun ValueDisplayScreen( +fun UserInputComponentsScreen( value: Int, onClickStepper: () -> Unit, onClickSlider: () -> Unit @@ -29,17 +43,21 @@ fun ValueDisplayScreen( Column( modifier = Modifier .fillMaxSize() - .padding(top = 10.dp) + .padding(vertical = 10.dp) .padding(horizontal = 10.dp), - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterVertically) ) { Text( modifier = Modifier.fillMaxWidth(1f), - text = "$value", + text = "Previously selected value: ", textAlign = TextAlign.Center ) - Spacer(modifier = Modifier.size(4.dp)) + Text( + modifier = Modifier.fillMaxWidth(1f), + text = "$value", + textAlign = TextAlign.Center + ) CompactChip( onClick = onClickStepper, @@ -52,8 +70,6 @@ fun ValueDisplayScreen( } ) - Spacer(modifier = Modifier.size(4.dp)) - CompactChip( onClick = onClickSlider, label = { diff --git a/ComposeAdvanced/app/src/main/res/values/strings.xml b/ComposeAdvanced/app/src/main/res/values/strings.xml index 912a31a6f..4dbaee85e 100644 --- a/ComposeAdvanced/app/src/main/res/values/strings.xml +++ b/ComposeAdvanced/app/src/main/res/values/strings.xml @@ -27,5 +27,5 @@ Leading Text... Stepper Slider - Value Display + User Input Components From 5b2b1fbbc2cd9a632aaba9fa38c1f61b7b728bd6 Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Wed, 16 Feb 2022 21:53:27 -0500 Subject: [PATCH 4/6] Updated the package name so it's not camel case --- .../wearable/composeadvanced/presentation/MainActivity.kt | 6 +++--- .../ui/{userInputComponents => userinput}/SliderScreen.kt | 2 +- .../ui/{userInputComponents => userinput}/StepperScreen.kt | 2 +- .../UserInputComponentsScreen.kt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{userInputComponents => userinput}/SliderScreen.kt (98%) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{userInputComponents => userinput}/StepperScreen.kt (98%) rename ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/{userInputComponents => userinput}/UserInputComponentsScreen.kt (99%) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt index 54053d5cb..9d2818e4f 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt @@ -50,9 +50,9 @@ import com.example.android.wearable.composeadvanced.presentation.theme.WearAppTh import com.example.android.wearable.composeadvanced.presentation.ui.ScalingLazyListStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.ScrollStateViewModel import com.example.android.wearable.composeadvanced.presentation.ui.landing.LandingScreen -import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.SliderScreen -import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.StepperScreen -import com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents.UserInputComponentsScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userinput.SliderScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userinput.StepperScreen +import com.example.android.wearable.composeadvanced.presentation.ui.userinput.UserInputComponentsScreen import com.example.android.wearable.composeadvanced.presentation.ui.watch.WatchDetailScreen import com.example.android.wearable.composeadvanced.presentation.ui.watchlist.WatchListScreen diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt similarity index 98% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt index 4fa7a2c6f..7f2f18ff7 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/SliderScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents +package com.example.android.wearable.composeadvanced.presentation.ui.userinput import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt similarity index 98% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt index 592abfc06..3b856cc01 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/StepperScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents +package com.example.android.wearable.composeadvanced.presentation.ui.userinput import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt similarity index 99% rename from ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt rename to ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt index 882c6f9f7..55cc30743 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userInputComponents/UserInputComponentsScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.android.wearable.composeadvanced.presentation.ui.userInputComponents +package com.example.android.wearable.composeadvanced.presentation.ui.userinput import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column From 44dd074cf2d0eeb42381993e3353d75e4b7e0a04 Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Thu, 17 Feb 2022 17:17:34 -0500 Subject: [PATCH 5/6] Added comments and fixed a few style checks --- .../wearable/composeadvanced/presentation/MainActivity.kt | 4 +++- .../composeadvanced/presentation/navigation/Screen.kt | 4 ++-- .../composeadvanced/presentation/ui/landing/LandingScreen.kt | 2 -- .../composeadvanced/presentation/ui/userinput/SliderScreen.kt | 1 - .../presentation/ui/userinput/StepperScreen.kt | 1 - .../presentation/ui/userinput/UserInputComponentsScreen.kt | 1 - 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt index 9d2818e4f..04af4476b 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt @@ -22,9 +22,9 @@ import androidx.compose.foundation.background import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.lifecycle.viewmodel.compose.viewModel @@ -117,6 +117,8 @@ fun WearApp(watchRepository: WatchRepository) { currentBackStackEntry?.arguments?.getSerializable(SCROLL_TYPE_NAV_ARGUMENT) ?: DestinationScrollType.NONE + // Display value is passed down to various user input screens, for the slider and stepper + // components specifically, to demonstrate how they work. var displayValueForUserInput by remember { mutableStateOf(2) } Scaffold( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt index a281492e7..c22fd78c9 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/navigation/Screen.kt @@ -33,6 +33,6 @@ sealed class Screen( object WatchList : Screen("watchList") object WatchDetail : Screen("watchDetail") object UserInputComponents : Screen("userInputComponents") - object Stepper: Screen("stepper") - object Slider: Screen("slider") + object Stepper : Screen("stepper") + object Slider : Screen("slider") } diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt index 877509038..d3987d4fb 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/landing/LandingScreen.kt @@ -19,12 +19,10 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt index 7f2f18ff7..9080100bc 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/SliderScreen.kt @@ -26,7 +26,6 @@ import androidx.wear.compose.material.InlineSlider /** * Displays a Slider, which allows users to make a selection from a range of values. - * https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#InlineSlider(kotlin.Float,kotlin.Function1,kotlin.Int,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.ranges.ClosedFloatingPointRange,kotlin.Boolean,kotlin.Function0,kotlin.Function0,androidx.wear.compose.material.InlineSliderColors) */ @Composable fun SliderScreen( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt index 3b856cc01..b7d77f556 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/StepperScreen.kt @@ -27,7 +27,6 @@ import androidx.wear.compose.material.Text /** * Displays a Stepper, which allows users to make a selection from a range of values. - * https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#Stepper(kotlin.Int,kotlin.Function1,androidx.compose.ui.Modifier,kotlin.ranges.IntProgression,kotlin.Function0,kotlin.Function0,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1) */ @Composable fun StepperScreen( diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt index 55cc30743..0bea371b6 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt @@ -80,6 +80,5 @@ fun UserInputComponentsScreen( ) } ) - } } From fec699619cf1cb1369eb80f2755d48ce96711629 Mon Sep 17 00:00:00 2001 From: Mandy Chan Date: Fri, 18 Feb 2022 12:21:52 -0500 Subject: [PATCH 6/6] Added TODO and accepted a few suggestions --- .../wearable/composeadvanced/presentation/MainActivity.kt | 4 +++- .../ui/userinput/UserInputComponentsScreen.kt | 8 +------- ComposeAdvanced/app/src/main/res/values/strings.xml | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt index 04af4476b..35a23f7fd 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/MainActivity.kt @@ -117,9 +117,11 @@ fun WearApp(watchRepository: WatchRepository) { currentBackStackEntry?.arguments?.getSerializable(SCROLL_TYPE_NAV_ARGUMENT) ?: DestinationScrollType.NONE + // TODO: consider moving to ViewModel // Display value is passed down to various user input screens, for the slider and stepper // components specifically, to demonstrate how they work. - var displayValueForUserInput by remember { mutableStateOf(2) } + var defaultSelectedValue = 2 + var displayValueForUserInput by remember { mutableStateOf(defaultSelectedValue) } Scaffold( timeText = { diff --git a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt index 0bea371b6..a8a3deeff 100644 --- a/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt +++ b/ComposeAdvanced/app/src/main/java/com/example/android/wearable/composeadvanced/presentation/ui/userinput/UserInputComponentsScreen.kt @@ -49,13 +49,7 @@ fun UserInputComponentsScreen( ) { Text( modifier = Modifier.fillMaxWidth(1f), - text = "Previously selected value: ", - textAlign = TextAlign.Center - ) - - Text( - modifier = Modifier.fillMaxWidth(1f), - text = "$value", + text = "${stringResource(R.string.selected_value)}: $value", textAlign = TextAlign.Center ) diff --git a/ComposeAdvanced/app/src/main/res/values/strings.xml b/ComposeAdvanced/app/src/main/res/values/strings.xml index 4dbaee85e..a50d54395 100644 --- a/ComposeAdvanced/app/src/main/res/values/strings.xml +++ b/ComposeAdvanced/app/src/main/res/values/strings.xml @@ -28,4 +28,5 @@ Stepper Slider User Input Components + Selected Value