From c2d373b7218041c9e4ad7fc6545e895c2a16ad38 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 8 Jan 2021 01:20:03 +0100 Subject: [PATCH] Merge historyListBuilder class inside historyScreen widget; Click on history entry to load it --- lib/main.dart | 2 +- lib/ui/historyListBuilder.dart | 88 ---------------------------------- lib/ui/historyScreen.dart | 41 ++++++++++++---- lib/ui/home.dart | 4 +- pubspec.yaml | 47 ------------------ 5 files changed, 34 insertions(+), 148 deletions(-) delete mode 100644 lib/ui/historyListBuilder.dart diff --git a/lib/main.dart b/lib/main.dart index 0c673f8..b90210d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ +import 'package:gecko/ui/home.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/ui/home.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/ui/historyListBuilder.dart b/lib/ui/historyListBuilder.dart deleted file mode 100644 index 0413321..0000000 --- a/lib/ui/historyListBuilder.dart +++ /dev/null @@ -1,88 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:truncate/truncate.dart'; - -// class HistoryListScreen extends StatefulWidget { -// @override -// _HistoryListScreen createState() => _HistoryListScreen(); -// } - -// class _HistoryListScreen extends State { -// @override -// Widget build(BuildContext context) { -// print('Coucou page 2'); - -// return MaterialApp( -// home: Scaffold( -// backgroundColor: Colors.grey[300], -// body: SafeArea(child: Text('Hello !')))); -// } -// } - -class HistoryListBuilder extends StatelessWidget { - // const String({this.isPubkey}); - // final PubkeyCallBack isPubkey; - // GlobalKey _myKey = GlobalKey(); - - const HistoryListBuilder( - {Key key, - @required ScrollController scrollController, - @required this.transBC, - @required this.historyData}) - : _scrollController = scrollController, - super(key: key); - - final ScrollController _scrollController; - final List transBC; - final historyData; - - @override - Widget build(BuildContext context) { - return SafeArea( - // new NotificationListener( - // child: new ListView( - // controller: _scrollController, - // ), - // onNotification: (t) { - // if (t is ScrollEndNotification) { - // fetchMore(opts); - // } - // }, - // ); - - // child: new NotificationListener( - child: new ListView( - controller: _scrollController, - children: [ - for (var repository in transBC) - ListTile( - contentPadding: const EdgeInsets.all(5.0), - leading: Text(repository[3].toString()), - title: Text(repository[1].toString() + - '\n' + - truncate(repository[2], 17, - omission: "...", position: TruncatePosition.end)), - subtitle: Text(repository[5]), - dense: true, - // enabled: _act == 2, - onTap: () {/* TODO: Load this history: repository[2] */}), - if (historyData.isLoading) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircularProgressIndicator(), - ], - ), - ], - ), - // onNotification: (t) { - // if (t is ScrollEndNotification) { - // // fetchMore(opts); - // print(_scrollController.position.pixels); - // } - // return t; - // }, - ); - } -} - -// typedef PubkeyCallBack = void Function(String pubkey); \ No newline at end of file diff --git a/lib/ui/historyScreen.dart b/lib/ui/historyScreen.dart index 82933e9..914b8d6 100644 --- a/lib/ui/historyScreen.dart +++ b/lib/ui/historyScreen.dart @@ -1,15 +1,15 @@ +import 'package:gecko/parsingGVA.dart'; +import 'package:gecko/query.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:qrscan/qrscan.dart' as scanner; -import 'package:gecko/ui/historyListBuilder.dart'; import 'dart:async'; import 'dart:typed_data'; import 'dart:ui'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:gecko/parsingGVA.dart'; -import 'package:gecko/query.dart'; import 'package:sentry/sentry.dart' as sentry; +import 'package:truncate/truncate.dart'; //ignore: must_be_immutable class HistoryScreen extends StatefulWidget { @@ -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(); @@ -183,11 +183,31 @@ class HistoryScreenState extends State { List _transBC = parseHistory(blockchainTX); return Expanded( - child: HistoryListBuilder( - scrollController: _scrollController, - transBC: _transBC, - historyData: result), - ); + child: ListView( + controller: _scrollController, + children: [ + for (var repository in _transBC) + ListTile( + contentPadding: const EdgeInsets.all(5.0), + leading: Text(repository[3].toString()), + title: Text(repository[1].toString() + + '\n' + + truncate(repository[2], 17, + omission: "...", position: TruncatePosition.end)), + subtitle: Text(repository[5]), + dense: true, + onTap: () { + isPubkey(repository[2]); + }), + if (result.isLoading) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator(), + ], + ), + ], + )); }, ), ], @@ -231,6 +251,7 @@ class HistoryScreenState extends State { setState(() { this.pubkey = pubkey; + this._outputPubkey.text = pubkey; }); return pubkey; diff --git a/lib/ui/home.dart b/lib/ui/home.dart index 24b04e1..eb57f02 100644 --- a/lib/ui/home.dart +++ b/lib/ui/home.dart @@ -1,8 +1,8 @@ -import 'package:flutter/material.dart'; +import 'package:gecko/ui/historyScreen.dart'; import 'package:gecko/ui/generateWallets.dart'; +import 'package:flutter/material.dart'; import 'dart:typed_data'; import 'dart:ui'; -import 'package:gecko/ui/historyScreen.dart'; //ignore: must_be_immutable class HomeScreen extends StatefulWidget { diff --git a/pubspec.yaml b/pubspec.yaml index aaee89e..31126b9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,16 +5,6 @@ description: A new Flutter project. # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 0.0.0+5 environment: @@ -42,52 +32,15 @@ flutter_icons: android: "launcher_icon" ios: true image_path: "assets/icon/gecko5b96.png" - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - # The following section is specific to Flutter. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - # To add assets to your application, add an assets section, like this: assets: - images/ - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages