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