mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
add change rep to desktop
This commit is contained in:
parent
a282e1607c
commit
3125a25a69
2 changed files with 125 additions and 13 deletions
|
@ -87,6 +87,7 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
whileFuture: changeFuture(_textController.text),
|
||||
context: context,
|
||||
message: "Updating representative...",
|
||||
isDesktop: Util.isDesktop,
|
||||
onException: (ex) {
|
||||
String msg = ex.toString();
|
||||
while (msg.isNotEmpty && msg.startsWith("Exception:")) {
|
||||
|
@ -214,7 +215,7 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
left: 32,
|
||||
),
|
||||
child: Text(
|
||||
"${ref.watch(walletsChangeNotifierProvider.select((value) => value.getManager(widget.walletId).walletName))} xPub",
|
||||
"Change representative",
|
||||
style: STextStyles.desktopH2(context),
|
||||
),
|
||||
),
|
||||
|
@ -240,7 +241,7 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
),
|
||||
child: Column(
|
||||
children: [
|
||||
if (isDesktop) const SizedBox(height: 44),
|
||||
if (isDesktop) const SizedBox(height: 24),
|
||||
ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Expanded(
|
||||
|
@ -269,15 +270,48 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
} else {
|
||||
child = Column(
|
||||
children: [
|
||||
RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
representative!,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
],
|
||||
ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
child,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: ConditionalParent(
|
||||
condition: isDesktop,
|
||||
builder: (child) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Current representative",
|
||||
style: STextStyles.desktopTextExtraExtraSmall(
|
||||
context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
child,
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SelectableText(
|
||||
representative!,
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextExtraExtraSmall(
|
||||
context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
)
|
||||
: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -337,6 +371,7 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (isDesktop) const SizedBox(height: 60),
|
||||
if (!isDesktop) const Spacer(),
|
||||
PrimaryButton(
|
||||
label: "Save",
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart';
|
||||
|
@ -21,11 +22,13 @@ import 'package:stackwallet/route_generator.dart';
|
|||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
||||
enum _WalletOptions {
|
||||
addressList,
|
||||
deleteWallet,
|
||||
changeRepresentative,
|
||||
showXpub;
|
||||
|
||||
String get prettyName {
|
||||
|
@ -34,6 +37,8 @@ enum _WalletOptions {
|
|||
return "Address list";
|
||||
case _WalletOptions.deleteWallet:
|
||||
return "Delete wallet";
|
||||
case _WalletOptions.changeRepresentative:
|
||||
return "Change representative";
|
||||
case _WalletOptions.showXpub:
|
||||
return "Show xPub";
|
||||
}
|
||||
|
@ -70,6 +75,9 @@ class WalletOptionsButton extends StatelessWidget {
|
|||
onAddressListPressed: () async {
|
||||
Navigator.of(context).pop(_WalletOptions.addressList);
|
||||
},
|
||||
onChangeRepPressed: () async {
|
||||
Navigator.of(context).pop(_WalletOptions.changeRepresentative);
|
||||
},
|
||||
onShowXpubPressed: () async {
|
||||
Navigator.of(context).pop(_WalletOptions.showXpub);
|
||||
},
|
||||
|
@ -134,6 +142,32 @@ class WalletOptionsButton extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
|
||||
if (result == true) {
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case _WalletOptions.changeRepresentative:
|
||||
final result = await showDialog<bool?>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => Navigator(
|
||||
initialRoute: ChangeRepresentativeView.routeName,
|
||||
onGenerateRoute: RouteGenerator.generateRoute,
|
||||
onGenerateInitialRoutes: (_, __) {
|
||||
return [
|
||||
RouteGenerator.generateRoute(
|
||||
RouteSettings(
|
||||
name: ChangeRepresentativeView.routeName,
|
||||
arguments: walletId,
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (result == true) {
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
@ -171,18 +205,24 @@ class WalletOptionsPopupMenu extends ConsumerWidget {
|
|||
required this.onDeletePressed,
|
||||
required this.onAddressListPressed,
|
||||
required this.onShowXpubPressed,
|
||||
required this.onChangeRepPressed,
|
||||
required this.walletId,
|
||||
}) : super(key: key);
|
||||
|
||||
final VoidCallback onDeletePressed;
|
||||
final VoidCallback onAddressListPressed;
|
||||
final VoidCallback onShowXpubPressed;
|
||||
final VoidCallback onChangeRepPressed;
|
||||
final String walletId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bool xpubEnabled = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId).hasXPub));
|
||||
final manager = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId)));
|
||||
final bool xpubEnabled = manager.hasXPub;
|
||||
|
||||
final bool canChangeRep =
|
||||
manager.coin == Coin.nano || manager.coin == Coin.banano;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
|
@ -237,6 +277,43 @@ class WalletOptionsPopupMenu extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (canChangeRep)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (canChangeRep)
|
||||
TransparentButton(
|
||||
onPressed: onChangeRepPressed,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.eye,
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldActiveSearchIconLeft,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_WalletOptions.changeRepresentative.prettyName,
|
||||
style: STextStyles.desktopTextExtraExtraSmall(
|
||||
context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (xpubEnabled)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
|
|
Loading…
Reference in a new issue