Fix a few bugs

This commit is contained in:
poka 2021-12-01 08:14:07 +01:00
parent 8f0018e326
commit 46bfb61391
13 changed files with 839 additions and 717 deletions

View File

@ -65,6 +65,8 @@ Future<void> main() async {
configBox = await Hive.openBox("configBox"); configBox = await Hive.openBox("configBox");
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox"); g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
g1WalletsBox.clear();
// final HiveStore _store = // final HiveStore _store =
// await HiveStore.open(path: '${appPath.path}/gqlCache'); // await HiveStore.open(path: '${appPath.path}/gqlCache');

View File

@ -61,6 +61,10 @@ class CesiumPlusProvider with ChangeNotifier {
Future<String> getName(String _pubkey) async { Future<String> getName(String _pubkey) async {
String _name; String _name;
if (g1WalletsBox.get(_pubkey).csName != null) {
return g1WalletsBox.get(_pubkey).csName;
}
List queryOptions = await _buildQuery(_pubkey); List queryOptions = await _buildQuery(_pubkey);
final response = await http.post((Uri.parse(queryOptions[0])), final response = await http.post((Uri.parse(queryOptions[0])),
body: queryOptions[1], headers: queryOptions[2]); body: queryOptions[1], headers: queryOptions[2]);
@ -75,6 +79,8 @@ class CesiumPlusProvider with ChangeNotifier {
} }
_name = responseJson['hits']['hits'][0]['_source']['title']; _name = responseJson['hits']['hits'][0]['_source']['title'];
g1WalletsBox.get(_pubkey).csName = _name;
return _name; return _name;
} }
@ -83,6 +89,8 @@ class CesiumPlusProvider with ChangeNotifier {
return g1WalletsBox.get(_pubkey).avatar; return g1WalletsBox.get(_pubkey).avatar;
} }
log.d(_pubkey);
List queryOptions = await _buildQuery(_pubkey); List queryOptions = await _buildQuery(_pubkey);
http.Response response; http.Response response;
@ -106,10 +114,14 @@ class CesiumPlusProvider with ChangeNotifier {
File('${(await getTemporaryDirectory()).path}/avatar_$_pubkey.png'); File('${(await getTemporaryDirectory()).path}/avatar_$_pubkey.png');
await avatarFile.writeAsBytes(base64.decode(_avatar)); await avatarFile.writeAsBytes(base64.decode(_avatar));
return Image.file( final finalAvatar = Image.file(
avatarFile, avatarFile,
height: size, height: size,
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
); );
g1WalletsBox.get(_pubkey).avatar = finalAvatar;
return finalAvatar;
} }
} }

View File

@ -17,7 +17,24 @@ class G1WalletsList {
@HiveField(4) @HiveField(4)
Image avatar; 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) { G1WalletsList.fromJson(Map<String, dynamic> json) {
pubkey = json['pubkey']; pubkey = json['pubkey'];

View File

@ -23,13 +23,16 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
balance: fields[1] as double, balance: fields[1] as double,
id: fields[3] as Id, id: fields[3] as Id,
avatar: fields[4] as Image, avatar: fields[4] as Image,
username: fields[5] as String,
csName: fields[6] as String,
isMembre: fields[7] as bool,
); );
} }
@override @override
void write(BinaryWriter writer, G1WalletsList obj) { void write(BinaryWriter writer, G1WalletsList obj) {
writer writer
..writeByte(4) ..writeByte(7)
..writeByte(0) ..writeByte(0)
..write(obj.pubkey) ..write(obj.pubkey)
..writeByte(1) ..writeByte(1)
@ -37,7 +40,13 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
..writeByte(3) ..writeByte(3)
..write(obj.id) ..write(obj.id)
..writeByte(4) ..writeByte(4)
..write(obj.avatar); ..write(obj.avatar)
..writeByte(5)
..write(obj.username)
..writeByte(6)
..write(obj.csName)
..writeByte(7)
..write(obj.isMembre);
} }
@override @override

View File

@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:dubp/dubp.dart'; import 'package:dubp/dubp.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -16,7 +14,6 @@ import 'package:intl/intl.dart';
import 'package:truncate/truncate.dart'; import 'package:truncate/truncate.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:fast_base58/fast_base58.dart'; import 'package:fast_base58/fast_base58.dart';
import 'package:http/http.dart' as http;
class WalletsProfilesProvider with ChangeNotifier { class WalletsProfilesProvider with ChangeNotifier {
WalletsProfilesProvider(this.pubkey); WalletsProfilesProvider(this.pubkey);
@ -32,6 +29,7 @@ class WalletsProfilesProvider with ChangeNotifier {
String rawSvg; String rawSvg;
TextEditingController payAmount = TextEditingController(); TextEditingController payAmount = TextEditingController();
TextEditingController payComment = TextEditingController(); TextEditingController payComment = TextEditingController();
num balance;
Future scan(context) async { Future scan(context) async {
await Permission.camera.request(); await Permission.camera.request();
@ -47,7 +45,7 @@ class WalletsProfilesProvider with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return const WalletViewScreen(); return WalletViewScreen(pubkey: pubkey);
}), }),
); );
} else { } else {
@ -258,17 +256,24 @@ class WalletsProfilesProvider with ChangeNotifier {
return Jdenticon.toSvg(_pubkey); return Jdenticon.toSvg(_pubkey);
} }
Future<num> getBalance(String _pubkey) async { // Future<num> getBalance(String _pubkey) async {
num balance; // final url = Uri.parse(
final url = Uri.parse( // '$endPointGVA?query={%20balance(script:%20%22$_pubkey%22)%20{%20amount%20base%20}%20}');
'$endPointGVA?query={%20balance(script:%20%22$_pubkey%22)%20{%20amount%20base%20}%20}'); // final response = await http.get(url);
final response = await http.get(url); // final result = json.decode(response.body);
final result = json.decode(response.body);
if (result['data']['balance'] == null) { // if (result['data']['balance'] == null) {
balance = 0.0; // balance = 0.0;
} else { // } else {
balance = removeDecimalZero(result['data']['balance']['amount'] / 100); // 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; return balance;

View File

@ -42,7 +42,10 @@ class AvatarFullscreen extends StatelessWidget {
// alignment: Alignment.center, // alignment: Alignment.center,
// height: MediaQuery.of(context).size.height, // height: MediaQuery.of(context).size.height,
// width: MediaQuery.of(context).size.width, // width: MediaQuery.of(context).size.width,
child: avatar, child: Image(
image: avatar.image,
height: avatar.height,
fit: BoxFit.fitWidth),
), ),
), ),
), ),

