mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
WIP: desktop wallet keys popup qr code
This commit is contained in:
parent
3a15538273
commit
549087a4f4
2 changed files with 113 additions and 6 deletions
|
@ -2,8 +2,11 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:event_bus/event_bus.dart';
|
import 'package:event_bus/event_bus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
|
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart';
|
import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart';
|
||||||
|
@ -16,15 +19,19 @@ import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_vie
|
||||||
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||||
|
import 'package:stackwallet/route_generator.dart';
|
||||||
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
|
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
|
||||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||||
|
import 'package:stackwallet/utilities/address_utils.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/flush_bar_type.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
@ -786,6 +793,7 @@ class WalletKeysButton extends StatelessWidget {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
builder: (context) => UnlockWalletKeysDesktop(
|
builder: (context) => UnlockWalletKeysDesktop(
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
),
|
),
|
||||||
|
@ -998,8 +1006,20 @@ class _UnlockWalletKeysDesktopState
|
||||||
.mnemonic;
|
.mnemonic;
|
||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => WalletKeysDesktopPopup(
|
barrierDismissible: false,
|
||||||
words: words,
|
builder: (context) => Navigator(
|
||||||
|
initialRoute: WalletKeysDesktopPopup.routeName,
|
||||||
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
|
onGenerateInitialRoutes: (_, __) {
|
||||||
|
return [
|
||||||
|
RouteGenerator.generateRoute(
|
||||||
|
RouteSettings(
|
||||||
|
name: WalletKeysDesktopPopup.routeName,
|
||||||
|
arguments: words,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1022,9 +1042,13 @@ class WalletKeysDesktopPopup extends StatelessWidget {
|
||||||
const WalletKeysDesktopPopup({
|
const WalletKeysDesktopPopup({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.words,
|
required this.words,
|
||||||
|
this.clipboardInterface = const ClipboardWrapper(),
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final List<String> words;
|
final List<String> words;
|
||||||
|
final ClipboardInterface clipboardInterface;
|
||||||
|
|
||||||
|
static const String routeName = "walletKeysDesktopPopup";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1045,7 +1069,11 @@ class WalletKeysDesktopPopup extends StatelessWidget {
|
||||||
style: STextStyles.desktopH3(context),
|
style: STextStyles.desktopH3(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const DesktopDialogCloseButton(),
|
DesktopDialogCloseButton(
|
||||||
|
onPressedOverride: () {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -1098,7 +1126,11 @@ class WalletKeysDesktopPopup extends StatelessWidget {
|
||||||
child: SecondaryButton(
|
child: SecondaryButton(
|
||||||
label: "Show QR code",
|
label: "Show QR code",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// todo show qr code
|
final String value = AddressUtils.encodeQRSeedData(words);
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
QRCodeDesktopPopupContent.routeName,
|
||||||
|
arguments: value,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1108,8 +1140,18 @@ class WalletKeysDesktopPopup extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
label: "Copy",
|
label: "Copy",
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
// todo copy to clipboard
|
await clipboardInterface.setData(
|
||||||
|
ClipboardData(text: words.join(" ")),
|
||||||
|
);
|
||||||
|
unawaited(
|
||||||
|
showFloatingFlushBar(
|
||||||
|
type: FlushBarType.info,
|
||||||
|
message: "Copied to clipboard",
|
||||||
|
iconAsset: Assets.svg.copy,
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1124,3 +1166,40 @@ class WalletKeysDesktopPopup extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QRCodeDesktopPopupContent extends StatelessWidget {
|
||||||
|
const QRCodeDesktopPopupContent({
|
||||||
|
Key? key,
|
||||||
|
required this.value,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
static const String routeName = "qrCodeDesktopPopupContent";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DesktopDialog(
|
||||||
|
maxWidth: 614,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: const [
|
||||||
|
DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 14,
|
||||||
|
),
|
||||||
|
QrImage(
|
||||||
|
data: value,
|
||||||
|
size: 300,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).extension<StackColors>()!.accentColorDark,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1048,6 +1048,34 @@ class RouteGenerator {
|
||||||
builder: (_) => const AdvancedSettings(),
|
builder: (_) => const AdvancedSettings(),
|
||||||
settings: RouteSettings(name: settings.name));
|
settings: RouteSettings(name: settings.name));
|
||||||
|
|
||||||
|
case WalletKeysDesktopPopup.routeName:
|
||||||
|
if (args is List<String>) {
|
||||||
|
return getRoute(
|
||||||
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
|
builder: (_) => WalletKeysDesktopPopup(
|
||||||
|
words: args,
|
||||||
|
),
|
||||||
|
settings: RouteSettings(
|
||||||
|
name: settings.name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
|
case QRCodeDesktopPopupContent.routeName:
|
||||||
|
if (args is String) {
|
||||||
|
return getRoute(
|
||||||
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
|
builder: (_) => QRCodeDesktopPopupContent(
|
||||||
|
value: args,
|
||||||
|
),
|
||||||
|
settings: RouteSettings(
|
||||||
|
name: settings.name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
// == End of desktop specific routes =====================================
|
// == End of desktop specific routes =====================================
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue