WIP: desktop wallet network settings popups

This commit is contained in:
julian 2022-11-02 13:43:23 -06:00
parent 4aec412ce7
commit 1f1253e070
2 changed files with 513 additions and 440 deletions

View file

@ -23,7 +23,9 @@ import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.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';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/animated_text.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
import 'package:stackwallet/widgets/progress_bar.dart'; import 'package:stackwallet/widgets/progress_bar.dart';
@ -75,17 +77,19 @@ class _WalletNetworkSettingsViewState
late int _blocksRemaining; late int _blocksRemaining;
Future<void> _attemptRescan() async { Future<void> _attemptRescan() async {
if (!Platform.isLinux) Wakelock.enable(); if (!Platform.isLinux) await Wakelock.enable();
int maxUnusedAddressGap = 20; int maxUnusedAddressGap = 20;
const int maxNumberOfIndexesToCheck = 1000; const int maxNumberOfIndexesToCheck = 1000;
showDialog<dynamic>( unawaited(
context: context, showDialog<dynamic>(
useSafeArea: false, context: context,
barrierDismissible: false, useSafeArea: false,
builder: (context) => const RescanningDialog(), barrierDismissible: false,
builder: (context) => const RescanningDialog(),
),
); );
try { try {
@ -131,7 +135,7 @@ class _WalletNetworkSettingsViewState
); );
} }
} catch (e) { } catch (e) {
if (!Platform.isLinux) Wakelock.disable(); if (!Platform.isLinux) await Wakelock.disable();
if (mounted) { if (mounted) {
// pop rescanning dialog // pop rescanning dialog
@ -162,7 +166,7 @@ class _WalletNetworkSettingsViewState
} }
} }
if (!Platform.isLinux) Wakelock.disable(); if (!Platform.isLinux) await Wakelock.disable();
} }
String _percentString(double value) { String _percentString(double value) {
@ -262,9 +266,11 @@ class _WalletNetworkSettingsViewState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width; final screenWidth = MediaQuery.of(context).size.width;
final bool isDesktop = Util.isDesktop;
final progressLength = final progressLength = isDesktop
screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize; ? 450.0
: screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize;
final coin = ref final coin = ref
.read(walletsChangeNotifierProvider) .read(walletsChangeNotifierProvider)
@ -300,443 +306,464 @@ class _WalletNetworkSettingsViewState
} }
} }
return Scaffold( return ConditionalParent(
backgroundColor: Theme.of(context).extension<StackColors>()!.background, condition: !isDesktop,
appBar: AppBar( builder: (child) {
leading: AppBarBackButton( return Scaffold(
onPressed: () { backgroundColor:
Navigator.of(context).pop(); Theme.of(context).extension<StackColors>()!.background,
}, appBar: AppBar(
), leading: AppBarBackButton(
title: Text( onPressed: () {
"Network", Navigator.of(context).pop();
style: STextStyles.navBarTitle(context), },
),
actions: [
Padding(
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
right: 10,
), ),
child: AspectRatio( title: Text(
aspectRatio: 1, "Network",
child: AppBarIconButton( style: STextStyles.navBarTitle(context),
key: const Key("walletNetworkSettingsAddNewNodeViewButton"), ),
size: 36, actions: [
shadows: const [], Padding(
color: Theme.of(context).extension<StackColors>()!.background, padding: const EdgeInsets.only(
icon: SvgPicture.asset( top: 10,
Assets.svg.verticalEllipsis, bottom: 10,
color: Theme.of(context) right: 10,
.extension<StackColors>()!
.accentColorDark,
width: 20,
height: 20,
), ),
onPressed: () { child: AspectRatio(
showDialog<dynamic>( aspectRatio: 1,
barrierColor: Colors.transparent, child: AppBarIconButton(
barrierDismissible: true, key: const Key("walletNetworkSettingsAddNewNodeViewButton"),
context: context, size: 36,
builder: (_) { shadows: const [],
return Stack( color:
children: [ Theme.of(context).extension<StackColors>()!.background,
Positioned( icon: SvgPicture.asset(
top: 9, Assets.svg.verticalEllipsis,
right: 10, color: Theme.of(context)
child: Container( .extension<StackColors>()!
decoration: BoxDecoration( .accentColorDark,
color: Theme.of(context) width: 20,
.extension<StackColors>()! height: 20,
.popupBG, ),
borderRadius: BorderRadius.circular( onPressed: () {
Constants.size.circularBorderRadius), showDialog<dynamic>(
// boxShadow: [CFColors.standardBoxShadow], barrierColor: Colors.transparent,
boxShadow: const [], barrierDismissible: true,
), context: context,
child: Column( builder: (_) {
crossAxisAlignment: CrossAxisAlignment.start, return Stack(
children: [ children: [
GestureDetector( Positioned(
onTap: () { top: 9,
Navigator.of(context).pop(); right: 10,
showDialog<dynamic>( child: Container(
context: context, decoration: BoxDecoration(
useSafeArea: false, color: Theme.of(context)
barrierDismissible: true, .extension<StackColors>()!
builder: (context) { .popupBG,
return ConfirmFullRescanDialog( borderRadius: BorderRadius.circular(
onConfirm: _attemptRescan, Constants.size.circularBorderRadius),
// boxShadow: [CFColors.standardBoxShadow],
boxShadow: const [],
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.of(context).pop();
showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return ConfirmFullRescanDialog(
onConfirm: _attemptRescan,
);
},
); );
}, },
); child: RoundedWhiteContainer(
}, child: Material(
child: RoundedWhiteContainer( color: Colors.transparent,
child: Material( child: Text(
color: Colors.transparent, "Rescan blockchain",
child: Text( style:
"Rescan blockchain", STextStyles.baseXS(context),
style: STextStyles.baseXS(context),
),
),
),
),
],
),
),
),
],
);
},
);
},
),
),
),
],
),
body: Padding(
padding: EdgeInsets.only(
top: 12,
left: _padding,
right: _padding,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Blockchain status",
textAlign: TextAlign.left,
style: STextStyles.smallMed12(context),
),
GestureDetector(
onTap: () {
ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.refresh();
},
child: Text(
"Resync",
style: STextStyles.link2(context),
),
),
],
),
const SizedBox(
height: 9,
),
if (_currentSyncStatus == WalletSyncStatus.synced)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radio,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
"Synchronized",
style: STextStyles.w600_10(context),
),
Text(
"100%",
style: STextStyles.syncPercent(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
),
),
],
),
),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: 1,
),
],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.syncing)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radioSyncing,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
AnimatedText(
style: STextStyles.w600_10(context),
stringsToLoopThrough: const [
"Synchronizing",
"Synchronizing.",
"Synchronizing..",
"Synchronizing...",
],
),
Row(
children: [
Text(
_percentString(_percent),
style:
STextStyles.syncPercent(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
),
),
if (coin == Coin.monero ||
coin == Coin.wownero ||
coin == Coin.epicCash)
Text(
" (Blocks to go: ${_blocksRemaining == -1 ? "?" : _blocksRemaining})",
style:
STextStyles.syncPercent(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
), ),
), ),
], ),
) ),
], ],
),
), ),
), ),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: _percent,
),
], ],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.unableToSync)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radioProblem,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
"Unable to synchronize",
style:
STextStyles.w600_10(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
Text(
"0%",
style: STextStyles.syncPercent(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
],
),
),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: 0,
),
],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.unableToSync)
Padding(
padding: const EdgeInsets.only(
top: 12,
),
child: RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.warningBackground,
child: Text(
"Please check your internet connection and make sure your current node is not having issues.",
style: STextStyles.baseXS(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.warningForeground,
),
),
),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${ref.watch(walletsChangeNotifierProvider.select((value) => value.getManager(widget.walletId).coin)).prettyName} nodes",
textAlign: TextAlign.left,
style: STextStyles.smallMed12(context),
),
BlueTextButton(
text: "Add new node",
onTap: () {
Navigator.of(context).pushNamed(
AddEditNodeView.routeName,
arguments: Tuple4(
AddEditNodeViewType.add,
ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.coin,
null,
WalletNetworkSettingsView.routeName,
),
); );
}, },
), );
], },
), ),
const SizedBox( ),
height: 8,
),
NodesList(
coin: ref.watch(walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).coin)),
popBackToRoute: WalletNetworkSettingsView.routeName,
),
],
), ),
], ],
), ),
), body: Padding(
padding: EdgeInsets.only(
top: 12,
left: _padding,
right: _padding,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
child,
],
),
),
),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Blockchain status",
textAlign: TextAlign.left,
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
: STextStyles.smallMed12(context),
),
GestureDetector(
onTap: () {
ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.refresh();
},
child: Text(
"Resync",
style: STextStyles.link2(context),
),
),
],
),
const SizedBox(
height: 9,
),
if (_currentSyncStatus == WalletSyncStatus.synced)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radio,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Synchronized",
style: STextStyles.w600_10(context),
),
Text(
"100%",
style: STextStyles.syncPercent(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
),
),
],
),
),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: 1,
),
],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.syncing)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radioSyncing,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AnimatedText(
style: STextStyles.w600_10(context),
stringsToLoopThrough: const [
"Synchronizing",
"Synchronizing.",
"Synchronizing..",
"Synchronizing...",
],
),
Row(
children: [
Text(
_percentString(_percent),
style:
STextStyles.syncPercent(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
),
),
if (coin == Coin.monero ||
coin == Coin.wownero ||
coin == Coin.epicCash)
Text(
" (Blocks to go: ${_blocksRemaining == -1 ? "?" : _blocksRemaining})",
style: STextStyles.syncPercent(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
),
),
],
)
],
),
),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: _percent,
),
],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.unableToSync)
RoundedWhiteContainer(
child: Row(
children: [
Container(
width: _iconSize,
height: _iconSize,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed
.withOpacity(0.2),
borderRadius: BorderRadius.circular(_iconSize),
),
child: Center(
child: SvgPicture.asset(
Assets.svg.radioProblem,
height: 14,
width: 14,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
),
SizedBox(
width: _boxPadding,
),
Column(
children: [
SizedBox(
width: progressLength,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Unable to synchronize",
style: STextStyles.w600_10(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
Text(
"0%",
style: STextStyles.syncPercent(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
),
),
],
),
),
const SizedBox(
height: 4,
),
ProgressBar(
width: progressLength,
height: 5,
fillColor: Theme.of(context)
.extension<StackColors>()!
.accentColorRed,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
percent: 0,
),
],
),
],
),
),
if (_currentSyncStatus == WalletSyncStatus.unableToSync)
Padding(
padding: const EdgeInsets.only(
top: 12,
),
child: RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.warningBackground,
child: Text(
"Please check your internet connection and make sure your current node is not having issues.",
style: STextStyles.baseXS(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.warningForeground,
),
),
),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${ref.watch(walletsChangeNotifierProvider.select((value) => value.getManager(widget.walletId).coin)).prettyName} nodes",
textAlign: TextAlign.left,
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
: STextStyles.smallMed12(context),
),
BlueTextButton(
text: "Add new node",
onTap: () {
Navigator.of(context).pushNamed(
AddEditNodeView.routeName,
arguments: Tuple4(
AddEditNodeViewType.add,
ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.coin,
null,
WalletNetworkSettingsView.routeName,
),
);
},
),
],
),
const SizedBox(
height: 8,
),
NodesList(
coin: ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(widget.walletId).coin)),
popBackToRoute: WalletNetworkSettingsView.routeName,
),
if (isDesktop)
const SizedBox(
height: 20,
),
if (isDesktop)
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Advanced",
textAlign: TextAlign.left,
style: STextStyles.desktopTextExtraExtraSmall(context),
),
],
),
],
), ),
); );
} }

