|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_riverpod/flutter_riverpod.dart'; |
| 3 | + |
| 4 | +import '../../themes/stack_colors.dart'; |
| 5 | +import '../../utilities/text_styles.dart'; |
| 6 | +import '../../utilities/util.dart'; |
| 7 | +import '../../widgets/background.dart'; |
| 8 | +import '../../widgets/conditional_parent.dart'; |
| 9 | +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; |
| 10 | +import '../../widgets/desktop/desktop_dialog_close_button.dart'; |
| 11 | +import 'sub_widgets/register_masternode_form.dart'; |
| 12 | + |
| 13 | +class CreateMasternodeView extends ConsumerStatefulWidget { |
| 14 | + const CreateMasternodeView({ |
| 15 | + super.key, |
| 16 | + required this.firoWalletId, |
| 17 | + this.popTxidOnSuccess = true, |
| 18 | + }); |
| 19 | + |
| 20 | + static const routeName = "/createMasternodeView"; |
| 21 | + |
| 22 | + final String firoWalletId; |
| 23 | + final bool popTxidOnSuccess; |
| 24 | + |
| 25 | + @override |
| 26 | + ConsumerState<CreateMasternodeView> createState() => |
| 27 | + _CreateMasternodeDialogState(); |
| 28 | +} |
| 29 | + |
| 30 | +class _CreateMasternodeDialogState extends ConsumerState<CreateMasternodeView> { |
| 31 | + @override |
| 32 | + Widget build(BuildContext context) { |
| 33 | + return ConditionalParent( |
| 34 | + condition: Util.isDesktop, |
| 35 | + builder: (child) => SizedBox( |
| 36 | + width: 660, |
| 37 | + child: Column( |
| 38 | + crossAxisAlignment: CrossAxisAlignment.stretch, |
| 39 | + mainAxisSize: MainAxisSize.min, |
| 40 | + children: [ |
| 41 | + Row( |
| 42 | + mainAxisAlignment: .spaceBetween, |
| 43 | + children: [ |
| 44 | + Padding( |
| 45 | + padding: const EdgeInsets.only(left: 32), |
| 46 | + child: Text( |
| 47 | + "Create masternode", |
| 48 | + style: STextStyles.desktopH3(context), |
| 49 | + ), |
| 50 | + ), |
| 51 | + const DesktopDialogCloseButton(), |
| 52 | + ], |
| 53 | + ), |
| 54 | + Flexible( |
| 55 | + child: Padding( |
| 56 | + padding: const EdgeInsets.only(left: 32, bottom: 32, right: 32), |
| 57 | + child: child, |
| 58 | + ), |
| 59 | + ), |
| 60 | + ], |
| 61 | + ), |
| 62 | + ), |
| 63 | + child: ConditionalParent( |
| 64 | + condition: !Util.isDesktop, |
| 65 | + builder: (child) => Background( |
| 66 | + child: Scaffold( |
| 67 | + backgroundColor: Theme.of( |
| 68 | + context, |
| 69 | + ).extension<StackColors>()!.background, |
| 70 | + appBar: AppBar( |
| 71 | + backgroundColor: Theme.of( |
| 72 | + context, |
| 73 | + ).extension<StackColors>()!.background, |
| 74 | + leading: AppBarBackButton( |
| 75 | + onPressed: () async { |
| 76 | + Navigator.of(context).pop(); |
| 77 | + }, |
| 78 | + ), |
| 79 | + title: Text( |
| 80 | + "Create masternode", |
| 81 | + style: STextStyles.navBarTitle(context), |
| 82 | + ), |
| 83 | + ), |
| 84 | + body: SafeArea( |
| 85 | + child: LayoutBuilder( |
| 86 | + builder: (context, constraints) { |
| 87 | + return Padding( |
| 88 | + padding: const EdgeInsets.symmetric(horizontal: 16), |
| 89 | + child: SingleChildScrollView( |
| 90 | + child: ConstrainedBox( |
| 91 | + constraints: BoxConstraints( |
| 92 | + minHeight: constraints.maxHeight, |
| 93 | + ), |
| 94 | + child: IntrinsicHeight( |
| 95 | + child: Padding( |
| 96 | + padding: const EdgeInsets.only(bottom: 16), |
| 97 | + child: child, |
| 98 | + ), |
| 99 | + ), |
| 100 | + ), |
| 101 | + ), |
| 102 | + ); |
| 103 | + }, |
| 104 | + ), |
| 105 | + ), |
| 106 | + ), |
| 107 | + ), |
| 108 | + child: RegisterMasternodeForm( |
| 109 | + firoWalletId: widget.firoWalletId, |
| 110 | + onRegistrationSuccess: (txid) { |
| 111 | + if (widget.popTxidOnSuccess && mounted) { |
| 112 | + Navigator.of(context, rootNavigator: Util.isDesktop).pop(txid); |
| 113 | + } |
| 114 | + }, |
| 115 | + ), |
| 116 | + ), |
| 117 | + ); |
| 118 | + } |
| 119 | +} |
0 commit comments