diff --git a/lib/query.dart b/lib/query.dart index 96daef9..52754ab 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -38,17 +38,21 @@ const String getHistory = r''' outputs writtenTime } - } - currentUd { - amount - base } + currentUd { + amount + base + } + balance(script: $pubkey) { + amount + base + } } '''; const String getBalance = r''' query ($pubkey: String!) { - balance(script: "$pubkey") { + balance(script: $pubkey) { amount base } diff --git a/lib/ui/historyScreen.dart b/lib/ui/historyScreen.dart index 914b8d6..0ef4198 100644 --- a/lib/ui/historyScreen.dart +++ b/lib/ui/historyScreen.dart @@ -33,8 +33,8 @@ class HistoryScreenState extends State { final TextEditingController _outputPubkey = new TextEditingController(); final nRepositories = 20; - String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug - // String pubkey = ''; + // String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug + String pubkey = ''; bool isBuilding = true; ScrollController _scrollController = new ScrollController(); @@ -72,6 +72,7 @@ class HistoryScreenState extends State { print('isBuilding: ' + isBuilding.toString()); return Column(children: [ TextField( + // Entrée de la pubkey onChanged: (text) { print("Clé tappxé: $text"); this.pubkey = text; @@ -98,7 +99,7 @@ class HistoryScreenState extends State { ]); } - Expanded historyQuery() { + historyQuery() { return Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -137,6 +138,8 @@ class HistoryScreenState extends State { final String fetchMoreCursor = pageInfo['endCursor']; + final num balance = result.data['balance']['amount'] / 100; + FetchMoreOptions opts = FetchMoreOptions( variables: {'cursor': fetchMoreCursor}, updateQuery: (previousResultData, fetchMoreResultData) { @@ -182,10 +185,14 @@ class HistoryScreenState extends State { "###### DEBUG H Parse blockchainTX list. Cursor: $fetchMoreCursor ######"); List _transBC = parseHistory(blockchainTX); + // Build history list return Expanded( child: ListView( controller: _scrollController, children: [ + Text(balance.toString() + ' Ğ1', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 30.0, color: Colors.black)), for (var repository in _transBC) ListTile( contentPadding: const EdgeInsets.all(5.0), @@ -254,6 +261,10 @@ class HistoryScreenState extends State { this._outputPubkey.text = pubkey; }); + // setState(() { + // this._outputBalance.text = balance.toString(); + // }); + return pubkey; }