mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
Integrated wallet names generation
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
@@ -33,6 +35,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
|
||||
String pin;
|
||||
String title;
|
||||
double _aspectRatio;
|
||||
Flushbar<void> _progressBar;
|
||||
|
||||
int currentPinLength() => pin.length;
|
||||
|
||||
@@ -80,6 +83,17 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void changeProcessText(String text) {
|
||||
hideProgressText();
|
||||
_progressBar = createBar<void>(text, duration: null)
|
||||
..show(_key.currentContext);
|
||||
}
|
||||
|
||||
void hideProgressText() {
|
||||
_progressBar?.dismiss();
|
||||
_progressBar = null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
key: _key, body: body(context), resizeToAvoidBottomPadding: false);
|
||||
|
||||
@@ -8,19 +8,23 @@ import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
|
||||
class SetupPinCodePage extends BasePage {
|
||||
SetupPinCodePage(this.pinCodeViewModel, {this.onSuccessfulPinSetup});
|
||||
SetupPinCodePage(this.pinCodeViewModel, {this.onSuccessfulPinSetup})
|
||||
: pinCodeStateKey = GlobalKey<PinCodeState>();
|
||||
|
||||
final SetupPinCodeViewModel pinCodeViewModel;
|
||||
final void Function(BuildContext, String) onSuccessfulPinSetup;
|
||||
final void Function(PinCodeState<PinCodeWidget>, String) onSuccessfulPinSetup;
|
||||
final GlobalKey<PinCodeState> pinCodeStateKey;
|
||||
|
||||
@override
|
||||
String get title => S.current.setup_pin;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => PinCodeWidget(
|
||||
key: pinCodeStateKey,
|
||||
hasLengthSwitcher: true,
|
||||
onFullPin: (String pin, PinCodeState<PinCodeWidget> state) async {
|
||||
if (pinCodeViewModel.isOriginalPinCodeFull && !pinCodeViewModel.isRepeatedPinCodeFull) {
|
||||
if (pinCodeViewModel.isOriginalPinCodeFull &&
|
||||
!pinCodeViewModel.isRepeatedPinCodeFull) {
|
||||
state.title = S.current.enter_your_pin_again;
|
||||
state.clear();
|
||||
return;
|
||||
@@ -53,7 +57,7 @@ class SetupPinCodePage extends BasePage {
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
onSuccessfulPinSetup(context, pin);
|
||||
onSuccessfulPinSetup(pinCodeStateKey.currentState, pin);
|
||||
state.reset();
|
||||
},
|
||||
alertBarrierDismissible: false,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/screens/wallet_list/widgets/wallet_menu_alert.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
@@ -42,6 +44,7 @@ class WalletListBodyState extends State<WalletListBody> {
|
||||
Image.asset('assets/images/bitcoin.png', height: 24, width: 24);
|
||||
final scrollController = ScrollController();
|
||||
final double tileHeight = 60;
|
||||
Flushbar<void> _progressBar;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -164,8 +167,7 @@ class WalletListBodyState extends State<WalletListBody> {
|
||||
),
|
||||
bottomSection: Column(children: <Widget>[
|
||||
PrimaryImageButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).pushNamed(Routes.newWallet),
|
||||
onPressed: () => _generateNewWallet(),
|
||||
image: newWalletImage,
|
||||
text: S.of(context).wallet_list_create_new_wallet,
|
||||
color: Theme.of(context).accentTextTheme.subtitle.decorationColor,
|
||||
@@ -237,4 +239,25 @@ class WalletListBodyState extends State<WalletListBody> {
|
||||
auth.close();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _generateNewWallet() async {
|
||||
try {
|
||||
changeProcessText('Creating new wallet'); // FIXME: Unnamed constant
|
||||
await widget.walletListViewModel.walletNewVM.create(options: 'English'); // FIXME: Unnamed constant
|
||||
hideProgressText();
|
||||
await Navigator.of(context).pushNamed(Routes.seed, arguments: true);
|
||||
} catch(e) {
|
||||
changeProcessText('Error: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
void changeProcessText(String text) {
|
||||
_progressBar = createBar<void>(text, duration: null)
|
||||
..show(context);
|
||||
}
|
||||
|
||||
void hideProgressText() {
|
||||
_progressBar?.dismiss();
|
||||
_progressBar = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user