@@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.height
1414import androidx.compose.foundation.layout.padding
1515import androidx.compose.material3.MaterialTheme
1616import androidx.compose.material3.ShapeDefaults
17- import androidx.compose.material3.Text
1817import androidx.compose.runtime.Composable
1918import androidx.compose.runtime.remember
2019import androidx.compose.ui.Alignment
@@ -25,10 +24,8 @@ import androidx.compose.ui.layout.ContentScale
2524import androidx.compose.ui.platform.LocalInspectionMode
2625import androidx.compose.ui.platform.testTag
2726import androidx.compose.ui.res.painterResource
28- import androidx.compose.ui.text.font.FontWeight
2927import androidx.compose.ui.tooling.preview.Preview
3028import androidx.compose.ui.unit.dp
31- import androidx.compose.ui.unit.sp
3229import ir.ehsannarmani.compose_charts.LineChart
3330import ir.ehsannarmani.compose_charts.models.DividerProperties
3431import ir.ehsannarmani.compose_charts.models.DrawStyle
@@ -44,8 +41,11 @@ import to.bitkit.data.dto.price.PriceDTO
4441import to.bitkit.data.dto.price.PriceWidgetData
4542import to.bitkit.data.dto.price.TradingPair
4643import to.bitkit.models.widget.PricePreferences
44+ import to.bitkit.ui.components.BodySSB
4745import to.bitkit.ui.components.Caption13Up
46+ import to.bitkit.ui.components.Display34
4847import to.bitkit.ui.components.HorizontalSpacer
48+ import to.bitkit.ui.components.Title
4949import to.bitkit.ui.theme.AppThemeSurface
5050import to.bitkit.ui.theme.Colors
5151
@@ -56,8 +56,7 @@ fun PriceCard(
5656 priceDTO : PriceDTO ,
5757) {
5858 val widgetData = remember(pricePreferences.enabledPairs, priceDTO.widgets) {
59- priceDTO.widgets.firstOrNull { it.pair in pricePreferences.enabledPairs }
60- ? : priceDTO.widgets.firstOrNull()
59+ priceDTO.resolveWidget(pricePreferences)
6160 } ? : return
6261
6362 Box (
@@ -85,22 +84,16 @@ fun PriceCard(
8584 .testTag(" PriceWidgetRow-${widgetData.pair.displayName} " )
8685 )
8786 HorizontalSpacer (16 .dp)
88- Text (
87+ Title (
8988 text = widgetData.change.formatted,
9089 color = if (widgetData.change.isPositive) Colors .Green else Colors .Red ,
91- fontSize = 22 .sp,
92- lineHeight = 26 .sp,
93- fontWeight = FontWeight .Bold ,
9490 modifier = Modifier .testTag(" price_card_pair_change_${widgetData.pair} " )
9591 )
9692 }
9793
98- Text (
94+ Display34 (
9995 text = " ${widgetData.pair.symbol} ${widgetData.price} " ,
10096 color = Colors .White ,
101- fontSize = 34 .sp,
102- lineHeight = 34 .sp,
103- fontWeight = FontWeight .Bold ,
10497 modifier = Modifier
10598 .fillMaxWidth()
10699 .testTag(" price_card_pair_price_${widgetData.pair} " )
@@ -124,8 +117,7 @@ fun PriceCardSmall(
124117 priceDTO : PriceDTO ,
125118) {
126119 val widgetData = remember(pricePreferences.enabledPairs, priceDTO.widgets) {
127- priceDTO.widgets.firstOrNull { it.pair in pricePreferences.enabledPairs }
128- ? : priceDTO.widgets.firstOrNull()
120+ priceDTO.resolveWidget(pricePreferences)
129121 } ? : return
130122
131123 Box (
@@ -157,22 +149,16 @@ fun PriceCardSmall(
157149 color = Colors .White64 ,
158150 )
159151 }
160- Text (
152+ Title (
161153 text = " ${widgetData.pair.symbol} ${widgetData.price} " ,
162154 color = Colors .White ,
163- fontSize = 22 .sp,
164- lineHeight = 26 .sp,
165- fontWeight = FontWeight .Bold ,
166155 modifier = Modifier
167156 .fillMaxWidth()
168157 .testTag(" price_card_small_pair_price_${widgetData.pair} " )
169158 )
170- Text (
159+ BodySSB (
171160 text = widgetData.change.formatted,
172161 color = if (widgetData.change.isPositive) Colors .Green else Colors .Red ,
173- fontSize = 15 .sp,
174- lineHeight = 20 .sp,
175- fontWeight = FontWeight .SemiBold ,
176162 modifier = Modifier .testTag(" price_card_small_pair_change_${widgetData.pair} " )
177163 )
178164 }
@@ -188,6 +174,9 @@ fun PriceCardSmall(
188174 }
189175}
190176
177+ private fun PriceDTO.resolveWidget (prefs : PricePreferences ): PriceWidgetData ? =
178+ widgets.firstOrNull { it.pair in prefs.enabledPairs } ? : widgets.firstOrNull()
179+
191180@Composable
192181fun ChartComponent (
193182 widgetData : PriceWidgetData ,
@@ -264,9 +253,7 @@ private fun FullBlockCardPreview() {
264253 .padding(16 .dp)
265254 ) {
266255 PriceCard (
267- pricePreferences = PricePreferences (
268- showSource = true ,
269- ),
256+ pricePreferences = PricePreferences (),
270257 priceDTO = PriceDTO (
271258 widgets = listOf (
272259 PriceWidgetData (
0 commit comments