Responsive wallet options screen
This commit is contained in:
parent
6be4a92f20
commit
44fe648f0b
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -31,8 +31,8 @@ Future<void> main() async {
|
|||
await _walletsProvider.initWalletFolder();
|
||||
appVersion = await _homeProvider.getAppVersion();
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
final HiveStore _store =
|
||||
await HiveStore.open(path: '${appPath.path}/gqlCache');
|
||||
// final HiveStore _store =
|
||||
// await HiveStore.open(path: '${appPath.path}/gqlCache');
|
||||
|
||||
// Get a valid GVA endpoint
|
||||
endPointGVA = await _homeProvider.getValidEndpoint();
|
||||
|
@ -51,7 +51,7 @@ Future<void> main() async {
|
|||
await SentryFlutter.init((options) {
|
||||
options.dsn =
|
||||
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
||||
}, appRunner: () => runApp(Gecko(endPointGVA, _store)));
|
||||
}, appRunner: () => runApp(Gecko(endPointGVA)));
|
||||
|
||||
// runZoned<Future<void>>(
|
||||
// () async {
|
||||
|
@ -68,14 +68,13 @@ Future<void> main() async {
|
|||
} else {
|
||||
print('Debug mode enabled: No sentry alerte');
|
||||
|
||||
runApp(Gecko(endPointGVA, _store));
|
||||
runApp(Gecko(endPointGVA));
|
||||
}
|
||||
}
|
||||
|
||||
class Gecko extends StatelessWidget {
|
||||
Gecko(this.randomEndpoint, this._store);
|
||||
Gecko(this.randomEndpoint);
|
||||
final String randomEndpoint;
|
||||
final HiveStore _store;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -86,7 +85,7 @@ class Gecko extends StatelessWidget {
|
|||
|
||||
final _client = ValueNotifier(
|
||||
GraphQLClient(
|
||||
cache: GraphQLCache(store: _store),
|
||||
cache: GraphQLCache(),
|
||||
link: _httpLink,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:truncate/truncate.dart';
|
||||
import 'package:qrscan/qrscan.dart' as scanner;
|
||||
|
||||
|
@ -355,6 +356,28 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
return await scanner.generateBarCode(_pubkey);
|
||||
}
|
||||
|
||||
Future defAsDefaultWallet(String _id) async {
|
||||
await defaultWalletFile.delete();
|
||||
await defaultWalletFile.create();
|
||||
await defaultWalletFile
|
||||
.writeAsString(_id)
|
||||
.then((value) => notifyListeners());
|
||||
}
|
||||
|
||||
Future changeAvatar() async {
|
||||
File _image;
|
||||
final picker = ImagePicker();
|
||||
|
||||
final pickedFile = await picker.getImage(source: ImageSource.gallery);
|
||||
|
||||
if (pickedFile != null) {
|
||||
_image = File(pickedFile.path);
|
||||
return _image;
|
||||
} else {
|
||||
print('No image selected.');
|
||||
}
|
||||
}
|
||||
|
||||
void reloadBuild() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:ui';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/history.dart';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:gecko/models/queries.dart';
|
||||
|
@ -23,6 +24,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
int derivation;
|
||||
int _nbrLinesName = 1;
|
||||
bool _isNewNameValid = false;
|
||||
bool isDefaultWallet;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -49,7 +51,12 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
_walletOptions.nameController.text.length >= 15
|
||||
? _nbrLinesName = 2
|
||||
: _nbrLinesName = 1;
|
||||
if (_walletOptions.nameController.text.length >= 26) _nbrLinesName = 3;
|
||||
if (_walletOptions.nameController.text.length >= 26 && isTall)
|
||||
_nbrLinesName = 3;
|
||||
|
||||
defaultWallet == _walletOptions.walletID
|
||||
? isDefaultWallet = true
|
||||
: isDefaultWallet = false;
|
||||
|
||||
// print(_walletOptions.generateQRcode(_walletOptions.pubkey.text));
|
||||
|
||||
|
@ -59,8 +66,9 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
Navigator.pushNamed(context, '/mywallets');
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
|
@ -73,8 +81,9 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
Navigator.pushNamed(context, '/mywallets');
|
||||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
|
@ -84,7 +93,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
Container(
|
||||
height: 15,
|
||||
height: isTall ? 15 : 0,
|
||||
color: Color(0xffFFD68E),
|
||||
),
|
||||
Container(
|
||||
|
@ -99,15 +108,25 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
)),
|
||||
child: Row(children: <Widget>[
|
||||
SizedBox(width: 25),
|
||||
Image.asset(
|
||||
'assets/chopp-gecko2.png',
|
||||
),
|
||||
Column(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/camera.png',
|
||||
),
|
||||
SizedBox(height: 100)
|
||||
]),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.changeAvatar();
|
||||
print('CHANGE AVATAR');
|
||||
},
|
||||
child: Image.asset(
|
||||
'assets/chopp-gecko2.png',
|
||||
)),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.changeAvatar();
|
||||
print('CHANGE AVATAR');
|
||||
},
|
||||
child: Column(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/camera.png',
|
||||
),
|
||||
SizedBox(height: 100)
|
||||
])),
|
||||
// SizedBox(width: 20),
|
||||
Column(children: <Widget>[
|
||||
Row(children: <Widget>[
|
||||
|
@ -129,12 +148,12 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 27,
|
||||
fontSize: isTall ? 27 : 23,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Monospace')),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
Query(
|
||||
options: QueryOptions(
|
||||
document: gql(getBalance),
|
||||
|
@ -178,11 +197,13 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
: 0),
|
||||
child: Text('$wBalanceUD',
|
||||
style: TextStyle(
|
||||
fontSize: 20, color: Colors.black)),
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black)),
|
||||
),
|
||||
Text(' DU',
|
||||
style: TextStyle(
|
||||
fontSize: 20, color: Colors.black))
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black))
|
||||
]);
|
||||
|
||||
// Text(
|
||||
|
@ -198,7 +219,9 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
_walletOptions.bluringBalance();
|
||||
},
|
||||
child: Image.asset(
|
||||
'assets/walletOptions/icon_oeuil.png',
|
||||
_walletOptions.isBalanceBlur
|
||||
? 'assets/walletOptions/icon_oeuil.png'
|
||||
: 'assets/walletOptions/icon_oeuil_close.png',
|
||||
)),
|
||||
]),
|
||||
SizedBox(width: 0),
|
||||
|
@ -254,15 +277,17 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
]),
|
||||
]),
|
||||
])),
|
||||
SizedBox(height: 4 * ratio),
|
||||
FutureBuilder(
|
||||
future: _walletOptions
|
||||
.generateQRcode(_walletOptions.pubkey.text),
|
||||
builder: (context, snapshot) {
|
||||
return snapshot.data != null
|
||||
? Image.memory(snapshot.data, height: 300)
|
||||
? Image.memory(snapshot.data,
|
||||
height: isTall ? 300 : 270)
|
||||
: Text('-', style: TextStyle(fontSize: 20));
|
||||
}),
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 15 * ratio),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
|
@ -317,7 +342,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
color: Colors.grey[50]))
|
||||
]))),
|
||||
]))),
|
||||
SizedBox(height: 10),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
_historyProvider.isPubkey(ctx, _walletOptions.pubkey.text,
|
||||
|
@ -330,27 +355,46 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
Image.asset(
|
||||
'assets/walletOptions/clock.png',
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
SizedBox(width: 12),
|
||||
Text('Historique des transactions',
|
||||
style:
|
||||
TextStyle(fontSize: 20, color: Colors.black)),
|
||||
]))),
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 12 * ratio),
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
onTap: !isDefaultWallet
|
||||
? () async {
|
||||
await _walletOptions
|
||||
.defAsDefaultWallet(_walletOptions.walletID)
|
||||
.then((value) => {
|
||||
_myWalletProvider
|
||||
.getAllWalletsNames(_currentChest),
|
||||
_myWalletProvider.rebuildWidget()
|
||||
});
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
SizedBox(width: 35),
|
||||
Image.asset(
|
||||
'assets/walletOptions/android-checkmark.png',
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text('Portefeuille par defaut',
|
||||
style:
|
||||
TextStyle(fontSize: 20, color: Colors.black)),
|
||||
SizedBox(width: 31),
|
||||
CircleAvatar(
|
||||
backgroundColor:
|
||||
Colors.grey[isDefaultWallet ? 300 : 500],
|
||||
child: Image.asset(
|
||||
'assets/walletOptions/android-checkmark.png',
|
||||
)),
|
||||
SizedBox(width: 12),
|
||||
Text(
|
||||
isDefaultWallet
|
||||
? 'Ce portefeuille est celui par defaut'
|
||||
: 'Définir comme portefeuille par défaut',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: isDefaultWallet
|
||||
? Colors.grey[500]
|
||||
: Colors.black)),
|
||||
]))),
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 17 * ratio),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.deleteWallet(
|
||||
|
@ -362,11 +406,11 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
});
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
SizedBox(width: 30),
|
||||
SizedBox(width: 33),
|
||||
Image.asset(
|
||||
'assets/walletOptions/trash.png',
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
SizedBox(width: 14),
|
||||
Text('Supprimer ce portefeuille',
|
||||
style: TextStyle(
|
||||
fontSize: 20, color: Color(0xffD80000))),
|
||||
|
|
|
@ -30,6 +30,8 @@ class WalletsHome extends StatelessWidget {
|
|||
if (myWalletProvider.listWallets != '') {
|
||||
firstWalletDerivation =
|
||||
int.parse(myWalletProvider.listWallets.split('\n')[0].split(':')[3]);
|
||||
|
||||
myWalletProvider.getDefaultWallet();
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
|
|
|
@ -295,7 +295,14 @@ packages:
|
|||
name: image_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.7.2"
|
||||
version: "0.7.3"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_for_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
image_picker_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -19,7 +19,7 @@ dependencies:
|
|||
qrscan: ^0.2.22
|
||||
permission_handler: ^6.0.1
|
||||
image_gallery_saver: ^1.6.8
|
||||
image_picker: ^0.7.2
|
||||
image_picker: ^0.7.3
|
||||
# graphql_flutter: ^4.0.1 #^3.1.0
|
||||
graphql_flutter: ^5.0.0-nullsafety.1
|
||||
provider: ^4.3.2+3
|
||||
|
|
Loading…
Reference in New Issue