Skip to content

Commit 9ecee6a

Browse files
committed
Update style
2 parents d98e1f4 + 99c8de4 commit 9ecee6a

14 files changed

Lines changed: 183 additions & 174 deletions

File tree

app/src/main/java/one/mixin/android/ui/home/web3/trade/SpotTradeGuidePage.kt

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package one.mixin.android.ui.home.web3.trade
22

3-
import androidx.compose.foundation.BorderStroke
43
import androidx.compose.foundation.background
54
import androidx.compose.foundation.clickable
65
import androidx.compose.foundation.horizontalScroll
@@ -24,7 +23,6 @@ import androidx.compose.material.Button
2423
import androidx.compose.material.ButtonDefaults
2524
import androidx.compose.material.CircularProgressIndicator
2625
import androidx.compose.material.Icon
27-
import androidx.compose.material.Surface
2826
import androidx.compose.material.Text
2927
import androidx.compose.runtime.Composable
3028
import androidx.compose.runtime.LaunchedEffect
@@ -35,6 +33,7 @@ import androidx.compose.runtime.mutableStateOf
3533
import androidx.compose.runtime.remember
3634
import androidx.compose.runtime.rememberCoroutineScope
3735
import androidx.compose.runtime.setValue
36+
import androidx.compose.ui.draw.alpha
3837
import androidx.compose.ui.draw.clip
3938
import androidx.compose.ui.Alignment
4039
import androidx.compose.ui.Modifier
@@ -55,7 +54,6 @@ import one.mixin.android.R
5554
import one.mixin.android.compose.CoilImage
5655
import one.mixin.android.compose.theme.MixinAppTheme
5756
import one.mixin.android.extension.numberFormat8
58-
import one.mixin.android.extension.priceFormat
5957
import one.mixin.android.ui.home.web3.components.OutlinedTab
6058
import one.mixin.android.ui.wallet.alert.components.cardBackground
6159
import one.mixin.android.vo.safe.TokenItem
@@ -281,13 +279,13 @@ private fun SpotTradeExampleCard(
281279
fontWeight = FontWeight.W500,
282280
color = MixinAppTheme.colors.textPrimary,
283281
)
284-
Spacer(modifier = Modifier.height(12.dp))
282+
Spacer(modifier = Modifier.height(16.dp))
285283
if (limitStrategy != null) {
286284
StrategyRow(
287285
strategy = strategy,
288286
onStrategySelected = { strategy = it },
289287
)
290-
Spacer(modifier = Modifier.height(12.dp))
288+
Spacer(modifier = Modifier.height(16.dp))
291289
}
292290
ExampleValueRow(
293291
title = stringResource(R.string.Trade_Guide_Trading_Pair),
@@ -300,13 +298,19 @@ private fun SpotTradeExampleCard(
300298
onSwitch = {
301299
val currentFromPrice = if (isPairReversed) btcToken.safePrice() else usdtToken.safePrice()
302300
val newFromPrice = if (isPairReversed) usdtToken.safePrice() else btcToken.safePrice()
303-
payAmount = convertPayAmount(payAmount, currentFromPrice, newFromPrice)
301+
val converted = convertPayAmount(payAmount, currentFromPrice, newFromPrice)
302+
// switching to USDT as from token: ceil to integer
303+
payAmount = if (isPairReversed) {
304+
converted.setScale(0, RoundingMode.CEILING)
305+
} else {
306+
converted
307+
}
304308
isPairReversed = !isPairReversed
305309
},
306310
)
307311
},
308312
)
309-
Spacer(modifier = Modifier.height(12.dp))
313+
Spacer(modifier = Modifier.height(16.dp))
310314
ExampleValueRow(
311315
title = stringResource(R.string.Trade_Guide_Pay_Amount),
312316
value = {
@@ -323,35 +327,24 @@ private fun SpotTradeExampleCard(
323327
)
324328
},
325329
)
326-
Spacer(modifier = Modifier.height(12.dp))
327-
ExampleValueRow(
328-
title = stringResource(
329-
if (limitStrategy == null) R.string.Trade_Guide_Exchange_Price else R.string.Trade_Guide_Order_Price
330-
),
331-
value = {
332-
PriceSubtitle(
333-
marketPrice = effectivePrice,
334-
isReversed = isPriceDisplayReversed,
335-
onSwitchDirection = { isPriceDisplayReversed = !isPriceDisplayReversed },
336-
onPriceExpired = { priceRefreshFlag = !priceRefreshFlag },
337-
)
338-
},
339-
)
340-
if (limitStrategy != null) {
341-
Spacer(modifier = Modifier.height(12.dp))
342-
ExampleValueRow(
343-
title = stringResource(R.string.Trade_Guide_Market_Price),
344-
value = {
345-
PriceSubtitle(
346-
marketPrice = marketPrice,
347-
isReversed = isPriceDisplayReversed,
348-
onSwitchDirection = { isPriceDisplayReversed = !isPriceDisplayReversed },
349-
onPriceExpired = { priceRefreshFlag = !priceRefreshFlag },
350-
)
351-
},
330+
Spacer(modifier = Modifier.height(20.dp))
331+
Column {
332+
Text(
333+
text = stringResource(if (limitStrategy == null) R.string.Trade_Guide_Exchange_Price else R.string.Trade_Guide_Order_Price),
334+
fontSize = 14.sp,
335+
lineHeight = 18.sp,
336+
color = MixinAppTheme.colors.textPrimary,
337+
)
338+
Spacer(modifier = Modifier.height(16.dp))
339+
PriceSubtitle(
340+
marketPrice = effectivePrice,
341+
fill = true,
342+
isReversed = isPriceDisplayReversed,
343+
onSwitchDirection = { isPriceDisplayReversed = !isPriceDisplayReversed },
344+
onPriceExpired = { priceRefreshFlag = !priceRefreshFlag },
352345
)
353346
}
354-
Spacer(modifier = Modifier.height(12.dp))
347+
Spacer(modifier = Modifier.height(16.dp))
355348
ExampleValueRow(
356349
title = stringResource(R.string.Estimated_Receive),
357350
value = {
@@ -388,24 +381,28 @@ private fun StrategyRow(
388381
ExampleValueRow(
389382
title = stringResource(R.string.Trade_Guide_Trading_Strategy),
390383
value = {
391-
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
384+
Row( modifier = Modifier
385+
.clip(RoundedCornerShape(8.dp))
386+
.background(MixinAppTheme.colors.backgroundWindow)
387+
.padding(2.dp),
388+
horizontalArrangement = Arrangement.spacedBy(8.dp)) {
392389
LimitStrategy.entries.forEach { item ->
393390
val selected = item == strategy
394391
Box(
395392
modifier = Modifier
396-
.clip(RoundedCornerShape(20.dp))
393+
.clip(RoundedCornerShape(8.dp))
397394
.background(
398395
if (selected) MixinAppTheme.colors.accent
399-
else MixinAppTheme.colors.backgroundWindow
396+
else Color.Transparent
400397
)
401398
.clickable { onStrategySelected(item) }
402-
.padding(horizontal = 12.dp, vertical = 8.dp),
399+
.padding(horizontal = 8.dp, vertical = 2.dp),
403400
contentAlignment = Alignment.Center,
404401
) {
405402
Text(
406403
text = stringResource(item.titleRes),
407404
color = if (selected) Color.White else MixinAppTheme.colors.textPrimary,
408-
fontSize = 13.sp,
405+
fontSize = 14.sp,
409406
lineHeight = 18.sp,
410407
)
411408
}
@@ -429,7 +426,7 @@ private fun ExampleValueRow(
429426
Column(modifier = Modifier.weight(1f)) {
430427
Text(
431428
text = title,
432-
fontSize = 13.sp,
429+
fontSize = 14.sp,
433430
lineHeight = 18.sp,
434431
color = MixinAppTheme.colors.textAssist,
435432
)
@@ -512,7 +509,7 @@ private fun AmountStepper(
512509
horizontalArrangement = Arrangement.spacedBy(8.dp),
513510
) {
514511
StepperButton(
515-
text = "-",
512+
isAdd = false,
516513
enabled = amount > step,
517514
onClick = onDecrease,
518515
)
@@ -524,34 +521,35 @@ private fun AmountStepper(
524521
fontWeight = FontWeight.W500,
525522
)
526523
StepperButton(
527-
text = "+",
524+
isAdd = true,
528525
enabled = true,
529526
onClick = onIncrease,
530527
)
531528
}
532529
}
533-
534530
@Composable
535531
private fun StepperButton(
536-
text: String,
532+
isAdd: Boolean,
537533
enabled: Boolean,
538534
onClick: () -> Unit,
539535
) {
540-
Surface(
541-
color = if (enabled) Color.Transparent else MixinAppTheme.colors.backgroundWindow,
542-
shape = CircleShape,
543-
border = BorderStroke(1.dp, MixinAppTheme.colors.borderColor),
536+
Box(
544537
modifier = Modifier
545538
.size(24.dp)
539+
.clip(CircleShape)
540+
.background(MixinAppTheme.colors.backgroundWindow)
541+
.alpha(if (enabled) 1f else 0.5f)
546542
.clickable(enabled = enabled, onClick = onClick),
543+
contentAlignment = Alignment.Center,
547544
) {
548-
Box(contentAlignment = Alignment.Center) {
549-
Text(
550-
text = text,
551-
fontSize = 14.sp,
552-
color = if (enabled) MixinAppTheme.colors.textPrimary else MixinAppTheme.colors.textAssist,
553-
)
554-
}
545+
Icon(
546+
painter = painterResource(
547+
id = if (isAdd) R.drawable.ic_perps_add else R.drawable.ic_perps_minus
548+
),
549+
contentDescription = null,
550+
tint = Color.Unspecified,
551+
modifier = Modifier.size(16.dp),
552+
)
555553
}
556554
}
557555

@@ -561,6 +559,7 @@ private fun PriceSubtitle(
561559
isReversed: Boolean,
562560
onSwitchDirection: () -> Unit,
563561
onPriceExpired: () -> Unit = {},
562+
fill: Boolean = false,
564563
) {
565564
var quoteCountDown by remember(marketPrice) { mutableFloatStateOf(0f) }
566565

@@ -584,7 +583,7 @@ private fun PriceSubtitle(
584583
val inverted = safeDivide(BigDecimal.ONE, marketPrice)
585584
"1 USDT ≈ ${inverted.numberFormat8()} BTC"
586585
} else {
587-
"1 BTC ≈ ${marketPrice.priceFormat()} USDT"
586+
"1 BTC ≈ ${"%,d".format(marketPrice.toLong())} USDT"
588587
},
589588
fontSize = 14.sp,
590589
color = MixinAppTheme.colors.textAssist,
@@ -596,6 +595,9 @@ private fun PriceSubtitle(
596595
color = MixinAppTheme.colors.textPrimary,
597596
backgroundColor = MixinAppTheme.colors.textAssist,
598597
)
598+
if(fill){
599+
Spacer(modifier = Modifier.weight(1f))
600+
}
599601
Icon(
600602
painter = painterResource(id = R.drawable.ic_price_switch),
601603
contentDescription = null,
@@ -629,7 +631,7 @@ private fun TradeGuideInfoCard(
629631
fontWeight = FontWeight.W500,
630632
color = MixinAppTheme.colors.textPrimary,
631633
)
632-
Spacer(modifier = Modifier.height(12.dp))
634+
Spacer(modifier = Modifier.height(16.dp))
633635
Text(
634636
text = description,
635637
fontSize = 14.sp,

app/src/main/java/one/mixin/android/ui/home/web3/trade/perps/PerpsMarketDetailPage.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ fun PerpsMarketDetailPage(
205205
if (currentPosition != null) {
206206
OpenPositionCard(
207207
position = currentPosition,
208-
viewModel = viewModel
208+
viewModel = viewModel,
209+
onShare = {
210+
PerpsPositionShareActivity.show(context, currentPosition)
211+
},
209212
)
210213
Spacer(modifier = Modifier.height(16.dp))
211214
}
@@ -606,6 +609,7 @@ private fun MarketDetailCard(
606609
private fun OpenPositionCard(
607610
position: PerpsPositionItem,
608611
viewModel: PerpetualViewModel,
612+
onShare: () -> Unit,
609613
) {
610614
val context = LocalContext.current
611615
val quoteColorReversed = context.defaultSharedPreferences
@@ -656,6 +660,15 @@ private fun OpenPositionCard(
656660
fontWeight = FontWeight.Medium,
657661
color = MixinAppTheme.colors.textPrimary
658662
)
663+
Spacer(modifier = Modifier.weight(1f))
664+
Icon(
665+
painter = painterResource(id = R.drawable.ic_share_arrow),
666+
contentDescription = null,
667+
tint = MixinAppTheme.colors.accent,
668+
modifier = Modifier
669+
.size(24.dp)
670+
.clickable(onClick = onShare),
671+
)
659672
}
660673

661674
Spacer(modifier = Modifier.height(12.dp))

app/src/main/java/one/mixin/android/ui/wallet/alert/AlertEditPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fun AlertEditPage(coin: CoinItem?, alert: Alert?, onAdd: (CoinItem) -> Unit, pop
158158
},
159159
) {
160160
PageScaffold(
161-
title = stringResource(id = if (alert == null) R.string.Add_Alert else R.string.Edit_Alert),
161+
title = stringResource(id = if (alert == null) R.string.Alert else R.string.Edit_Alert),
162162
verticalScrollable = false,
163163
pop = pop,
164164
) {
@@ -508,7 +508,7 @@ fun AlertEditPage(coin: CoinItem?, alert: Alert?, onAdd: (CoinItem) -> Unit, pop
508508
}
509509
Text(
510510
modifier = Modifier.alpha(if (isLoading) 0f else 1f),
511-
text = stringResource(if (alert == null) R.string.Add_Alert else R.string.Save),
511+
text = stringResource(if (alert == null) R.string.Alert else R.string.Save),
512512
color = if (enable) Color.White else MixinAppTheme.colors.textAssist,
513513
)
514514
}

app/src/main/java/one/mixin/android/ui/wallet/alert/AlertPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fun AlertPage(coin: CoinItem, pop: () -> Unit, onAdd: () -> Unit, toAll: () -> U
9797
) {
9898
Box(modifier = Modifier.padding(horizontal = 32.dp), contentAlignment = Alignment.Center) {
9999
Text(
100-
text = stringResource(R.string.Add_Alert),
100+
text = stringResource(R.string.Alert),
101101
color = Color.White,
102102
)
103103
}
@@ -135,7 +135,7 @@ fun AlertPage(coin: CoinItem, pop: () -> Unit, onAdd: () -> Unit, toAll: () -> U
135135
) {
136136
Box(modifier = Modifier.padding(horizontal = 32.dp), contentAlignment = Alignment.Center) {
137137
Text(
138-
text = stringResource(R.string.Add_Alert),
138+
text = stringResource(R.string.Alert),
139139
color = Color.White,
140140
)
141141
}

app/src/main/java/one/mixin/android/ui/wallet/alert/AllAlertPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fun AllAlertPage(coins: Set<CoinItem>?, openFilter: () -> Unit, pop: () -> Unit,
8282
)
8383
Spacer(modifier = Modifier.width(4.dp))
8484
Text(
85-
text = stringResource(R.string.Add_Alert), color = Color(0xFF3D75E3)
85+
text = stringResource(R.string.Alert), color = Color(0xFF3D75E3)
8686
)
8787
}
8888
}
@@ -117,7 +117,7 @@ fun AllAlertPage(coins: Set<CoinItem>?, openFilter: () -> Unit, pop: () -> Unit,
117117
)
118118
Spacer(modifier = Modifier.width(4.dp))
119119
Text(
120-
text = stringResource(R.string.Add_Alert), color = Color(0xFF3D75E3)
120+
text = stringResource(R.string.Alert), color = Color(0xFF3D75E3)
121121
)
122122
}
123123
}

app/src/main/java/one/mixin/android/ui/wallet/fiatmoney/OrderStatusFragment.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ class OrderStatusFragment : BaseFragment(R.layout.fragment_order_status) {
519519
RiskConfig(
520520
BuildConfig.CHCEKOUT_ID,
521521
RISK_ENVIRONMENT,
522-
false,
523-
null,
524522
),
525523
)
526524
if (riskInstance == null) {

0 commit comments

Comments
 (0)