mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Try to show seeds if wallet files gets corrupted (#1567)
* add litecoin nodes minor ui fix * Try to open the wallet or fetch the seeds and show them to the user * make sure the seeds are only displayed after authentication
This commit is contained in:
parent
9da9bee384
commit
5e944a8bf7
9 changed files with 175 additions and 13 deletions
|
@ -4,11 +4,13 @@ import 'package:cake_wallet/entities/preferences_key.dart';
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mailer/flutter_mailer.dart';
|
||||
import 'package:cake_wallet/utils/package_info.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -254,4 +256,53 @@ class ExceptionHandler {
|
|||
'productName': data.productName,
|
||||
};
|
||||
}
|
||||
|
||||
static void showError(String error, {int? delayInSeconds}) async {
|
||||
if (_hasError) {
|
||||
return;
|
||||
}
|
||||
_hasError = true;
|
||||
|
||||
if (delayInSeconds != null) {
|
||||
Future.delayed(Duration(seconds: delayInSeconds), () => _showCopyPopup(error));
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) async => _showCopyPopup(error),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> _showCopyPopup(String content) async {
|
||||
if (navigatorKey.currentContext != null) {
|
||||
final shouldCopy = await showPopUp<bool?>(
|
||||
context: navigatorKey.currentContext!,
|
||||
builder: (context) {
|
||||
return AlertWithTwoActions(
|
||||
isDividerExist: true,
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: content,
|
||||
rightButtonText: S.of(context).copy,
|
||||
leftButtonText: S.of(context).close,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
actionLeftButton: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (shouldCopy == true) {
|
||||
await Clipboard.setData(ClipboardData(text: content));
|
||||
await showBar<void>(
|
||||
navigatorKey.currentContext!,
|
||||
S.of(navigatorKey.currentContext!).copied_to_clipboard,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_hasError = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue