@@ -3,7 +3,6 @@ package to.bitkit.appwidget.ui.price
33import android.appwidget.AppWidgetManager
44import android.content.Intent
55import android.graphics.Bitmap
6- import androidx.annotation.StringRes
76import androidx.compose.runtime.Composable
87import androidx.compose.ui.unit.dp
98import androidx.glance.GlanceModifier
@@ -34,15 +33,14 @@ import to.bitkit.appwidget.ui.components.GlanceWidgetScaffold
3433import to.bitkit.appwidget.ui.components.HorizontalSpacer
3534import to.bitkit.appwidget.ui.components.VerticalSpacer
3635import to.bitkit.appwidget.ui.theme.GlanceTextStyles
37- import to.bitkit.data.dto.price.GraphPeriod
3836import to.bitkit.data.dto.price.PriceWidgetData
3937import to.bitkit.ui.theme.Colors
38+ import java.util.Locale
4039
4140@Suppress(" RestrictedApi" )
4241@Composable
4342fun PriceGlanceContent (
4443 widget : PriceWidgetData ? ,
45- priceAvailable : Boolean ,
4644 entry : AppWidgetEntry ,
4745 chartBitmap : Bitmap ? = null,
4846) {
@@ -54,7 +52,7 @@ fun PriceGlanceContent(
5452 }
5553
5654 GlanceWidgetScaffold (onClick = configIntent) {
57- if (! priceAvailable || widget == null ) {
55+ if (widget == null ) {
5856 CaptionB (text = context.getString(R .string.appwidget__loading))
5957 return @GlanceWidgetScaffold
6058 }
@@ -71,15 +69,14 @@ fun PriceGlanceContent(
7169@Composable
7270private fun WideContent (widget : PriceWidgetData , chartBitmap : Bitmap ? ) {
7371 val changeColor = if (widget.change.isPositive) Colors .Green else Colors .Red
74- val periodLabel = LocalContext .current.getString(widget.period.labelRes())
7572
7673 Row (
7774 verticalAlignment = Alignment .CenterVertically ,
7875 modifier = GlanceModifier .fillMaxWidth()
7976 ) {
8077 Text (
81- text = " ${widget.pair.displayName} $periodLabel " .uppercase(),
82- style = GlanceTextStyles .captionUp ,
78+ text = " ${widget.pair.displayName} ${widget.period.value} " .uppercase(Locale . ENGLISH ),
79+ style = GlanceTextStyles .captionB ,
8380 modifier = GlanceModifier .then(WidthModifier (Dimension .Expand ))
8481 )
8582 HorizontalSpacer (16 .dp)
@@ -104,17 +101,16 @@ private fun WideContent(widget: PriceWidgetData, chartBitmap: Bitmap?) {
104101@Composable
105102private fun CompactContent (widget : PriceWidgetData , chartBitmap : Bitmap ? ) {
106103 val changeColor = if (widget.change.isPositive) Colors .Green else Colors .Red
107- val periodLabel = LocalContext .current.getString(widget.period.labelRes())
108104
109105 Row (modifier = GlanceModifier .fillMaxWidth()) {
110106 Text (
111- text = widget.pair.displayName.uppercase(),
112- style = GlanceTextStyles .captionUp ,
107+ text = widget.pair.displayName.uppercase(Locale . ENGLISH ),
108+ style = GlanceTextStyles .captionB ,
113109 modifier = GlanceModifier .then(WidthModifier (Dimension .Expand ))
114110 )
115111 Text (
116- text = periodLabel. uppercase(),
117- style = GlanceTextStyles .captionUp ,
112+ text = widget.period.value. uppercase(Locale . ENGLISH ),
113+ style = GlanceTextStyles .captionB ,
118114 )
119115 }
120116 VerticalSpacer (8 .dp)
@@ -154,11 +150,3 @@ private fun ChartBox(chartBitmap: Bitmap?) {
154150 )
155151 }
156152}
157-
158- @StringRes
159- private fun GraphPeriod.labelRes (): Int = when (this ) {
160- GraphPeriod .ONE_DAY -> R .string.appwidget__price__day
161- GraphPeriod .ONE_WEEK -> R .string.appwidget__price__week
162- GraphPeriod .ONE_MONTH -> R .string.appwidget__price__month
163- GraphPeriod .ONE_YEAR -> R .string.appwidget__price__year
164- }
0 commit comments