Skip to content
Snippets Groups Projects
walletOptions.dart 13.54 KiB
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:dubp/dubp.dart';
import 'package:gecko/models/myWallets.dart';
import 'package:gecko/models/walletOptions.dart';
import 'dart:async';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';

// ignore: must_be_immutable
class WalletOptions extends StatelessWidget with ChangeNotifier {
  WalletOptions(
      {Key keyMyWallets,
      @required this.walletNbr,
      @required this.walletName,
      @required this.derivation})
      : super(key: keyMyWallets);
  int walletNbr;
  String walletName;
  int derivation;

  StreamController<ErrorAnimationType> errorController;
  TextEditingController _enterPin = TextEditingController();
  final formKey = GlobalKey<FormState>();
  bool hasError = false;
  var pinColor = Color(0xffF9F9F1);
  var walletPin = '';

  Future<NewWallet> get badWallet => null;

  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    print("Build walletOptions");
    WalletOptionsProvider _walletOptions =
        Provider.of<WalletOptionsProvider>(context);
    MyWalletsProvider _myWalletProvider =
        Provider.of<MyWalletsProvider>(context);
    errorController = StreamController<ErrorAnimationType>();
    // _walletOptions.isWalletUnlock = false;

    final int _pinLenght = _walletOptions.getPinLenght(this.walletNbr);

    return WillPopScope(
        onWillPop: () {
          _walletOptions.isWalletUnlock = false;
          return Future<bool>.value(true);
        },
        child: Scaffold(
            resizeToAvoidBottomInset: false,
            appBar: AppBar(
                leading: IconButton(
                    icon: Icon(Icons.arrow_back, color: Colors.black),
                    onPressed: () {
                      _walletOptions.isWalletUnlock = false;
                      Navigator.of(context).pop();
                    }),
                title: SizedBox(
                  height: 22,
                  child: Text(walletName),
                )),
            body: Builder(
                builder: (ctx) => SafeArea(
                        child: Column(children: <Widget>[
                      Visibility(
                          visible: _walletOptions.isWalletUnlock,
                          child: Expanded(
                              child: Column(children: <Widget>[
                            SizedBox(height: 15),