mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-05-02 19:02:17 +00:00
restore options refactor clean up
This commit is contained in:
parent
250fba3985
commit
541c57f997
7 changed files with 215 additions and 190 deletions
lib
pages/add_wallet_views
name_your_wallet_view
restore_wallet_view/restore_options_view
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/exit_to_my_stack_button.dart';
|
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/exit_to_my_stack_button.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
||||||
|
|
|
@ -4,6 +4,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart';
|
import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart';
|
||||||
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart';
|
||||||
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart';
|
||||||
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart';
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart';
|
||||||
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
||||||
|
@ -221,7 +225,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: PlatformRestoreOptionsLayout(
|
body: RestoreOptionsPlatformLayout(
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
|
@ -370,7 +374,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
),
|
),
|
||||||
RestoreNextButton(
|
RestoreOptionsNextButton(
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
onPressed: _nextEnabled ? nextPressed : null,
|
onPressed: _nextEnabled ? nextPressed : null,
|
||||||
),
|
),
|
||||||
|
@ -381,189 +385,3 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlatformRestoreOptionsLayout extends StatelessWidget {
|
|
||||||
const PlatformRestoreOptionsLayout({
|
|
||||||
Key? key,
|
|
||||||
required this.isDesktop,
|
|
||||||
required this.child,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
final bool isDesktop;
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (isDesktop) {
|
|
||||||
return child;
|
|
||||||
} else {
|
|
||||||
return Container(
|
|
||||||
color: CFColors.background,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (ctx, constraints) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
|
||||||
child: IntrinsicHeight(
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RestoreFromDatePicker extends StatefulWidget {
|
|
||||||
const RestoreFromDatePicker({Key? key, required this.onTap})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
final VoidCallback onTap;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<RestoreFromDatePicker> createState() => _RestoreFromDatePickerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RestoreFromDatePickerState extends State<RestoreFromDatePicker> {
|
|
||||||
late final TextEditingController _dateController;
|
|
||||||
late final VoidCallback onTap;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
onTap = widget.onTap;
|
|
||||||
_dateController = TextEditingController();
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_dateController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: TextField(
|
|
||||||
onTap: onTap,
|
|
||||||
controller: _dateController,
|
|
||||||
style: STextStyles.field,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Restore from...",
|
|
||||||
suffixIcon: UnconstrainedBox(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
width: 16,
|
|
||||||
),
|
|
||||||
SvgPicture.asset(
|
|
||||||
Assets.svg.calendar,
|
|
||||||
color: CFColors.neutral50,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 12,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
key: const Key("restoreOptionsViewDatePickerKey"),
|
|
||||||
readOnly: true,
|
|
||||||
toolbarOptions: const ToolbarOptions(
|
|
||||||
copy: true,
|
|
||||||
cut: false,
|
|
||||||
paste: false,
|
|
||||||
selectAll: false,
|
|
||||||
),
|
|
||||||
onChanged: (newValue) {},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MobileMnemonicLengthSelector extends ConsumerWidget {
|
|
||||||
const MobileMnemonicLengthSelector({
|
|
||||||
Key? key,
|
|
||||||
required this.chooseMnemonicLength,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
final VoidCallback chooseMnemonicLength;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
const TextField(
|
|
||||||
// controller: _lengthController,
|
|
||||||
readOnly: true,
|
|
||||||
textInputAction: TextInputAction.none,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 12,
|
|
||||||
),
|
|
||||||
child: RawMaterialButton(
|
|
||||||
splashColor: CFColors.splashLight,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
Constants.size.circularBorderRadius,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: chooseMnemonicLength,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"${ref.watch(mnemonicWordCountStateProvider.state).state} words",
|
|
||||||
style: STextStyles.itemSubtitle12,
|
|
||||||
),
|
|
||||||
SvgPicture.asset(
|
|
||||||
Assets.svg.chevronDown,
|
|
||||||
width: 8,
|
|
||||||
height: 4,
|
|
||||||
color: CFColors.gray3,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RestoreNextButton extends StatelessWidget {
|
|
||||||
const RestoreNextButton({Key? key, required this.isDesktop, this.onPressed})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
final bool isDesktop;
|
|
||||||
final VoidCallback? onPressed;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
minHeight: isDesktop ? 70 : 0,
|
|
||||||
),
|
|
||||||
child: TextButton(
|
|
||||||
onPressed: onPressed,
|
|
||||||
style: onPressed != null
|
|
||||||
? CFColors.getPrimaryEnabledButtonColor(context)
|
|
||||||
: CFColors.getPrimaryDisabledButtonColor(context),
|
|
||||||
child: Text(
|
|
||||||
"Next",
|
|
||||||
style: STextStyles.button,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
||||||
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/cfcolors.dart';
|
||||||
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
|
||||||
|
class MobileMnemonicLengthSelector extends ConsumerWidget {
|
||||||
|
const MobileMnemonicLengthSelector({
|
||||||
|
Key? key,
|
||||||
|
required this.chooseMnemonicLength,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final VoidCallback chooseMnemonicLength;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
const TextField(
|
||||||
|
// controller: _lengthController,
|
||||||
|
readOnly: true,
|
||||||
|
textInputAction: TextInputAction.none,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
),
|
||||||
|
child: RawMaterialButton(
|
||||||
|
splashColor: CFColors.splashLight,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: chooseMnemonicLength,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"${ref.watch(mnemonicWordCountStateProvider.state).state} words",
|
||||||
|
style: STextStyles.itemSubtitle12,
|
||||||
|
),
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.chevronDown,
|
||||||
|
width: 8,
|
||||||
|
height: 4,
|
||||||
|
color: CFColors.gray3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/cfcolors.dart';
|
||||||
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
|
||||||
|
class RestoreFromDatePicker extends StatefulWidget {
|
||||||
|
const RestoreFromDatePicker({Key? key, required this.onTap})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RestoreFromDatePicker> createState() => _RestoreFromDatePickerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RestoreFromDatePickerState extends State<RestoreFromDatePicker> {
|
||||||
|
late final TextEditingController _dateController;
|
||||||
|
late final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
onTap = widget.onTap;
|
||||||
|
_dateController = TextEditingController();
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_dateController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: TextField(
|
||||||
|
onTap: onTap,
|
||||||
|
controller: _dateController,
|
||||||
|
style: STextStyles.field,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Restore from...",
|
||||||
|
suffixIcon: UnconstrainedBox(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.calendar,
|
||||||
|
color: CFColors.neutral50,
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
key: const Key("restoreOptionsViewDatePickerKey"),
|
||||||
|
readOnly: true,
|
||||||
|
toolbarOptions: const ToolbarOptions(
|
||||||
|
copy: true,
|
||||||
|
cut: false,
|
||||||
|
paste: false,
|
||||||
|
selectAll: false,
|
||||||
|
),
|
||||||
|
onChanged: (newValue) {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:stackwallet/utilities/cfcolors.dart';
|
||||||
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
|
||||||
|
class RestoreOptionsNextButton extends StatelessWidget {
|
||||||
|
const RestoreOptionsNextButton({
|
||||||
|
Key? key,
|
||||||
|
required this.isDesktop,
|
||||||
|
this.onPressed,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final bool isDesktop;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
minHeight: isDesktop ? 70 : 0,
|
||||||
|
),
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
style: onPressed != null
|
||||||
|
? CFColors.getPrimaryEnabledButtonColor(context)
|
||||||
|
: CFColors.getPrimaryDisabledButtonColor(context),
|
||||||
|
child: Text(
|
||||||
|
"Next",
|
||||||
|
style: STextStyles.button,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:stackwallet/utilities/cfcolors.dart';
|
||||||
|
|
||||||
|
class RestoreOptionsPlatformLayout extends StatelessWidget {
|
||||||
|
const RestoreOptionsPlatformLayout({
|
||||||
|
Key? key,
|
||||||
|
required this.isDesktop,
|
||||||
|
required this.child,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final bool isDesktop;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (isDesktop) {
|
||||||
|
return child;
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
color: CFColors.background,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (ctx, constraints) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
||||||
|
child: IntrinsicHeight(
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view
|
||||||
import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart';
|
||||||
import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
||||||
import 'package:stackwallet/pages/address_book_views/address_book_view.dart';
|
import 'package:stackwallet/pages/address_book_views/address_book_view.dart';
|
||||||
|
|
Loading…
Reference in a new issue