@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.width
1010import androidx.compose.runtime.Composable
1111import androidx.compose.ui.Alignment
1212import androidx.compose.ui.Modifier
13+ import androidx.compose.ui.platform.LocalInspectionMode
1314import androidx.compose.ui.res.stringResource
1415import androidx.compose.ui.tooling.preview.Preview
1516import androidx.compose.ui.tooling.preview.PreviewParameter
@@ -20,6 +21,7 @@ import to.bitkit.ext.DatePattern
2021import to.bitkit.ext.formatted
2122import to.bitkit.ext.rawId
2223import to.bitkit.models.PrimaryDisplay
24+ import to.bitkit.models.formatToModernDisplay
2325import to.bitkit.ui.LocalCurrencies
2426import to.bitkit.ui.components.BodyMSB
2527import to.bitkit.ui.components.CaptionB
@@ -70,6 +72,7 @@ fun ActivityRow(
7072 Spacer (modifier = Modifier .width(16 .dp))
7173 Column (
7274 verticalArrangement = Arrangement .spacedBy(4 .dp),
75+ modifier = Modifier .weight(1f )
7376 ) {
7477 TransactionStatusText (
7578 txType = txType,
@@ -91,9 +94,10 @@ fun ActivityRow(
9194 CaptionB (
9295 text = subtitleText,
9396 color = Colors .White64 ,
97+ maxLines = 1 ,
9498 )
9599 }
96- Spacer (modifier = Modifier .weight( 1f ))
100+ Spacer (modifier = Modifier .width( 16 .dp ))
97101 AmountView (
98102 item = item,
99103 prefix = amountPrefix,
@@ -141,47 +145,68 @@ private fun AmountView(
141145 item : Activity ,
142146 prefix : String ,
143147) {
144- val currency = currencyViewModel ? : return
145- val (_, _, _, _, displayUnit, primaryDisplay) = LocalCurrencies .current
146148 val amount = when (item) {
147149 is Activity .Lightning -> item.v1.value
148150 is Activity .Onchain -> when (item.v1.txType) {
149151 PaymentType .SENT -> item.v1.value + item.v1.fee
150152 else -> item.v1.value
151153 }
152154 }
155+
156+ val isPreview = LocalInspectionMode .current
157+ if (isPreview) {
158+ AmountViewContent (
159+ title = amount.toLong().formatToModernDisplay(),
160+ titlePrefix = prefix,
161+ subtitle = " $ 123.45" ,
162+ )
163+ return
164+ }
165+
166+ val currency = currencyViewModel ? : return
167+ val (_, _, _, _, displayUnit, primaryDisplay) = LocalCurrencies .current
168+
153169 currency.convert(sats = amount.toLong())?.let { converted ->
154170 val btcComponents = converted.bitcoinDisplay(displayUnit)
155- Column (
156- horizontalAlignment = Alignment .End ,
157- verticalArrangement = Arrangement .spacedBy(2 .dp),
171+ if (primaryDisplay == PrimaryDisplay .BITCOIN ) {
172+ AmountViewContent (
173+ title = btcComponents.value,
174+ titlePrefix = prefix,
175+ subtitle = " ${converted.symbol} ${converted.formatted} " ,
176+ )
177+ } else {
178+ AmountViewContent (
179+ title = " ${converted.symbol} ${converted.formatted} " ,
180+ titlePrefix = prefix,
181+ subtitle = btcComponents.value,
182+ )
183+ }
184+ }
185+ }
186+
187+ @Composable
188+ private fun AmountViewContent (
189+ title : String ,
190+ titlePrefix : String ,
191+ subtitle : String ,
192+ modifier : Modifier = Modifier ,
193+ ) {
194+ Column (
195+ modifier = modifier,
196+ horizontalAlignment = Alignment .End ,
197+ verticalArrangement = Arrangement .spacedBy(2 .dp),
198+ ) {
199+ Row (
200+ verticalAlignment = Alignment .CenterVertically ,
201+ horizontalArrangement = Arrangement .spacedBy(1 .dp),
158202 ) {
159- if (primaryDisplay == PrimaryDisplay .BITCOIN ) {
160- Row (
161- verticalAlignment = Alignment .CenterVertically ,
162- horizontalArrangement = Arrangement .spacedBy(1 .dp),
163- ) {
164- BodyMSB (text = prefix, color = Colors .White64 )
165- BodyMSB (text = btcComponents.value)
166- }
167- CaptionB (
168- text = " ${converted.symbol} ${converted.formatted} " ,
169- color = Colors .White64 ,
170- )
171- } else {
172- Row (
173- verticalAlignment = Alignment .CenterVertically ,
174- horizontalArrangement = Arrangement .spacedBy(1 .dp),
175- ) {
176- BodyMSB (text = prefix, color = Colors .White64 )
177- BodyMSB (text = " ${converted.symbol} ${converted.formatted} " )
178- }
179- CaptionB (
180- text = btcComponents.value,
181- color = Colors .White64 ,
182- )
183- }
203+ BodyMSB (text = titlePrefix, color = Colors .White64 )
204+ BodyMSB (text = title)
184205 }
206+ CaptionB (
207+ text = subtitle,
208+ color = Colors .White64 ,
209+ )
185210 }
186211}
187212
0 commit comments