Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions lib/features/home/widgets/order_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,35 @@ class OrderListItem extends ConsumerWidget {
fontWeight: FontWeight.w500,
),
)
: Row(
children: [
Text(
'${S.of(context)!.marketPrice} ',
: premiumValue == 0
? Text(
S.of(context)!.marketPrice,
style: TextStyle(
fontSize: 14,
color: Colors.white70,
fontWeight: FontWeight.w500,
),
)
: Row(
children: [
Text(
'${S.of(context)!.marketPrice} ',
style: TextStyle(
fontSize: 14,
color: Colors.white70,
fontWeight: FontWeight.w500,
),
),
Text(
premiumText,
style: TextStyle(
fontSize: 14,
color: premiumColor,
fontWeight: FontWeight.w500,
),
),
],
),
Text(
premiumText,
style: TextStyle(
fontSize: 14,
color: premiumColor,
fontWeight: FontWeight.w500,
),
),
],
),
),
],
),
Expand Down
19 changes: 17 additions & 2 deletions lib/features/order/screens/take_order_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,23 @@ class TakeOrderScreen extends ConsumerWidget {
final currencyFlag = CurrencyUtils.getFlagFromCurrencyData(order.currency!, currencyData);
final amountString =
'${order.fiatAmount} ${order.currency} $currencyFlag';
final priceText =
order.amount == '0' ? S.of(context)!.atMarketPrice : '';
String priceText = '';
if (order.amount == '0') {
final premium = order.premium;
final premiumValue = premium != null ? double.tryParse(premium) ?? 0.0 : 0.0;

if (premiumValue == 0) {
// No premium - show only market price
priceText = S.of(context)!.atMarketPrice;
} else {
// Has premium/discount - show market price with percentage
final isPremiumPositive = premiumValue >= 0;
final premiumDisplay = isPremiumPositive
? '(+$premiumValue%)'
: '($premiumValue%)';
priceText = '${S.of(context)!.atMarketPrice} $premiumDisplay';
}
}

final hasFixedSatsAmount = order.amount != null && order.amount != '0';

Expand Down
2 changes: 2 additions & 0 deletions lib/features/order/widgets/payment_methods_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ class PaymentMethodsSection extends ConsumerWidget {
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.activeColor,
foregroundColor: Colors.black,
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24),
minimumSize: const Size(0, 52),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
Expand Down
48 changes: 38 additions & 10 deletions lib/features/trades/screens/trade_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,24 @@ class TradeDetailScreen extends ConsumerWidget {

// If `orderPayload.amount` is 0, the trade is "at market price"
final isZeroAmount = (tradeState.order!.amount == 0);
final priceText = isZeroAmount ? S.of(context)!.atMarketPrice : '';
String priceText = '';

if (isZeroAmount) {
final premium = tradeState.order!.premium;
final premiumValue = premium.toDouble();

if (premiumValue == 0) {
// No premium - show only market price
priceText = S.of(context)!.atMarketPrice;
} else {
// Has premium/discount - show market price with percentage
final isPremiumPositive = premiumValue >= 0;
final premiumDisplay = isPremiumPositive
? '(+$premiumValue%)'
: '($premiumValue%)';
priceText = '${S.of(context)!.atMarketPrice} $premiumDisplay';
}
}

final paymentMethod = tradeState.order!.paymentMethod;
final createdOn = formatDateTime(
Expand Down Expand Up @@ -164,14 +181,26 @@ class TradeDetailScreen extends ConsumerWidget {

final hasFixedSatsAmount = tradeState.order!.amount != 0;
final satAmount = hasFixedSatsAmount ? ' ${tradeState.order!.amount}' : '';
final priceText = !hasFixedSatsAmount ? S.of(context)!.atMarketPrice : '';

final premium = tradeState.order!.premium;
final premiumText = premium == 0
? ''
: (premium > 0)
? S.of(context)!.withPremiumPercent(premium.toString())
: S.of(context)!.withDiscountPercent(premium.abs().toString());

// For market price orders, show premium in the same format as order book
String priceText = '';

if (!hasFixedSatsAmount) {
final premium = tradeState.order!.premium;
final premiumValue = premium.toDouble();

if (premiumValue == 0) {
// No premium - show only market price
priceText = S.of(context)!.atMarketPrice;
} else {
// Has premium/discount - show market price with percentage
final isPremiumPositive = premiumValue >= 0;
final premiumDisplay = isPremiumPositive
? '(+$premiumValue%)'
: '($premiumValue%)';
priceText = '${S.of(context)!.atMarketPrice} $premiumDisplay';
}
}

// Payment method
final method = tradeState.order!.paymentMethod;
Expand All @@ -196,7 +225,6 @@ class TradeDetailScreen extends ConsumerWidget {
: tradeState.order!.fiatAmount.toString(),
currency: tradeState.order!.fiatCode,
priceText: priceText,
premiumText: premiumText,
),
const SizedBox(height: 16),
PaymentMethodCard(
Expand Down