Big change on profiles UX; Can switch between pay view and history view
This commit is contained in:
parent
5c8fd998af
commit
b69d8d3f2b
|
@ -20,6 +20,8 @@ class HistoryProvider with ChangeNotifier {
|
|||
bool isFirstBuild = true;
|
||||
String fetchMoreCursor;
|
||||
Map pageInfo;
|
||||
bool isHistoryScreen = false;
|
||||
String historySwitchButtun = "Voir l'historique";
|
||||
|
||||
Future scan() async {
|
||||
await Permission.camera.request();
|
||||
|
@ -58,7 +60,22 @@ class HistoryProvider with ChangeNotifier {
|
|||
print("C'est une pubkey !!!");
|
||||
|
||||
this.pubkey = pubkey;
|
||||
getShortPubkey(pubkey);
|
||||
|
||||
this.outputPubkey.text = pubkey;
|
||||
print(pubkeyShort);
|
||||
|
||||
isHistoryScreen = false;
|
||||
historySwitchButtun = "Voir l'historique";
|
||||
notifyListeners();
|
||||
|
||||
return pubkey;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
String getShortPubkey(String pubkey) {
|
||||
List<int> pubkeyByte = Base58Decode(pubkey);
|
||||
Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes);
|
||||
String pubkeyCheksum = Base58Encode(pubkeyS256.bytes);
|
||||
|
@ -70,14 +87,8 @@ class HistoryProvider with ChangeNotifier {
|
|||
position: TruncatePosition.end) +
|
||||
truncate(pubkey, 4, omission: "", position: TruncatePosition.start) +
|
||||
':$pubkeyChecksumShort';
|
||||
this.outputPubkey.text = pubkey;
|
||||
print(pubkeyShort);
|
||||
notifyListeners();
|
||||
|
||||
return pubkey;
|
||||
}
|
||||
|
||||
return '';
|
||||
return pubkeyShort;
|
||||
}
|
||||
|
||||
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
|
||||
|
@ -128,11 +139,13 @@ class HistoryProvider with ChangeNotifier {
|
|||
num amountUD = amount / currentUD;
|
||||
if (direction == "RECEIVED") {
|
||||
transBC[i].add(transaction['issuers'][0]);
|
||||
transBC[i].add(getShortPubkey(transaction['issuers'][0]));
|
||||
transBC[i].add(amount.toString());
|
||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||
} else if (direction == "SENT") {
|
||||
final outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
||||
transBC[i].add(outPubkey);
|
||||
transBC[i].add(getShortPubkey(outPubkey));
|
||||
transBC[i].add('- ' + amount.toString());
|
||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||
}
|
||||
|
@ -215,6 +228,16 @@ class HistoryProvider with ChangeNotifier {
|
|||
Scaffold.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
void switchProfileView() {
|
||||
isHistoryScreen = !isHistoryScreen;
|
||||
if (isHistoryScreen) {
|
||||
historySwitchButtun = "Payer";
|
||||
} else {
|
||||
historySwitchButtun = "Voir l'historique";
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// num getBalance(_pubkey) {
|
||||
// getBalance(_pubkey);
|
||||
// }
|
||||
|
|
|
@ -104,11 +104,6 @@ class HomeProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
searchAction() {
|
||||
//TODO: OPEN SEARCH MODE !!
|
||||
print('Search mode');
|
||||
}
|
||||
|
||||
T getRandomElement<T>(List<T> list) {
|
||||
final random = Random();
|
||||
var i = random.nextInt(list.length);
|
||||
|
|
|
@ -10,7 +10,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'dart:ui';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:truncate/truncate.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||
|
@ -21,6 +20,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
final _formKey = GlobalKey<FormState>();
|
||||
FocusNode _pubkeyFocus = FocusNode();
|
||||
List cesiumData;
|
||||
final double avatarsSize = 80;
|
||||
|
||||
FetchMore fetchMore;
|
||||
FetchMoreOptions opts;
|
||||
|
@ -55,13 +55,13 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
),
|
||||
),
|
||||
body: Column(children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
SizedBox(height: 0),
|
||||
if (_historyProvider.pubkey != '')
|
||||
historyQuery(context, _historyProvider),
|
||||
]));
|
||||
}
|
||||
|
||||
Widget historyQuery(context, _historyProvider) {
|
||||
Widget historyQuery(context, HistoryProvider _historyProvider) {
|
||||
_pubkeyFocus.unfocus();
|
||||
// HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
CesiumPlusProvider _cesiumPlusProvider =
|
||||
|
@ -122,7 +122,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
child: ListView(
|
||||
controller: scrollController,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 20),
|
||||
if (_historyProvider.pubkey != '')
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
@ -131,7 +131,8 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
children: [
|
||||
if (_isFirstExec)
|
||||
Container(
|
||||
padding: const EdgeInsets.only(left: 30),
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(12, 0, 5, 0),
|
||||
child: FutureBuilder(
|
||||
future: _cesiumPlusProvider
|
||||
.getAvatar(_historyProvider.pubkey),
|
||||
|
@ -148,24 +149,24 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
return Image.file(
|
||||
File(appPath.path +
|
||||
'/default_avatar.png'),
|
||||
height: 65);
|
||||
height: avatarsSize);
|
||||
}
|
||||
if (_avatar.hasError) {
|
||||
return Image.file(
|
||||
File(appPath.path +
|
||||
'/default_avatar.png'),
|
||||
height: 65);
|
||||
height: avatarsSize);
|
||||
}
|
||||
if (_avatar.hasData) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
child: Image.file(_avatar.data[0],
|
||||
height: 65));
|
||||
height: avatarsSize));
|
||||
}
|
||||
return Image.file(
|
||||
File(appPath.path +
|
||||
'/default_avatar.png'),
|
||||
height: 65);
|
||||
height: avatarsSize);
|
||||
})),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
|
@ -181,52 +182,60 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
30, 0, 15, 0), // .only(right: 15),
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.payments),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return paymentPopup(context);
|
||||
});
|
||||
},
|
||||
iconSize: 30,
|
||||
color: Color(0xFFB16E16)))
|
||||
30, 0, 5, 0), // .only(right: 15),
|
||||
child: Text('TODO')),
|
||||
SizedBox(width: 0)
|
||||
]),
|
||||
SizedBox(height: 15),
|
||||
if (_isFirstExec)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
||||
// padding: const EdgeInsets.,
|
||||
child: FutureBuilder(
|
||||
future: _cesiumPlusProvider
|
||||
.getName(_historyProvider.pubkey),
|
||||
initialData: '',
|
||||
initialData: '...',
|
||||
builder: (context, snapshot) {
|
||||
return Text(snapshot.data,
|
||||
style: TextStyle(fontSize: 16));
|
||||
return Text(
|
||||
snapshot.data != ''
|
||||
? snapshot.data
|
||||
: '-',
|
||||
style: TextStyle(fontSize: 20));
|
||||
}))
|
||||
]),
|
||||
SizedBox(height: 15),
|
||||
SizedBox(height: 18),
|
||||
if (_isFirstExec)
|
||||
Text(balance.toString() + ' Ğ1',
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
||||
child: Text(balance.toString() + ' Ğ1',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20.0)),
|
||||
style: TextStyle(fontSize: 18.0))),
|
||||
SizedBox(height: 20),
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
height: 5,
|
||||
thickness: 0.5,
|
||||
indent: 0,
|
||||
endIndent: 0,
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 1,
|
||||
primary: Colors.grey[50], // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
_historyProvider.transBC == null
|
||||
? Text('Aucune transaction à afficher.')
|
||||
: loopTransactions(context, result),
|
||||
onPressed: () {
|
||||
_historyProvider.switchProfileView();
|
||||
},
|
||||
child: Text(_historyProvider.historySwitchButtun,
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Color(0xffD28928)))),
|
||||
// const Divider(
|
||||
// color: Colors.grey,
|
||||
// height: 5,
|
||||
// thickness: 0.5,
|
||||
// indent: 0,
|
||||
// endIndent: 0,
|
||||
// ),
|
||||
_historyProvider.isHistoryScreen
|
||||
? historyView(context, result)
|
||||
: payView(context),
|
||||
],
|
||||
)),
|
||||
onNotification: (t) {
|
||||
|
@ -243,59 +252,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
));
|
||||
}
|
||||
|
||||
Widget loopTransactions(context, result) {
|
||||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
Widget payView(context) {
|
||||
TextEditingController payComment = new TextEditingController();
|
||||
|
||||
return Column(children: <Widget>[
|
||||
for (var repository in _historyProvider.transBC)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.all(5.0),
|
||||
leading: Text(repository[1].toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[800],
|
||||
fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center),
|
||||
title: Text(repository[5],
|
||||
style: TextStyle(fontSize: 14.0),
|
||||
textAlign: TextAlign.center),
|
||||
subtitle: Text(
|
||||
truncate(repository[2], 20,
|
||||
omission: "...", position: TruncatePosition.end),
|
||||
style: TextStyle(fontSize: 11.0, fontFamily: 'Monospace'),
|
||||
textAlign: TextAlign.center),
|
||||
trailing: Text("${repository[3]} Ğ1",
|
||||
style: TextStyle(fontSize: 14.0),
|
||||
textAlign: TextAlign.justify),
|
||||
dense: true,
|
||||
isThreeLine: false,
|
||||
onTap: () {
|
||||
// this._outputPubkey.text = repository[2];
|
||||
_historyProvider.isPubkey(repository[2]);
|
||||
})),
|
||||
if (result.isLoading)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CircularProgressIndicator(),
|
||||
],
|
||||
),
|
||||
// if (_historyProvider.isTheEnd) // What I did before ...
|
||||
if (!_historyProvider.pageInfo['hasPreviousPage'])
|
||||
Column(children: <Widget>[
|
||||
SizedBox(height: 15),
|
||||
Text("Début de l'historique.",
|
||||
textAlign: TextAlign.center, style: TextStyle(fontSize: 20)),
|
||||
SizedBox(height: 15)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
Widget paymentPopup(context) {
|
||||
return AlertDialog(
|
||||
content: Stack(
|
||||
return Stack(
|
||||
overflow: Overflow.visible,
|
||||
children: <Widget>[
|
||||
Form(
|
||||
|
@ -303,14 +263,19 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text('À:'),
|
||||
SizedBox(height: 20),
|
||||
Text('Commentaire:'),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(this._outputPubkey.text,
|
||||
child: TextField(
|
||||
controller: payComment,
|
||||
maxLines: 2,
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
TextStyle(fontSize: 15, fontWeight: FontWeight.w500)),
|
||||
),
|
||||
decoration: InputDecoration(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold))),
|
||||
SizedBox(height: 20),
|
||||
Text('Montant (Ğ1):'),
|
||||
Padding(
|
||||
|
@ -318,6 +283,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
child: TextFormField(
|
||||
textAlign: TextAlign.center,
|
||||
autofocus: true,
|
||||
maxLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.allow(RegExp(r'(^\d*\.?\d*)'))
|
||||
|
@ -340,7 +306,58 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget historyView(context, result) {
|
||||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
|
||||
return _historyProvider.transBC == null
|
||||
? Text('Aucune transaction à afficher.')
|
||||
: Column(children: <Widget>[
|
||||
for (var repository in _historyProvider.transBC)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.all(5.0),
|
||||
leading: Text(repository[1].toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[800],
|
||||
fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center),
|
||||
title: Text(repository[3],
|
||||
style: TextStyle(
|
||||
fontSize: 15.0, fontFamily: 'Monospace'),
|
||||
textAlign: TextAlign.center),
|
||||
subtitle: Text(repository[6] != '' ? repository[6] : '-',
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
textAlign: TextAlign.center),
|
||||
trailing: Text("${repository[4]} Ğ1",
|
||||
style: TextStyle(fontSize: 14.0),
|
||||
textAlign: TextAlign.justify),
|
||||
dense: true,
|
||||
isThreeLine: false,
|
||||
onTap: () {
|
||||
// this._outputPubkey.text = repository[2];
|
||||
_historyProvider.isPubkey(repository[2]);
|
||||
})),
|
||||
if (result.isLoading)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CircularProgressIndicator(),
|
||||
],
|
||||
),
|
||||
// if (_historyProvider.isTheEnd) // What I did before ...
|
||||
if (!_historyProvider.pageInfo['hasPreviousPage'])
|
||||
Column(children: <Widget>[
|
||||
SizedBox(height: 15),
|
||||
Text("Début de l'historique.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 20)),
|
||||
SizedBox(height: 15)
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ class HomeScreen extends StatelessWidget {
|
|||
} else {
|
||||
_homeProvider.handleSearchEnd();
|
||||
}
|
||||
_homeProvider.searchAction();
|
||||
}))
|
||||
],
|
||||
backgroundColor: Color(0xffFFD58D),
|
||||
|
|
|
@ -91,7 +91,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
new ElevatedButton(
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Color(0xffFFD68E), // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
|
|
Loading…
Reference in New Issue