Files
efrilm 38850b281f
Build & Deploy iOS to TestFlight / build-and-deploy (push) Waiting to run
feat: integrate enakgame and voucher
2026-10-10 02:33:16 +07:00

117 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import '../../../../common/theme/theme.dart';
import '../../../../domain/wallet/wallet.dart';
import '../wallet_ui.dart';
class WalletTransactionTile extends StatelessWidget {
const WalletTransactionTile({
super.key,
required this.transaction,
this.showCurrency = false,
});
final WalletTransaction transaction;
/// Tampilkan mata uang di samping jumlah, untuk list yang mencampur
/// EnakPoint & EnakCoin. Satu order menghasilkan dua transaksi (POINT dan
/// COIN) dengan deskripsi dan jumlah yang sama.
final bool showCurrency;
@override
Widget build(BuildContext context) {
final tx = transaction;
final color = signedAmountColor(tx.amount);
// Tipe baru yang belum dikenal app: description saja, tanpa label.
final isKnownType = tx.type != WalletTransactionType.unknown;
final title = isKnownType ? tx.type.label : tx.description;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: color.withOpacity(0.1),
shape: BoxShape.circle,
),
child: Icon(
tx.isIncoming ? Icons.south_west : Icons.north_east,
color: color,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: AppStyle.md.copyWith(fontWeight: FontWeight.w700),
),
if (isKnownType && tx.description.isNotEmpty) ...[
const SizedBox(height: 2),
Text(
tx.description,
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
],
if (tx.createdAt != null) ...[
const SizedBox(height: 2),
Text(
formatWibDateTime(tx.createdAt!),
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
),
],
if (tx.isIncoming && tx.expiresAt != null) ...[
const SizedBox(height: 4),
Text(
'Berlaku sampai ${formatWibDate(tx.expiresAt!)}',
style: AppStyle.xs.copyWith(
color: AppColor.warning,
fontWeight: FontWeight.w600,
),
),
],
],
),
),
const SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
formatSignedAmount(tx.amount),
style: AppStyle.md.copyWith(
color: color,
fontWeight: FontWeight.w700,
),
),
if (showCurrency) ...[
const SizedBox(width: 4),
WalletCurrencyIcon(currency: tx.currency, size: 16),
],
],
),
if (showCurrency) ...[
const SizedBox(height: 2),
Text(
tx.currency.label,
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
),
],
],
),
],
),
);
}
}