Skip to content

Commit

Permalink
Merge pull request #623 from cypherstack/ui-fixes
Browse files Browse the repository at this point in the history
add change rep to desktop
  • Loading branch information
julian-CStack authored Jul 21, 2023
2 parents a282e16 + 89e803d commit 68af283
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crypto_plugins/flutter_libmonero
Submodule flutter_libmonero updated 0 files
Original file line number Diff line number Diff line change
Expand Up @@ -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:")) {
Expand Down Expand Up @@ -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),
),
),
Expand All @@ -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(
Expand Down Expand Up @@ -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,
),
Row(
children: [
child,
],
),
],
),
child: SelectableText(
representative!,
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
)
: STextStyles.itemSubtitle12(context),
),
),
),
const SizedBox(
Expand Down Expand Up @@ -337,6 +371,7 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
),
),
),
if (isDesktop) const SizedBox(height: 60),
if (!isDesktop) const Spacer(),
PrimaryButton(
label: "Save",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -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";
}
Expand Down Expand Up @@ -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);
},
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 68af283

Please sign in to comment.