Newer
Older
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';
import 'package:gecko/models/queries.dart';
import 'package:gecko/screens/avatar_fullscreen.dart';
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})
: super(key: key);
final String pubkey;
final String username;
final Image avatar;
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
WalletsProfilesProvider _historyProvider =
Provider.of<WalletsProfilesProvider>(context);
CesiumPlusProvider _cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context);
// WalletOptionsProvider _walletOptions = WalletOptionsProvider();
double _avatarSize = 150;
return Scaffold(
appBar: AppBar(
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
elevation: 0,
toolbarHeight: 60 * ratio,
title: const SizedBox(
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>[
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.symmetric(horizontal: 30),
child: Row(children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: [
GestureDetector(
key: const Key('copyPubkey'),
onTap: () {
Clipboard.setData(ClipboardData(
text: pubkey ?? _historyProvider.pubkey));
_historyProvider.snackCopyKey(context);
},
child: Text(
_historyProvider.getShortPubkey(
pubkey ?? _historyProvider.pubkey),
style: const TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
),
const SizedBox(height: 10),
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
if (username == null)
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) {
return const Text('');
} else {
return SizedBox(
width: 230,
child: Text(
result?.data['idty']['username'] ?? '',
style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
),
);
}
},
),
if (username != null)
Text(
username,
style: const TextStyle(
fontSize: 27,
color: Color(0xff814C00),
),
),
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) {
if (_avatar.connectionState !=
ConnectionState.done ||
_avatar.hasError) {
return Stack(children: [
ClipOval(
child: _cesiumPlusProvider
.defaultAvatar(_avatarSize),
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Positioned(
top: 16.5,
right: 47.5,
width: 55,
height: 55,
child: CircularProgressIndicator(
strokeWidth: 6,
color: orangeC,
),
),
]);
}
if (_avatar.hasData) {
return GestureDetector(
key: const Key('openAvatar'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return AvatarFullscreen(_avatar.data);
}),
);
},
child: ClipOval(
child: _avatar.data,
),
);
}
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),
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
]),
]),
),
),
SizedBox(height: isTall ? 60 : 30),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
Column(children: <Widget>[
SizedBox(
height: 120,
child: ClipOval(
child: Material(
color: const Color(0xffFFD58D), // button color
child: InkWell(
key: const Key('viewHistory'),
splashColor: orangeC, // inkwell color
child: const Padding(
padding: EdgeInsets.all(15),
child: Image(
image: AssetImage(
'assets/walletOptions/clock.png'),
height: 90)),
onTap: () {
null;
}),
),
),
),
const SizedBox(height: 9),
const Text(
"Voir\nl'historique",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
]),
Column(children: <Widget>[
SizedBox(
height: 120,
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),
const Text(
"Copier\nla clef",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
]),
]),
// 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));
// },
// ),
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
const Spacer(),
Container(
height: 120,
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(
padding: EdgeInsets.all(16),
child: Image(
image: AssetImage('assets/vector_white.png'),
)),
onTap: () {
null;
}),
),
),
),
const SizedBox(height: 9),
const Text(
"Faire un\nvirement",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
SizedBox(height: isTall ? 100 : 50)
]),
));
}
}