Merge pull request #47 from cypherstack/ui-testing

UI testing
This commit is contained in:
Rylee Davis 2022-09-07 20:50:41 -06:00 committed by GitHub
commit 2b6aa83535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 135 additions and 34 deletions

View file

@ -69,7 +69,13 @@ class _TransactionDetailsViewState
coin = widget.coin;
amount = Format.satoshisToAmount(_transaction.amount);
fee = Format.satoshisToAmount(_transaction.fees);
amountPrefix = _transaction.txType.toLowerCase() == "sent" ? "- " : "+ ";
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
_transaction.subType == "mint") {
amountPrefix = "";
} else {
amountPrefix = _transaction.txType.toLowerCase() == "sent" ? "- " : "+ ";
}
// if (coin == Coin.firo || coin == Coin.firoTestNet) {
// showFeePending = true;
@ -85,6 +91,16 @@ class _TransactionDetailsViewState
}
String whatIsIt(String type) {
if (coin == Coin.firo || coin == Coin.firoTestNet) {
if (_transaction.subType == "mint") {
if (_transaction.confirmedStatus) {
return "Minted";
} else {
return "Minting";
}
}
}
if (type == "Received") {
// if (_transaction.isMinting) {
// return "Minting";
@ -127,6 +143,66 @@ class _TransactionDetailsViewState
String _note = "";
Future<bool> showExplorerWarning(String explorer) async {
final bool? shouldContinue = await showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (_) => StackDialog(
title: "Attention",
message:
"You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.",
icon: Row(
children: [
Consumer(builder: (_, ref, __) {
return Checkbox(
value: ref.watch(prefsChangeNotifierProvider
.select((value) => value.hideBlockExplorerWarning)),
onChanged: (value) {
if (value is bool) {
ref
.read(prefsChangeNotifierProvider)
.hideBlockExplorerWarning = value;
setState(() {});
}
},
);
}),
Text(
"Never show again",
style: STextStyles.smallMed14,
)
],
),
leftButton: TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: Text(
"Cancel",
style: STextStyles.button.copyWith(
color: CFColors.stackAccent,
),
),
),
rightButton: TextButton(
style: Theme.of(context).textButtonTheme.style?.copyWith(
backgroundColor: MaterialStateProperty.all<Color>(
CFColors.stackAccent,
),
),
onPressed: () {
Navigator.of(context).pop(false);
},
child: Text(
"Continue",
style: STextStyles.button,
),
),
),
);
return shouldContinue ?? false;
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -224,12 +300,16 @@ class _TransactionDetailsViewState
),
),
if (!(coin == Coin.monero &&
_transaction.txType.toLowerCase() == "sent"))
_transaction.txType.toLowerCase() == "sent") &&
!((coin == Coin.firo || coin == Coin.firoTestNet) &&
_transaction.subType == "mint"))
const SizedBox(
height: 12,
),
if (!(coin == Coin.monero &&
_transaction.txType.toLowerCase() == "sent"))
_transaction.txType.toLowerCase() == "sent") &&
!((coin == Coin.firo || coin == Coin.firoTestNet) &&
_transaction.subType == "mint"))
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -472,6 +552,19 @@ class _TransactionDetailsViewState
coin: coin,
txid: _transaction.txid,
);
if (ref
.read(prefsChangeNotifierProvider)
.hideBlockExplorerWarning ==
false) {
final shouldContinue =
await showExplorerWarning(uri.host);
if (!shouldContinue) {
return;
}
}
// ref
// .read(
// shouldShowLockscreenOnResumeStateProvider

View file

@ -2769,34 +2769,12 @@ class FiroWallet extends CoinServiceAPI {
}
}
if (value.txType == "Received" &&
!listLelantusTxData.containsKey(value.txid)) {
// Every receive should be listed whether minted or not.
if (value.txType == "Received" && value.subType != "mint") {
// Every receive other than a mint should be shown. Mints will be collected and shown from the send side
listLelantusTxData[value.txid] = value;
} else if (value.txType == "Sent"
// &&
// hasAtLeastOneReceive &&
// value.subType == "mint"
) {
} else if (value.txType == "Sent") {
// all sends should be shown, mints will be displayed correctly in the ui
listLelantusTxData[value.txid] = value;
// use mint sends to update receives with user readable values.
// int sharedFee = value.fees ~/ howManyReceiveInputs;
//
// for (var element in value.inputs) {
// if (listLelantusTxData.containsKey(element.txid) &&
// listLelantusTxData[element.txid]!.txType == "Received") {
// listLelantusTxData[element.txid] =
// listLelantusTxData[element.txid]!.copyWith(
// fees: sharedFee,
// subType: "mint",
// height: value.height,
// confirmedStatus: value.confirmedStatus,
// otherData: value.txid,
// );
// }
// }
}
});
@ -3305,11 +3283,12 @@ class FiroWallet extends CoinServiceAPI {
}
}
final int confirms = txObject["confirmations"] as int? ?? 0;
// create final tx map
midSortedTx["txid"] = txObject["txid"];
midSortedTx["confirmed_status"] = (txObject["confirmations"] is int) &&
(txObject["confirmations"] as int > 0);
midSortedTx["confirmations"] = txObject["confirmations"] ?? 0;
midSortedTx["confirmed_status"] = confirms >= MINIMUM_CONFIRMATIONS;
midSortedTx["confirmations"] = confirms;
midSortedTx["timestamp"] = txObject["blocktime"] ??
(DateTime.now().millisecondsSinceEpoch ~/ 1000);
if (foundInSenders) {

View file

@ -8,8 +8,8 @@ class _CoinThemeColor {
Color get bitcoin => const Color(0xFFFCC17B);
Color get firo => const Color(0xFFFF897A);
Color get dogecoin => const Color(0xFFFFE079);
Color get epicCash => const Color(0xFFC1C1FF);
Color get monero => const Color(0xFFB1C5FF);
Color get epicCash => const Color(0xFFC5C7CB);
Color get monero => const Color(0xFFF06923);
Color forCoin(Coin coin) {
switch (coin) {

View file

@ -33,6 +33,7 @@ class Prefs extends ChangeNotifier {
_autoBackupLocation = await _getAutoBackupLocation();
_backupFrequencyType = await _getBackupFrequencyType();
_lastAutoBackup = await _getLastAutoBackup();
_hideBlockExplorerWarning = await _getHideBlockExplorerWarning();
_initialized = true;
}
@ -466,4 +467,32 @@ class Prefs extends ChangeNotifier {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "autoBackupFileUri") as DateTime?;
}
// auto backup
bool _hideBlockExplorerWarning = false;
bool get hideBlockExplorerWarning => _hideBlockExplorerWarning;
set hideBlockExplorerWarning(bool hideBlockExplorerWarning) {
if (_hideBlockExplorerWarning != hideBlockExplorerWarning) {
DB.instance
.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "hideBlockExplorerWarning",
value: hideBlockExplorerWarning)
.then((_) {
_hideBlockExplorerWarning = hideBlockExplorerWarning;
notifyListeners();
});
}
}
Future<bool> _getHideBlockExplorerWarning() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "hideBlockExplorerWarning") as bool? ??
false;
}
}