Skip to content

Commit

Permalink
Adjust the transaction details
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Sep 25, 2024
1 parent 035c28a commit 472195b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/lib/models/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Transaction {
required this.to,
required this.asset,
required this.amount,
// required this.memo, // check how to get it
// required this.memo, //TODO: check how to get it (transaction link)
required this.type,
required this.status,
required this.date,
Expand Down
1 change: 1 addition & 0 deletions app/lib/screens/wallets/transaction_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TransactionDetailsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Transaction Details')),
body: Column(
children: [
Expanded(
Expand Down
30 changes: 16 additions & 14 deletions app/lib/screens/wallets/transactions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:threebotlogin/services/stellar_service.dart';
import 'package:threebotlogin/widgets/wallets/transaction.dart';
import 'package:threebotlogin/widgets/wallets/vertical_divider.dart';
import 'package:stellar_flutter_sdk/src/responses/operations/payment_operation_response.dart';
import 'package:stellar_flutter_sdk/src/responses/operations/path_payment_strict_receive_operation_response.dart';
// import 'package:stellar_flutter_sdk/src/responses/operations/path_payment_strict_receive_operation_response.dart';

class WalletTransactionsWidget extends StatefulWidget {
const WalletTransactionsWidget({super.key, required this.wallet});
Expand All @@ -30,21 +30,23 @@ class _WalletTransactionsWidgetState extends State<WalletTransactionsWidget> {
hash: tx.transactionHash!,
from: tx.from!.accountId,
to: tx.to!.accountId,
asset: tx.asset.toString(),
asset: tx.assetCode.toString(),
amount: tx.amount!,
type: TransactionType.Payment,
type: tx.to!.accountId == widget.wallet.stellarAddress
? TransactionType.Receive
: TransactionType.Payment,
status: tx.transactionSuccessful!,
date: tx.createdAt!);
} else if (tx is PathPaymentStrictReceiveOperationResponse) {
return Transaction(
hash: tx.transactionHash!,
from: tx.from!,
to: tx.to!,
asset: tx.asset.toString(),
type: TransactionType.Payment,
status: tx.transactionSuccessful!,
amount: tx.amount!,
date: tx.createdAt!);
date: DateTime.parse(tx.createdAt!).toLocal().toString());
// } else if (tx is PathPaymentStrictReceiveOperationResponse) {
// return Transaction(
// hash: tx.transactionHash!,
// from: tx.from!,
// to: tx.to!,
// asset: tx.assetCode.toString(),
// type: TransactionType.Receive,
// status: tx.transactionSuccessful!,
// amount: tx.amount!,
// date: tx.createdAt!);
}
// TODO: handle creation transaction
}).toList();
Expand Down
6 changes: 1 addition & 5 deletions app/lib/widgets/wallets/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class TransactionWidget extends StatelessWidget {
: Theme.of(context).colorScheme.error,
)),
),
Text(
DateTime.parse(transaction.date).toLocal().toString(),
Text(transaction.date,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
Expand All @@ -84,9 +83,6 @@ class TransactionWidget extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
// color: status == 'Successful'
// ? Theme.of(context).colorScheme.primary
// : Theme.of(context).colorScheme.error,
border: Border.all(
color: transaction.status
? Theme.of(context).colorScheme.primary
Expand Down
57 changes: 34 additions & 23 deletions app/lib/widgets/wallets/transaction_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,39 @@ class TransactionDetails extends StatelessWidget {
children: [
Text(label,
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground)),
const SizedBox(height: 4.0),
Text(value,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground)),
color: Theme.of(context).colorScheme.onBackground,
fontWeight: FontWeight.bold)),
const SizedBox(height: 10),
label == 'Type'
? Container(
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6),
decoration: BoxDecoration(
border: Border.all(
color: value == 'Receive'
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.error,
),
borderRadius: BorderRadius.circular(20),
),
child: Text(value,
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
color: value == 'Receive'
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.error,
)),
)
: Text(value,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.colorScheme
.onBackground)),
],
),
),
Expand All @@ -41,29 +69,12 @@ class TransactionDetails extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.arrow_back)),
const Text(
'Transaction Details',
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16.0),
buildDetailRow('From', transaction.from),
const Divider(),
buildDetailRow('To', transaction.to),
const Divider(),
buildDetailRow('Type', transaction.type.toString()),
buildDetailRow('Type', transaction.type.name),
const Divider(),
buildDetailRow('Amount', transaction.amount),
const Divider(),
Expand Down
1 change: 1 addition & 0 deletions app/lib/widgets/wallets/wallet_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class WalletCardWidget extends StatelessWidget {
),
),
const SizedBox(height: 10),
// TODO: hide the balance if there is no account for this wallet
Row(
children: [
Text(
Expand Down

0 comments on commit 472195b

Please sign in to comment.