Merge historyListBuilder class inside historyScreen widget; Click on history entry to load it

This commit is contained in:
poka 2021-01-08 01:20:03 +01:00
parent 24704a40be
commit c2d373b721
5 changed files with 34 additions and 148 deletions

View File

@ -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';

View File

@ -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<HistoryListScreen> {
// @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<MyState> _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: <Widget>[
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: <Widget>[
CircularProgressIndicator(),
],
),
],
),
// onNotification: (t) {
// if (t is ScrollEndNotification) {
// // fetchMore(opts);
// print(_scrollController.position.pixels);
// }
// return t;
// },
);
}
}
// typedef PubkeyCallBack = void Function(String pubkey);

View File

@ -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<HistoryScreen> {
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<HistoryScreen> {
List _transBC = parseHistory(blockchainTX);
return Expanded(
child: HistoryListBuilder(
scrollController: _scrollController,
transBC: _transBC,
historyData: result),
);
child: ListView(
controller: _scrollController,
children: <Widget>[
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: <Widget>[
CircularProgressIndicator(),
],
),
],
));
},
),
],
@ -231,6 +251,7 @@ class HistoryScreenState extends State<HistoryScreen> {
setState(() {
this.pubkey = pubkey;
this._outputPubkey.text = pubkey;
});
return pubkey;

View File

@ -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 {

View File

@ -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