mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
WIP: desktop wallet network settings popups
This commit is contained in:
parent
4aec412ce7
commit
1f1253e070
2 changed files with 513 additions and 440 deletions
|
@ -23,7 +23,9 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.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/conditional_parent.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/progress_bar.dart';
|
||||
|
@ -75,17 +77,19 @@ class _WalletNetworkSettingsViewState
|
|||
late int _blocksRemaining;
|
||||
|
||||
Future<void> _attemptRescan() async {
|
||||
if (!Platform.isLinux) Wakelock.enable();
|
||||
if (!Platform.isLinux) await Wakelock.enable();
|
||||
|
||||
int maxUnusedAddressGap = 20;
|
||||
|
||||
const int maxNumberOfIndexesToCheck = 1000;
|
||||
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const RescanningDialog(),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -131,7 +135,7 @@ class _WalletNetworkSettingsViewState
|
|||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!Platform.isLinux) Wakelock.disable();
|
||||
if (!Platform.isLinux) await Wakelock.disable();
|
||||
|
||||
if (mounted) {
|
||||
// pop rescanning dialog
|
||||
|
@ -162,7 +166,7 @@ class _WalletNetworkSettingsViewState
|
|||
}
|
||||
}
|
||||
|
||||
if (!Platform.isLinux) Wakelock.disable();
|
||||
if (!Platform.isLinux) await Wakelock.disable();
|
||||
}
|
||||
|
||||
String _percentString(double value) {
|
||||
|
@ -262,9 +266,11 @@ class _WalletNetworkSettingsViewState
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final bool isDesktop = Util.isDesktop;
|
||||
|
||||
final progressLength =
|
||||
screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize;
|
||||
final progressLength = isDesktop
|
||||
? 450.0
|
||||
: screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize;
|
||||
|
||||
final coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
|
@ -300,8 +306,12 @@ class _WalletNetworkSettingsViewState
|
|||
}
|
||||
}
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) {
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
backgroundColor:
|
||||
Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: AppBar(
|
||||
leading: AppBarBackButton(
|
||||
onPressed: () {
|
||||
|
@ -325,7 +335,8 @@ class _WalletNetworkSettingsViewState
|
|||
key: const Key("walletNetworkSettingsAddNewNodeViewButton"),
|
||||
size: 36,
|
||||
shadows: const [],
|
||||
color: Theme.of(context).extension<StackColors>()!.background,
|
||||
color:
|
||||
Theme.of(context).extension<StackColors>()!.background,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.verticalEllipsis,
|
||||
color: Theme.of(context)
|
||||
|
@ -356,7 +367,8 @@ class _WalletNetworkSettingsViewState
|
|||
boxShadow: const [],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
|
@ -377,7 +389,8 @@ class _WalletNetworkSettingsViewState
|
|||
color: Colors.transparent,
|
||||
child: Text(
|
||||
"Rescan blockchain",
|
||||
style: STextStyles.baseXS(context),
|
||||
style:
|
||||
STextStyles.baseXS(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -406,7 +419,14 @@ class _WalletNetworkSettingsViewState
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Column(
|
||||
child,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
|
@ -415,7 +435,9 @@ class _WalletNetworkSettingsViewState
|
|||
Text(
|
||||
"Blockchain status",
|
||||
textAlign: TextAlign.left,
|
||||
style: STextStyles.smallMed12(context),
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextExtraExtraSmall(context)
|
||||
: STextStyles.smallMed12(context),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
|
@ -467,8 +489,7 @@ class _WalletNetworkSettingsViewState
|
|||
SizedBox(
|
||||
width: progressLength,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Synchronized",
|
||||
|
@ -476,8 +497,7 @@ class _WalletNetworkSettingsViewState
|
|||
),
|
||||
Text(
|
||||
"100%",
|
||||
style: STextStyles.syncPercent(context)
|
||||
.copyWith(
|
||||
style: STextStyles.syncPercent(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorGreen,
|
||||
|
@ -538,8 +558,7 @@ class _WalletNetworkSettingsViewState
|
|||
SizedBox(
|
||||
width: progressLength,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AnimatedText(
|
||||
style: STextStyles.w600_10(context),
|
||||
|
@ -555,8 +574,7 @@ class _WalletNetworkSettingsViewState
|
|||
Text(
|
||||
_percentString(_percent),
|
||||
style:
|
||||
STextStyles.syncPercent(context)
|
||||
.copyWith(
|
||||
STextStyles.syncPercent(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorYellow,
|
||||
|
@ -567,8 +585,7 @@ class _WalletNetworkSettingsViewState
|
|||
coin == Coin.epicCash)
|
||||
Text(
|
||||
" (Blocks to go: ${_blocksRemaining == -1 ? "?" : _blocksRemaining})",
|
||||
style:
|
||||
STextStyles.syncPercent(context)
|
||||
style: STextStyles.syncPercent(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -632,13 +649,11 @@ class _WalletNetworkSettingsViewState
|
|||
SizedBox(
|
||||
width: progressLength,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Unable to synchronize",
|
||||
style:
|
||||
STextStyles.w600_10(context).copyWith(
|
||||
style: STextStyles.w600_10(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorRed,
|
||||
|
@ -646,8 +661,7 @@ class _WalletNetworkSettingsViewState
|
|||
),
|
||||
Text(
|
||||
"0%",
|
||||
style: STextStyles.syncPercent(context)
|
||||
.copyWith(
|
||||
style: STextStyles.syncPercent(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorRed,
|
||||
|
@ -703,7 +717,9 @@ class _WalletNetworkSettingsViewState
|
|||
Text(
|
||||
"${ref.watch(walletsChangeNotifierProvider.select((value) => value.getManager(widget.walletId).coin)).prettyName} nodes",
|
||||
textAlign: TextAlign.left,
|
||||
style: STextStyles.smallMed12(context),
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextExtraExtraSmall(context)
|
||||
: STextStyles.smallMed12(context),
|
||||
),
|
||||
BlueTextButton(
|
||||
text: "Add new node",
|
||||
|
@ -728,15 +744,26 @@ class _WalletNetworkSettingsViewState
|
|||
height: 8,
|
||||
),
|
||||
NodesList(
|
||||
coin: ref.watch(walletsChangeNotifierProvider.select(
|
||||
(value) => value.getManager(widget.walletId).coin)),
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
|||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.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';
|
||||
|
||||
class NetworkInfoButton extends ConsumerStatefulWidget {
|
||||
|
@ -150,6 +153,48 @@ class _NetworkInfoButtonState extends ConsumerState<NetworkInfoButton> {
|
|||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (Util.isDesktop) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxHeight: 600,
|
||||
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(
|
||||
|
@ -158,6 +203,7 @@ class _NetworkInfoButtonState extends ConsumerState<NetworkInfoButton> {
|
|||
_currentNodeStatus,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
|
|
Loading…
Reference in a new issue