2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-01-10 23:53:09 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
|
|
|
|
import 'package:stackwallet/models/paymint/transactions_model.dart' as old;
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
2023-01-10 23:53:09 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class TxIcon extends StatelessWidget {
|
|
|
|
const TxIcon({Key? key, required this.transaction}) : super(key: key);
|
2023-01-10 23:53:09 +00:00
|
|
|
final old.Transaction transaction;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
static const Size size = Size(32, 32);
|
|
|
|
|
2022-09-23 14:33:44 +00:00
|
|
|
String _getAssetName(
|
|
|
|
bool isCancelled, bool isReceived, bool isPending, BuildContext context) {
|
2022-09-07 15:56:10 +00:00
|
|
|
if (!isReceived && transaction.subType == "mint") {
|
2022-09-06 21:51:22 +00:00
|
|
|
if (isCancelled) {
|
|
|
|
return Assets.svg.anonymizeFailed;
|
|
|
|
}
|
|
|
|
if (isPending) {
|
|
|
|
return Assets.svg.anonymizePending;
|
|
|
|
}
|
|
|
|
return Assets.svg.anonymize;
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
if (isReceived) {
|
|
|
|
if (isCancelled) {
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.receiveCancelled(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
if (isPending) {
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.receivePending(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.receive(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
} else {
|
|
|
|
if (isCancelled) {
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.sendCancelled(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
if (isPending) {
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.sendPending(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.send(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final txIsReceived = transaction.txType == "Received";
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
width: size.width,
|
|
|
|
height: size.height,
|
|
|
|
child: Center(
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
_getAssetName(
|
|
|
|
transaction.isCancelled,
|
|
|
|
txIsReceived,
|
|
|
|
!transaction.confirmedStatus,
|
2022-09-23 14:33:44 +00:00
|
|
|
context,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
width: size.width,
|
|
|
|
height: size.height,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-01-10 23:53:09 +00:00
|
|
|
|
|
|
|
class TxIcon2 extends StatelessWidget {
|
|
|
|
const TxIcon2({
|
|
|
|
Key? key,
|
|
|
|
required this.transaction,
|
|
|
|
required this.currentHeight,
|
|
|
|
required this.coin,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final isar_models.Transaction transaction;
|
|
|
|
final int currentHeight;
|
|
|
|
final Coin coin;
|
|
|
|
|
|
|
|
static const Size size = Size(32, 32);
|
|
|
|
|
|
|
|
String _getAssetName(
|
|
|
|
bool isCancelled, bool isReceived, bool isPending, BuildContext context) {
|
|
|
|
if (!isReceived &&
|
|
|
|
transaction.subType == isar_models.TransactionSubType.mint) {
|
|
|
|
if (isCancelled) {
|
|
|
|
return Assets.svg.anonymizeFailed;
|
|
|
|
}
|
|
|
|
if (isPending) {
|
|
|
|
return Assets.svg.anonymizePending;
|
|
|
|
}
|
|
|
|
return Assets.svg.anonymize;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isReceived) {
|
|
|
|
if (isCancelled) {
|
|
|
|
return Assets.svg.receiveCancelled(context);
|
|
|
|
}
|
|
|
|
if (isPending) {
|
|
|
|
return Assets.svg.receivePending(context);
|
|
|
|
}
|
|
|
|
return Assets.svg.receive(context);
|
|
|
|
} else {
|
|
|
|
if (isCancelled) {
|
|
|
|
return Assets.svg.sendCancelled(context);
|
|
|
|
}
|
|
|
|
if (isPending) {
|
|
|
|
return Assets.svg.sendPending(context);
|
|
|
|
}
|
|
|
|
return Assets.svg.send(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final txIsReceived =
|
|
|
|
transaction.type == isar_models.TransactionType.incoming;
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
width: size.width,
|
|
|
|
height: size.height,
|
|
|
|
child: Center(
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
_getAssetName(
|
2023-01-11 20:47:27 +00:00
|
|
|
transaction.isCancelled,
|
2023-01-10 23:53:09 +00:00
|
|
|
txIsReceived,
|
|
|
|
!transaction.isConfirmed(
|
|
|
|
currentHeight,
|
|
|
|
coin.requiredConfirmations,
|
|
|
|
),
|
|
|
|
context,
|
|
|
|
),
|
|
|
|
width: size.width,
|
|
|
|
height: size.height,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|