2021-11-29 04:05:08 +01:00
|
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:gecko/globals.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:gecko/models/cesium_plus.dart';
|
2021-11-30 01:25:48 +01:00
|
|
|
import 'package:gecko/models/wallets_profiles.dart';
|
2021-11-29 05:53:21 +01:00
|
|
|
import 'package:gecko/models/queries.dart';
|
|
|
|
import 'package:gecko/screens/avatar_fullscreen.dart';
|
2021-11-30 10:28:13 +01:00
|
|
|
import 'package:gecko/screens/common_elements.dart';
|
|
|
|
import 'package:gecko/screens/history.dart';
|
2021-11-29 05:53:21 +01:00
|
|
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
2021-11-29 04:05:08 +01:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class WalletViewScreen extends StatelessWidget {
|
2021-12-01 08:14:07 +01:00
|
|
|
const WalletViewScreen(
|
|
|
|
{@required this.pubkey, this.username, this.avatar, Key key})
|
2021-11-30 01:25:48 +01:00
|
|
|
: super(key: key);
|
|
|
|
final String pubkey;
|
|
|
|
final String username;
|
|
|
|
final Image avatar;
|
2021-12-01 08:14:07 +01:00
|
|
|
final double buttonSize = 100;
|
|
|
|
final double buttonFontSize = 18;
|
2021-11-29 04:05:08 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2021-11-30 01:25:48 +01:00
|
|
|
WalletsProfilesProvider _historyProvider =
|
2021-11-30 10:28:13 +01:00
|
|
|
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
2021-11-29 04:05:08 +01:00
|
|
|
CesiumPlusProvider _cesiumPlusProvider =
|
2021-11-30 10:28:13 +01:00
|
|
|
Provider.of<CesiumPlusProvider>(context, listen: false);
|
2021-11-29 04:05:08 +01:00
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2021-11-30 01:25:48 +01:00
|
|
|
elevation: 0,
|
|
|
|
toolbarHeight: 60 * ratio,
|
|
|
|
title: const SizedBox(
|
|
|
|
height: 22,
|
|
|
|
child: Text('Voir un portefeuille'),
|
|
|
|
),
|
|
|
|
),
|
2021-11-29 04:05:08 +01:00
|
|
|
body: SafeArea(
|
|
|
|
child: Column(children: <Widget>[
|
2021-11-30 10:28:13 +01:00
|
|
|
headerProfileView(context, _historyProvider, _cesiumPlusProvider),
|
2021-12-01 08:14:07 +01:00
|
|
|
SizedBox(height: isTall ? 120 : 70),
|
2021-11-29 04:05:08 +01:00
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
|
|
|
Column(children: <Widget>[
|
|
|
|
SizedBox(
|
2021-12-01 08:14:07 +01:00
|
|
|
height: buttonSize,
|
2021-11-29 04:05:08 +01:00
|
|
|
child: ClipOval(
|
|
|
|
child: Material(
|
|
|
|
color: const Color(0xffFFD58D), // button color
|
|
|
|
child: InkWell(
|
|
|
|
key: const Key('viewHistory'),
|
|
|
|
splashColor: orangeC, // inkwell color
|
|
|
|
child: const Padding(
|
2021-12-01 08:14:07 +01:00
|
|
|
padding: EdgeInsets.all(13),
|
2021-11-29 04:05:08 +01:00
|
|
|
child: Image(
|
|
|
|
image: AssetImage(
|
|
|
|
'assets/walletOptions/clock.png'),
|
|
|
|
height: 90)),
|
|
|
|
onTap: () {
|
2021-11-30 10:28:13 +01:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
FaderTransition(
|
|
|
|
page: HistoryScreen(
|
2021-12-01 08:14:07 +01:00
|
|
|
pubkey: pubkey,
|
|
|
|
username: username ??
|
|
|
|
g1WalletsBox.get(pubkey).username,
|
|
|
|
avatar: avatar ??
|
|
|
|
g1WalletsBox.get(pubkey).avatar,
|
2021-11-30 10:28:13 +01:00
|
|
|
),
|
|
|
|
isFast: false),
|
|
|
|
);
|
2021-11-29 04:05:08 +01:00
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 9),
|
2021-12-01 08:14:07 +01:00
|
|
|
Text(
|
2021-11-29 04:05:08 +01:00
|
|
|
"Voir\nl'historique",
|
|
|
|
textAlign: TextAlign.center,
|
2021-12-01 08:14:07 +01:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
2021-11-29 04:05:08 +01:00
|
|
|
),
|
|
|
|
]),
|
|
|
|
Column(children: <Widget>[
|
|
|
|
SizedBox(
|
2021-12-01 08:14:07 +01:00
|
|
|
height: buttonSize,
|
2021-11-29 04:05:08 +01:00
|
|
|
child: ClipOval(
|
|
|
|
child: Material(
|
|
|
|
color: const Color(0xffFFD58D), // button color
|
|
|
|
child: InkWell(
|
|
|
|
key: const Key('copyKey'),
|
|
|
|
splashColor: orangeC, // inkwell color
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(20),
|
|
|
|
child: Image(
|
|
|
|
image: AssetImage('assets/copy_key.png'),
|
|
|
|
height: 90)),
|
|
|
|
onTap: () {
|
|
|
|
Clipboard.setData(
|
|
|
|
ClipboardData(text: _historyProvider.pubkey));
|
|
|
|
_historyProvider.snackCopyKey(context);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 9),
|
2021-12-01 08:14:07 +01:00
|
|
|
Text(
|
2021-11-29 04:05:08 +01:00
|
|
|
"Copier\nla clef",
|
|
|
|
textAlign: TextAlign.center,
|
2021-12-01 08:14:07 +01:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
2021-11-29 04:05:08 +01:00
|
|
|
),
|
|
|
|
]),
|
|
|
|
]),
|
2021-11-30 01:25:48 +01:00
|
|
|
// FutureBuilder(
|
|
|
|
// future: _walletOptions.generateQRcode(_historyProvider.pubkey),
|
|
|
|
// builder: (context, snapshot) {
|
|
|
|
// return snapshot.data != null
|
|
|
|
// ? GestureDetector(
|
|
|
|
// key: const Key('openQrcode'),
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// MaterialPageRoute(builder: (context) {
|
|
|
|
// return AvatarFullscreen(
|
|
|
|
// Image.memory(snapshot.data),
|
|
|
|
// title: 'QrCode du profil',
|
|
|
|
// color: Colors.white,
|
|
|
|
// );
|
|
|
|
// }),
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// child: Image.memory(snapshot.data, height: 60 * ratio),
|
|
|
|
// )
|
|
|
|
// : const Text('-', style: TextStyle(fontSize: 20));
|
|
|
|
// },
|
|
|
|
// ),
|
2021-11-29 04:05:08 +01:00
|
|
|
const Spacer(),
|
|
|
|
Container(
|
2021-12-01 08:14:07 +01:00
|
|
|
height: buttonSize,
|
2021-11-29 04:05:08 +01:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: const Color(0xff7c94b6),
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(100)),
|
|
|
|
border: Border.all(
|
|
|
|
color: const Color(0xFF6c4204),
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: ClipOval(
|
|
|
|
child: Material(
|
|
|
|
color: orangeC, // button color
|
|
|
|
child: InkWell(
|
|
|
|
key: const Key('pay'),
|
|
|
|
splashColor: yellowC, // inkwell color
|
|
|
|
child: const Padding(
|
2021-12-01 08:14:07 +01:00
|
|
|
padding: EdgeInsets.all(14),
|
2021-11-29 04:05:08 +01:00
|
|
|
child: Image(
|
|
|
|
image: AssetImage('assets/vector_white.png'),
|
|
|
|
)),
|
|
|
|
onTap: () {
|
|
|
|
null;
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 9),
|
2021-12-01 08:14:07 +01:00
|
|
|
Text(
|
2021-11-29 04:05:08 +01:00
|
|
|
"Faire un\nvirement",
|
|
|
|
textAlign: TextAlign.center,
|
2021-12-01 08:14:07 +01:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: buttonFontSize, fontWeight: FontWeight.w500),
|
2021-11-29 04:05:08 +01:00
|
|
|
),
|
2021-12-01 08:14:07 +01:00
|
|
|
SizedBox(height: isTall ? 120 : 70)
|
2021-11-29 04:05:08 +01:00
|
|
|
]),
|
|
|
|
));
|
|
|
|
}
|
2021-11-30 10:28:13 +01:00
|
|
|
|
|
|
|
Widget headerProfileView(
|
|
|
|
BuildContext context,
|
|
|
|
WalletsProfilesProvider _historyProvider,
|
|
|
|
CesiumPlusProvider _cesiumPlusProvider) {
|
|
|
|
const double _avatarSize = 140;
|
|
|
|
|
|
|
|
return Column(children: <Widget>[
|
|
|
|
Container(
|
|
|
|
height: 10,
|
|
|
|
color: yellowC,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
colors: [
|
|
|
|
yellowC,
|
|
|
|
const Color(0xFFE7811A),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 30, right: 40),
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
|
|
|
|
Widget>[
|
|
|
|
Row(children: [
|
|
|
|
GestureDetector(
|
|
|
|
key: const Key('copyPubkey'),
|
|
|
|
onTap: () {
|
2021-12-01 08:14:07 +01:00
|
|
|
Clipboard.setData(ClipboardData(text: pubkey));
|
2021-11-30 10:28:13 +01:00
|
|
|
_historyProvider.snackCopyKey(context);
|
|
|
|
},
|
|
|
|
child: Text(
|
2021-12-01 08:14:07 +01:00
|
|
|
_historyProvider.getShortPubkey(pubkey),
|
2021-11-30 10:28:13 +01:00
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 30,
|
|
|
|
fontWeight: FontWeight.w800,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
const SizedBox(height: 10),
|
2021-12-01 08:14:07 +01:00
|
|
|
if (username == null && g1WalletsBox.get(pubkey).username == null)
|
2021-11-30 10:28:13 +01:00
|
|
|
Query(
|
|
|
|
options: QueryOptions(
|
|
|
|
document: gql(getId),
|
|
|
|
variables: {
|
|
|
|
'pubkey': _historyProvider.pubkey,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
builder: (QueryResult result,
|
|
|
|
{VoidCallback refetch, FetchMore fetchMore}) {
|
|
|
|
if (result.isLoading || result.hasException) {
|
|
|
|
return const Text('...');
|
|
|
|
} else if (result.data['idty'] == null ||
|
|
|
|
result.data['idty']['username'] == null) {
|
2021-12-01 08:14:07 +01:00
|
|
|
g1WalletsBox.get(pubkey).username = '';
|
2021-11-30 10:28:13 +01:00
|
|
|
return const Text('');
|
|
|
|
} else {
|
2021-12-01 08:14:07 +01:00
|
|
|
g1WalletsBox.get(pubkey).username =
|
|
|
|
result?.data['idty']['username'] ?? '';
|
2021-11-30 10:28:13 +01:00
|
|
|
return SizedBox(
|
|
|
|
width: 230,
|
|
|
|
child: Text(
|
|
|
|
result?.data['idty']['username'] ?? '',
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 27,
|
|
|
|
color: Color(0xff814C00),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2021-12-01 08:14:07 +01:00
|
|
|
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),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-11-30 10:28:13 +01:00
|
|
|
if (username != null)
|
2021-12-01 08:14:07 +01:00
|
|
|
SizedBox(
|
|
|
|
width: 230,
|
|
|
|
child: Text(
|
|
|
|
username,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 27,
|
|
|
|
color: Color(0xff814C00),
|
|
|
|
),
|
2021-11-30 10:28:13 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 25),
|
|
|
|
FutureBuilder(
|
|
|
|
future: _cesiumPlusProvider.getName(_historyProvider.pubkey),
|
|
|
|
initialData: '...',
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return SizedBox(
|
|
|
|
width: 230,
|
|
|
|
child: Text(
|
|
|
|
snapshot.data ?? '-',
|
|
|
|
style:
|
|
|
|
const TextStyle(fontSize: 18, color: Colors.black),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
const SizedBox(height: 30),
|
|
|
|
]),
|
|
|
|
const Spacer(),
|
|
|
|
Column(children: <Widget>[
|
|
|
|
if (avatar == null)
|
|
|
|
FutureBuilder(
|
|
|
|
future: _cesiumPlusProvider.getAvatar(
|
|
|
|
_historyProvider.pubkey, _avatarSize),
|
|
|
|
builder:
|
|
|
|
(BuildContext context, AsyncSnapshot<Image> _avatar) {
|
2021-12-01 08:14:07 +01:00
|
|
|
if (_avatar.connectionState != ConnectionState.done) {
|
2021-11-30 10:28:13 +01:00
|
|
|
return Stack(children: [
|
|
|
|
ClipOval(
|
|
|
|
child:
|
|
|
|
_cesiumPlusProvider.defaultAvatar(_avatarSize),
|
|
|
|
),
|
|
|
|
Positioned(
|
2021-12-01 08:14:07 +01:00
|
|
|
top: 15,
|
|
|
|
right: 45,
|
|
|
|
width: 51,
|
|
|
|
height: 51,
|
2021-11-30 10:28:13 +01:00
|
|
|
child: CircularProgressIndicator(
|
2021-12-01 08:14:07 +01:00
|
|
|
strokeWidth: 5,
|
2021-11-30 10:28:13 +01:00
|
|
|
color: orangeC,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
if (_avatar.hasData) {
|
|
|
|
return GestureDetector(
|
|
|
|
key: const Key('openAvatar'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return AvatarFullscreen(_avatar.data);
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: ClipOval(
|
2021-12-01 08:14:07 +01:00
|
|
|
child: Image(
|
|
|
|
image: _avatar.data.image,
|
|
|
|
height: _avatarSize,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
2021-11-30 10:28:13 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return ClipOval(
|
|
|
|
child: _cesiumPlusProvider.defaultAvatar(_avatarSize),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
if (avatar != null)
|
|
|
|
GestureDetector(
|
|
|
|
key: const Key('openAvatar'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return AvatarFullscreen(avatar);
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: ClipOval(
|
|
|
|
child: Image(
|
|
|
|
image: avatar.image,
|
|
|
|
height: _avatarSize,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 25),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
2021-11-29 04:05:08 +01:00
|
|
|
}
|