mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
added block explorer warning
This commit is contained in:
parent
0cfa7240ea
commit
3c31008af8
2 changed files with 102 additions and 0 deletions
|
@ -143,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(
|
||||
|
@ -492,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue