Skip to content

Commit dba0524

Browse files
committed
wear: adjust Chip buttons for larger text sizes
* Wear App Quality Guidelines
1 parent 2b47cbf commit dba0524

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

wearapp/src/main/java/com/thewizrd/simpleweather/ui/components/WeatherAlertPanel.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
88
import androidx.compose.foundation.layout.fillMaxWidth
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.foundation.layout.size
11+
import androidx.compose.foundation.layout.wrapContentHeight
1112
import androidx.compose.foundation.layout.wrapContentSize
1213
import androidx.compose.foundation.shape.CircleShape
1314
import androidx.compose.runtime.Composable
@@ -22,13 +23,15 @@ import androidx.compose.ui.focus.FocusRequester
2223
import androidx.compose.ui.graphics.Color
2324
import androidx.compose.ui.res.painterResource
2425
import androidx.compose.ui.text.style.TextAlign
26+
import androidx.compose.ui.text.style.TextOverflow
2527
import androidx.compose.ui.unit.dp
2628
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
2729
import androidx.wear.compose.material.Chip
2830
import androidx.wear.compose.material.ChipDefaults
2931
import androidx.wear.compose.material.Icon
3032
import androidx.wear.compose.material.Text
3133
import androidx.wear.compose.material.dialog.Dialog
34+
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
3235
import com.google.android.horologist.compose.navscaffold.scrollableColumn
3336
import com.thewizrd.common.controls.WeatherAlertViewModel
3437
import com.thewizrd.shared_resources.utils.getColorFromAlertSeverity
@@ -62,9 +65,14 @@ private fun WeatherAlertPanel(
6265
val severityColor = remember(alertSeverityColor) { Color(alertSeverityColor) }
6366

6467
Chip(
65-
modifier = Modifier.fillMaxWidth(),
68+
modifier = Modifier
69+
.fillMaxWidth()
70+
.wrapContentHeight(),
6671
label = {
67-
Text(text = title)
72+
Text(
73+
text = title,
74+
overflow = TextOverflow.Ellipsis
75+
)
6876
},
6977
icon = {
7078
Icon(
@@ -133,6 +141,7 @@ private fun WeatherAlertPanel(
133141
}
134142

135143
@WearPreviewDevices
144+
@WearPreviewFontScales
136145
@Composable
137146
private fun PreviewWeatherAlertPanel() {
138147
Box(

wearapp/src/main/java/com/thewizrd/simpleweather/ui/components/WeatherDetailItem.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ package com.thewizrd.simpleweather.ui.components
22

33
import androidx.compose.foundation.Image
44
import androidx.compose.foundation.layout.fillMaxWidth
5-
import androidx.compose.foundation.layout.heightIn
65
import androidx.compose.foundation.layout.size
6+
import androidx.compose.foundation.layout.wrapContentHeight
77
import androidx.compose.foundation.layout.wrapContentSize
88
import androidx.compose.runtime.Composable
99
import androidx.compose.ui.Alignment
1010
import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.draw.rotate
1212
import androidx.compose.ui.platform.LocalInspectionMode
1313
import androidx.compose.ui.res.painterResource
14-
import androidx.compose.ui.unit.dp
1514
import androidx.wear.compose.material.Chip
1615
import androidx.wear.compose.material.ChipDefaults
1716
import androidx.wear.compose.material.Text
@@ -32,7 +31,7 @@ fun WeatherDetailItem(
3231
Chip(
3332
modifier = Modifier
3433
.fillMaxWidth()
35-
.heightIn(min = 60.dp),
34+
.wrapContentHeight(),
3635
label = {
3736
Text(
3837
text = spannableStringToAnnotatedString(model.label)

wearapp/src/main/java/com/thewizrd/simpleweather/ui/weather/WeatherNowScreen.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,20 @@ private fun NavigationButton(
824824
Chip(
825825
modifier = Modifier
826826
.fillMaxWidth()
827+
.wrapContentHeight()
827828
.padding(vertical = 2.dp, horizontal = 16.dp),
828829
onClick = onClick,
829830
colors = ChipDefaults.secondaryChipColors(),
830831
label = {
831-
Text(text = label)
832+
Text(
833+
modifier = Modifier
834+
.fillMaxWidth()
835+
.wrapContentHeight(),
836+
text = label,
837+
overflow = TextOverflow.Ellipsis,
838+
softWrap = true,
839+
maxLines = 2
840+
)
832841
},
833842
icon = {
834843
Icon(

0 commit comments

Comments
 (0)