View File

@ -12,7 +12,6 @@ import 'dart:ui';
import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class HistoryScreen extends StatelessWidget with ChangeNotifier { class HistoryScreen extends StatelessWidget with ChangeNotifier {
@ -37,9 +36,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
CesiumPlusProvider _cesiumPlusProvider = CesiumPlusProvider _cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context, listen: false); Provider.of<CesiumPlusProvider>(context, listen: false);
log.i('Build pubkey : ' + _historyProvider.pubkey); log.i('Build pubkey : ' + pubkey);
WidgetsBinding.instance.addPostFrameCallback((_) {}); WidgetsBinding.instance.addPostFrameCallback((_) {});
_historyProvider.balance = _historyProvider.transBC = null;
return Scaffold( return Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
appBar: AppBar( appBar: AppBar(
@ -52,8 +53,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
), ),
body: Column(children: <Widget>[ body: Column(children: <Widget>[
headerProfileView(context, _historyProvider, _cesiumPlusProvider), 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) { CesiumPlusProvider _cesiumPlusProvider) {
WalletsProfilesProvider _historyProvider = WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context, listen: true); Provider.of<WalletsProfilesProvider>(context, listen: true);
RefreshController _refreshController =
RefreshController(initialRefresh: false);
return Expanded( return Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -72,12 +70,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
options: QueryOptions( options: QueryOptions(
document: gql(getHistory), document: gql(getHistory),
variables: <String, dynamic>{ variables: <String, dynamic>{
'pubkey': _historyProvider.pubkey, 'pubkey': pubkey,
'number': nRepositories, 'number': nRepositories,
'cursor': null 'cursor': null
}, },
), ),
builder: (QueryResult result, {fetchMore, refetch}) { builder: (QueryResult result, {fetchMore, refetch}) {
// log.d(result.data);
if (result.isLoading && result.data == null) { if (result.isLoading && result.data == null) {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
@ -90,13 +90,24 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
SizedBox(height: 50), SizedBox(height: 50),
Text( Text(
"Aucun noeud GVA valide n'a pu être trouvé.\nVeuillez réessayer ultérieurement.", "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) { if (result.data['balance'] == null) {
return const Text('Aucune donnée à afficher.'); _historyProvider.balance = 0.0;
} else {
_historyProvider.balance = _historyProvider
.removeDecimalZero(result.data['balance']['amount'] / 100);
} }
opts = _historyProvider.checkQueryResult(result, opts, pubkey); opts = _historyProvider.checkQueryResult(result, opts, pubkey);
@ -105,25 +116,18 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
return NotificationListener( return NotificationListener(
child: Builder( child: Builder(
builder: (context) => Expanded( builder: (context) => Expanded(
child: SmartRefresher( child: ListView(
enablePullUp: false, key: const Key('listTransactions'),
controller: _refreshController, controller: scrollController,
onRefresh: () { children: <Widget>[historyView(context, result)],
_historyProvider.resetdHistory();
_refreshController.refreshCompleted();
},
child: ListView(
key: const Key('listTransactions'),
controller: scrollController,
children: <Widget>[historyView(context, result)],
),
), ),
), ),
), ),
onNotification: (t) { onNotification: (t) {
if (t is ScrollEndNotification && if (t is ScrollEndNotification &&
scrollController.position.pixels >= scrollController.position.pixels >=
scrollController.position.maxScrollExtent * 0.7) { scrollController.position.maxScrollExtent * 0.7 &&
_historyProvider.pageInfo['hasPreviousPage']) {
fetchMore(opts); fetchMore(opts);
} }
return true; return true;
@ -139,48 +143,15 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
return _historyProvider.transBC == null 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>[ : Column(children: <Widget>[
getTransactionTile(context, _historyProvider), 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 && if (result.isLoading &&
_historyProvider.pageInfo['hasPreviousPage']) _historyProvider.pageInfo['hasPreviousPage'])
Row( Row(
@ -189,7 +160,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
CircularProgressIndicator(), CircularProgressIndicator(),
], ],
), ),
// if (_historyProvider.isTheEnd) // What I did before ...
if (!_historyProvider.pageInfo['hasPreviousPage']) if (!_historyProvider.pageInfo['hasPreviousPage'])
Column( Column(
children: const <Widget>[ children: const <Widget>[
@ -214,6 +184,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
String lastDateDelimiter; String lastDateDelimiter;
const double _avatarSize = 200; const double _avatarSize = 200;
bool isTody = false;
bool isYesterday = false;
bool isThisWeek = false;
const Map<int, String> monthsInYear = { const Map<int, String> monthsInYear = {
1: "Janvier", 1: "Janvier",
2: "Février", 2: "Février",
@ -242,7 +216,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
} else { } else {
dateForm = "${date.day} ${monthsInYear[date.month]}"; dateForm = "${date.day} ${monthsInYear[date.month]}";
} }
log.d(dateForm);
int weekNumber(DateTime date) { int weekNumber(DateTime date) {
int dayOfYear = int.parse(DateFormat("D").format(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) == 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"; dateDelimiter = lastDateDelimiter = "Aujourd'hui";
isTody = true;
} else if (DateTime(date.year, date.month, date.day) == } 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"; dateDelimiter = lastDateDelimiter = "Hier";
isYesterday = true;
} else if (weekNumber(date) == weekNumber(now) && } else if (weekNumber(date) == weekNumber(now) &&
date.year == now.year && 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"; dateDelimiter = lastDateDelimiter = "Cette semaine";
isThisWeek = true;
} else if (lastDateDelimiter != monthsInYear[date.month] && } 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) { if (date.year == now.year) {
dateDelimiter = lastDateDelimiter = monthsInYear[date.month]; dateDelimiter = lastDateDelimiter = monthsInYear[date.month];
} else { } else {
@ -377,11 +363,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (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( GestureDetector(
key: const Key('copyPubkey'), key: const Key('copyPubkey'),
onTap: () { onTap: () {
Clipboard.setData(ClipboardData( Clipboard.setData(ClipboardData(text: pubkey));
text: pubkey ?? _historyProvider.pubkey));
_historyProvider.snackCopyKey(context); _historyProvider.snackCopyKey(context);
}, },
child: Text( child: Text(
_historyProvider.getShortPubkey( _historyProvider.getShortPubkey(pubkey),
pubkey ?? _historyProvider.pubkey),
style: const TextStyle( style: const TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
@ -442,7 +426,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
options: QueryOptions( options: QueryOptions(
document: gql(getId), document: gql(getId),
variables: { variables: {
'pubkey': _historyProvider.pubkey, 'pubkey': pubkey,
}, },
), ),
builder: (QueryResult result, builder: (QueryResult result,
@ -467,11 +451,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
}, },
), ),
if (username != null) if (username != null)
Text( SizedBox(
username, width: 230,
style: const TextStyle( child: Text(
fontSize: 27, username,
color: Color(0xff814C00), style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
), ),
), ),
const SizedBox(height: 25), const SizedBox(height: 25),
@ -497,24 +484,22 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
Column(children: <Widget>[ Column(children: <Widget>[
if (avatar == null) if (avatar == null)
FutureBuilder( FutureBuilder(
future: _cesiumPlusProvider.getAvatar( future: _cesiumPlusProvider.getAvatar(pubkey, _avatarSize),
_historyProvider.pubkey, _avatarSize),
builder: builder:
(BuildContext context, AsyncSnapshot<Image> _avatar) { (BuildContext context, AsyncSnapshot<Image> _avatar) {
if (_avatar.connectionState != ConnectionState.done || if (_avatar.connectionState != ConnectionState.done) {
_avatar.hasError) {
return Stack(children: [ return Stack(children: [
ClipOval( ClipOval(
child: child:
_cesiumPlusProvider.defaultAvatar(_avatarSize), _cesiumPlusProvider.defaultAvatar(_avatarSize),
), ),
Positioned( Positioned(
top: 16.5, top: 15,
right: 47.5, right: 45,
width: 55, width: 51,
height: 55, height: 51,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 6, strokeWidth: 5,
color: orangeC, color: orangeC,
), ),
), ),
@ -532,7 +517,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
); );
}, },
child: ClipOval( child: ClipOval(
child: _avatar.data, child: Image(
image: _avatar.data.image,
height: _avatarSize,
fit: BoxFit.cover,
),
), ),
); );
} }

View File

@ -9,8 +9,8 @@ import 'package:gecko/models/wallets_profiles.dart';
import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/my_wallets.dart';
import 'package:gecko/models/queries.dart'; import 'package:gecko/models/queries.dart';
import 'package:gecko/models/wallet_options.dart'; import 'package:gecko/models/wallet_options.dart';
import 'package:gecko/screens/history.dart';
import 'package:gecko/screens/myWallets/change_pin.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:graphql_flutter/graphql_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -18,352 +18,406 @@ import 'package:flutter/services.dart';
int _nbrLinesName = 1; int _nbrLinesName = 1;
bool _isNewNameValid = false; bool _isNewNameValid = false;
Widget cesiumWalletOptions(BuildContext context, ChestData cesiumWallet, class CesiumWalletOptions extends StatelessWidget {
MyWalletsProvider _myWalletProvider) { const CesiumWalletOptions(
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); {Key key, Key keyMyWallets, @required this.cesiumWallet})
WalletOptionsProvider _walletOptions = : super(key: key);
Provider.of<WalletOptionsProvider>(context);
ChestProvider _chestProvider =
Provider.of<ChestProvider>(context, listen: false);
WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context);
final String shortPubkey = final ChestData cesiumWallet;
_walletOptions.getShortPubkey(_walletOptions.pubkey.text);
if (_walletOptions.nameController.text == null || _isNewNameValid == false) { @override
_walletOptions.nameController.text = cesiumWallet.name; Widget build(BuildContext context) {
} else { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
cesiumWallet.name = _walletOptions.nameController.text; 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 final String shortPubkey =
? _nbrLinesName = 2 _walletOptions.getShortPubkey(_walletOptions.pubkey.text);
: _nbrLinesName = 1;
if (_walletOptions.nameController.text.length >= 26 && isTall) {
_nbrLinesName = 3;
}
return Scaffold( if (_walletOptions.nameController.text == null ||
resizeToAvoidBottomInset: false, _isNewNameValid == false) {
body: Builder( _walletOptions.nameController.text = cesiumWallet.name;
builder: (ctx) => SafeArea( } else {
child: Column(children: <Widget>[ cesiumWallet.name = _walletOptions.nameController.text;
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 (result.isLoading) { _walletOptions.nameController.text.length >= 15
return const Text('Loading'); ? _nbrLinesName = 2
} : _nbrLinesName = 1;
if (_walletOptions.nameController.text.length >= 26 && isTall) {
_nbrLinesName = 3;
}
// List repositories = result.data['viewer']['repositories']['nodes']; return WillPopScope(
String wBalanceUD; onWillPop: () {
if (result.data['balance'] == null) { _walletOptions.isEditing = false;
wBalanceUD = '0.0'; _walletOptions.isBalanceBlur = true;
} else { Navigator.popUntil(
int wBalanceG1 = result.data['balance']['amount']; context,
int currentUD = result.data['currentUd']['amount']; ModalRoute.withName('/'),
double wBalanceUDBrut = );
wBalanceG1 / currentUD; // .toString(); return Future<bool>.value(true);
wBalanceUD = double.parse( },
(wBalanceUDBrut).toStringAsFixed(2)) child: Scaffold(
.toString(); resizeToAvoidBottomInset: false,
} appBar: AppBar(
return Row(children: <Widget>[ toolbarHeight: 60 * ratio,
ImageFiltered( elevation: 0,
imageFilter: ImageFilter.blur( leading: IconButton(
sigmaX: _walletOptions.isBalanceBlur ? 6 : 0, icon: const Icon(Icons.arrow_back, color: Colors.black),
sigmaY: _walletOptions.isBalanceBlur ? 5 : 0), onPressed: () {
child: Text(wBalanceUD, _walletOptions.isEditing = false;
style: TextStyle( _walletOptions.isBalanceBlur = true;
fontSize: isTall ? 20 : 18, Navigator.popUntil(
color: Colors.black)), context,
), ModalRoute.withName('/'),
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), title: SizedBox(
GestureDetector( height: 22,
key: const Key('copyPubkey'), child: Consumer<WalletOptionsProvider>(
onTap: () { builder: (context, walletProvider, _) {
Clipboard.setData( return Text(_walletOptions.nameController.text);
ClipboardData(text: _walletOptions.pubkey.text)); }),
_walletOptions.snackCopyKey(ctx); ),
}, ),
child: SizedBox( 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, height: 50,
child: Row(children: <Widget>[ child: Row(children: <Widget>[
const SizedBox(width: 30), const SizedBox(width: 31),
Image.asset( Image.asset(
'assets/walletOptions/key.png', 'assets/chests/secret_code.png',
height: 45, height: 24,
), ),
const SizedBox(width: 20), const SizedBox(width: 20),
Text("${shortPubkey.split(':')[0]}:", const Text('Changer mon code secret',
style: const TextStyle( style: TextStyle(fontSize: 20, color: Colors.black)),
fontSize: 22, ]),
fontWeight: FontWeight.w800, ),
fontFamily: 'Monospace', ),
color: Colors.black)), SizedBox(height: 7 * ratio),
Text(shortPubkey.split(':')[1], InkWell(
style: const TextStyle( key: const Key('deleteWallet'),
fontSize: 22, onTap: () async {
fontWeight: FontWeight.w800, await _chestProvider.deleteChest(context, cesiumWallet);
fontFamily: 'Monospace')), },
const SizedBox(width: 15), child: SizedBox(
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(
height: 50, height: 50,
child: Row(children: <Widget>[ child: Row(children: <Widget>[
const SizedBox(width: 30), const SizedBox(width: 33),
Image.asset( Image.asset(
'assets/walletOptions/clock.png', 'assets/walletOptions/trash.png',
height: 45, height: 45,
), ),
const SizedBox(width: 22), const SizedBox(width: 21),
const Text('Historique des transactions', const Text(
style: TextStyle(fontSize: 20, color: Colors.black)), 'Supprimer ce coffre',
]))), style: TextStyle(
SizedBox(height: 7 * ratio), fontSize: 20,
InkWell( color: Color(0xffD80000),
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,
);
},
), ),
); ),
}, ]),
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),
),
),
]),
),
),
]),
), ),
), );
); }
} }

View File

@ -7,6 +7,7 @@ import 'package:gecko/models/my_wallets.dart';
import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/wallet_options.dart'; import 'package:gecko/models/wallet_options.dart';
import 'package:flutter/material.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:gecko/screens/myWallets/choose_chest.dart';
import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -86,7 +87,7 @@ class UnlockingWallet extends StatelessWidget {
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
)), )),
SizedBox(height: 40 * ratio), SizedBox(height: 40 * ratio),
pinForm(context, _pinLenght), pinForm(context, _pinLenght, currentChest),
SizedBox(height: 3 * ratio), SizedBox(height: 3 * ratio),
InkWell( InkWell(
key: const Key('chooseChest'), key: const Key('chooseChest'),
@ -114,7 +115,7 @@ class UnlockingWallet extends StatelessWidget {
)); ));
} }
Widget pinForm(context, _pinLenght) { Widget pinForm(context, _pinLenght, ChestData currentChest) {
// var _walletPin = ''; // var _walletPin = '';
// ignore: close_sinks // ignore: close_sinks
StreamController<ErrorAnimationType> errorController = StreamController<ErrorAnimationType> errorController =
@ -194,7 +195,16 @@ class UnlockingWallet extends StatelessWidget {
pinColor = Colors.green[400]; pinColor = Colors.green[400];
// await Future.delayed(Duration(milliseconds: 50)); // await Future.delayed(Duration(milliseconds: 50));
if (action == "mywallets") { 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") { } else if (action == "pay") {
resultPay = resultPay =
await _historyProvider.pay(context, _pin.toUpperCase()); await _historyProvider.pay(context, _pin.toUpperCase());

View File

@ -3,12 +3,11 @@ 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/globals.dart';
import 'package:gecko/models/wallets_profiles.dart';
import 'package:gecko/models/my_wallets.dart'; import 'package:gecko/models/my_wallets.dart';
import 'package:gecko/models/queries.dart'; import 'package:gecko/models/queries.dart';
import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/wallet_options.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:graphql_flutter/graphql_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -25,11 +24,10 @@ class WalletOptions extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
WalletOptionsProvider _walletOptions = WalletOptionsProvider _walletOptions =
Provider.of<WalletOptionsProvider>(context); Provider.of<WalletOptionsProvider>(context, listen: false);
MyWalletsProvider _myWalletProvider = MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context);
final int _currentChest = _myWalletProvider.getCurrentChest(); final int _currentChest = _myWalletProvider.getCurrentChest();
final String shortPubkey = final String shortPubkey =
@ -71,29 +69,36 @@ class WalletOptions extends StatelessWidget {
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
toolbarHeight: 60 * ratio, toolbarHeight: 60 * ratio,
leading: IconButton( elevation: 0,
icon: const Icon(Icons.arrow_back, color: Colors.black), leading: IconButton(
onPressed: () { icon: const Icon(Icons.arrow_back, color: Colors.black),
_walletOptions.isEditing = false; onPressed: () {
_walletOptions.isBalanceBlur = true; _walletOptions.isEditing = false;
Navigator.popUntil( _walletOptions.isBalanceBlur = true;
context, Navigator.popUntil(
ModalRoute.withName('/mywallets'), context,
); ModalRoute.withName('/mywallets'),
}), );
title: SizedBox( }),
height: 22, title: SizedBox(
child: Text(_walletOptions.nameController.text), height: 22,
)), child: Consumer<WalletOptionsProvider>(
builder: (context, walletProvider, _) {
return Text(_walletOptions.nameController.text);
}),
),
),
body: Builder( body: Builder(
builder: (ctx) => SafeArea( builder: (ctx) => SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
Container( Container(
height: isTall ? 15 : 0, height: isTall ? 5 : 0,
color: yellowC, color: yellowC,
), ),
Container( Consumer<WalletOptionsProvider>(
builder: (context, walletProvider, _) {
return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
@ -106,29 +111,30 @@ class WalletOptions extends StatelessWidget {
child: Row(children: <Widget>[ child: Row(children: <Widget>[
const SizedBox(width: 25), const SizedBox(width: 25),
InkWell( InkWell(
onTap: () async { onTap: () async {
File newAvatar = await _walletOptions.changeAvatar(); File newAvatar = await walletProvider.changeAvatar();
if (newAvatar != null) { if (newAvatar != null) {
wallet.imageFile = newAvatar; wallet.imageFile = newAvatar;
} }
_walletOptions.reloadBuild(); walletProvider.reloadBuild();
}, },
child: wallet.imageFile == null child: wallet.imageFile == null
? Image.asset( ? Image.asset(
'assets/avatars/${wallet.imageName}', 'assets/avatars/${wallet.imageName}',
width: 110, width: 110,
) )
: Image.file( : Image.file(
wallet.imageFile, wallet.imageFile,
width: 110, width: 110,
)), ),
),
InkWell( InkWell(
onTap: () async { onTap: () async {
File newAvatar = await _walletOptions.changeAvatar(); File newAvatar = await walletProvider.changeAvatar();
if (newAvatar != null) { if (newAvatar != null) {
wallet.imageFile = newAvatar; wallet.imageFile = newAvatar;
} }
_walletOptions.reloadBuild(); walletProvider.reloadBuild();
}, },
child: Column(children: <Widget>[ child: Column(children: <Widget>[
Image.asset( Image.asset(
@ -145,9 +151,9 @@ class WalletOptions extends StatelessWidget {
child: TextField( child: TextField(
key: const Key('walletName'), key: const Key('walletName'),
autofocus: false, autofocus: false,
focusNode: _walletOptions.walletNameFocus, focusNode: walletProvider.walletNameFocus,
enabled: _walletOptions.isEditing, enabled: walletProvider.isEditing,
controller: _walletOptions.nameController, controller: walletProvider.nameController,
maxLines: _nbrLinesName, maxLines: _nbrLinesName,
textAlign: TextAlign.center, textAlign: TextAlign.center,
decoration: const InputDecoration( decoration: const InputDecoration(
@ -168,7 +174,7 @@ class WalletOptions extends StatelessWidget {
options: QueryOptions( options: QueryOptions(
document: gql(getBalance), document: gql(getBalance),
variables: { variables: {
'pubkey': _walletOptions.pubkey.text, 'pubkey': walletProvider.pubkey.text,
}, },
// pollInterval: Duration(seconds: 1), // pollInterval: Duration(seconds: 1),
), ),
@ -186,6 +192,8 @@ class WalletOptions extends StatelessWidget {
String wBalanceUD; String wBalanceUD;
if (result.data['balance'] == null) { if (result.data['balance'] == null) {
wBalanceUD = '0.0'; wBalanceUD = '0.0';
} else if (result.hasException) {
wBalanceUD = '?';
} else { } else {
int wBalanceG1 = int wBalanceG1 =
result.data['balance']['amount']; result.data['balance']['amount'];
@ -201,13 +209,15 @@ class WalletOptions extends StatelessWidget {
ImageFiltered( ImageFiltered(
imageFilter: ImageFilter.blur( imageFilter: ImageFilter.blur(
sigmaX: sigmaX:
_walletOptions.isBalanceBlur ? 6 : 0, walletProvider.isBalanceBlur ? 6 : 0,
sigmaY: sigmaY:
_walletOptions.isBalanceBlur ? 5 : 0), walletProvider.isBalanceBlur ? 5 : 0),
child: Text(wBalanceUD, child: Text(
style: TextStyle( wBalanceUD,
fontSize: isTall ? 20 : 18, style: TextStyle(
color: Colors.black)), fontSize: isTall ? 20 : 18,
color: Colors.black),
),
), ),
Text(' DU', Text(' DU',
style: TextStyle( style: TextStyle(
@ -226,10 +236,10 @@ class WalletOptions extends StatelessWidget {
InkWell( InkWell(
key: const Key('displayBalance'), key: const Key('displayBalance'),
onTap: () { onTap: () {
_walletOptions.bluringBalance(); walletProvider.bluringBalance();
}, },
child: Image.asset( child: Image.asset(
_walletOptions.isBalanceBlur walletProvider.isBalanceBlur
? 'assets/walletOptions/icon_oeuil.png' ? 'assets/walletOptions/icon_oeuil.png'
: 'assets/walletOptions/icon_oeuil_close.png', : 'assets/walletOptions/icon_oeuil_close.png',
height: 35, height: 35,
@ -241,16 +251,16 @@ class WalletOptions extends StatelessWidget {
InkWell( InkWell(
key: const Key('renameWallet'), key: const Key('renameWallet'),
onTap: () async { onTap: () async {
_isNewNameValid = _walletOptions.editWalletName( _isNewNameValid = walletProvider.editWalletName(
wallet.id(), wallet.id(),
isCesium: false); isCesium: false);
await Future.delayed( await Future.delayed(
const Duration(milliseconds: 30)); const Duration(milliseconds: 30));
_walletOptions.walletNameFocus.requestFocus(); walletProvider.walletNameFocus.requestFocus();
}, },
child: ClipRRect( child: ClipRRect(
child: Image.asset( child: Image.asset(
_walletOptions.isEditing walletProvider.isEditing
? 'assets/walletOptions/android-checkmark.png' ? 'assets/walletOptions/android-checkmark.png'
: 'assets/walletOptions/edit.png', : 'assets/walletOptions/edit.png',
width: 20, width: 20,
@ -262,7 +272,9 @@ class WalletOptions extends StatelessWidget {
]) ])
]), ]),
]), ]),
])), ]),
);
}),
SizedBox(height: 4 * ratio), SizedBox(height: 4 * ratio),
FutureBuilder( FutureBuilder(
future: future:
@ -274,158 +286,173 @@ class WalletOptions extends StatelessWidget {
}, },
), ),
SizedBox(height: 15 * ratio), SizedBox(height: 15 * ratio),
GestureDetector( Consumer<WalletOptionsProvider>(
key: const Key('copyPubkey'), builder: (context, walletProvider, _) {
onTap: () { return Column(children: [
Clipboard.setData( GestureDetector(
ClipboardData(text: _walletOptions.pubkey.text)); key: const Key('copyPubkey'),
_walletOptions.snackCopyKey(ctx); onTap: () {
}, Clipboard.setData(
child: SizedBox( ClipboardData(text: walletProvider.pubkey.text));
height: 50, walletProvider.snackCopyKey(ctx);
child: Row(children: <Widget>[ },
const SizedBox(width: 30), child: SizedBox(
Image.asset( height: 50,
'assets/walletOptions/key.png', child: Row(children: <Widget>[
height: 45, const SizedBox(width: 30),
), Image.asset(
const SizedBox(width: 20), 'assets/walletOptions/key.png',
Text("${shortPubkey.split(':')[0]}:", height: 45,
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: () { const SizedBox(width: 20),
Clipboard.setData( Text("${shortPubkey.split(':')[0]}:",
ClipboardData(text: _walletOptions.pubkey.text)); style: const TextStyle(
_walletOptions.snackCopyKey(ctx); fontSize: 22,
}, fontWeight: FontWeight.w800,
child: Row(children: <Widget>[ fontFamily: 'Monospace',
Image.asset( color: Colors.black)),
'assets/walletOptions/copy-white.png', 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, height: 25,
), ),
const SizedBox(width: 7), ),
Text( const SizedBox(width: 22),
'Copier', Text(
style: walletProvider.isDefaultWallet
TextStyle(fontSize: 15, color: Colors.grey[50]), ? '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: 17 * ratio),
), if (!walletProvider.isDefaultWallet)
SizedBox(height: 10 * ratio), InkWell(
InkWell( key: const Key('deleteWallet'),
key: const Key('displayHistory'), onTap: !walletProvider.isDefaultWallet
onTap: () { ? () async {
if (_historyProvider.isPubkey( await walletProvider.deleteWallet(
context, _walletOptions.pubkey.text)) { context, wallet);
Navigator.push( WidgetsBinding.instance.addPostFrameCallback((_) {
context, _myWalletProvider.listWallets =
MaterialPageRoute(builder: (context) { _myWalletProvider
return const WalletViewScreen(); .readAllWallets(_currentChest);
}), _myWalletProvider.rebuildWidget();
); });
} }
}, : null,
child: SizedBox( child: Row(children: <Widget>[
height: 50, const SizedBox(width: 30),
child: Row(children: <Widget>[ Image.asset(
const SizedBox(width: 30), 'assets/walletOptions/trash.png',
Image.asset( height: 45,
'assets/walletOptions/clock.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))),
]),
),
]), ]),
), ),
), ),

View File

@ -7,7 +7,6 @@ import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/wallet_options.dart'; import 'package:gecko/models/wallet_options.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/screens/common_elements.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/chest_options.dart';
import 'package:gecko/screens/myWallets/choose_chest.dart'; import 'package:gecko/screens/myWallets/choose_chest.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart'; import 'package:gecko/screens/myWallets/wallet_options.dart';
@ -27,10 +26,8 @@ class WalletsHome extends StatelessWidget {
final int _currentChestNumber = myWalletProvider.getCurrentChest(); final int _currentChestNumber = myWalletProvider.getCurrentChest();
final ChestData _currentChest = chestBox.get(_currentChestNumber); final ChestData _currentChest = chestBox.get(_currentChestNumber);
if (!_currentChest.isCesium) { myWalletProvider.listWallets =
myWalletProvider.listWallets = myWalletProvider.readAllWallets(_currentChestNumber);
myWalletProvider.readAllWallets(_currentChestNumber);
}
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {
@ -57,9 +54,7 @@ class WalletsHome extends StatelessWidget {
backgroundColor: const Color(0xffFFD58D), backgroundColor: const Color(0xffFFD58D),
), ),
body: SafeArea( body: SafeArea(
child: _currentChest.isCesium child: myWalletsTiles(context),
? cesiumWalletOptions(context, _currentChest, myWalletProvider)
: myWalletsTiles(context),
), ),
), ),
); );

View File

@ -68,7 +68,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return const WalletViewScreen(); return WalletViewScreen(pubkey: text);
}), }),
); );
} }
@ -452,7 +452,7 @@ class OldHistoryScreen extends StatelessWidget with ChangeNotifier {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return const WalletViewScreen(); return WalletViewScreen(pubkey: repository[2]);
}), }),
); );
} }

View File

@ -12,11 +12,14 @@ import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class WalletViewScreen extends StatelessWidget { 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); : super(key: key);
final String pubkey; final String pubkey;
final String username; final String username;
final Image avatar; final Image avatar;
final double buttonSize = 100;
final double buttonFontSize = 18;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -34,42 +37,15 @@ class WalletViewScreen extends StatelessWidget {
height: 22, height: 22,
child: Text('Voir un portefeuille'), 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( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
headerProfileView(context, _historyProvider, _cesiumPlusProvider), headerProfileView(context, _historyProvider, _cesiumPlusProvider),
SizedBox(height: isTall ? 60 : 30), SizedBox(height: isTall ? 120 : 70),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
Column(children: <Widget>[ Column(children: <Widget>[
SizedBox( SizedBox(
height: 120, height: buttonSize,
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: const Color(0xffFFD58D), // button color color: const Color(0xffFFD58D), // button color
@ -77,7 +53,7 @@ class WalletViewScreen extends StatelessWidget {
key: const Key('viewHistory'), key: const Key('viewHistory'),
splashColor: orangeC, // inkwell color splashColor: orangeC, // inkwell color
child: const Padding( child: const Padding(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(13),
child: Image( child: Image(
image: AssetImage( image: AssetImage(
'assets/walletOptions/clock.png'), 'assets/walletOptions/clock.png'),
@ -87,9 +63,11 @@ class WalletViewScreen extends StatelessWidget {
context, context,
FaderTransition( FaderTransition(
page: HistoryScreen( page: HistoryScreen(
pubkey: pubkey ?? _historyProvider.pubkey, pubkey: pubkey,
username: username, username: username ??
avatar: avatar, g1WalletsBox.get(pubkey).username,
avatar: avatar ??
g1WalletsBox.get(pubkey).avatar,
), ),
isFast: false), isFast: false),
); );
@ -98,15 +76,16 @@ class WalletViewScreen extends StatelessWidget {
), ),
), ),
const SizedBox(height: 9), const SizedBox(height: 9),
const Text( Text(
"Voir\nl'historique", "Voir\nl'historique",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500), style: TextStyle(
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
), ),
]), ]),
Column(children: <Widget>[ Column(children: <Widget>[
SizedBox( SizedBox(
height: 120, height: buttonSize,
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: const Color(0xffFFD58D), // button color color: const Color(0xffFFD58D), // button color
@ -127,10 +106,11 @@ class WalletViewScreen extends StatelessWidget {
), ),
), ),
const SizedBox(height: 9), const SizedBox(height: 9),
const Text( Text(
"Copier\nla clef", "Copier\nla clef",
textAlign: TextAlign.center, 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(), const Spacer(),
Container( Container(
height: 120, height: buttonSize,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xff7c94b6), color: const Color(0xff7c94b6),
borderRadius: const BorderRadius.all(Radius.circular(100)), borderRadius: const BorderRadius.all(Radius.circular(100)),
@ -175,7 +155,7 @@ class WalletViewScreen extends StatelessWidget {
key: const Key('pay'), key: const Key('pay'),
splashColor: yellowC, // inkwell color splashColor: yellowC, // inkwell color
child: const Padding( child: const Padding(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(14),
child: Image( child: Image(
image: AssetImage('assets/vector_white.png'), image: AssetImage('assets/vector_white.png'),
)), )),
@ -186,12 +166,13 @@ class WalletViewScreen extends StatelessWidget {
), ),
), ),
const SizedBox(height: 9), const SizedBox(height: 9),
const Text( Text(
"Faire un\nvirement", "Faire un\nvirement",
textAlign: TextAlign.center, 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( GestureDetector(
key: const Key('copyPubkey'), key: const Key('copyPubkey'),
onTap: () { onTap: () {
Clipboard.setData( Clipboard.setData(ClipboardData(text: pubkey));
ClipboardData(text: pubkey ?? _historyProvider.pubkey));
_historyProvider.snackCopyKey(context); _historyProvider.snackCopyKey(context);
}, },
child: Text( child: Text(
_historyProvider _historyProvider.getShortPubkey(pubkey),
.getShortPubkey(pubkey ?? _historyProvider.pubkey),
style: const TextStyle( style: const TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
@ -241,7 +220,7 @@ class WalletViewScreen extends StatelessWidget {
), ),
]), ]),
const SizedBox(height: 10), const SizedBox(height: 10),
if (username == null) if (username == null && g1WalletsBox.get(pubkey).username == null)
Query( Query(
options: QueryOptions( options: QueryOptions(
document: gql(getId), document: gql(getId),
@ -255,8 +234,11 @@ class WalletViewScreen extends StatelessWidget {
return const Text('...'); return const Text('...');
} else if (result.data['idty'] == null || } else if (result.data['idty'] == null ||
result.data['idty']['username'] == null) { result.data['idty']['username'] == null) {
g1WalletsBox.get(pubkey).username = '';
return const Text(''); return const Text('');
} else { } else {
g1WalletsBox.get(pubkey).username =
result?.data['idty']['username'] ?? '';
return SizedBox( return SizedBox(
width: 230, width: 230,
child: Text( 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) if (username != null)
Text( SizedBox(
username, width: 230,
style: const TextStyle( child: Text(
fontSize: 27, username,
color: Color(0xff814C00), style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
), ),
), ),
const SizedBox(height: 25), const SizedBox(height: 25),
@ -302,20 +298,19 @@ class WalletViewScreen extends StatelessWidget {
_historyProvider.pubkey, _avatarSize), _historyProvider.pubkey, _avatarSize),
builder: builder:
(BuildContext context, AsyncSnapshot<Image> _avatar) { (BuildContext context, AsyncSnapshot<Image> _avatar) {
if (_avatar.connectionState != ConnectionState.done || if (_avatar.connectionState != ConnectionState.done) {
_avatar.hasError) {
return Stack(children: [ return Stack(children: [
ClipOval( ClipOval(
child: child:
_cesiumPlusProvider.defaultAvatar(_avatarSize), _cesiumPlusProvider.defaultAvatar(_avatarSize),
), ),
Positioned( Positioned(
top: 16.5, top: 15,
right: 47.5, right: 45,
width: 55, width: 51,
height: 55, height: 51,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 6, strokeWidth: 5,
color: orangeC, color: orangeC,
), ),
), ),
@ -333,7 +328,11 @@ class WalletViewScreen extends StatelessWidget {
); );
}, },
child: ClipOval( child: ClipOval(
child: _avatar.data, child: Image(
image: _avatar.data.image,
height: _avatarSize,
fit: BoxFit.cover,
),
), ),
); );
} }