mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
Scan for Lelantus transactions desktop UI
Squashed commit msgs: WIP add lelantus checkmark to restore options view, pass to restore view make bool optional, pass it style restore option text
This commit is contained in:
parent
ef96f3b76c
commit
32561b5694
4 changed files with 119 additions and 12 deletions
|
@ -72,6 +72,9 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
|
|
||||||
bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport;
|
bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport;
|
||||||
|
|
||||||
|
bool enableLelantusScanning = false;
|
||||||
|
bool get supportsLelantus => coin is Firo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
walletName = widget.walletName;
|
walletName = widget.walletName;
|
||||||
|
@ -107,12 +110,13 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
await Navigator.of(context).pushNamed(
|
await Navigator.of(context).pushNamed(
|
||||||
RestoreWalletView.routeName,
|
RestoreWalletView.routeName,
|
||||||
arguments: Tuple5(
|
arguments: Tuple6(
|
||||||
walletName,
|
walletName,
|
||||||
coin,
|
coin,
|
||||||
ref.read(mnemonicWordCountStateProvider.state).state,
|
ref.read(mnemonicWordCountStateProvider.state).state,
|
||||||
_restoreFromDate,
|
_restoreFromDate,
|
||||||
passwordController.text,
|
passwordController.text,
|
||||||
|
enableLelantusScanning,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -437,6 +441,32 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: enableLelantusScanning,
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
enableLelantusScanning = newValue ?? true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Scan for Lelantus transactions',
|
||||||
|
style: isDesktop
|
||||||
|
? STextStyles.desktopTextExtraSmall(context)
|
||||||
|
.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textSubtitle1,
|
||||||
|
)
|
||||||
|
: STextStyles.itemSubtitle(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: BorderRadius.circular(
|
||||||
Constants.size.circularBorderRadius,
|
Constants.size.circularBorderRadius,
|
||||||
|
|
|
@ -22,15 +22,9 @@ import 'package:flutter_libmonero/monero/monero.dart' as libxmr;
|
||||||
import 'package:flutter_libmonero/wownero/wownero.dart' as libwow;
|
import 'package:flutter_libmonero/wownero/wownero.dart' as libwow;
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
import '../../../notifications/show_flush_bar.dart';
|
import '../../../notifications/show_flush_bar.dart';
|
||||||
import '../add_token_view/edit_wallet_tokens_view.dart';
|
|
||||||
import 'confirm_recovery_dialog.dart';
|
|
||||||
import 'sub_widgets/restore_failed_dialog.dart';
|
|
||||||
import 'sub_widgets/restore_succeeded_dialog.dart';
|
|
||||||
import 'sub_widgets/restoring_dialog.dart';
|
|
||||||
import '../select_wallet_for_token_view.dart';
|
|
||||||
import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
|
||||||
import '../../home_view/home_view.dart';
|
|
||||||
import '../../../pages_desktop_specific/desktop_home_view.dart';
|
import '../../../pages_desktop_specific/desktop_home_view.dart';
|
||||||
import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||||
import '../../../providers/db/main_db_provider.dart';
|
import '../../../providers/db/main_db_provider.dart';
|
||||||
|
@ -64,7 +58,14 @@ import '../../../widgets/icon_widgets/qrcode_icon.dart';
|
||||||
import '../../../widgets/table_view/table_view.dart';
|
import '../../../widgets/table_view/table_view.dart';
|
||||||
import '../../../widgets/table_view/table_view_cell.dart';
|
import '../../../widgets/table_view/table_view_cell.dart';
|
||||||
import '../../../widgets/table_view/table_view_row.dart';
|
import '../../../widgets/table_view/table_view_row.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import '../../home_view/home_view.dart';
|
||||||
|
import '../add_token_view/edit_wallet_tokens_view.dart';
|
||||||
|
import '../select_wallet_for_token_view.dart';
|
||||||
|
import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
||||||
|
import 'confirm_recovery_dialog.dart';
|
||||||
|
import 'sub_widgets/restore_failed_dialog.dart';
|
||||||
|
import 'sub_widgets/restore_succeeded_dialog.dart';
|
||||||
|
import 'sub_widgets/restoring_dialog.dart';
|
||||||
|
|
||||||
class RestoreWalletView extends ConsumerStatefulWidget {
|
class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
const RestoreWalletView({
|
const RestoreWalletView({
|
||||||
|
@ -74,6 +75,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
required this.seedWordsLength,
|
required this.seedWordsLength,
|
||||||
required this.mnemonicPassphrase,
|
required this.mnemonicPassphrase,
|
||||||
required this.restoreFromDate,
|
required this.restoreFromDate,
|
||||||
|
this.enableLelantusScanning = false,
|
||||||
this.barcodeScanner = const BarcodeScannerWrapper(),
|
this.barcodeScanner = const BarcodeScannerWrapper(),
|
||||||
this.clipboard = const ClipboardWrapper(),
|
this.clipboard = const ClipboardWrapper(),
|
||||||
});
|
});
|
||||||
|
@ -85,6 +87,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
final String mnemonicPassphrase;
|
final String mnemonicPassphrase;
|
||||||
final int seedWordsLength;
|
final int seedWordsLength;
|
||||||
final DateTime restoreFromDate;
|
final DateTime restoreFromDate;
|
||||||
|
final bool enableLelantusScanning;
|
||||||
|
|
||||||
final BarcodeScannerInterface barcodeScanner;
|
final BarcodeScannerInterface barcodeScanner;
|
||||||
final ClipboardInterface clipboard;
|
final ClipboardInterface clipboard;
|
||||||
|
@ -256,6 +259,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
||||||
otherDataJsonString = jsonEncode(
|
otherDataJsonString = jsonEncode(
|
||||||
{
|
{
|
||||||
WalletInfoKeys.lelantusCoinIsarRescanRequired: false,
|
WalletInfoKeys.lelantusCoinIsarRescanRequired: false,
|
||||||
|
WalletInfoKeys.enableLelantusScanning:
|
||||||
|
widget.enableLelantusScanning,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -331,6 +336,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO [prio=high]: Update wallet with widget.enableLelantusScanning.
|
||||||
|
|
||||||
// TODO: extract interface with isRestore param
|
// TODO: extract interface with isRestore param
|
||||||
switch (wallet.runtimeType) {
|
switch (wallet.runtimeType) {
|
||||||
case const (EpiccashWallet):
|
case const (EpiccashWallet):
|
||||||
|
|
|
@ -8,9 +8,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
import '../../../../../providers/db/main_db_provider.dart';
|
||||||
import '../../../../../providers/global/prefs_provider.dart';
|
import '../../../../../providers/global/prefs_provider.dart';
|
||||||
import '../../../../../providers/global/wallets_provider.dart';
|
import '../../../../../providers/global/wallets_provider.dart';
|
||||||
import '../../../../../themes/stack_colors.dart';
|
import '../../../../../themes/stack_colors.dart';
|
||||||
|
@ -18,10 +22,12 @@ import '../../../../../utilities/assets.dart';
|
||||||
import '../../../../../utilities/text_styles.dart';
|
import '../../../../../utilities/text_styles.dart';
|
||||||
import '../../../../../wallets/crypto_currency/coins/banano.dart';
|
import '../../../../../wallets/crypto_currency/coins/banano.dart';
|
||||||
import '../../../../../wallets/crypto_currency/coins/firo.dart';
|
import '../../../../../wallets/crypto_currency/coins/firo.dart';
|
||||||
|
import '../../../../../wallets/isar/models/wallet_info.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart';
|
import '../../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart';
|
import '../../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart';
|
import '../../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
|
import '../../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
|
||||||
|
import '../../../../../widgets/custom_buttons/draggable_switch_button.dart';
|
||||||
import '../../../../../widgets/desktop/desktop_dialog.dart';
|
import '../../../../../widgets/desktop/desktop_dialog.dart';
|
||||||
import '../../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
import '../../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import '../../../../../widgets/rounded_container.dart';
|
import '../../../../../widgets/rounded_container.dart';
|
||||||
|
@ -53,6 +59,8 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||||
|
bool? enableLelantusScanning = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final wallet = ref.watch(
|
final wallet = ref.watch(
|
||||||
|
@ -61,6 +69,13 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Parse otherDataJsonString to get the enableLelantusScanning value.
|
||||||
|
if (wallet.info.otherDataJsonString != null) {
|
||||||
|
final otherDataJson = json.decode(wallet.info.otherDataJsonString!);
|
||||||
|
enableLelantusScanning =
|
||||||
|
otherDataJson["enableLelantusScanning"] as bool? ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
final coinControlPrefEnabled = ref.watch(
|
final coinControlPrefEnabled = ref.watch(
|
||||||
prefsChangeNotifierProvider.select(
|
prefsChangeNotifierProvider.select(
|
||||||
(value) => value.enableCoinControl,
|
(value) => value.enableCoinControl,
|
||||||
|
@ -136,6 +151,58 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||||
iconAsset: Assets.svg.cashFusion,
|
iconAsset: Assets.svg.cashFusion,
|
||||||
onPressed: () => widget.onFusionPressed?.call(),
|
onPressed: () => widget.onFusionPressed?.call(),
|
||||||
),
|
),
|
||||||
|
if (wallet.info.coin is Firo)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 6,
|
||||||
|
horizontal: 32,
|
||||||
|
),
|
||||||
|
child: RoundedContainer(
|
||||||
|
color: Colors.transparent,
|
||||||
|
borderColor: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultBG,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(width: 3),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
width: 40,
|
||||||
|
child: DraggableSwitchButton(
|
||||||
|
isOn: enableLelantusScanning ?? false,
|
||||||
|
onValueChanged: (newValue) {
|
||||||
|
// Toggle enableLelantusScanning in wallet info.
|
||||||
|
wallet.info.updateOtherData(newEntries: {
|
||||||
|
WalletInfoKeys.enableLelantusScanning:
|
||||||
|
!(enableLelantusScanning ?? false)
|
||||||
|
}, isar: ref.read(mainDBProvider).isar).then((value) {
|
||||||
|
// Should setState be used here?
|
||||||
|
enableLelantusScanning =
|
||||||
|
!(enableLelantusScanning ?? false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Scan for Lelantus transactions",
|
||||||
|
style: STextStyles.w600_20(context),
|
||||||
|
),
|
||||||
|
// Text(
|
||||||
|
// detail,
|
||||||
|
// style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 28,
|
height: 28,
|
||||||
),
|
),
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
import 'models/add_wallet_list_entity/add_wallet_list_entity.dart';
|
import 'models/add_wallet_list_entity/add_wallet_list_entity.dart';
|
||||||
import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart';
|
import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart';
|
||||||
import 'models/buy/response_objects/quote.dart';
|
import 'models/buy/response_objects/quote.dart';
|
||||||
|
@ -194,7 +196,6 @@ import 'wallets/models/tx_data.dart';
|
||||||
import 'wallets/wallet/wallet.dart';
|
import 'wallets/wallet/wallet.dart';
|
||||||
import 'widgets/choose_coin_view.dart';
|
import 'widgets/choose_coin_view.dart';
|
||||||
import 'widgets/frost_scaffold.dart';
|
import 'widgets/frost_scaffold.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains all the routes for the app.
|
* This file contains all the routes for the app.
|
||||||
|
@ -1390,7 +1391,8 @@ class RouteGenerator {
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
case RestoreWalletView.routeName:
|
case RestoreWalletView.routeName:
|
||||||
if (args is Tuple5<String, CryptoCurrency, int, DateTime, String>) {
|
if (args
|
||||||
|
is Tuple6<String, CryptoCurrency, int, DateTime, String, bool>) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => RestoreWalletView(
|
builder: (_) => RestoreWalletView(
|
||||||
|
@ -1399,6 +1401,7 @@ class RouteGenerator {
|
||||||
seedWordsLength: args.item3,
|
seedWordsLength: args.item3,
|
||||||
restoreFromDate: args.item4,
|
restoreFromDate: args.item4,
|
||||||
mnemonicPassphrase: args.item5,
|
mnemonicPassphrase: args.item5,
|
||||||
|
enableLelantusScanning: args.item6 ?? false,
|
||||||
),
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
|
|
Loading…
Reference in a new issue