Loading progress bar
This commit is contained in:
parent
1dbe275564
commit
4887184bde
|
@ -87,6 +87,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Amount must be positive"),
|
||||
"amountTooHigh":
|
||||
MessageLookupByLibrary.simpleMessage("Amount too high"),
|
||||
"applicationReset":
|
||||
MessageLookupByLibrary.simpleMessage("Application Reset"),
|
||||
"approve": MessageLookupByLibrary.simpleMessage("APPROVE"),
|
||||
"areYouSureYouWantToDeleteThisContact":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
|
@ -111,6 +113,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"color": MessageLookupByLibrary.simpleMessage("Color"),
|
||||
"confirmDeleteAccount": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you SURE you want to DELETE this account? You MUST have a BACKUP to recover it. This operation is NOT reversible."),
|
||||
"confirmResetApp": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure you want to reset the app? Your accounts will NOT be deleted"),
|
||||
"confirmSignATransactionToAddressFor": m2,
|
||||
"confirmSigning":
|
||||
MessageLookupByLibrary.simpleMessage("Confirm Signing"),
|
||||
|
@ -160,6 +164,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"largestSpendingsByAddress": MessageLookupByLibrary.simpleMessage(
|
||||
"Largest Spendings by Address"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Light"),
|
||||
"loading": MessageLookupByLibrary.simpleMessage("Loading..."),
|
||||
"max": MessageLookupByLibrary.simpleMessage("MAX"),
|
||||
"maxAmountPerNote":
|
||||
MessageLookupByLibrary.simpleMessage("Max Amount per Note"),
|
||||
|
@ -201,6 +206,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage(
|
||||
"Please authenticate to show account seed"),
|
||||
"pleaseConfirm": MessageLookupByLibrary.simpleMessage("Please Confirm"),
|
||||
"pleaseQuitAndRestartTheAppNow": MessageLookupByLibrary.simpleMessage(
|
||||
"Please Quit and Restart the app now"),
|
||||
"pnl": MessageLookupByLibrary.simpleMessage("Pnl"),
|
||||
"pnlHistory": MessageLookupByLibrary.simpleMessage("PNL History"),
|
||||
"preparingTransaction":
|
||||
|
@ -222,6 +229,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Rescan Requested..."),
|
||||
"rescanWalletFromTheFirstBlock": MessageLookupByLibrary.simpleMessage(
|
||||
"Rescan wallet from the first block?"),
|
||||
"reset": MessageLookupByLibrary.simpleMessage("RESET"),
|
||||
"restart": MessageLookupByLibrary.simpleMessage("Restart"),
|
||||
"retrieveTransactionDetails": MessageLookupByLibrary.simpleMessage(
|
||||
"Retrieve Transaction Details"),
|
||||
"roundToMillis":
|
||||
|
|
|
@ -85,6 +85,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"Cantidad debe ser un positivo"),
|
||||
"amountTooHigh":
|
||||
MessageLookupByLibrary.simpleMessage("Cantidad demasiado alta"),
|
||||
"applicationReset":
|
||||
MessageLookupByLibrary.simpleMessage("Application Reset"),
|
||||
"approve": MessageLookupByLibrary.simpleMessage("APROBAR"),
|
||||
"areYouSureYouWantToDeleteThisContact":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
|
@ -109,6 +111,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"color": MessageLookupByLibrary.simpleMessage("Color"),
|
||||
"confirmDeleteAccount": MessageLookupByLibrary.simpleMessage(
|
||||
"¿Está SEGURO de que desea BORRAR esta cuenta? DEBE tener una COPIA DE SEGURIDAD para recuperarla. Esta operación NO es reversible."),
|
||||
"confirmResetApp": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure you want to reset the app? Your accounts will NOT be deleted"),
|
||||
"confirmSignATransactionToAddressFor": m2,
|
||||
"confirmSigning":
|
||||
MessageLookupByLibrary.simpleMessage("Confirm Signing"),
|
||||
|
@ -159,6 +163,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"largestSpendingsByAddress": MessageLookupByLibrary.simpleMessage(
|
||||
"Pagos más grandes por dirección"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Día"),
|
||||
"loading": MessageLookupByLibrary.simpleMessage("Loading..."),
|
||||
"max": MessageLookupByLibrary.simpleMessage("MAX"),
|
||||
"maxAmountPerNote":
|
||||
MessageLookupByLibrary.simpleMessage("Monto máximo por nota"),
|
||||
|
@ -222,6 +227,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Escaneo solicitado…"),
|
||||
"rescanWalletFromTheFirstBlock": MessageLookupByLibrary.simpleMessage(
|
||||
"¿Escanear billetera desde el primer bloque?"),
|
||||
"reset": MessageLookupByLibrary.simpleMessage("RESET"),
|
||||
"restart": MessageLookupByLibrary.simpleMessage("Restart"),
|
||||
"retrieveTransactionDetails": MessageLookupByLibrary.simpleMessage(
|
||||
"Obtener detalles de la transacción"),
|
||||
"roundToMillis":
|
||||
|
|
|
@ -87,6 +87,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"Le montant doit être positif"),
|
||||
"amountTooHigh":
|
||||
MessageLookupByLibrary.simpleMessage("Montant trop haut"),
|
||||
"applicationReset":
|
||||
MessageLookupByLibrary.simpleMessage("Application Reset"),
|
||||
"approve": MessageLookupByLibrary.simpleMessage("APPROUVER"),
|
||||
"areYouSureYouWantToDeleteThisContact":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
|
@ -111,6 +113,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"color": MessageLookupByLibrary.simpleMessage("Couleur"),
|
||||
"confirmDeleteAccount": MessageLookupByLibrary.simpleMessage(
|
||||
"Êtes-vous SUR de vouloir SUPPRIMER ce compte ? Vous DEVEZ avoir une SAUVEGARDE pour le récupérer. Cette opération n\'est PAS réversible."),
|
||||
"confirmResetApp": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure you want to reset the app? Your accounts will NOT be deleted"),
|
||||
"confirmSignATransactionToAddressFor": m2,
|
||||
"confirmSigning":
|
||||
MessageLookupByLibrary.simpleMessage("Confirm Signing"),
|
||||
|
@ -160,6 +164,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"largestSpendingsByAddress": MessageLookupByLibrary.simpleMessage(
|
||||
"Dépenses les plus importantes par adresse"),
|
||||
"light": MessageLookupByLibrary.simpleMessage("Clair"),
|
||||
"loading": MessageLookupByLibrary.simpleMessage("Loading..."),
|
||||
"max": MessageLookupByLibrary.simpleMessage("MAX"),
|
||||
"maxAmountPerNote":
|
||||
MessageLookupByLibrary.simpleMessage("Montant maximum par note"),
|
||||
|
@ -223,6 +228,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Parcours demandé..."),
|
||||
"rescanWalletFromTheFirstBlock": MessageLookupByLibrary.simpleMessage(
|
||||
"Reparcourir la chaine à partir du premier bloc?"),
|
||||
"reset": MessageLookupByLibrary.simpleMessage("RESET"),
|
||||
"restart": MessageLookupByLibrary.simpleMessage("Restart"),
|
||||
"retrieveTransactionDetails": MessageLookupByLibrary.simpleMessage(
|
||||
"Récupérer les détails de la transaction"),
|
||||
"roundToMillis":
|
||||
|
|
|
@ -1801,6 +1801,66 @@ class S {
|
|||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Application Reset`
|
||||
String get applicationReset {
|
||||
return Intl.message(
|
||||
'Application Reset',
|
||||
name: 'applicationReset',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Are you sure you want to reset the app? Your accounts will NOT be deleted`
|
||||
String get confirmResetApp {
|
||||
return Intl.message(
|
||||
'Are you sure you want to reset the app? Your accounts will NOT be deleted',
|
||||
name: 'confirmResetApp',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `RESET`
|
||||
String get reset {
|
||||
return Intl.message(
|
||||
'RESET',
|
||||
name: 'reset',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Loading...`
|
||||
String get loading {
|
||||
return Intl.message(
|
||||
'Loading...',
|
||||
name: 'loading',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Restart`
|
||||
String get restart {
|
||||
return Intl.message(
|
||||
'Restart',
|
||||
name: 'restart',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Please Quit and Restart the app now`
|
||||
String get pleaseQuitAndRestartTheAppNow {
|
||||
return Intl.message(
|
||||
'Please Quit and Restart the app now',
|
||||
name: 'pleaseQuitAndRestartTheAppNow',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
||||
|
|
|
@ -173,5 +173,11 @@
|
|||
"copy": "Copy",
|
||||
"textCopiedToClipboard": "{text} copied to clipboard",
|
||||
"multipleAddresses": "multiple addresses",
|
||||
"addnew": "NEW/RESTORE"
|
||||
"addnew": "NEW/RESTORE",
|
||||
"applicationReset": "Application Reset",
|
||||
"confirmResetApp": "Are you sure you want to reset the app? Your accounts will NOT be deleted",
|
||||
"reset": "RESET",
|
||||
"loading": "Loading...",
|
||||
"restart": "Restart",
|
||||
"pleaseQuitAndRestartTheAppNow": "Please Quit and Restart the app now"
|
||||
}
|
||||
|
|
|
@ -172,5 +172,10 @@
|
|||
"copy": "Copy",
|
||||
"textCopiedToClipboard": "{text} copied to clipboard",
|
||||
"multipleAddresses": "multiple addresses",
|
||||
"addnew": "AGGREGAR"
|
||||
"addnew": "AGGREGAR",
|
||||
"applicationReset": "Application Reset",
|
||||
"confirmResetApp": "Are you sure you want to reset the app? Your accounts will NOT be deleted",
|
||||
"reset": "RESET",
|
||||
"loading": "Loading...",
|
||||
"restart": "Restart"
|
||||
}
|
||||
|
|
|
@ -172,5 +172,10 @@
|
|||
"copy": "Copy",
|
||||
"textCopiedToClipboard": "{text} copied to clipboard",
|
||||
"multipleAddresses": "multiple addresses",
|
||||
"addnew": "AJOUTER"
|
||||
"addnew": "AJOUTER",
|
||||
"applicationReset": "Application Reset",
|
||||
"confirmResetApp": "Are you sure you want to reset the app? Your accounts will NOT be deleted",
|
||||
"reset": "RESET",
|
||||
"loading": "Loading...",
|
||||
"restart": "Restart"
|
||||
}
|
||||
|
|
309
lib/main.dart
309
lib/main.dart
|
@ -17,6 +17,7 @@ import 'package:path_provider/path_provider.dart';
|
|||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:rate_my_app/rate_my_app.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:warp_api/warp_api.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
@ -70,9 +71,9 @@ Future<void> initUniLinks(BuildContext context) async {
|
|||
try {
|
||||
final initialLink = await getInitialLink();
|
||||
if (initialLink != null)
|
||||
Navigator.of(context).pushNamed('/send', arguments: SendPageArgs(uri: initialLink));
|
||||
} on PlatformException {
|
||||
}
|
||||
Navigator.of(context).pushNamed(
|
||||
'/send', arguments: SendPageArgs(uri: initialLink));
|
||||
} on PlatformException {}
|
||||
|
||||
subUniLinks = linkStream.listen((String? uri) {
|
||||
Navigator.of(context).pushNamed('/send', arguments: SendPageArgs(uri: uri));
|
||||
|
@ -90,6 +91,51 @@ void handleQuickAction(BuildContext context, String shortcut) {
|
|||
}
|
||||
}
|
||||
|
||||
class LoadProgress extends StatelessWidget {
|
||||
double value;
|
||||
|
||||
LoadProgress(this.value);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(height: 200, width: 200, child:
|
||||
Column(
|
||||
children: [
|
||||
Text(S.of(context).loading, style: Theme.of(context).textTheme.headline4),
|
||||
Padding(padding: EdgeInsets.all(16)),
|
||||
LinearProgressIndicator(value: value),
|
||||
Padding(padding: EdgeInsets.all(16)),
|
||||
ElevatedButton(
|
||||
onPressed: () => _reset(context), child: Text('EMERGENCY RESET'))
|
||||
]
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_reset(BuildContext context) async {
|
||||
final s = S.of(context);
|
||||
final confirmation = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
title: Text(S.of(context).applicationReset),
|
||||
content: Text(S.of(context).confirmResetApp),
|
||||
actions: confirmButtons(context, () {
|
||||
Navigator.of(context).pop(true);
|
||||
}, okLabel: S.of(context).reset, cancelValue: false)),
|
||||
) ?? false;
|
||||
if (confirmation) {
|
||||
WarpApi.resetApp();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.clear();
|
||||
await showMessageBox(context, s.restart, s.pleaseQuitAndRestartTheAppNow, s.ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final home = ZWalletApp();
|
||||
|
@ -99,45 +145,50 @@ void main() {
|
|||
builder: (context, snapshot) {
|
||||
return snapshot.connectionState == ConnectionState.waiting
|
||||
? MaterialApp(home: Container()) :
|
||||
Observer(builder: (context) {
|
||||
final theme = settings.themeData.copyWith(
|
||||
dataTableTheme: DataTableThemeData(
|
||||
headingRowColor: MaterialStateColor.resolveWith(
|
||||
(_) => settings.themeData.highlightColor)));
|
||||
return MaterialApp(
|
||||
title: coin.app,
|
||||
theme: theme,
|
||||
home: home,
|
||||
scaffoldMessengerKey: rootScaffoldMessengerKey,
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
onGenerateRoute: (RouteSettings routeSettings) {
|
||||
var routes = <String, WidgetBuilder>{
|
||||
'/account': (context) => AccountPage(),
|
||||
'/restore': (context) => RestorePage(),
|
||||
'/send': (context) =>
|
||||
SendPage(routeSettings.arguments as SendPageArgs?),
|
||||
'/receive': (context) => PaymentURIPage(routeSettings.arguments as String?),
|
||||
'/accounts': (context) => AccountManagerPage(),
|
||||
'/settings': (context) => SettingsPage(),
|
||||
'/tx': (context) =>
|
||||
TransactionPage(routeSettings.arguments as Tx),
|
||||
'/backup': (context) => BackupPage(routeSettings.arguments as int?),
|
||||
'/multipay': (context) => MultiPayPage(),
|
||||
'/multisig': (context) => MultisigPage(),
|
||||
'/multisign': (context) => MultisigAggregatorPage(routeSettings.arguments as TxSummary),
|
||||
'/multisig_shares': (context) => MultisigSharesPage(routeSettings.arguments as String),
|
||||
'/edit_theme': (context) => ThemeEditorPage(onSaved: settings.updateCustomThemeColors),
|
||||
};
|
||||
return MaterialPageRoute(builder: routes[routeSettings.name]!);
|
||||
},
|
||||
);
|
||||
});
|
||||
Observer(builder: (context) {
|
||||
final theme = settings.themeData.copyWith(
|
||||
dataTableTheme: DataTableThemeData(
|
||||
headingRowColor: MaterialStateColor.resolveWith(
|
||||
(_) => settings.themeData.highlightColor)));
|
||||
return MaterialApp(
|
||||
title: coin.app,
|
||||
theme: theme,
|
||||
home: home,
|
||||
scaffoldMessengerKey: rootScaffoldMessengerKey,
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
onGenerateRoute: (RouteSettings routeSettings) {
|
||||
var routes = <String, WidgetBuilder>{
|
||||
'/account': (context) => AccountPage(),
|
||||
'/restore': (context) => RestorePage(),
|
||||
'/send': (context) =>
|
||||
SendPage(routeSettings.arguments as SendPageArgs?),
|
||||
'/receive': (context) =>
|
||||
PaymentURIPage(routeSettings.arguments as String?),
|
||||
'/accounts': (context) => AccountManagerPage(),
|
||||
'/settings': (context) => SettingsPage(),
|
||||
'/tx': (context) =>
|
||||
TransactionPage(routeSettings.arguments as Tx),
|
||||
'/backup': (context) =>
|
||||
BackupPage(routeSettings.arguments as int?),
|
||||
'/multipay': (context) => MultiPayPage(),
|
||||
'/multisig': (context) => MultisigPage(),
|
||||
'/multisign': (context) => MultisigAggregatorPage(
|
||||
routeSettings.arguments as TxSummary),
|
||||
'/multisig_shares': (context) =>
|
||||
MultisigSharesPage(routeSettings.arguments as String),
|
||||
'/edit_theme': (context) =>
|
||||
ThemeEditorPage(onSaved: settings.updateCustomThemeColors),
|
||||
};
|
||||
return MaterialPageRoute(builder: routes[routeSettings.name]!);
|
||||
},
|
||||
);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -201,7 +252,7 @@ class ZWalletAppState extends State<ZWalletApp> {
|
|||
return FutureBuilder(
|
||||
future: _init(context),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return Container();
|
||||
if (!snapshot.hasData) return LoadProgress(0.7);
|
||||
return accountManager.accounts.isNotEmpty
|
||||
? AccountPage()
|
||||
: AccountManagerPage();
|
||||
|
@ -210,31 +261,38 @@ class ZWalletAppState extends State<ZWalletApp> {
|
|||
}
|
||||
|
||||
final GlobalKey<ScaffoldMessengerState> rootScaffoldMessengerKey =
|
||||
GlobalKey<ScaffoldMessengerState>();
|
||||
GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
List<ElevatedButton> confirmButtons(
|
||||
BuildContext context, VoidCallback? onPressed,
|
||||
List<ElevatedButton> confirmButtons(BuildContext context,
|
||||
VoidCallback? onPressed,
|
||||
{String? okLabel, Icon? okIcon, cancelValue}) {
|
||||
final navigator = Navigator.of(context);
|
||||
return <ElevatedButton>[
|
||||
ElevatedButton.icon(
|
||||
icon: Icon(Icons.cancel),
|
||||
label: Text(S.of(context).cancel),
|
||||
label: Text(S
|
||||
.of(context)
|
||||
.cancel),
|
||||
onPressed: () {
|
||||
cancelValue != null ? navigator.pop(cancelValue) : navigator.pop();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Theme.of(context).buttonTheme.colorScheme!.secondary)),
|
||||
primary: Theme
|
||||
.of(context)
|
||||
.buttonTheme
|
||||
.colorScheme!
|
||||
.secondary)),
|
||||
ElevatedButton.icon(
|
||||
icon: okIcon ?? Icon(Icons.done),
|
||||
label: Text(okLabel ?? S.of(context).ok),
|
||||
label: Text(okLabel ?? S
|
||||
.of(context)
|
||||
.ok),
|
||||
onPressed: onPressed,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
List<TimeSeriesPoint<V>> sampleDaily<T, Y, V>(
|
||||
List<T> timeseries,
|
||||
List<TimeSeriesPoint<V>> sampleDaily<T, Y, V>(List<T> timeseries,
|
||||
int start,
|
||||
int end,
|
||||
int Function(T) getDay,
|
||||
|
@ -274,33 +332,45 @@ void showQR(BuildContext context, String text, String title) {
|
|||
showDialog(
|
||||
context: context,
|
||||
barrierColor: Colors.black,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Container(
|
||||
width: double.maxFinite,
|
||||
child: SingleChildScrollView(child: Column(children: [
|
||||
QrImage(data: text, backgroundColor: Colors.white),
|
||||
Padding(padding: EdgeInsets.all(8)),
|
||||
Text(title, style: Theme.of(context).textTheme.subtitle1),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
ElevatedButton.icon(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
final snackBar = SnackBar(content: Text(s.textCopiedToClipboard(title)));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(snackBar);
|
||||
}, icon: Icon(Icons.copy), label: Text(s.copy))
|
||||
])))
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
content: Container(
|
||||
width: double.maxFinite,
|
||||
child: SingleChildScrollView(child: Column(children: [
|
||||
QrImage(data: text, backgroundColor: Colors.white),
|
||||
Padding(padding: EdgeInsets.all(8)),
|
||||
Text(title, style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.subtitle1),
|
||||
Padding(padding: EdgeInsets.all(4)),
|
||||
ElevatedButton.icon(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
final snackBar = SnackBar(
|
||||
content: Text(s.textCopiedToClipboard(title)));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(
|
||||
snackBar);
|
||||
}, icon: Icon(Icons.copy), label: Text(s.copy))
|
||||
])))
|
||||
));
|
||||
}
|
||||
|
||||
Future<bool> rescanDialog(
|
||||
BuildContext context) async {
|
||||
Future<bool> rescanDialog(BuildContext context) async {
|
||||
final approved = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(S.of(context).rescan),
|
||||
content: Text(S.of(context).rescanWalletFromTheFirstBlock),
|
||||
actions: confirmButtons(context, () => Navigator.of(context).pop(true), cancelValue: false))) ?? false;
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
title: Text(S
|
||||
.of(context)
|
||||
.rescan),
|
||||
content: Text(S
|
||||
.of(context)
|
||||
.rescanWalletFromTheFirstBlock),
|
||||
actions: confirmButtons(
|
||||
context, () => Navigator.of(context).pop(true),
|
||||
cancelValue: false))) ?? false;
|
||||
if (approved)
|
||||
return await confirmWifi(context);
|
||||
return false;
|
||||
|
@ -312,31 +382,40 @@ Future<bool> confirmWifi(BuildContext context) async {
|
|||
return await showDialog<bool?>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(S.of(context).rescan),
|
||||
content: Text('On Mobile Data, scanning may incur additional charges. Do you want to proceed?'),
|
||||
actions: confirmButtons(context, () => Navigator.of(context).pop(true), cancelValue: false))) ?? false;
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
title: Text(S
|
||||
.of(context)
|
||||
.rescan),
|
||||
content: Text(
|
||||
'On Mobile Data, scanning may incur additional charges. Do you want to proceed?'),
|
||||
actions: confirmButtons(
|
||||
context, () => Navigator.of(context).pop(true),
|
||||
cancelValue: false))) ?? false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> showMessageBox(
|
||||
BuildContext context, String title, String content, String label) async {
|
||||
Future<bool> showMessageBox(BuildContext context, String title, String content,
|
||||
String label) async {
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: confirmButtons(context, () {
|
||||
Navigator.of(context).pop(true);
|
||||
}, okLabel: label, cancelValue: false)),
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: confirmButtons(context, () {
|
||||
Navigator.of(context).pop(true);
|
||||
}, okLabel: label, cancelValue: false)),
|
||||
);
|
||||
return confirm ?? false;
|
||||
}
|
||||
|
||||
double getScreenSize(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final size = MediaQuery
|
||||
.of(context)
|
||||
.size;
|
||||
return min(size.height, size.width);
|
||||
}
|
||||
|
||||
|
@ -354,7 +433,8 @@ TextStyle fontWeight(TextStyle style, num v) {
|
|||
return style2.copyWith(fontWeight: FontWeight.w800);
|
||||
else if (value >= coin.weights[1])
|
||||
return style2.copyWith(fontWeight: FontWeight.w600);
|
||||
else if (value >= coin.weights[0]) return style2.copyWith(fontWeight: FontWeight.w400);
|
||||
else if (value >= coin.weights[0])
|
||||
return style2.copyWith(fontWeight: FontWeight.w400);
|
||||
return style2.copyWith(fontWeight: FontWeight.w200);
|
||||
}
|
||||
|
||||
|
@ -375,20 +455,25 @@ bool checkNumber(String s) {
|
|||
try {
|
||||
NumberFormat.currency().parse(s);
|
||||
}
|
||||
on FormatException { return false; }
|
||||
on FormatException {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int precision(bool? mZEC) => (mZEC == null || mZEC) ? 3 : 8;
|
||||
|
||||
Future<String?> scanCode(BuildContext context) async {
|
||||
final code = await FlutterBarcodeScanner.scanBarcode('#FF0000', S.of(context).cancel, true, ScanMode.QR);
|
||||
final code = await FlutterBarcodeScanner.scanBarcode('#FF0000', S
|
||||
.of(context)
|
||||
.cancel, true, ScanMode.QR);
|
||||
if (code == "-1") return null;
|
||||
return code;
|
||||
}
|
||||
|
||||
String addressLeftTrim(String address) =>
|
||||
address != "" ? address.substring(0, 8) + "..." + address.substring(address.length - 16) : "";
|
||||
address != "" ? address.substring(0, 8) + "..." +
|
||||
address.substring(address.length - 16) : "";
|
||||
|
||||
void showSnackBar(String msg) {
|
||||
final snackBar = SnackBar(content: Text(msg));
|
||||
|
@ -396,11 +481,18 @@ void showSnackBar(String msg) {
|
|||
}
|
||||
|
||||
enum DeviceWidth {
|
||||
xs, sm, md, lg, xl
|
||||
xs,
|
||||
sm,
|
||||
md,
|
||||
lg,
|
||||
xl
|
||||
}
|
||||
|
||||
DeviceWidth getWidth(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
final width = MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width;
|
||||
if (width < 600) return DeviceWidth.xs;
|
||||
if (width < 960) return DeviceWidth.sm;
|
||||
if (width < 1280) return DeviceWidth.md;
|
||||
|
@ -409,7 +501,8 @@ DeviceWidth getWidth(BuildContext context) {
|
|||
}
|
||||
|
||||
String decimalFormat(double x, int decimalDigits, { String symbol = '' }) =>
|
||||
NumberFormat.currency(decimalDigits: decimalDigits, symbol: symbol).format(x).trimRight();
|
||||
NumberFormat.currency(decimalDigits: decimalDigits, symbol: symbol).format(
|
||||
x).trimRight();
|
||||
|
||||
String amountToString(int amount) => decimalFormat(amount / ZECUNIT, 8);
|
||||
|
||||
|
@ -439,20 +532,24 @@ Future<void> shieldTAddr(BuildContext context) async {
|
|||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(S.of(context).shieldTransparentBalance),
|
||||
content: Text(S
|
||||
.of(context)
|
||||
.doYouWantToTransferYourEntireTransparentBalanceTo(coin.ticker)),
|
||||
actions: confirmButtons(context, () async {
|
||||
final s = S.of(context);
|
||||
Navigator.of(context).pop();
|
||||
final snackBar1 = SnackBar(content: Text(s.shieldingInProgress));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(snackBar1);
|
||||
final txid = await WarpApi.shieldTAddr(accountManager.active.id);
|
||||
final snackBar2 = SnackBar(content: Text("${s.txId}: $txid"));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(snackBar2);
|
||||
})),
|
||||
builder: (context) =>
|
||||
AlertDialog(
|
||||
title: Text(S
|
||||
.of(context)
|
||||
.shieldTransparentBalance),
|
||||
content: Text(S
|
||||
.of(context)
|
||||
.doYouWantToTransferYourEntireTransparentBalanceTo(
|
||||
coin.ticker)),
|
||||
actions: confirmButtons(context, () async {
|
||||
final s = S.of(context);
|
||||
Navigator.of(context).pop();
|
||||
final snackBar1 = SnackBar(content: Text(s.shieldingInProgress));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(snackBar1);
|
||||
final txid = await WarpApi.shieldTAddr(accountManager.active.id);
|
||||
final snackBar2 = SnackBar(content: Text("${s.txId}: $txid"));
|
||||
rootScaffoldMessengerKey.currentState?.showSnackBar(snackBar2);
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ typedef void *DartPostCObjectFnType;
|
|||
|
||||
void init_wallet(char *db_path, char *ld_url);
|
||||
|
||||
void reset_app(void);
|
||||
|
||||
void warp_sync(bool get_tx, uint32_t anchor_offset, int64_t port);
|
||||
|
||||
void dart_post_cobject(DartPostCObjectFnType ptr);
|
||||
|
|
|
@ -72,6 +72,14 @@ pub fn init_wallet(db_path: &str, ld_url: &str) {
|
|||
MULTISIG_SIGN_LOCK.get_or_init(|| Mutex::new(MultisigClient::new()));
|
||||
}
|
||||
|
||||
pub fn reset_app() {
|
||||
let res = || {
|
||||
let wallet = get_lock(&WALLET)?;
|
||||
wallet.reset_db()
|
||||
};
|
||||
log_result(res())
|
||||
}
|
||||
|
||||
pub fn new_account(name: &str, data: &str) -> i32 {
|
||||
let res = || {
|
||||
let wallet = get_lock(&WALLET)?;
|
||||
|
|
|
@ -13,6 +13,11 @@ pub unsafe extern "C" fn init_wallet(db_path: *mut c_char, ld_url: *mut c_char)
|
|||
api::init_wallet(&db_path, &ld_url);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn reset_app() {
|
||||
api::reset_app();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn warp_sync(get_tx: bool, anchor_offset: u32, port: i64) {
|
||||
api::warp_sync(get_tx, anchor_offset, port);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d9d9baa7f69a0cb22d85c9145c30979cdeb2bdb
|
||||
Subproject commit d2c3e8e6c69ff033e50ed20af75a49a8f3c3c3da
|
|
@ -68,6 +68,10 @@ class WarpApi {
|
|||
dbPath.toNativeUtf8().cast<Int8>(), ldUrl.toNativeUtf8().cast<Int8>());
|
||||
}
|
||||
|
||||
static void resetApp() {
|
||||
warp_api_lib.reset_app();
|
||||
}
|
||||
|
||||
static int newAccount(String name, String key) {
|
||||
return warp_api_lib.new_account(
|
||||
name.toNativeUtf8().cast<Int8>(), key.toNativeUtf8().cast<Int8>());
|
||||
|
|
|
@ -33,6 +33,15 @@ class NativeLibrary {
|
|||
late final _dart_init_wallet _init_wallet =
|
||||
_init_wallet_ptr.asFunction<_dart_init_wallet>();
|
||||
|
||||
void reset_app() {
|
||||
return _reset_app();
|
||||
}
|
||||
|
||||
late final _reset_app_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_reset_app>>('reset_app');
|
||||
late final _dart_reset_app _reset_app =
|
||||
_reset_app_ptr.asFunction<_dart_reset_app>();
|
||||
|
||||
void warp_sync(
|
||||
int get_tx,
|
||||
int anchor_offset,
|
||||
|
@ -577,6 +586,10 @@ typedef _dart_init_wallet = void Function(
|
|||
ffi.Pointer<ffi.Int8> ld_url,
|
||||
);
|
||||
|
||||
typedef _c_reset_app = ffi.Void Function();
|
||||
|
||||
typedef _dart_reset_app = void Function();
|
||||
|
||||
typedef _c_warp_sync = ffi.Void Function(
|
||||
ffi.Int8 get_tx,
|
||||
ffi.Uint32 anchor_offset,
|
||||
|
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.1.0+187
|
||||
version: 1.1.1+188
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
@ -89,7 +89,7 @@ dev_dependencies:
|
|||
flutter_native_splash: ^1.2.3
|
||||
|
||||
flutter_app_name:
|
||||
name: "YWalletTest"
|
||||
name: "YWallet"
|
||||
|
||||
flutter_icons:
|
||||
android: true
|
||||
|
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.1.0+187
|
||||
version: 1.1.1+188
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
|
Loading…
Reference in New Issue