Improve history view

This commit is contained in:
poka 2020-12-14 11:04:13 +01:00
parent 81915382f3
commit 25515905ec
5 changed files with 41 additions and 13 deletions

View File

@ -57,7 +57,7 @@ Future getBalance(String pubkey) async {
Future getHistory(String pubkey) async { Future getHistory(String pubkey) async {
print(pubkey); print(pubkey);
var query = """{ var query = """{
transactionsHistory(pubkey: "$pubkey") { txsHistoryBc(pubkeyOrScript: "$pubkey") {
received { received {
writtenTime writtenTime
issuers issuers
@ -74,7 +74,14 @@ Future getHistory(String pubkey) async {
final res = await buildQ(query); final res = await buildQ(query);
// Parse history // Parse history
var result = res.data["transactionsHistory"]["received"]; var result;
try {
result = res.data["txsHistoryBc"]["received"];
} catch (e) {
print("DEBUG: " + e.toString());
print(res.data);
return false;
}
var i = 0; var i = 0;
// String outPubkey; // String outPubkey;
var trans = []; var trans = [];

View File

@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
// import 'package:image_gallery_saver/image_gallery_saver.dart'; // import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:qrscan/qrscan.dart' as scanner; import 'package:qrscan/qrscan.dart' as scanner;
import 'package:intl/intl.dart';
// import 'package:flutter_html_view';
import 'api.dart'; import 'api.dart';
void main() { void main() {
@ -59,6 +61,7 @@ class _MyAppState extends State<MyApp> {
enabled: false, enabled: false,
controller: this._outputPubkey, controller: this._outputPubkey,
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Clé publique scanné', hintText: 'Clé publique scanné',
hintStyle: TextStyle(fontSize: 15), hintStyle: TextStyle(fontSize: 15),
@ -81,7 +84,7 @@ class _MyAppState extends State<MyApp> {
horizontal: 7, vertical: 15), horizontal: 7, vertical: 15),
), ),
style: style:
TextStyle(fontSize: 18.0, color: Colors.black)), TextStyle(fontSize: 30.0, color: Colors.black)),
TextField( TextField(
enabled: false, enabled: false,
controller: this._outputHistory, controller: this._outputHistory,
@ -95,7 +98,7 @@ class _MyAppState extends State<MyApp> {
horizontal: 7, vertical: 15), horizontal: 7, vertical: 15),
), ),
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 13.0,
height: 1.5, height: 1.5,
color: Colors.black)), color: Colors.black)),
SizedBox(height: 20), SizedBox(height: 20),
@ -171,27 +174,33 @@ class _MyAppState extends State<MyApp> {
this._outputBalance.text = ""; this._outputBalance.text = "";
this._outputHistory.text = ""; this._outputHistory.text = "";
// final udValue = await getUD(); // final udValue = await getUD();
final myBalance = await getBalance(barcode.toString());
final myHistory = await getHistory(barcode.toString());
this._outputPubkey.text = barcode; this._outputPubkey.text = barcode;
this._outputBalance.text = myBalance.toString() + " Ḡ1"; final myBalance = await getBalance(barcode.toString());
this._outputBalance.text = myBalance.toString() + " Ğ1";
final myHistory = await getHistory(barcode.toString());
if (myHistory == false) {
return false;
}
String historyBloc = ""; String historyBloc = "";
var j = 0; var j = 0;
for (var i in myHistory) { for (var i in myHistory) {
print(i); // print(i);
var date = i[0]; var dateBrut = i[0];
date = DateTime.fromMillisecondsSinceEpoch(date * 1000); dateBrut = DateTime.fromMillisecondsSinceEpoch(dateBrut * 1000);
final DateFormat formatter = DateFormat('dd-MM-yy - H:M');
final String date = formatter.format(dateBrut);
final issuer = i[1]; final issuer = i[1];
final amount = i[2]; final amount = i[2];
// final amountUD = i[3]; // final amountUD = i[3];
final comment = i[4]; final comment = i[4];
historyBloc += date.toString() + historyBloc += date.toString() +
" | " + " \n " +
issuer.toString() + issuer.toString() +
" | " + " \n " +
amount.toString() + amount.toString() +
" | " + " Ğ1\n " +
comment.toString() + comment.toString() +
"\n---\n"; "\n---\n";
j++; j++;

View File

@ -144,6 +144,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:

View File

@ -31,6 +31,7 @@ dependencies:
gql_dio_link: gql_dio_link:
gql_exec: gql_exec:
gql_link: gql_link:
intl:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.

4
scripts/build-apk.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
flutter build apk --split-per-abi