2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2023-04-27 22:56:17 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-01-12 04:26:38 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
2023-04-27 22:56:17 +00:00
|
|
|
import 'package:stackwallet/models/isar/sw_theme.dart';
|
2023-04-27 13:22:08 +00:00
|
|
|
import 'package:stackwallet/themes/theme_providers.dart';
|
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
|
|
|
|
2023-04-27 13:22:08 +00:00
|
|
|
class TxIcon extends ConsumerWidget {
|
2023-01-12 04:26:38 +00:00
|
|
|
const TxIcon({
|
2023-01-10 23:53:09 +00:00
|
|
|
Key? key,
|
|
|
|
required this.transaction,
|
|
|
|
required this.currentHeight,
|
|
|
|
required this.coin,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
2023-01-12 04:26:38 +00:00
|
|
|
final Transaction transaction;
|
2023-01-10 23:53:09 +00:00
|
|
|
final int currentHeight;
|
|
|
|
final Coin coin;
|
|
|
|
|
|
|
|
static const Size size = Size(32, 32);
|
|
|
|
|
2023-04-27 22:56:17 +00:00
|
|
|
// String _getBundleAssetName(
|
|
|
|
// bool isCancelled, bool isReceived, bool isPending, BuildContext context) {
|
|
|
|
// if (!isReceived && transaction.subType == TransactionSubType.mint) {
|
|
|
|
// if (isCancelled) {
|
|
|
|
// return Assets.svg.anonymizeFailed;
|
|
|
|
// }
|
|
|
|
// if (isPending) {
|
|
|
|
// return Assets.svg.anonymizePending;
|
|
|
|
// }
|
|
|
|
// return Assets.svg.anonymize;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
2023-01-10 23:53:09 +00:00
|
|
|
String _getAssetName(
|
2023-04-27 22:56:17 +00:00
|
|
|
bool isCancelled, bool isReceived, bool isPending, ThemeAssets assets) {
|
2023-01-12 04:26:38 +00:00
|
|
|
if (!isReceived && transaction.subType == TransactionSubType.mint) {
|
2023-01-10 23:53:09 +00:00
|
|
|
if (isCancelled) {
|
|
|
|
return Assets.svg.anonymizeFailed;
|
|
|
|
}
|
|
|
|
if (isPending) {
|
|
|
|
return Assets.svg.anonymizePending;
|
|
|
|
}
|
|
|
|
return Assets.svg.anonymize;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isReceived) {
|
|
|
|
if (isCancelled) {
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.receive;
|
2023-01-10 23:53:09 +00:00
|
|
|
}
|
|
|
|
if (isPending) {
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.receivePending;
|
2023-01-10 23:53:09 +00:00
|
|
|
}
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.receive;
|
2023-01-10 23:53:09 +00:00
|
|
|
} else {
|
|
|
|
if (isCancelled) {
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.sendCancelled;
|
2023-01-10 23:53:09 +00:00
|
|
|
}
|
|
|
|
if (isPending) {
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.sendPending;
|
2023-01-10 23:53:09 +00:00
|
|
|
}
|
2023-04-27 22:56:17 +00:00
|
|
|
return assets.send;
|
2023-01-10 23:53:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2023-04-27 13:22:08 +00:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-01-12 04:26:38 +00:00
|
|
|
final txIsReceived = transaction.type == TransactionType.incoming;
|
2023-01-10 23:53:09 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
),
|
2023-05-08 18:03:38 +00:00
|
|
|
ref.watch(themeProvider).assets,
|
2023-01-10 23:53:09 +00:00
|
|
|
),
|
|
|
|
width: size.width,
|
|
|
|
height: size.height,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|