View file

@ -12,6 +12,9 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.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';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
class NetworkInfoButton extends ConsumerStatefulWidget { class NetworkInfoButton extends ConsumerStatefulWidget {
@ -150,14 +153,57 @@ class _NetworkInfoButtonState extends ConsumerState<NetworkInfoButton> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).pushNamed( if (Util.isDesktop) {
WalletNetworkSettingsView.routeName, showDialog<void>(
arguments: Tuple3( context: context,
walletId, builder: (context) => DesktopDialog(
_currentSyncStatus, maxHeight: 600,
_currentNodeStatus, maxWidth: 580,
), child: Column(
); mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(
left: 32,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Network",
style: STextStyles.desktopH3(context),
),
const DesktopDialogCloseButton(),
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 16,
left: 32,
right: 32,
bottom: 32,
),
child: WalletNetworkSettingsView(
walletId: walletId,
initialSyncStatus: _currentSyncStatus,
initialNodeStatus: _currentNodeStatus,
),
),
],
),
),
);
} else {
Navigator.of(context).pushNamed(
WalletNetworkSettingsView.routeName,
arguments: Tuple3(
walletId,
_currentSyncStatus,
_currentNodeStatus,
),
);
}
}, },
child: Container( child: Container(
color: Colors.transparent, color: Colors.transparent,