Improve padding
This commit is contained in:
parent
855499e731
commit
70bd64bcef
|
@ -1,6 +1,11 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
num removeDecimalZero(double n) {
|
||||||
|
String result = n.toStringAsFixed(n.truncateToDouble() == n ? 0 : 1);
|
||||||
|
return num.parse(result);
|
||||||
|
}
|
||||||
|
|
||||||
List parseHistory(txs) {
|
List parseHistory(txs) {
|
||||||
var transBC = [];
|
var transBC = [];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -23,19 +28,20 @@ List parseHistory(txs) {
|
||||||
transBC[i].add(date);
|
transBC[i].add(date);
|
||||||
print(
|
print(
|
||||||
"DEBUG date et comment: ${date.toString()} -- ${transaction['comment'].toString()}");
|
"DEBUG date et comment: ${date.toString()} -- ${transaction['comment'].toString()}");
|
||||||
var amountBrut = int.parse(output.split(':')[0]);
|
int amountBrut = int.parse(output.split(':')[0]);
|
||||||
final base = int.parse(output.split(':')[1]);
|
final base = int.parse(output.split(':')[1]);
|
||||||
final applyBase = base - currentBase;
|
final int applyBase = base - currentBase;
|
||||||
final amount = amountBrut * pow(10, applyBase) / 100;
|
final num amount = removeDecimalZero(amountBrut * pow(10, applyBase) / 100);
|
||||||
var amountUD = amount / currentUD;
|
num amountUD = amount / currentUD;
|
||||||
|
int padNbr = 14 - amount.toString().length;
|
||||||
if (direction == "RECEIVED") {
|
if (direction == "RECEIVED") {
|
||||||
transBC[i].add(transaction['issuers'][0]);
|
transBC[i].add(transaction['issuers'][0]);
|
||||||
transBC[i].add(amount);
|
transBC[i].add(' ' + amount.toString().padRight(padNbr));
|
||||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||||
} else if (direction == "SENT") {
|
} else if (direction == "SENT") {
|
||||||
final outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
final outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
||||||
transBC[i].add(outPubkey);
|
transBC[i].add(outPubkey);
|
||||||
transBC[i].add(-amount);
|
transBC[i].add(' -' + amount.toString().padRight(padNbr - 1));
|
||||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||||
}
|
}
|
||||||
transBC[i].add(transaction['comment']);
|
transBC[i].add(transaction['comment']);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
|
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||||
import 'package:sentry/sentry.dart' as sentry;
|
import 'package:sentry/sentry.dart' as sentry;
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -21,9 +22,15 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
TextEditingController _pubkey = new TextEditingController();
|
TextEditingController _pubkey = new TextEditingController();
|
||||||
TextEditingController _pin = new TextEditingController();
|
TextEditingController _pin = new TextEditingController();
|
||||||
String generatedMnemonic;
|
String generatedMnemonic;
|
||||||
|
bool walletIsGenerated = false;
|
||||||
NewWallet actualWallet;
|
NewWallet actualWallet;
|
||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
bool hasError = false;
|
||||||
|
String validPin = 'NO PIN';
|
||||||
|
String currentText = "";
|
||||||
|
var pinColor = Colors.grey[300];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
|
@ -95,23 +102,27 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: new RaisedButton(
|
child: new RaisedButton(
|
||||||
color: Color(0xffFFD68E),
|
color: Color(0xffFFD68E),
|
||||||
onPressed: () {
|
onPressed: walletIsGenerated
|
||||||
Navigator.push(
|
? () {
|
||||||
context,
|
Navigator.push(
|
||||||
MaterialPageRoute(builder: (context) {
|
context,
|
||||||
return ValidStoreWalletScreen(
|
MaterialPageRoute(builder: (context) {
|
||||||
generatedMnemonic: this.generatedMnemonic,
|
return ValidStoreWalletScreen(
|
||||||
generatedWallet:
|
generatedMnemonic: this.generatedMnemonic,
|
||||||
this.actualWallet); //, this.actualWallet);
|
generatedWallet: this.actualWallet);
|
||||||
}),
|
}),
|
||||||
).then((value) => setState(() {
|
).then((value) => setState(() {
|
||||||
if (value) {
|
if (value) {
|
||||||
_pin.clear();
|
_pin.clear();
|
||||||
_mnemonicController.clear();
|
_mnemonicController.clear();
|
||||||
_pubkey.clear();
|
_pubkey.clear();
|
||||||
}
|
this.generatedMnemonic = null;
|
||||||
}));
|
this.actualWallet = null;
|
||||||
},
|
this.walletIsGenerated = false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
: null,
|
||||||
child: Text('Enregistrer ce wallet',
|
child: Text('Enregistrer ce wallet',
|
||||||
style: TextStyle(fontSize: 20))))),
|
style: TextStyle(fontSize: 20))))),
|
||||||
SizedBox(height: 15)
|
SizedBox(height: 15)
|
||||||
|
@ -132,6 +143,7 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
||||||
|
this.walletIsGenerated = true;
|
||||||
return this.generatedMnemonic;
|
return this.generatedMnemonic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +227,75 @@ class _ValidStoreWalletScreen extends State<ValidStoreWalletScreen> {
|
||||||
color: Color(0xffFFD68E),
|
color: Color(0xffFFD68E),
|
||||||
onPressed: () => storeWallet(widget.generatedWallet),
|
onPressed: () => storeWallet(widget.generatedWallet),
|
||||||
child: Text('Confirmer', style: TextStyle(fontSize: 20))),
|
child: Text('Confirmer', style: TextStyle(fontSize: 20))),
|
||||||
|
// Form(
|
||||||
|
// child: Padding(
|
||||||
|
// padding:
|
||||||
|
// const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
|
||||||
|
// child: PinCodeTextField(
|
||||||
|
// appContext: context,
|
||||||
|
// pastedTextStyle: TextStyle(
|
||||||
|
// color: Colors.green.shade600,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// length: 6,
|
||||||
|
// obscureText: false,
|
||||||
|
// obscuringCharacter: '*',
|
||||||
|
// animationType: AnimationType.fade,
|
||||||
|
// validator: (v) {
|
||||||
|
// if (v.length < 6) {
|
||||||
|
// return "Votre code PIN fait 6 caractères";
|
||||||
|
// } else {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// pinTheme: PinTheme(
|
||||||
|
// shape: PinCodeFieldShape.box,
|
||||||
|
// borderRadius: BorderRadius.circular(5),
|
||||||
|
// fieldHeight: 60,
|
||||||
|
// fieldWidth: 50,
|
||||||
|
// activeFillColor: hasError ? Colors.orange : Colors.white,
|
||||||
|
// ),
|
||||||
|
// cursorColor: Colors.black,
|
||||||
|
// animationDuration: Duration(milliseconds: 300),
|
||||||
|
// textStyle: TextStyle(fontSize: 20, height: 1.6),
|
||||||
|
// backgroundColor: pinColor,
|
||||||
|
// enableActiveFill: false,
|
||||||
|
// errorAnimationController: errorController,
|
||||||
|
// controller: _enterPin,
|
||||||
|
// keyboardType: TextInputType.text,
|
||||||
|
// boxShadows: [
|
||||||
|
// BoxShadow(
|
||||||
|
// offset: Offset(0, 1),
|
||||||
|
// color: Colors.black12,
|
||||||
|
// blurRadius: 10,
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// onCompleted: (v) async {
|
||||||
|
// print("Completed");
|
||||||
|
// final resultWallet = await readLocalWallet(v.toUpperCase());
|
||||||
|
// if (resultWallet == 'bad') {
|
||||||
|
// errorController.add(ErrorAnimationType
|
||||||
|
// .shake); // Triggering error shake animation
|
||||||
|
// setState(() {
|
||||||
|
// hasError = true;
|
||||||
|
// pinColor = Colors.red[200];
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setState(() {
|
||||||
|
// pinColor = Colors.green[200];
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// onChanged: (value) {
|
||||||
|
// if (pinColor != Colors.grey[300]) {
|
||||||
|
// setState(() {
|
||||||
|
// pinColor = Colors.grey[300];
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// print(value);
|
||||||
|
// },
|
||||||
|
// )),
|
||||||
|
// )
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,7 +77,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Tappez/Collez une clé publique, ou scannez',
|
hintText: 'Tappez/Collez une clé publique, ou scannez',
|
||||||
hintStyle: TextStyle(fontSize: 15),
|
hintStyle: TextStyle(fontSize: 14),
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 7, vertical: 15),
|
contentPadding: EdgeInsets.symmetric(horizontal: 7, vertical: 15),
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
focusedBorder: InputBorder.none,
|
focusedBorder: InputBorder.none,
|
||||||
|
@ -85,7 +85,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
errorBorder: InputBorder.none,
|
errorBorder: InputBorder.none,
|
||||||
disabledBorder: InputBorder.none,
|
disabledBorder: InputBorder.none,
|
||||||
),
|
),
|
||||||
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold)),
|
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
||||||
historyQuery(),
|
historyQuery(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,8 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
|
|
||||||
final String fetchMoreCursor = pageInfo['endCursor'];
|
final String fetchMoreCursor = pageInfo['endCursor'];
|
||||||
|
|
||||||
final num balance = result.data['balance']['amount'] / 100;
|
final num balance =
|
||||||
|
removeDecimalZero(result.data['balance']['amount'] / 100);
|
||||||
|
|
||||||
FetchMoreOptions opts = FetchMoreOptions(
|
FetchMoreOptions opts = FetchMoreOptions(
|
||||||
variables: {'cursor': fetchMoreCursor},
|
variables: {'cursor': fetchMoreCursor},
|
||||||
|
@ -181,19 +182,26 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
child: ListView(
|
child: ListView(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
SizedBox(height: 7),
|
||||||
if (this.pubkey != '')
|
if (this.pubkey != '')
|
||||||
Text(balance.toString() + ' Ğ1',
|
Text(balance.toString() + ' Ğ1',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: 30.0)),
|
style: TextStyle(fontSize: 30.0)),
|
||||||
|
SizedBox(height: 12),
|
||||||
for (var repository in _transBC)
|
for (var repository in _transBC)
|
||||||
ListTile(
|
ListTile(
|
||||||
contentPadding: const EdgeInsets.all(5.0),
|
contentPadding: const EdgeInsets.all(5.0),
|
||||||
leading: Text(repository[3].toString()),
|
leading:
|
||||||
title: Text(repository[1].toString() +
|
Text(repository[3], style: TextStyle(fontSize: 14.0)),
|
||||||
'\n' +
|
title: Text(
|
||||||
truncate(repository[2], 17,
|
repository[1].toString() +
|
||||||
omission: "...", position: TruncatePosition.end)),
|
'\n' +
|
||||||
subtitle: Text(repository[5]),
|
truncate(repository[2], 17,
|
||||||
|
omission: "...",
|
||||||
|
position: TruncatePosition.end),
|
||||||
|
style: TextStyle(fontSize: 14.0)),
|
||||||
|
subtitle:
|
||||||
|
Text(repository[5], style: TextStyle(fontSize: 14.0)),
|
||||||
dense: true,
|
dense: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
isPubkey(repository[2]);
|
isPubkey(repository[2]);
|
||||||
|
@ -264,4 +272,9 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num removeDecimalZero(double n) {
|
||||||
|
String result = n.toStringAsFixed(n.truncateToDouble() == n ? 0 : 1);
|
||||||
|
return num.parse(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue