Skip to content

Commit b4c1bef

Browse files
committed
Update page
1 parent 4cd5286 commit b4c1bef

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,23 @@ class TotalPositionValueAdapter : RecyclerView.Adapter<TotalPositionValueAdapter
8686
lossColor
8787
}
8888
)
89-
subtitleTv.isGone = true
89+
if (subtitlePercent == null) {
90+
subtitleTv.isGone = true
91+
} else {
92+
subtitleTv.isVisible = true
93+
subtitleTv.text = context.getString(
94+
R.string.Perpetual_Amount_Percent_Format,
95+
formatSignedUsd(subtitleValue),
96+
subtitlePercent.toDouble()
97+
)
98+
subtitleTv.setTextColor(
99+
if (isProfit) {
100+
gainColor
101+
} else {
102+
lossColor
103+
}
104+
)
105+
}
90106
} else {
91107
valueTv.setTextColor(resolveAttrColor(itemView, R.attr.text_primary))
92108
if (subtitlePercent == null) {

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ class AllPositionsFragment : BaseFragment(R.layout.fragment_all_closed_positions
252252
if (lastClosedTotalPnl != totalPnl || lastClosedTotalEntryValue != totalEntryValue) {
253253
lastClosedTotalPnl = totalPnl
254254
lastClosedTotalEntryValue = totalEntryValue
255+
val nowValue = totalEntryValue + totalPnl
256+
val percent = calculateClosedPercent(nowValue, totalEntryValue)
255257
totalValueAdapter.submitTotal(BigDecimal.valueOf(totalPnl))
256-
totalValueAdapter.submitSubtitle(BigDecimal.valueOf(totalPnl), BigDecimal.ZERO)
258+
totalValueAdapter.submitSubtitle(BigDecimal.valueOf(totalPnl), BigDecimal.valueOf(percent))
257259
}
258260
}
259261
}
@@ -282,4 +284,11 @@ class AllPositionsFragment : BaseFragment(R.layout.fragment_all_closed_positions
282284
}
283285
return value / base * 100
284286
}
287+
288+
private fun calculateClosedPercent(nowValue: Double, entryValue: Double): Double {
289+
if (entryValue == 0.0) {
290+
return 0.0
291+
}
292+
return (nowValue / entryValue - 1.0) * 100
293+
}
285294
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ private fun OpenPositionCard(
633633
verticalAlignment = Alignment.CenterVertically
634634
) {
635635
Text(
636-
text = stringResource(R.string.Order_Value),
636+
text = stringResource(R.string.perps_position),
637637
fontSize = 16.sp,
638638
fontWeight = FontWeight.Medium,
639639
color = MixinAppTheme.colors.textPrimary

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,7 @@
23232323
<string name="Perpetual_Leverage_Format">%1$d倍</string>
23242324
<string name="Open_Positions">持仓(%1$d)</string>
23252325
<string name="perps_positions">持仓</string>
2326+
<string name="perps_position">持仓</string>
23262327
<string name="perps_activity">历史记录</string>
23272328
<string name="No_Positions">暂无持仓</string>
23282329
<string name="No_Closed_Positions">暂无历史记录</string>

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@
483483
<string name="error_invalid_quote_amount">ERROR 10614: The input amount is either too small or too large, please adjust the amount.</string>
484484
<string name="error_invalid_quote_amount_detailed">ERROR 10614: The amount exceeds the maximum allowable value of %1$s. Please adjust the amount. Try placing a limit order? No restrictions on amount or token.</string>
485485
<string name="error_no_available_quote">ERROR 10615: This trading pair is currently not supported, please try switching to a different token.</string>
486-
<string name="error_perps_order_value_too_small">ERROR 10650: Order value is too small.</string>
486+
<string name="error_perps_order_value_too_small">ERROR 10650: Size is too small.</string>
487487
<string name="error_perps_market_already_has_active_position">ERROR 10651: The current market already has an open position.</string>
488488
<string name="error_waiting_other_orders">The current market already has an open position.</string>
489489
<string name="error_phone_verification_code_expired">ERROR 20114: Expired phone verification code</string>
@@ -2333,7 +2333,7 @@
23332333
<string name="Perpetual_Leverage_Impact_1">Leverage amplifies both gains and losses.</string>
23342334
<string name="Perpetual_Leverage_Impact_2">Higher leverage means greater P&amp;L fluctuation with price movements.</string>
23352335
<string name="Perpetual_Leverage_Risk">Please choose leverage reasonably, with high leverage, even small price movements can lead to significant losses.</string>
2336-
<string name="Perpetual_Position_Desc">The order value of current contract is calculated by "Margin × Leverage", representing the asset size controlled in this transaction.</string>
2336+
<string name="Perpetual_Position_Desc">The size of current contract is calculated by "Margin × Leverage", representing the asset size controlled in this transaction.</string>
23372337
<string name="Perpetual_Position_Usage">Usage</string>
23382338
<string name="Perpetual_Position_Usage_Desc_1">Determines the market exposure size of this transaction.</string>
23392339
<string name="Perpetual_Position_Usage_Desc_2">Affects the amplification factor of profit and loss changes.</string>
@@ -2346,7 +2346,7 @@
23462346
<string name="Leverage">Leverage</string>
23472347
<string name="Select_Token">Select Token</string>
23482348
<string name="Select_Leverage">Select Leverage</string>
2349-
<string name="Order_Value">Order Value</string>
2349+
<string name="Order_Value">Size</string>
23502350
<string name="Liquidation_Price">Liquidation Price</string>
23512351
<string name="Price_Change_Profit">Price %1$s %2$s%% → Profit %3$s%4$s%% (%5$s%6$s)</string>
23522352
<string name="Long">Long</string>
@@ -2383,14 +2383,15 @@
23832383
<string name="Perpetual_Closed_Long_Title">Close Long</string>
23842384
<string name="Perpetual_Closed_Short_Title">Close Short</string>
23852385
<string name="Estimated_Liquidation_Price">Estimated Liquidation Price</string>
2386-
<string name="Total_Position_Value">Total Order Value</string>
2386+
<string name="Total_Position_Value">Total Size</string>
23872387
<string name="Perpetual_Side_Symbol_Title">%1$s %2$s</string>
23882388
<string name="Perpetual_Leverage_Format">%1$dx</string>
23892389
<string name="Perpetual_Usd_Amount" translatable="false">$%1$f</string>
23902390
<string name="Perpetual_Usd_Amount_Signed" translatable="false">%1$s$%2$f</string>
23912391
<string name="Perpetual_Amount_Percent_Format" translatable="false">%1$s(%2$.2f%%)</string>
23922392
<string name="Open_Positions">Positions(%1$d)</string>
23932393
<string name="perps_positions">Positions</string>
2394+
<string name="perps_position">Position</string>
23942395
<string name="perps_activity">Activity</string>
23952396
<string name="No_Positions">No Positions</string>
23962397
<string name="No_Closed_Positions">No Activities</string>

0 commit comments

Comments
 (0)