diff --git a/lib/api.dart b/lib/api.dart index a6e7514..b76e935 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -296,7 +296,7 @@ List parseHistory(txs) { i++; } - transBC.sort((b, a) => Comparable.compare(a[0], b[0])); + // transBC.sort((b, a) => Comparable.compare(a[0], b[0])); return transBC; } diff --git a/lib/home.dart b/lib/home.dart index f219923..a2bc529 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -9,35 +9,19 @@ import "package:dio/dio.dart"; import 'package:graphql_flutter/graphql_flutter.dart'; import 'query.dart'; -/// Integrates a list of articles with [ListPreferencesScreen]. +//ignore: must_be_immutable class HistoryListScreen extends StatefulWidget { @override _HistoryListScreenState createState() => _HistoryListScreenState(); } -// class HistoryListScreen extends StatefulWidget { -// // GeckoHome({Key key, this.title}) : super(key: key); -// // final String title; - -// const HistoryListScreen({ -// @required this.repository, -// final String title, -// Key key, -// }) : assert(repository != null), -// super(key: key); - -// final Repository repository; - -// @override -// _GeckoHomeState createState() => _GeckoHomeState(); -// } - class _HistoryListScreenState extends State { Uint8List bytes = Uint8List(0); TextEditingController _outputPubkey; TextEditingController _outputBalance; - final nRepositories = 20; + final nRepositories = 3; var pubkey = ''; + var titi = 'totooooooop'; ScrollController _scrollController = new ScrollController(); @override @@ -54,10 +38,11 @@ class _HistoryListScreenState extends State { @override Widget build(BuildContext context) { - // final pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; + pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // var pubkey = ''; print('Build state : ' + pubkey); + print(titi); return MaterialApp( home: Scaffold( backgroundColor: Colors.grey[300], @@ -68,9 +53,10 @@ class _HistoryListScreenState extends State { TextField( // enabled: false, onChanged: (text) { - print("Clé tappé: $text"); - // pubkey = text; - pubkey = isPubkey(text); + print("Clé tappxé: $text"); + pubkey = text; + // pubkey = + isPubkey(text); }, controller: this._outputPubkey, maxLines: 1, @@ -114,10 +100,9 @@ class _HistoryListScreenState extends State { children: [ Query( options: QueryOptions( - documentNode: gql(getMyRepositories), + documentNode: gql(getHistory), variables: { - 'pubkey': - 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU', // pubkey, + 'pubkey': pubkey, // pubkey, 'number': nRepositories, // set cursor to null so as to start at the beginning // 'cursor': 0 @@ -138,8 +123,7 @@ class _HistoryListScreenState extends State { if (result.data == null && result.exception.toString() == null) { - return const Text( - 'Both data and errors are null, this is a known bug after refactoring, you might forget to set Github token'); + return const Text('Both data and errors are null'); } final List blockchainTX = @@ -152,7 +136,9 @@ class _HistoryListScreenState extends State { final Map pageInfo = result.data['txsHistoryBc']['both']['pageInfo']; - final String fetchMoreCursor = pageInfo['endCursor']; + + final String fetchMoreCursor = + pageInfo['endCursor'] ?? 'cest null...'; FetchMoreOptions opts = FetchMoreOptions( variables: {'cursor': fetchMoreCursor}, @@ -170,7 +156,9 @@ class _HistoryListScreenState extends State { fetchMoreResultData['txsHistoryBc']['both'] ['edges'] = repos; - print('A: ' + fetchMoreCursor + ' B'); + print('DEBUG NULL OPTION: '); + print(fetchMoreResultData); + print(fetchMoreCursor); return fetchMoreResultData; }, ); @@ -180,13 +168,15 @@ class _HistoryListScreenState extends State { if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { if (!result.loading) { - print('B'); - print(opts); + print('DEBUG NULL scrollController: ' + + fetchMoreCursor); fetchMore(opts); } } }); + print( + 'DEBUG blockchainTX: ' + blockchainTX.toString()); List transBC = parseHistory(blockchainTX); // parseHistory(mempoolTX); @@ -204,7 +194,7 @@ class _HistoryListScreenState extends State { BorderRadius.circular(3.0)), // 3 child: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(100.0), // 4 child: Column( children: [ @@ -278,7 +268,6 @@ class _HistoryListScreenState extends State { child: FittedBox( child: FloatingActionButton( onPressed: () => _scan(), - // label: Text('Scanner'), child: Container( height: 40.0, width: 40.0, @@ -319,15 +308,16 @@ class _HistoryListScreenState extends State { print("C'est une pubkey !!!"); showHistory(pubkey); - // setState(() {}); + // var tata = _scrollController; + + // setState(() { + // print('setPubkey: ' + pubkey); + // pubkey = pubkey; + // // fetchMoreCursor = fetchMoreCursor; + // titi = 'lourd'; + // }); return pubkey; - - // print(pubkey); - // setState(({pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'}) { - // pubkey = pubkey; - // print('setState : ' + pubkey); - // }); } else { return ''; } diff --git a/lib/main.dart b/lib/main.dart index 997531e..59d00b3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,7 +24,8 @@ class Gecko extends StatelessWidget { ); return MaterialApp( title: 'Ğecko', - theme: ThemeData(primaryColor: Colors.white, accentColor: Colors.black), + theme: + ThemeData(primaryColor: Colors.blue[50], accentColor: Colors.black), home: GraphQLProvider( client: _client, child: HistoryListScreen(), diff --git a/lib/query.dart b/lib/query.dart index e815d66..7009608 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -1,4 +1,4 @@ -const String getMyRepositories = r''' +const String getHistory = r''' query ($pubkey: String!, $number: Int!, $cursor: String) { txsHistoryBc( pubkeyOrScript: $pubkey @@ -45,3 +45,11 @@ const String getMyRepositories = r''' } } '''; + +const String getxBalance = r''' + query ($pubkey: String!) { + balance(script: "$pubkey") { + amount + base + } + ''';