Can change pin code of Cesium chest
This commit is contained in:
parent
106fcf2835
commit
dfbab5a219
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -3,24 +3,24 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/chest_data.dart';
|
|
||||||
|
|
||||||
class ChangePinProvider with ChangeNotifier {
|
class ChangePinProvider with ChangeNotifier {
|
||||||
bool ischangedPin = false;
|
bool ischangedPin = false;
|
||||||
TextEditingController newPin = TextEditingController();
|
TextEditingController newPin = TextEditingController();
|
||||||
|
String pinToGive;
|
||||||
|
|
||||||
Future<NewWallet> get badWallet => null;
|
Future<NewWallet> get badWallet => null;
|
||||||
|
|
||||||
Future<NewWallet> changePin(_name, _oldPin) async {
|
Future<NewWallet> changePin(String _oldPin) async {
|
||||||
try {
|
try {
|
||||||
final _dewif = chestBox.get(configBox.get('currentChest')).dewif;
|
final _dewif = chestBox.get(configBox.get('currentChest')).dewif;
|
||||||
|
|
||||||
NewWallet newWalletFile = await DubpRust.changeDewifPin(
|
NewWallet newWalletFile = await DubpRust.changeDewifPin(
|
||||||
dewif: _dewif,
|
dewif: _dewif,
|
||||||
oldPin: _oldPin,
|
oldPin: _oldPin.toUpperCase(),
|
||||||
);
|
);
|
||||||
|
|
||||||
newPin.text = newWalletFile.pin;
|
newPin.text = pinToGive = newWalletFile.pin;
|
||||||
ischangedPin = true;
|
ischangedPin = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return newWalletFile;
|
return newWalletFile;
|
||||||
|
@ -30,12 +30,14 @@ class ChangePinProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeNewPinChest(context, NewWallet _newWalletFile) async {
|
void storeNewPinChest(context, NewWallet _newWalletFile) {
|
||||||
ChestData currentChest = chestBox.getAt(configBox.get('currentChest'));
|
// ChestData currentChest = chestBox.getAt(configBox.get('currentChest'));
|
||||||
currentChest.dewif = _newWalletFile.dewif;
|
// currentChest.dewif = _newWalletFile.dewif;
|
||||||
// currentChest.name = _name;
|
// await chestBox.add(currentChest);
|
||||||
chestBox.add(currentChest);
|
|
||||||
|
|
||||||
Navigator.pop(context);
|
chestBox.get(configBox.get('currentChest')).dewif = _newWalletFile.dewif;
|
||||||
|
|
||||||
|
Navigator.pop(context, pinToGive);
|
||||||
|
pinToGive = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,19 @@ class ChestProvider with ChangeNotifier {
|
||||||
final bool _answer = await _confirmDeletingChest(context, _chest.name);
|
final bool _answer = await _confirmDeletingChest(context, _chest.name);
|
||||||
|
|
||||||
if (_answer) {
|
if (_answer) {
|
||||||
chestBox.delete(_chest.key);
|
await chestBox.delete(_chest.key);
|
||||||
int lastChest = chestBox.toMap().keys.first;
|
if (chestBox.isEmpty) {
|
||||||
configBox.put('currentChest', lastChest);
|
await configBox.put('currentChest', 0);
|
||||||
notifyListeners();
|
} else {
|
||||||
|
int lastChest = chestBox.toMap().keys.first;
|
||||||
|
await configBox.put('currentChest', lastChest);
|
||||||
|
}
|
||||||
|
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context,
|
context,
|
||||||
ModalRoute.withName('/'),
|
ModalRoute.withName('/'),
|
||||||
);
|
);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ class HomeScreen extends StatelessWidget {
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: isTall ? 70 : 60),
|
padding: EdgeInsets.only(top: isTall ? 100 : 60),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
@ -6,8 +6,10 @@ import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/chest_data.dart';
|
import 'package:gecko/models/chest_data.dart';
|
||||||
import 'package:gecko/models/chest_provider.dart';
|
import 'package:gecko/models/chest_provider.dart';
|
||||||
import 'package:gecko/models/history.dart';
|
import 'package:gecko/models/history.dart';
|
||||||
|
import 'package:gecko/models/my_wallets.dart';
|
||||||
import 'package:gecko/models/queries.dart';
|
import 'package:gecko/models/queries.dart';
|
||||||
import 'package:gecko/models/wallet_options.dart';
|
import 'package:gecko/models/wallet_options.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/change_pin.dart';
|
||||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -15,11 +17,13 @@ import 'package:flutter/services.dart';
|
||||||
int _nbrLinesName = 1;
|
int _nbrLinesName = 1;
|
||||||
bool _isNewNameValid = false;
|
bool _isNewNameValid = false;
|
||||||
|
|
||||||
Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet) {
|
Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet,
|
||||||
|
MyWalletsProvider _myWalletProvider) {
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
WalletOptionsProvider _walletOptions =
|
WalletOptionsProvider _walletOptions =
|
||||||
Provider.of<WalletOptionsProvider>(context);
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
ChestProvider _chestProvider = Provider.of<ChestProvider>(context);
|
ChestProvider _chestProvider =
|
||||||
|
Provider.of<ChestProvider>(context, listen: false);
|
||||||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||||
|
|
||||||
final String shortPubkey =
|
final String shortPubkey =
|
||||||
|
@ -231,7 +235,7 @@ Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet) {
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/walletOptions/key.png',
|
'assets/walletOptions/key.png',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 20),
|
||||||
Text("${shortPubkey.split(':')[0]}:",
|
Text("${shortPubkey.split(':')[0]}:",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
|
@ -284,25 +288,63 @@ Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet) {
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/walletOptions/clock.png',
|
'assets/walletOptions/clock.png',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 22),
|
||||||
const Text('Historique des transactions',
|
const Text('Historique des transactions',
|
||||||
style: TextStyle(fontSize: 20, color: Colors.black)),
|
style: TextStyle(fontSize: 20, color: Colors.black)),
|
||||||
]))),
|
]))),
|
||||||
SizedBox(height: 12 * ratio),
|
SizedBox(height: 7 * ratio),
|
||||||
InkWell(
|
InkWell(
|
||||||
key: const Key('deleteWallet'),
|
key: const Key('changePin'),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _chestProvider.deleteChest(context, cesiumWallet);
|
// await _chestProvider.changePin(context, cesiumWallet);
|
||||||
},
|
_myWalletProvider.pinCode = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return ChangePinScreen(
|
||||||
|
walletName: cesiumWallet.name,
|
||||||
|
walletProvider: _myWalletProvider,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
height: 50,
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
const SizedBox(width: 28),
|
||||||
|
Image.asset(
|
||||||
|
'assets/chests/secret_code.png',
|
||||||
|
),
|
||||||
|
const SizedBox(width: 18),
|
||||||
|
const Text('Changer mon code secret',
|
||||||
|
style: TextStyle(fontSize: 20, color: Colors.black)),
|
||||||
|
])),
|
||||||
|
),
|
||||||
|
SizedBox(height: 7 * ratio),
|
||||||
|
InkWell(
|
||||||
|
key: const Key('deleteWallet'),
|
||||||
|
onTap: () async {
|
||||||
|
await _chestProvider.deleteChest(context, cesiumWallet);
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
height: 50,
|
||||||
child: Row(children: <Widget>[
|
child: Row(children: <Widget>[
|
||||||
const SizedBox(width: 33),
|
const SizedBox(width: 33),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/walletOptions/trash.png',
|
'assets/walletOptions/trash.png',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 14),
|
const SizedBox(width: 25),
|
||||||
const Text('Supprimer ce coffre',
|
const Text(
|
||||||
style: TextStyle(fontSize: 20, color: Color(0xffD80000))),
|
'Supprimer ce coffre',
|
||||||
])),
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: Color(0xffD80000),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,16 +4,19 @@ import 'package:dubp/dubp.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/change_pin.dart';
|
import 'package:gecko/models/change_pin.dart';
|
||||||
|
import 'package:gecko/models/my_wallets.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
||||||
ChangePinScreen(
|
ChangePinScreen(
|
||||||
{Key keyMyWallets, @required this.walletName, @required this.oldPin})
|
{Key keyMyWallets,
|
||||||
|
@required this.walletName,
|
||||||
|
@required this.walletProvider})
|
||||||
: super(key: keyMyWallets);
|
: super(key: keyMyWallets);
|
||||||
final String walletName;
|
final String walletName;
|
||||||
final String oldPin;
|
final MyWalletsProvider walletProvider;
|
||||||
Directory appPath;
|
Directory appPath;
|
||||||
NewWallet _newWalletFile;
|
NewWallet _newWalletFile;
|
||||||
|
|
||||||
|
@ -24,27 +27,27 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
||||||
// _walletOptions.changePin(walletName, oldPin);
|
// _walletOptions.changePin(walletName, oldPin);
|
||||||
// _walletOptions.newPin.text = _tmpPin;
|
// _walletOptions.newPin.text = _tmpPin;
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
_changePin.newPin.text = '';
|
_changePin.newPin.text = '';
|
||||||
return Future<bool>.value(true);
|
return Future<bool>.value(true);
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
toolbarHeight: 60 * ratio,
|
toolbarHeight: 60 * ratio,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_changePin.newPin.text = '';
|
_changePin.newPin.text = '';
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}),
|
}),
|
||||||
title: SizedBox(
|
title: SizedBox(
|
||||||
height: 22,
|
height: 22,
|
||||||
child: Text(walletName),
|
child: Text(walletName),
|
||||||
)),
|
)),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
const SizedBox(height: 80),
|
const SizedBox(height: 80),
|
||||||
Text(
|
Text(
|
||||||
'Choisissez un code secret autogénéré :',
|
'Choisissez un code secret autogénéré :',
|
||||||
|
@ -59,7 +62,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
enabled: true,
|
enabled: false,
|
||||||
controller: _changePin.newPin,
|
controller: _changePin.newPin,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
@ -73,7 +76,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
||||||
color: orangeC,
|
color: orangeC,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
_newWalletFile =
|
_newWalletFile =
|
||||||
await _changePin.changePin(walletName, oldPin);
|
await _changePin.changePin(walletProvider.pinCode);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -83,21 +86,28 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 12,
|
elevation: 12,
|
||||||
primary: Colors.green[400], //smoothYellow, // background
|
primary: Colors.green[400], //smoothYellow, // background
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
),
|
),
|
||||||
onPressed: _changePin.newPin.text != ''
|
onPressed: _changePin.newPin.text != ''
|
||||||
? () {
|
? () {
|
||||||
_changePin.newPin.text = '';
|
_changePin.newPin.text = '';
|
||||||
_changePin.storeNewPinChest(
|
_changePin.storeNewPinChest(context, _newWalletFile);
|
||||||
context, _newWalletFile);
|
walletProvider.pinCode = _changePin.newPin.text;
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: const Text('Confirmer',
|
child: const Text(
|
||||||
style: TextStyle(fontSize: 28))),
|
'Confirmer',
|
||||||
|
style: TextStyle(fontSize: 28),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
])))));
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,8 @@ class WalletsHome extends StatelessWidget {
|
||||||
child: !isWalletsExists
|
child: !isWalletsExists
|
||||||
? const NoKeyChainScreen()
|
? const NoKeyChainScreen()
|
||||||
: _currentChest.isCesium
|
: _currentChest.isCesium
|
||||||
? cesiumWalletOptions(context, _currentChest)
|
? cesiumWalletOptions(
|
||||||
|
context, _currentChest, myWalletProvider)
|
||||||
: myWalletsTiles(context),
|
: myWalletsTiles(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -7,7 +7,7 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.8.1"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -28,7 +28,7 @@ packages:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -108,7 +108,7 @@ packages:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.7.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -127,7 +127,7 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -169,7 +169,7 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.19"
|
version: "0.4.2"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.2+10
|
version: 0.0.2+11
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue