Fix a few bugs
This commit is contained in:
parent
8f0018e326
commit
46bfb61391
|
@ -65,6 +65,8 @@ Future<void> main() async {
|
|||
configBox = await Hive.openBox("configBox");
|
||||
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
|
||||
|
||||
g1WalletsBox.clear();
|
||||
|
||||
// final HiveStore _store =
|
||||
// await HiveStore.open(path: '${appPath.path}/gqlCache');
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
Future<String> getName(String _pubkey) async {
|
||||
String _name;
|
||||
|
||||
if (g1WalletsBox.get(_pubkey).csName != null) {
|
||||
return g1WalletsBox.get(_pubkey).csName;
|
||||
}
|
||||
|
||||
List queryOptions = await _buildQuery(_pubkey);
|
||||
final response = await http.post((Uri.parse(queryOptions[0])),
|
||||
body: queryOptions[1], headers: queryOptions[2]);
|
||||
|
@ -75,6 +79,8 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
}
|
||||
_name = responseJson['hits']['hits'][0]['_source']['title'];
|
||||
|
||||
g1WalletsBox.get(_pubkey).csName = _name;
|
||||
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
@ -83,6 +89,8 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
return g1WalletsBox.get(_pubkey).avatar;
|
||||
}
|
||||
|
||||
log.d(_pubkey);
|
||||
|
||||
List queryOptions = await _buildQuery(_pubkey);
|
||||
|
||||
http.Response response;
|
||||
|
@ -106,10 +114,14 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
File('${(await getTemporaryDirectory()).path}/avatar_$_pubkey.png');
|
||||
await avatarFile.writeAsBytes(base64.decode(_avatar));
|
||||
|
||||
return Image.file(
|
||||
final finalAvatar = Image.file(
|
||||
avatarFile,
|
||||
height: size,
|
||||
fit: BoxFit.fitWidth,
|
||||
);
|
||||
|
||||
g1WalletsBox.get(_pubkey).avatar = finalAvatar;
|
||||
|
||||
return finalAvatar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,24 @@ class G1WalletsList {
|
|||
@HiveField(4)
|
||||
Image avatar;
|
||||
|
||||
G1WalletsList({this.pubkey, this.balance, this.id, this.avatar});
|
||||
@HiveField(5)
|
||||
String username;
|
||||
|
||||
@HiveField(6)
|
||||
String csName;
|
||||
|
||||
@HiveField(7)
|
||||
bool isMembre;
|
||||
|
||||
G1WalletsList({
|
||||
this.pubkey,
|
||||
this.balance,
|
||||
this.id,
|
||||
this.avatar,
|
||||
this.username,
|
||||
this.csName,
|
||||
this.isMembre,
|
||||
});
|
||||
|
||||
G1WalletsList.fromJson(Map<String, dynamic> json) {
|
||||
pubkey = json['pubkey'];
|
||||
|
|
|
@ -23,13 +23,16 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
|
|||
balance: fields[1] as double,
|
||||
id: fields[3] as Id,
|
||||
avatar: fields[4] as Image,
|
||||
username: fields[5] as String,
|
||||
csName: fields[6] as String,
|
||||
isMembre: fields[7] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, G1WalletsList obj) {
|
||||
writer
|
||||
..writeByte(4)
|
||||
..writeByte(7)
|
||||
..writeByte(0)
|
||||
..write(obj.pubkey)
|
||||
..writeByte(1)
|
||||
|
@ -37,7 +40,13 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
|
|||
..writeByte(3)
|
||||
..write(obj.id)
|
||||
..writeByte(4)
|
||||
..write(obj.avatar);
|
||||
..write(obj.avatar)
|
||||
..writeByte(5)
|
||||
..write(obj.username)
|
||||
..writeByte(6)
|
||||
..write(obj.csName)
|
||||
..writeByte(7)
|
||||
..write(obj.isMembre);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:dubp/dubp.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -16,7 +14,6 @@ import 'package:intl/intl.dart';
|
|||
import 'package:truncate/truncate.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:fast_base58/fast_base58.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class WalletsProfilesProvider with ChangeNotifier {
|
||||
WalletsProfilesProvider(this.pubkey);
|
||||
|
@ -32,6 +29,7 @@ class WalletsProfilesProvider with ChangeNotifier {
|
|||
String rawSvg;
|
||||
TextEditingController payAmount = TextEditingController();
|
||||
TextEditingController payComment = TextEditingController();
|
||||
num balance;
|
||||
|
||||
Future scan(context) async {
|
||||
await Permission.camera.request();
|
||||
|
@ -47,7 +45,7 @@ class WalletsProfilesProvider with ChangeNotifier {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
return WalletViewScreen(pubkey: pubkey);
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
|
@ -258,17 +256,24 @@ class WalletsProfilesProvider with ChangeNotifier {
|
|||
return Jdenticon.toSvg(_pubkey);
|
||||
}
|
||||
|
||||
Future<num> getBalance(String _pubkey) async {
|
||||
num balance;
|
||||
final url = Uri.parse(
|
||||
'$endPointGVA?query={%20balance(script:%20%22$_pubkey%22)%20{%20amount%20base%20}%20}');
|
||||
final response = await http.get(url);
|
||||
final result = json.decode(response.body);
|
||||
// Future<num> getBalance(String _pubkey) async {
|
||||
// final url = Uri.parse(
|
||||
// '$endPointGVA?query={%20balance(script:%20%22$_pubkey%22)%20{%20amount%20base%20}%20}');
|
||||
// final response = await http.get(url);
|
||||
// final result = json.decode(response.body);
|
||||
|
||||
if (result['data']['balance'] == null) {
|
||||
balance = 0.0;
|
||||
} else {
|
||||
balance = removeDecimalZero(result['data']['balance']['amount'] / 100);
|
||||
// if (result['data']['balance'] == null) {
|
||||
// balance = 0.0;
|
||||
// } else {
|
||||
// balance = removeDecimalZero(result['data']['balance']['amount'] / 100);
|
||||
// }
|
||||
|
||||
// return balance;
|
||||
// }
|
||||
|
||||
Future<num> getBalance(String _pubkey) async {
|
||||
while (balance == null) {
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
}
|
||||
|
||||
return balance;
|
||||
|
|
|
@ -42,7 +42,10 @@ class AvatarFullscreen extends StatelessWidget {
|
|||
// alignment: Alignment.center,
|
||||
// height: MediaQuery.of(context).size.height,
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
child: avatar,
|
||||
child: Image(
|
||||
image: avatar.image,
|
||||
height: avatar.height,
|
||||
fit: BoxFit.fitWidth),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -12,7 +12,6 @@ import 'dart:ui';
|
|||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||
|
@ -37,9 +36,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
CesiumPlusProvider _cesiumPlusProvider =
|
||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||
log.i('Build pubkey : ' + _historyProvider.pubkey);
|
||||
log.i('Build pubkey : ' + pubkey);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {});
|
||||
|
||||
_historyProvider.balance = _historyProvider.transBC = null;
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
|
@ -52,8 +53,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
),
|
||||
body: Column(children: <Widget>[
|
||||
headerProfileView(context, _historyProvider, _cesiumPlusProvider),
|
||||
if (_historyProvider.pubkey != '')
|
||||
historyQuery(context, _historyProvider, _cesiumPlusProvider),
|
||||
historyQuery(context, _historyProvider, _cesiumPlusProvider),
|
||||
]));
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
CesiumPlusProvider _cesiumPlusProvider) {
|
||||
WalletsProfilesProvider _historyProvider =
|
||||
Provider.of<WalletsProfilesProvider>(context, listen: true);
|
||||
RefreshController _refreshController =
|
||||
RefreshController(initialRefresh: false);
|
||||
return Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
|
@ -72,12 +70,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
options: QueryOptions(
|
||||
document: gql(getHistory),
|
||||
variables: <String, dynamic>{
|
||||
'pubkey': _historyProvider.pubkey,
|
||||
'pubkey': pubkey,
|
||||
'number': nRepositories,
|
||||
'cursor': null
|
||||
},
|
||||
),
|
||||
builder: (QueryResult result, {fetchMore, refetch}) {
|
||||
// log.d(result.data);
|
||||
|
||||
if (result.isLoading && result.data == null) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
|
@ -90,13 +90,24 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
SizedBox(height: 50),
|
||||
Text(
|
||||
"Aucun noeud GVA valide n'a pu être trouvé.\nVeuillez réessayer ultérieurement.",
|
||||
style: TextStyle(fontSize: 17.0),
|
||||
style: TextStyle(fontSize: 18),
|
||||
)
|
||||
]);
|
||||
} else if (result.data == null) {
|
||||
return Column(children: const <Widget>[
|
||||
SizedBox(height: 50),
|
||||
Text(
|
||||
"Aucune donnée à afficher.",
|
||||
style: TextStyle(fontSize: 18),
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
if (result.data == null && result.exception.toString() == null) {
|
||||
return const Text('Aucune donnée à afficher.');
|
||||
if (result.data['balance'] == null) {
|
||||
_historyProvider.balance = 0.0;
|
||||
} else {
|
||||
_historyProvider.balance = _historyProvider
|
||||
.removeDecimalZero(result.data['balance']['amount'] / 100);
|
||||
}
|
||||
|
||||
opts = _historyProvider.checkQueryResult(result, opts, pubkey);
|
||||
|
@ -105,25 +116,18 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
return NotificationListener(
|
||||
child: Builder(
|
||||
builder: (context) => Expanded(
|
||||
child: SmartRefresher(
|
||||
enablePullUp: false,
|
||||
controller: _refreshController,
|
||||
onRefresh: () {
|
||||
_historyProvider.resetdHistory();
|
||||
_refreshController.refreshCompleted();
|
||||
},
|
||||
child: ListView(
|
||||
key: const Key('listTransactions'),
|
||||
controller: scrollController,
|
||||
children: <Widget>[historyView(context, result)],
|
||||
),
|
||||
child: ListView(
|
||||
key: const Key('listTransactions'),
|
||||
controller: scrollController,
|
||||
children: <Widget>[historyView(context, result)],
|
||||
),
|
||||
),
|
||||
),
|
||||
onNotification: (t) {
|
||||
if (t is ScrollEndNotification &&
|
||||
scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent * 0.7) {
|
||||
scrollController.position.maxScrollExtent * 0.7 &&
|
||||
_historyProvider.pageInfo['hasPreviousPage']) {
|
||||
fetchMore(opts);
|
||||
}
|
||||
return true;
|
||||
|
@ -139,48 +143,15 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
|
||||
return _historyProvider.transBC == null
|
||||
? const Text('Aucune transaction à afficher.')
|
||||
? Column(children: const <Widget>[
|
||||
SizedBox(height: 50),
|
||||
Text(
|
||||
"Aucune transaction à afficher.",
|
||||
style: TextStyle(fontSize: 18),
|
||||
)
|
||||
])
|
||||
: Column(children: <Widget>[
|
||||
getTransactionTile(context, _historyProvider),
|
||||
// for (var repository in _historyProvider.transBC)
|
||||
// if (repository[1].toString().split(' ')[0] == '22-11-21')
|
||||
// const Text("Aujourd'hui"),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
// child: ListTile(
|
||||
// key: Key('transaction${keyID++}'),
|
||||
// contentPadding: const EdgeInsets.all(5.0),
|
||||
// leading: Text(repository[1],
|
||||
// style: TextStyle(
|
||||
// fontSize: 12,
|
||||
// color: Colors.grey[800],
|
||||
// fontWeight: FontWeight.w700),
|
||||
// textAlign: TextAlign.center),
|
||||
// title: Text(repository[3],
|
||||
// style: const TextStyle(
|
||||
// fontSize: 15.0, fontFamily: 'Monospace'),
|
||||
// textAlign: TextAlign.center),
|
||||
// subtitle: Text(repository[6] != '' ? repository[6] : '-',
|
||||
// style: const TextStyle(fontSize: 12.0),
|
||||
// textAlign: TextAlign.center),
|
||||
// trailing: Text("${repository[4]} Ğ1",
|
||||
// style: const TextStyle(fontSize: 14.0),
|
||||
// textAlign: TextAlign.justify),
|
||||
// dense: true,
|
||||
// isThreeLine: false,
|
||||
// onTap: () {
|
||||
// if (_historyProvider.isPubkey(context, repository[2])) {
|
||||
// _homeProvider.currentIndex = 0;
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return const WalletViewScreen();
|
||||
// }),
|
||||
// );
|
||||
// }
|
||||
// Navigator.pop(context);
|
||||
// }),
|
||||
// ),
|
||||
if (result.isLoading &&
|
||||
_historyProvider.pageInfo['hasPreviousPage'])
|
||||
Row(
|
||||
|
@ -189,7 +160,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
CircularProgressIndicator(),
|
||||
],
|
||||
),
|
||||
// if (_historyProvider.isTheEnd) // What I did before ...
|
||||
if (!_historyProvider.pageInfo['hasPreviousPage'])
|
||||
Column(
|
||||
children: const <Widget>[
|
||||
|
@ -214,6 +184,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
String lastDateDelimiter;
|
||||
const double _avatarSize = 200;
|
||||
|
||||
bool isTody = false;
|
||||
bool isYesterday = false;
|
||||
bool isThisWeek = false;
|
||||
|
||||
const Map<int, String> monthsInYear = {
|
||||
1: "Janvier",
|
||||
2: "Février",
|
||||
|
@ -242,7 +216,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
} else {
|
||||
dateForm = "${date.day} ${monthsInYear[date.month]}";
|
||||
}
|
||||
log.d(dateForm);
|
||||
|
||||
int weekNumber(DateTime date) {
|
||||
int dayOfYear = int.parse(DateFormat("D").format(date));
|
||||
|
@ -250,17 +223,30 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
}
|
||||
|
||||
if (DateTime(date.year, date.month, date.day) ==
|
||||
DateTime(now.year, now.month, now.day)) {
|
||||
DateTime(now.year, now.month, now.day) &&
|
||||
!isTody) {
|
||||
dateDelimiter = lastDateDelimiter = "Aujourd'hui";
|
||||
isTody = true;
|
||||
} else if (DateTime(date.year, date.month, date.day) ==
|
||||
DateTime(now.year, now.month, now.day - 1)) {
|
||||
DateTime(now.year, now.month, now.day - 1) &&
|
||||
!isYesterday) {
|
||||
dateDelimiter = lastDateDelimiter = "Hier";
|
||||
isYesterday = true;
|
||||
} else if (weekNumber(date) == weekNumber(now) &&
|
||||
date.year == now.year &&
|
||||
lastDateDelimiter != "Cette semaine") {
|
||||
lastDateDelimiter != "Cette semaine" &&
|
||||
DateTime(date.year, date.month, date.day) !=
|
||||
DateTime(now.year, now.month, now.day - 1) &&
|
||||
!isThisWeek) {
|
||||
dateDelimiter = lastDateDelimiter = "Cette semaine";
|
||||
isThisWeek = true;
|
||||
} else if (lastDateDelimiter != monthsInYear[date.month] &&
|
||||
lastDateDelimiter != "${monthsInYear[date.month]} ${date.year}") {
|
||||
lastDateDelimiter != "${monthsInYear[date.month]} ${date.year}" &&
|
||||
DateTime(date.year, date.month, date.day) !=
|
||||
DateTime(now.year, now.month, now.day) &&
|
||||
DateTime(date.year, date.month, date.day) !=
|
||||
DateTime(now.year, now.month, now.day - 1) &&
|
||||
!(weekNumber(date) == weekNumber(now) && date.year == now.year)) {
|
||||
if (date.year == now.year) {
|
||||
dateDelimiter = lastDateDelimiter = monthsInYear[date.month];
|
||||
} else {
|
||||
|
@ -377,11 +363,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
return WalletViewScreen(pubkey: repository[2]);
|
||||
}),
|
||||
);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
// Navigator.pop(context);
|
||||
}),
|
||||
),
|
||||
]);
|
||||
|
@ -422,13 +408,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: pubkey ?? _historyProvider.pubkey));
|
||||
Clipboard.setData(ClipboardData(text: pubkey));
|
||||
_historyProvider.snackCopyKey(context);
|
||||
},
|
||||
child: Text(
|
||||
_historyProvider.getShortPubkey(
|
||||
pubkey ?? _historyProvider.pubkey),
|
||||
_historyProvider.getShortPubkey(pubkey),
|
||||
style: const TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w800,
|
||||
|
@ -442,7 +426,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
options: QueryOptions(
|
||||
document: gql(getId),
|
||||
variables: {
|
||||
'pubkey': _historyProvider.pubkey,
|
||||
'pubkey': pubkey,
|
||||
},
|
||||
),
|
||||
builder: (QueryResult result,
|
||||
|
@ -467,11 +451,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
},
|
||||
),
|
||||
if (username != null)
|
||||
Text(
|
||||
username,
|
||||
style: const TextStyle(
|
||||
fontSize: 27,
|
||||
color: Color(0xff814C00),
|
||||
SizedBox(
|
||||
width: 230,
|
||||
child: Text(
|
||||
username,
|
||||
style: const TextStyle(
|
||||
fontSize: 27,
|
||||
color: Color(0xff814C00),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
|
@ -497,24 +484,22 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Column(children: <Widget>[
|
||||
if (avatar == null)
|
||||
FutureBuilder(
|
||||
future: _cesiumPlusProvider.getAvatar(
|
||||
_historyProvider.pubkey, _avatarSize),
|
||||
future: _cesiumPlusProvider.getAvatar(pubkey, _avatarSize),
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<Image> _avatar) {
|
||||
if (_avatar.connectionState != ConnectionState.done ||
|
||||
_avatar.hasError) {
|
||||
if (_avatar.connectionState != ConnectionState.done) {
|
||||
return Stack(children: [
|
||||
ClipOval(
|
||||
child:
|
||||
_cesiumPlusProvider.defaultAvatar(_avatarSize),
|
||||
),
|
||||
Positioned(
|
||||
top: 16.5,
|
||||
right: 47.5,
|
||||
width: 55,
|
||||
height: 55,
|
||||
top: 15,
|
||||
right: 45,
|
||||
width: 51,
|
||||
height: 51,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 6,
|
||||
strokeWidth: 5,
|
||||
color: orangeC,
|
||||
),
|
||||
),
|
||||
|
@ -532,7 +517,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
);
|
||||
},
|
||||
child: ClipOval(
|
||||
child: _avatar.data,
|
||||
child: Image(
|
||||
image: _avatar.data.image,
|
||||
height: _avatarSize,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import 'package:gecko/models/wallets_profiles.dart';
|
|||
import 'package:gecko/models/my_wallets.dart';
|
||||
import 'package:gecko/models/queries.dart';
|
||||
import 'package:gecko/models/wallet_options.dart';
|
||||
import 'package:gecko/screens/history.dart';
|
||||
import 'package:gecko/screens/myWallets/change_pin.dart';
|
||||
import 'package:gecko/screens/wallet_view.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -18,352 +18,406 @@ import 'package:flutter/services.dart';
|
|||
int _nbrLinesName = 1;
|
||||
bool _isNewNameValid = false;
|
||||
|
||||
Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet,
|
||||
MyWalletsProvider _myWalletProvider) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
ChestProvider _chestProvider =
|
||||
Provider.of<ChestProvider>(context, listen: false);
|
||||
WalletsProfilesProvider _historyProvider =
|
||||
Provider.of<WalletsProfilesProvider>(context);
|
||||
class CesiumWalletOptions extends StatelessWidget {
|
||||
const CesiumWalletOptions(
|
||||
{Key key, Key keyMyWallets, @required this.cesiumWallet})
|
||||
: super(key: key);
|
||||
|
||||
final String shortPubkey =
|
||||
_walletOptions.getShortPubkey(_walletOptions.pubkey.text);
|
||||
final ChestData cesiumWallet;
|
||||
|
||||
if (_walletOptions.nameController.text == null || _isNewNameValid == false) {
|
||||
_walletOptions.nameController.text = cesiumWallet.name;
|
||||
} else {
|
||||
cesiumWallet.name = _walletOptions.nameController.text;
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
ChestProvider _chestProvider =
|
||||
Provider.of<ChestProvider>(context, listen: false);
|
||||
WalletsProfilesProvider _historyProvider =
|
||||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||
|
||||
_walletOptions.nameController.text.length >= 15
|
||||
? _nbrLinesName = 2
|
||||
: _nbrLinesName = 1;
|
||||
if (_walletOptions.nameController.text.length >= 26 && isTall) {
|
||||
_nbrLinesName = 3;
|
||||
}
|
||||
final String shortPubkey =
|
||||
_walletOptions.getShortPubkey(_walletOptions.pubkey.text);
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Builder(
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
Container(
|
||||
height: isTall ? 30 : 15,
|
||||
color: yellowC,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
yellowC,
|
||||
const Color(0xfffafafa),
|
||||
],
|
||||
)),
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 25),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
cesiumWallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
},
|
||||
child: cesiumWallet.imageFile == null
|
||||
? Image.asset(
|
||||
'assets/chests/${cesiumWallet.imageName}',
|
||||
width: 110,
|
||||
)
|
||||
: Image.file(cesiumWallet.imageFile, width: 110),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
cesiumWallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
},
|
||||
child: Column(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/camera.png',
|
||||
height: 40,
|
||||
),
|
||||
const SizedBox(height: 80)
|
||||
])),
|
||||
Column(children: <Widget>[
|
||||
Row(children: <Widget>[
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: TextField(
|
||||
key: const Key('walletName'),
|
||||
autofocus: false,
|
||||
focusNode: _walletOptions.walletNameFocus,
|
||||
enabled: _walletOptions.isEditing,
|
||||
controller: _walletOptions.nameController,
|
||||
maxLines: _nbrLinesName,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 27 : 23,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Monospace')),
|
||||
),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
Query(
|
||||
options: QueryOptions(
|
||||
document: gql(getBalance),
|
||||
variables: {
|
||||
'pubkey': _walletOptions.pubkey.text,
|
||||
},
|
||||
// pollInterval: Duration(seconds: 1),
|
||||
),
|
||||
builder: (QueryResult result,
|
||||
{VoidCallback refetch, FetchMore fetchMore}) {
|
||||
if (result.hasException) {
|
||||
return Text(result.exception.toString());
|
||||
}
|
||||
if (_walletOptions.nameController.text == null ||
|
||||
_isNewNameValid == false) {
|
||||
_walletOptions.nameController.text = cesiumWallet.name;
|
||||
} else {
|
||||
cesiumWallet.name = _walletOptions.nameController.text;
|
||||
}
|
||||
|
||||
if (result.isLoading) {
|
||||
return const Text('Loading');
|
||||
}
|
||||
_walletOptions.nameController.text.length >= 15
|
||||
? _nbrLinesName = 2
|
||||
: _nbrLinesName = 1;
|
||||
if (_walletOptions.nameController.text.length >= 26 && isTall) {
|
||||
_nbrLinesName = 3;
|
||||
}
|
||||
|
||||
// List repositories = result.data['viewer']['repositories']['nodes'];
|
||||
String wBalanceUD;
|
||||
if (result.data['balance'] == null) {
|
||||
wBalanceUD = '0.0';
|
||||
} else {
|
||||
int wBalanceG1 = result.data['balance']['amount'];
|
||||
int currentUD = result.data['currentUd']['amount'];
|
||||
double wBalanceUDBrut =
|
||||
wBalanceG1 / currentUD; // .toString();
|
||||
wBalanceUD = double.parse(
|
||||
(wBalanceUDBrut).toStringAsFixed(2))
|
||||
.toString();
|
||||
}
|
||||
return Row(children: <Widget>[
|
||||
ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(
|
||||
sigmaX: _walletOptions.isBalanceBlur ? 6 : 0,
|
||||
sigmaY: _walletOptions.isBalanceBlur ? 5 : 0),
|
||||
child: Text(wBalanceUD,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black)),
|
||||
),
|
||||
Text(' DU',
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black))
|
||||
]);
|
||||
|
||||
// Text(
|
||||
// '$wBalanceUD DU',
|
||||
// style: TextStyle(
|
||||
// fontSize: 20, color: Colors.black),
|
||||
// );
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
InkWell(
|
||||
key: const Key('displayBalance'),
|
||||
onTap: () {
|
||||
_walletOptions.bluringBalance();
|
||||
},
|
||||
child: Image.asset(
|
||||
_walletOptions.isBalanceBlur
|
||||
? 'assets/walletOptions/icon_oeuil.png'
|
||||
: 'assets/walletOptions/icon_oeuil_close.png',
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(width: 0),
|
||||
Column(children: <Widget>[
|
||||
InkWell(
|
||||
key: const Key('renameWallet'),
|
||||
onTap: () async {
|
||||
_isNewNameValid = _walletOptions.editWalletName(
|
||||
[cesiumWallet.key, 0],
|
||||
isCesium: cesiumWallet.isCesium);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 30));
|
||||
_walletOptions.walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
_walletOptions.isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 20,
|
||||
height: 20),
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 60,
|
||||
)
|
||||
])
|
||||
]),
|
||||
]),
|
||||
])),
|
||||
SizedBox(height: 4 * ratio),
|
||||
FutureBuilder(
|
||||
future: _walletOptions.generateQRcode(_walletOptions.pubkey.text),
|
||||
builder: (context, snapshot) {
|
||||
return snapshot.data != null
|
||||
? Image.memory(snapshot.data, height: isTall ? 300 : 270)
|
||||
: const Text('-', style: TextStyle(fontSize: 20));
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
_walletOptions.isEditing = false;
|
||||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 60 * ratio,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_walletOptions.isEditing = false;
|
||||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 15 * ratio),
|
||||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: SizedBox(
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return Text(_walletOptions.nameController.text);
|
||||
}),
|
||||
),
|
||||
),
|
||||
body: Builder(
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
yellowC,
|
||||
const Color(0xfffafafa),
|
||||
],
|
||||
)),
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 25),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
cesiumWallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
},
|
||||
child: cesiumWallet.imageFile == null
|
||||
? Image.asset(
|
||||
'assets/chests/${cesiumWallet.imageName}',
|
||||
width: 110,
|
||||
)
|
||||
: Image.file(cesiumWallet.imageFile, width: 110),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
cesiumWallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
},
|
||||
child: Column(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/camera.png',
|
||||
height: 40,
|
||||
),
|
||||
const SizedBox(height: 80)
|
||||
])),
|
||||
Column(children: <Widget>[
|
||||
Row(children: <Widget>[
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: TextField(
|
||||
key: const Key('walletName'),
|
||||
autofocus: false,
|
||||
focusNode: _walletOptions.walletNameFocus,
|
||||
enabled: _walletOptions.isEditing,
|
||||
controller: _walletOptions.nameController,
|
||||
maxLines: _nbrLinesName,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 27 : 23,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Monospace')),
|
||||
),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
Query(
|
||||
options: QueryOptions(
|
||||
document: gql(getBalance),
|
||||
variables: {
|
||||
'pubkey': _walletOptions.pubkey.text,
|
||||
},
|
||||
// pollInterval: Duration(seconds: 1),
|
||||
),
|
||||
builder: (QueryResult result,
|
||||
{VoidCallback refetch, FetchMore fetchMore}) {
|
||||
if (result.hasException) {
|
||||
return Text(result.exception.toString());
|
||||
}
|
||||
|
||||
if (result.isLoading) {
|
||||
return const Text('Loading');
|
||||
}
|
||||
|
||||
// List repositories = result.data['viewer']['repositories']['nodes'];
|
||||
String wBalanceUD;
|
||||
if (result.data['balance'] == null) {
|
||||
wBalanceUD = '0.0';
|
||||
} else {
|
||||
int wBalanceG1 =
|
||||
result.data['balance']['amount'];
|
||||
int currentUD =
|
||||
result.data['currentUd']['amount'];
|
||||
double wBalanceUDBrut =
|
||||
wBalanceG1 / currentUD; // .toString();
|
||||
wBalanceUD = double.parse(
|
||||
(wBalanceUDBrut).toStringAsFixed(2))
|
||||
.toString();
|
||||
}
|
||||
return Row(children: <Widget>[
|
||||
ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(
|
||||
sigmaX:
|
||||
_walletOptions.isBalanceBlur ? 6 : 0,
|
||||
sigmaY:
|
||||
_walletOptions.isBalanceBlur ? 5 : 0),
|
||||
child: Text(wBalanceUD,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black)),
|
||||
),
|
||||
Text(' DU',
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black))
|
||||
]);
|
||||
|
||||
// Text(
|
||||
// '$wBalanceUD DU',
|
||||
// style: TextStyle(
|
||||
// fontSize: 20, color: Colors.black),
|
||||
// );
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
InkWell(
|
||||
key: const Key('displayBalance'),
|
||||
onTap: () {
|
||||
_walletOptions.bluringBalance();
|
||||
},
|
||||
child: Image.asset(
|
||||
_walletOptions.isBalanceBlur
|
||||
? 'assets/walletOptions/icon_oeuil.png'
|
||||
: 'assets/walletOptions/icon_oeuil_close.png',
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(width: 0),
|
||||
Column(children: <Widget>[
|
||||
InkWell(
|
||||
key: const Key('renameWallet'),
|
||||
onTap: () async {
|
||||
_isNewNameValid = _walletOptions.editWalletName(
|
||||
[cesiumWallet.key, 0],
|
||||
isCesium: cesiumWallet.isCesium);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 30));
|
||||
_walletOptions.walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
_walletOptions.isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 20,
|
||||
height: 20),
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 60,
|
||||
)
|
||||
])
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 4 * ratio),
|
||||
FutureBuilder(
|
||||
future:
|
||||
_walletOptions.generateQRcode(_walletOptions.pubkey.text),
|
||||
builder: (context, snapshot) {
|
||||
return snapshot.data != null
|
||||
? Image.memory(snapshot.data,
|
||||
height: isTall ? 300 : 270)
|
||||
: const Text('-', style: TextStyle(fontSize: 20));
|
||||
}),
|
||||
SizedBox(height: 15 * ratio),
|
||||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/key.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Text("${shortPubkey.split(':')[0]}:",
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace',
|
||||
color: Colors.black)),
|
||||
Text(shortPubkey.split(':')[1],
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace')),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
elevation: 1,
|
||||
primary: orangeC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/copy-white.png',
|
||||
height: 25,
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text('Copier',
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.grey[50]))
|
||||
]))),
|
||||
]))),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
key: const Key('displayHistory'),
|
||||
onTap: () {
|
||||
if (_historyProvider.isPubkey(
|
||||
context, _walletOptions.pubkey.text)) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return HistoryScreen(
|
||||
pubkey: _walletOptions.pubkey.text);
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/clock.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
const Text('Historique des transactions',
|
||||
style:
|
||||
TextStyle(fontSize: 20, color: Colors.black)),
|
||||
]))),
|
||||
SizedBox(height: 7 * ratio),
|
||||
InkWell(
|
||||
key: const Key('changePin'),
|
||||
onTap: () async {
|
||||
// await _chestProvider.changePin(context, cesiumWallet);
|
||||
String newPin = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ChangePinScreen(
|
||||
walletName: cesiumWallet.name,
|
||||
walletProvider: _myWalletProvider,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (newPin != null) _myWalletProvider.pinCode = newPin;
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
const SizedBox(width: 31),
|
||||
Image.asset(
|
||||
'assets/walletOptions/key.png',
|
||||
height: 45,
|
||||
'assets/chests/secret_code.png',
|
||||
height: 24,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Text("${shortPubkey.split(':')[0]}:",
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace',
|
||||
color: Colors.black)),
|
||||
Text(shortPubkey.split(':')[1],
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace')),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
elevation: 1,
|
||||
primary: orangeC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/copy-white.png',
|
||||
height: 25,
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text('Copier',
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.grey[50]))
|
||||
]))),
|
||||
]))),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
key: const Key('displayHistory'),
|
||||
onTap: () {
|
||||
if (_historyProvider.isPubkey(
|
||||
context, _walletOptions.pubkey.text)) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
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>[
|
||||
const SizedBox(width: 30),
|
||||
const SizedBox(width: 33),
|
||||
Image.asset(
|
||||
'assets/walletOptions/clock.png',
|
||||
'assets/walletOptions/trash.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
const Text('Historique des transactions',
|
||||
style: TextStyle(fontSize: 20, color: Colors.black)),
|
||||
]))),
|
||||
SizedBox(height: 7 * ratio),
|
||||
InkWell(
|
||||
key: const Key('changePin'),
|
||||
onTap: () async {
|
||||
// await _chestProvider.changePin(context, cesiumWallet);
|
||||
_myWalletProvider.pinCode = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ChangePinScreen(
|
||||
walletName: cesiumWallet.name,
|
||||
walletProvider: _myWalletProvider,
|
||||
);
|
||||
},
|
||||
const SizedBox(width: 21),
|
||||
const Text(
|
||||
'Supprimer ce coffre',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Color(0xffD80000),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 31),
|
||||
Image.asset(
|
||||
'assets/chests/secret_code.png',
|
||||
height: 24,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
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>[
|
||||
const SizedBox(width: 33),
|
||||
Image.asset(
|
||||
'assets/walletOptions/trash.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 21),
|
||||
const Text(
|
||||
'Supprimer ce coffre',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Color(0xffD80000),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:gecko/models/my_wallets.dart';
|
|||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/models/wallet_options.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/screens/myWallets/cesium_wallet_options.dart';
|
||||
import 'package:gecko/screens/myWallets/choose_chest.dart';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -86,7 +87,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
fontWeight: FontWeight.w400),
|
||||
)),
|
||||
SizedBox(height: 40 * ratio),
|
||||
pinForm(context, _pinLenght),
|
||||
pinForm(context, _pinLenght, currentChest),
|
||||
SizedBox(height: 3 * ratio),
|
||||
InkWell(
|
||||
key: const Key('chooseChest'),
|
||||
|
@ -114,7 +115,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
));
|
||||
}
|
||||
|
||||
Widget pinForm(context, _pinLenght) {
|
||||
Widget pinForm(context, _pinLenght, ChestData currentChest) {
|
||||
// var _walletPin = '';
|
||||
// ignore: close_sinks
|
||||
StreamController<ErrorAnimationType> errorController =
|
||||
|
@ -194,7 +195,16 @@ class UnlockingWallet extends StatelessWidget {
|
|||
pinColor = Colors.green[400];
|
||||
// await Future.delayed(Duration(milliseconds: 50));
|
||||
if (action == "mywallets") {
|
||||
Navigator.pushNamed(formKey.currentContext, '/mywallets');
|
||||
currentChest.isCesium
|
||||
? Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return CesiumWalletOptions(
|
||||
cesiumWallet: currentChest);
|
||||
}),
|
||||
)
|
||||
: Navigator.pushNamed(
|
||||
formKey.currentContext, '/mywallets');
|
||||
} else if (action == "pay") {
|
||||
resultPay =
|
||||
await _historyProvider.pay(context, _pin.toUpperCase());
|
||||
|
|
|
@ -3,12 +3,11 @@ import 'dart:ui';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/wallets_profiles.dart';
|
||||
import 'package:gecko/models/my_wallets.dart';
|
||||
import 'package:gecko/models/queries.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/models/wallet_options.dart';
|
||||
import 'package:gecko/screens/wallet_view.dart';
|
||||
import 'package:gecko/screens/history.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -25,11 +24,10 @@ class WalletOptions extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
WalletsProfilesProvider _historyProvider =
|
||||
Provider.of<WalletsProfilesProvider>(context);
|
||||
|
||||
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||
final String shortPubkey =
|
||||
|
@ -71,29 +69,36 @@ class WalletOptions extends StatelessWidget {
|
|||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 60 * ratio,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_walletOptions.isEditing = false;
|
||||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Text(_walletOptions.nameController.text),
|
||||
)),
|
||||
toolbarHeight: 60 * ratio,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_walletOptions.isEditing = false;
|
||||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return Text(_walletOptions.nameController.text);
|
||||
}),
|
||||
),
|
||||
),
|
||||
body: Builder(
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
Container(
|
||||
height: isTall ? 15 : 0,
|
||||
height: isTall ? 5 : 0,
|
||||
color: yellowC,
|
||||
),
|
||||
Container(
|
||||
Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
|
@ -106,29 +111,30 @@ class WalletOptions extends StatelessWidget {
|
|||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 25),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
wallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
},
|
||||
child: wallet.imageFile == null
|
||||
? Image.asset(
|
||||
'assets/avatars/${wallet.imageName}',
|
||||
width: 110,
|
||||
)
|
||||
: Image.file(
|
||||
wallet.imageFile,
|
||||
width: 110,
|
||||
)),
|
||||
onTap: () async {
|
||||
File newAvatar = await walletProvider.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
wallet.imageFile = newAvatar;
|
||||
}
|
||||
walletProvider.reloadBuild();
|
||||
},
|
||||
child: wallet.imageFile == null
|
||||
? Image.asset(
|
||||
'assets/avatars/${wallet.imageName}',
|
||||
width: 110,
|
||||
)
|
||||
: Image.file(
|
||||
wallet.imageFile,
|
||||
width: 110,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
File newAvatar = await _walletOptions.changeAvatar();
|
||||
File newAvatar = await walletProvider.changeAvatar();
|
||||
if (newAvatar != null) {
|
||||
wallet.imageFile = newAvatar;
|
||||
}
|
||||
_walletOptions.reloadBuild();
|
||||
walletProvider.reloadBuild();
|
||||
},
|
||||
child: Column(children: <Widget>[
|
||||
Image.asset(
|
||||
|
@ -145,9 +151,9 @@ class WalletOptions extends StatelessWidget {
|
|||
child: TextField(
|
||||
key: const Key('walletName'),
|
||||
autofocus: false,
|
||||
focusNode: _walletOptions.walletNameFocus,
|
||||
enabled: _walletOptions.isEditing,
|
||||
controller: _walletOptions.nameController,
|
||||
focusNode: walletProvider.walletNameFocus,
|
||||
enabled: walletProvider.isEditing,
|
||||
controller: walletProvider.nameController,
|
||||
maxLines: _nbrLinesName,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
|
@ -168,7 +174,7 @@ class WalletOptions extends StatelessWidget {
|
|||
options: QueryOptions(
|
||||
document: gql(getBalance),
|
||||
variables: {
|
||||
'pubkey': _walletOptions.pubkey.text,
|
||||
'pubkey': walletProvider.pubkey.text,
|
||||
},
|
||||
// pollInterval: Duration(seconds: 1),
|
||||
),
|
||||
|
@ -186,6 +192,8 @@ class WalletOptions extends StatelessWidget {
|
|||
String wBalanceUD;
|
||||
if (result.data['balance'] == null) {
|
||||
wBalanceUD = '0.0';
|
||||
} else if (result.hasException) {
|
||||
wBalanceUD = '?';
|
||||
} else {
|
||||
int wBalanceG1 =
|
||||
result.data['balance']['amount'];
|
||||
|
@ -201,13 +209,15 @@ class WalletOptions extends StatelessWidget {
|
|||
ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(
|
||||
sigmaX:
|
||||
_walletOptions.isBalanceBlur ? 6 : 0,
|
||||
walletProvider.isBalanceBlur ? 6 : 0,
|
||||
sigmaY:
|
||||
_walletOptions.isBalanceBlur ? 5 : 0),
|
||||
child: Text(wBalanceUD,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black)),
|
||||
walletProvider.isBalanceBlur ? 5 : 0),
|
||||
child: Text(
|
||||
wBalanceUD,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 20 : 18,
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
Text(' DU',
|
||||
style: TextStyle(
|
||||
|
@ -226,10 +236,10 @@ class WalletOptions extends StatelessWidget {
|
|||
InkWell(
|
||||
key: const Key('displayBalance'),
|
||||
onTap: () {
|
||||
_walletOptions.bluringBalance();
|
||||
walletProvider.bluringBalance();
|
||||
},
|
||||
child: Image.asset(
|
||||
_walletOptions.isBalanceBlur
|
||||
walletProvider.isBalanceBlur
|
||||
? 'assets/walletOptions/icon_oeuil.png'
|
||||
: 'assets/walletOptions/icon_oeuil_close.png',
|
||||
height: 35,
|
||||
|
@ -241,16 +251,16 @@ class WalletOptions extends StatelessWidget {
|
|||
InkWell(
|
||||
key: const Key('renameWallet'),
|
||||
onTap: () async {
|
||||
_isNewNameValid = _walletOptions.editWalletName(
|
||||
_isNewNameValid = walletProvider.editWalletName(
|
||||
wallet.id(),
|
||||
isCesium: false);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 30));
|
||||
_walletOptions.walletNameFocus.requestFocus();
|
||||
walletProvider.walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
_walletOptions.isEditing
|
||||
walletProvider.isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 20,
|
||||
|
@ -262,7 +272,9 @@ class WalletOptions extends StatelessWidget {
|
|||
])
|
||||
]),
|
||||
]),
|
||||
])),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 4 * ratio),
|
||||
FutureBuilder(
|
||||
future:
|
||||
|
@ -274,158 +286,173 @@ class WalletOptions extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
SizedBox(height: 15 * ratio),
|
||||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/key.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Text("${shortPubkey.split(':')[0]}:",
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace',
|
||||
color: Colors.black)),
|
||||
Text(shortPubkey.split(':')[1],
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace')),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
elevation: 1,
|
||||
primary: orangeC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return Column(children: [
|
||||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: walletProvider.pubkey.text));
|
||||
walletProvider.snackCopyKey(ctx);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/key.png',
|
||||
height: 45,
|
||||
),
|
||||
onPressed: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/copy-white.png',
|
||||
const SizedBox(width: 20),
|
||||
Text("${shortPubkey.split(':')[0]}:",
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace',
|
||||
color: Colors.black)),
|
||||
Text(shortPubkey.split(':')[1],
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFamily: 'Monospace')),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
elevation: 1,
|
||||
primary: orangeC, // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: walletProvider.pubkey.text));
|
||||
walletProvider.snackCopyKey(ctx);
|
||||
},
|
||||
child: Row(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/walletOptions/copy-white.png',
|
||||
height: 25,
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
'Copier',
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.grey[50]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
key: const Key('displayHistory'),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return HistoryScreen(
|
||||
pubkey: walletProvider.pubkey.text,
|
||||
avatar: wallet.imageFile == null
|
||||
? Image.asset(
|
||||
'assets/avatars/${wallet.imageName}',
|
||||
width: 110,
|
||||
)
|
||||
: Image.file(
|
||||
wallet.imageFile,
|
||||
width: 110,
|
||||
));
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/clock.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
const Text('Historique des transactions',
|
||||
style:
|
||||
TextStyle(fontSize: 20, color: Colors.black)),
|
||||
]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12 * ratio),
|
||||
InkWell(
|
||||
key: const Key('setDefaultWallet'),
|
||||
onTap: !walletProvider.isDefaultWallet
|
||||
? () {
|
||||
defaultWallet = wallet;
|
||||
chestBox.get(currentChest).defaultWallet =
|
||||
wallet.number;
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 31),
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors
|
||||
.grey[walletProvider.isDefaultWallet ? 300 : 500],
|
||||
child: Image.asset(
|
||||
'assets/walletOptions/android-checkmark.png',
|
||||
height: 25,
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
'Copier',
|
||||
style:
|
||||
TextStyle(fontSize: 15, color: Colors.grey[50]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
Text(
|
||||
walletProvider.isDefaultWallet
|
||||
? 'Ce portefeuille est celui par defaut'
|
||||
: 'Définir comme portefeuille par défaut',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: walletProvider.isDefaultWallet
|
||||
? Colors.grey[500]
|
||||
: Colors.black)),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
key: const Key('displayHistory'),
|
||||
onTap: () {
|
||||
if (_historyProvider.isPubkey(
|
||||
context, _walletOptions.pubkey.text)) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/clock.png',
|
||||
height: 45,
|
||||
),
|
||||
SizedBox(height: 17 * ratio),
|
||||
if (!walletProvider.isDefaultWallet)
|
||||
InkWell(
|
||||
key: const Key('deleteWallet'),
|
||||
onTap: !walletProvider.isDefaultWallet
|
||||
? () async {
|
||||
await walletProvider.deleteWallet(
|
||||
context, wallet);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider
|
||||
.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
}
|
||||
: null,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/trash.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 19),
|
||||
const Text('Supprimer ce portefeuille',
|
||||
style: TextStyle(
|
||||
fontSize: 20, color: Color(0xffD80000))),
|
||||
]),
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
const Text('Historique des transactions',
|
||||
style: TextStyle(fontSize: 20, color: Colors.black)),
|
||||
]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12 * ratio),
|
||||
InkWell(
|
||||
key: const Key('setDefaultWallet'),
|
||||
onTap: !_walletOptions.isDefaultWallet
|
||||
? () {
|
||||
defaultWallet = wallet;
|
||||
chestBox.get(currentChest).defaultWallet =
|
||||
wallet.number;
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 31),
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors
|
||||
.grey[_walletOptions.isDefaultWallet ? 300 : 500],
|
||||
child: Image.asset(
|
||||
'assets/walletOptions/android-checkmark.png',
|
||||
height: 25,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 22),
|
||||
Text(
|
||||
_walletOptions.isDefaultWallet
|
||||
? 'Ce portefeuille est celui par defaut'
|
||||
: 'Définir comme portefeuille par défaut',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: _walletOptions.isDefaultWallet
|
||||
? Colors.grey[500]
|
||||
: Colors.black)),
|
||||
]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 17 * ratio),
|
||||
if (!_walletOptions.isDefaultWallet)
|
||||
InkWell(
|
||||
key: const Key('deleteWallet'),
|
||||
onTap: !_walletOptions.isDefaultWallet
|
||||
? () async {
|
||||
await _walletOptions.deleteWallet(context, wallet);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
}
|
||||
: null,
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Image.asset(
|
||||
'assets/walletOptions/trash.png',
|
||||
height: 45,
|
||||
),
|
||||
const SizedBox(width: 19),
|
||||
const Text('Supprimer ce portefeuille',
|
||||
style:
|
||||
TextStyle(fontSize: 20, color: Color(0xffD80000))),
|
||||
]),
|
||||
),
|
||||
]);
|
||||
}),
|
||||
]),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:gecko/models/wallet_data.dart';
|
|||
import 'package:gecko/models/wallet_options.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/screens/common_elements.dart';
|
||||
import 'package:gecko/screens/myWallets/cesium_wallet_options.dart';
|
||||
import 'package:gecko/screens/myWallets/chest_options.dart';
|
||||
import 'package:gecko/screens/myWallets/choose_chest.dart';
|
||||
import 'package:gecko/screens/myWallets/wallet_options.dart';
|
||||
|
@ -27,10 +26,8 @@ class WalletsHome extends StatelessWidget {
|
|||
|
||||
final int _currentChestNumber = myWalletProvider.getCurrentChest();
|
||||
final ChestData _currentChest = chestBox.get(_currentChestNumber);
|
||||
if (!_currentChest.isCesium) {
|
||||
myWalletProvider.listWallets =
|
||||
myWalletProvider.readAllWallets(_currentChestNumber);
|
||||
}
|
||||
myWalletProvider.listWallets =
|
||||
myWalletProvider.readAllWallets(_currentChestNumber);
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
|
@ -57,9 +54,7 @@ class WalletsHome extends StatelessWidget {
|
|||
backgroundColor: const Color(0xffFFD58D),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: _currentChest.isCesium
|
||||
? cesiumWalletOptions(context, _currentChest, myWalletProvider)
|
||||
: myWalletsTiles(context),
|
||||
child: myWalletsTiles(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -68,7 +68,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
return WalletViewScreen(pubkey: text);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return const WalletViewScreen();
|
||||
return WalletViewScreen(pubkey: repository[2]);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ import 'package:graphql_flutter/graphql_flutter.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
|
||||
class WalletViewScreen extends StatelessWidget {
|
||||
const WalletViewScreen({this.pubkey, this.username, this.avatar, Key key})
|
||||
const WalletViewScreen(
|
||||
{@required this.pubkey, this.username, this.avatar, Key key})
|
||||
: super(key: key);
|
||||
final String pubkey;
|
||||
final String username;
|
||||
final Image avatar;
|
||||
final double buttonSize = 100;
|
||||
final double buttonFontSize = 18;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -34,42 +37,15 @@ class WalletViewScreen extends StatelessWidget {
|
|||
height: 22,
|
||||
child: Text('Voir un portefeuille'),
|
||||
),
|
||||
// actions: [
|
||||
// FutureBuilder(
|
||||
// future: _walletOptions.generateQRcode(_historyProvider.pubkey),
|
||||
// builder: (context, snapshot) {
|
||||
// return snapshot.data != null
|
||||
// ? GestureDetector(
|
||||
// key: const Key('openAvatar'),
|
||||
// onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return AvatarFullscreen(
|
||||
// Image.memory(snapshot.data),
|
||||
// title: 'QrCode du profil',
|
||||
// );
|
||||
// }),
|
||||
// );
|
||||
// // isAvatarView = !isAvatarView;
|
||||
// // _historyProvider.resetdHistory();
|
||||
// },
|
||||
// child: Image.memory(snapshot.data, height: 40 * ratio),
|
||||
// )
|
||||
// : const Text('-', style: TextStyle(fontSize: 20));
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(width: 75)
|
||||
// ],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
headerProfileView(context, _historyProvider, _cesiumPlusProvider),
|
||||
SizedBox(height: isTall ? 60 : 30),
|
||||
SizedBox(height: isTall ? 120 : 70),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
height: 120,
|
||||
height: buttonSize,
|
||||
child: ClipOval(
|
||||
child: Material(
|
||||
color: const Color(0xffFFD58D), // button color
|
||||
|
@ -77,7 +53,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
key: const Key('viewHistory'),
|
||||
splashColor: orangeC, // inkwell color
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
padding: EdgeInsets.all(13),
|
||||
child: Image(
|
||||
image: AssetImage(
|
||||
'assets/walletOptions/clock.png'),
|
||||
|
@ -87,9 +63,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
context,
|
||||
FaderTransition(
|
||||
page: HistoryScreen(
|
||||
pubkey: pubkey ?? _historyProvider.pubkey,
|
||||
username: username,
|
||||
avatar: avatar,
|
||||
pubkey: pubkey,
|
||||
username: username ??
|
||||
g1WalletsBox.get(pubkey).username,
|
||||
avatar: avatar ??
|
||||
g1WalletsBox.get(pubkey).avatar,
|
||||
),
|
||||
isFast: false),
|
||||
);
|
||||
|
@ -98,15 +76,16 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
const Text(
|
||||
Text(
|
||||
"Voir\nl'historique",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
||||
),
|
||||
]),
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
height: 120,
|
||||
height: buttonSize,
|
||||
child: ClipOval(
|
||||
child: Material(
|
||||
color: const Color(0xffFFD58D), // button color
|
||||
|
@ -127,10 +106,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
const Text(
|
||||
Text(
|
||||
"Copier\nla clef",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
|
@ -159,7 +139,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
// ),
|
||||
const Spacer(),
|
||||
Container(
|
||||
height: 120,
|
||||
height: buttonSize,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xff7c94b6),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(100)),
|
||||
|
@ -175,7 +155,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
key: const Key('pay'),
|
||||
splashColor: yellowC, // inkwell color
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: EdgeInsets.all(14),
|
||||
child: Image(
|
||||
image: AssetImage('assets/vector_white.png'),
|
||||
)),
|
||||
|
@ -186,12 +166,13 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 9),
|
||||
const Text(
|
||||
Text(
|
||||
"Faire un\nvirement",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(height: isTall ? 100 : 50)
|
||||
SizedBox(height: isTall ? 120 : 70)
|
||||
]),
|
||||
));
|
||||
}
|
||||
|
@ -226,13 +207,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
GestureDetector(
|
||||
key: const Key('copyPubkey'),
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: pubkey ?? _historyProvider.pubkey));
|
||||
Clipboard.setData(ClipboardData(text: pubkey));
|
||||
_historyProvider.snackCopyKey(context);
|
||||
},
|
||||
child: Text(
|
||||
_historyProvider
|
||||
.getShortPubkey(pubkey ?? _historyProvider.pubkey),
|
||||
_historyProvider.getShortPubkey(pubkey),
|
||||
style: const TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w800,
|
||||
|
@ -241,7 +220,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
]),
|
||||
const SizedBox(height: 10),
|
||||
if (username == null)
|
||||
if (username == null && g1WalletsBox.get(pubkey).username == null)
|
||||
Query(
|
||||
options: QueryOptions(
|
||||
document: gql(getId),
|
||||
|
@ -255,8 +234,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
return const Text('...');
|
||||
} else if (result.data['idty'] == null ||
|
||||
result.data['idty']['username'] == null) {
|
||||
g1WalletsBox.get(pubkey).username = '';
|
||||
return const Text('');
|
||||
} else {
|
||||
g1WalletsBox.get(pubkey).username =
|
||||
result?.data['idty']['username'] ?? '';
|
||||
return SizedBox(
|
||||
width: 230,
|
||||
child: Text(
|
||||
|
@ -270,12 +252,26 @@ class WalletViewScreen extends StatelessWidget {
|
|||
}
|
||||
},
|
||||
),
|
||||
if (username == null && g1WalletsBox.get(pubkey).username != null)
|
||||
SizedBox(
|
||||
width: 230,
|
||||
child: Text(
|
||||
g1WalletsBox.get(pubkey).username,
|
||||
style: const TextStyle(
|
||||
fontSize: 27,
|
||||
color: Color(0xff814C00),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (username != null)
|
||||
Text(
|
||||
username,
|
||||
style: const TextStyle(
|
||||
fontSize: 27,
|
||||
color: Color(0xff814C00),
|
||||
SizedBox(
|
||||
width: 230,
|
||||
child: Text(
|
||||
username,
|
||||
style: const TextStyle(
|
||||
fontSize: 27,
|
||||
color: Color(0xff814C00),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
|
@ -302,20 +298,19 @@ class WalletViewScreen extends StatelessWidget {
|
|||
_historyProvider.pubkey, _avatarSize),
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<Image> _avatar) {
|
||||
if (_avatar.connectionState != ConnectionState.done ||
|
||||
_avatar.hasError) {
|
||||
if (_avatar.connectionState != ConnectionState.done) {
|
||||
return Stack(children: [
|
||||
ClipOval(
|
||||
child:
|
||||
_cesiumPlusProvider.defaultAvatar(_avatarSize),
|
||||
),
|
||||
Positioned(
|
||||
top: 16.5,
|
||||
right: 47.5,
|
||||
width: 55,
|
||||
height: 55,
|
||||
top: 15,
|
||||
right: 45,
|
||||
width: 51,
|
||||
height: 51,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 6,
|
||||
strokeWidth: 5,
|
||||
color: orangeC,
|
||||
),
|
||||
),
|
||||
|
@ -333,7 +328,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
child: ClipOval(
|
||||
child: _avatar.data,
|
||||
child: Image(
|
||||
image: _avatar.data.image,
|
||||
height: _avatarSize,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue