Provider for history is OK; fetchmore for GVA infinitescroll is OK but seems to have bugs;
This commit is contained in:
parent
a4b0a099ff
commit
5542a8eea8
|
@ -96,28 +96,36 @@ class Gecko extends StatelessWidget {
|
||||||
);
|
);
|
||||||
|
|
||||||
DubpRust.setup();
|
DubpRust.setup();
|
||||||
return MultiProvider(
|
return
|
||||||
providers: [
|
// MultiProvider(
|
||||||
Provider(create: (context) => HistoryProvider()),
|
// providers: [
|
||||||
Provider(create: (context) => MyWalletsProvider()),
|
// Provider(create: (context) => HistoryProvider()),
|
||||||
],
|
// Provider(create: (context) => MyWalletsProvider()),
|
||||||
child: MaterialApp(
|
// ],
|
||||||
title: 'Ğecko',
|
// child:
|
||||||
theme: ThemeData(
|
MaterialApp(
|
||||||
primaryColor: Color(0xffFFD58D),
|
title: 'Ğecko',
|
||||||
accentColor: Colors.grey[850],
|
theme: ThemeData(
|
||||||
textTheme: TextTheme(
|
primaryColor: Color(0xffFFD58D),
|
||||||
bodyText1: TextStyle(),
|
accentColor: Colors.grey[850],
|
||||||
bodyText2: TextStyle(),
|
textTheme: TextTheme(
|
||||||
).apply(
|
bodyText1: TextStyle(),
|
||||||
bodyColor: Color(0xff855F2D),
|
bodyText2: TextStyle(),
|
||||||
// displayColor: Colors.blue,
|
).apply(
|
||||||
|
bodyColor: Color(0xff855F2D),
|
||||||
|
// displayColor: Colors.blue,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
home: MultiProvider(
|
||||||
home: GraphQLProvider(
|
providers: [
|
||||||
client: _client,
|
// Provider(create: (context) => HistoryProvider()),
|
||||||
child: HomeScreen(),
|
Provider(create: (context) => MyWalletsProvider()),
|
||||||
),
|
ChangeNotifierProvider(create: (_) => HistoryProvider(''))
|
||||||
));
|
],
|
||||||
|
child: GraphQLProvider(
|
||||||
|
client: _client,
|
||||||
|
child: HomeScreen(),
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,13 @@ import 'package:sentry/sentry.dart' as sentry;
|
||||||
import 'package:qrscan/qrscan.dart' as scanner;
|
import 'package:qrscan/qrscan.dart' as scanner;
|
||||||
|
|
||||||
class HistoryProvider with ChangeNotifier {
|
class HistoryProvider with ChangeNotifier {
|
||||||
final TextEditingController _outputPubkey = new TextEditingController();
|
|
||||||
String pubkey = '';
|
String pubkey = '';
|
||||||
|
HistoryProvider(this.pubkey);
|
||||||
|
final TextEditingController _outputPubkey = new TextEditingController();
|
||||||
|
// String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug
|
||||||
|
|
||||||
ScrollController scrollController = new ScrollController();
|
// FetchMoreOptions opts;
|
||||||
|
// ScrollController scrollController = new ScrollController();
|
||||||
|
|
||||||
Future scan() async {
|
Future scan() async {
|
||||||
await Permission.camera.request();
|
await Permission.camera.request();
|
||||||
|
@ -56,4 +59,13 @@ class HistoryProvider with ChangeNotifier {
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scrollListener() {
|
||||||
|
// if (scrollController.offset >= scrollController.position.maxScrollExtent &&
|
||||||
|
// !scrollController.position.outOfRange) {
|
||||||
|
// print('On est en bas !!');
|
||||||
|
// // fetchMore(opts);
|
||||||
|
// notifyListeners();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,41 +3,35 @@ import 'package:gecko/query.dart';
|
||||||
import 'package:gecko/models/history.dart';
|
import 'package:gecko/models/history.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:truncate/truncate.dart';
|
import 'package:truncate/truncate.dart';
|
||||||
|
|
||||||
//ignore: must_be_immutable
|
//ignore: must_be_immutable
|
||||||
class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
Widget currentScreen;
|
|
||||||
|
|
||||||
Uint8List bytes = Uint8List(0);
|
|
||||||
final TextEditingController _outputPubkey = new TextEditingController();
|
final TextEditingController _outputPubkey = new TextEditingController();
|
||||||
|
ScrollController scrollController = new ScrollController();
|
||||||
final nRepositories = 20;
|
final nRepositories = 20;
|
||||||
|
HistoryProvider _historyProvider;
|
||||||
|
|
||||||
// String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug
|
FetchMore fetchMore;
|
||||||
String pubkey = '';
|
FetchMoreOptions opts;
|
||||||
bool isBuilding = true;
|
// scrollListener() {
|
||||||
|
// if (scrollController.offset >= scrollController.position.maxScrollExtent &&
|
||||||
HistoryProvider historyProvider = HistoryProvider();
|
// !scrollController.position.outOfRange) {
|
||||||
|
// print('On est en bas !!');
|
||||||
scrollListener() {
|
// print(opts.document);
|
||||||
if (historyProvider.scrollController.offset >=
|
// fetchMore(opts);
|
||||||
historyProvider.scrollController.position.maxScrollExtent &&
|
// notifyListeners();
|
||||||
!historyProvider.scrollController.position.outOfRange) {
|
// }
|
||||||
notifyListeners();
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print('Build pubkey : ' + pubkey);
|
_historyProvider = Provider.of<HistoryProvider>(context);
|
||||||
print('Build this.pubkey : ' + this.pubkey);
|
print('Build pubkey : ' + _historyProvider.pubkey);
|
||||||
print('isBuilding: ' + isBuilding.toString());
|
// scrollController.addListener(scrollListener);
|
||||||
historyProvider.scrollController.addListener(scrollListener);
|
|
||||||
historyProvider.scrollController = ScrollController();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
floatingActionButton: Container(
|
floatingActionButton: Container(
|
||||||
height: 80.0,
|
height: 80.0,
|
||||||
|
@ -46,11 +40,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
heroTag: "buttonScan",
|
heroTag: "buttonScan",
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await historyProvider.scan();
|
await _historyProvider.scan();
|
||||||
// print(resultScan);
|
|
||||||
// if (resultScan != 'false') {
|
|
||||||
// onTabTapped(0);
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 40.0,
|
height: 40.0,
|
||||||
|
@ -67,8 +57,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
// Entrée de la pubkey
|
// Entrée de la pubkey
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
print("Clé tappxé: $text");
|
print("Clé tappxé: $text");
|
||||||
this.pubkey = text;
|
_historyProvider.isPubkey(text);
|
||||||
historyProvider.isPubkey(text);
|
|
||||||
},
|
},
|
||||||
controller: this._outputPubkey,
|
controller: this._outputPubkey,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
@ -85,7 +74,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
disabledBorder: InputBorder.none,
|
disabledBorder: InputBorder.none,
|
||||||
),
|
),
|
||||||
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
||||||
if (this.pubkey != '') historyQuery(),
|
if (_historyProvider.pubkey != '') historyQuery(),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,13 +88,13 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
options: QueryOptions(
|
options: QueryOptions(
|
||||||
document: gql(getHistory),
|
document: gql(getHistory),
|
||||||
variables: <String, dynamic>{
|
variables: <String, dynamic>{
|
||||||
'pubkey': this.pubkey,
|
'pubkey': _historyProvider.pubkey,
|
||||||
'number': nRepositories,
|
'number': nRepositories,
|
||||||
// set cursor to null so as to start at the beginning
|
// set cursor to null so as to start at the beginning
|
||||||
'cursor': null
|
'cursor': null
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
builder: (QueryResult result, {refetch, FetchMore fetchMore}) {
|
builder: (QueryResult result, {refetch, fetchMore}) {
|
||||||
if (result.isLoading && result.data == null) {
|
if (result.isLoading && result.data == null) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
|
@ -138,7 +127,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
final num balance =
|
final num balance =
|
||||||
removeDecimalZero(result.data['balance']['amount'] / 100);
|
removeDecimalZero(result.data['balance']['amount'] / 100);
|
||||||
|
|
||||||
FetchMoreOptions opts = FetchMoreOptions(
|
opts = FetchMoreOptions(
|
||||||
variables: {'cursor': fetchMoreCursor},
|
variables: {'cursor': fetchMoreCursor},
|
||||||
updateQuery: (previousResultData, fetchMoreResultData) {
|
updateQuery: (previousResultData, fetchMoreResultData) {
|
||||||
final List<dynamic> repos = [
|
final List<dynamic> repos = [
|
||||||
|
@ -184,43 +173,57 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
List _transBC = parseHistory(blockchainTX);
|
List _transBC = parseHistory(blockchainTX);
|
||||||
|
|
||||||
// Build history list
|
// Build history list
|
||||||
return Expanded(
|
return NotificationListener(
|
||||||
child: ListView(
|
child: Expanded(
|
||||||
controller: historyProvider.scrollController,
|
child: ListView(
|
||||||
children: <Widget>[
|
controller: scrollController,
|
||||||
SizedBox(height: 7),
|
children: <Widget>[
|
||||||
if (this.pubkey != '')
|
SizedBox(height: 7),
|
||||||
Text(balance.toString() + ' Ğ1',
|
if (_historyProvider.pubkey != '')
|
||||||
textAlign: TextAlign.center,
|
Text(balance.toString() + ' Ğ1',
|
||||||
style: TextStyle(fontSize: 30.0)),
|
textAlign: TextAlign.center,
|
||||||
SizedBox(height: 12),
|
style: TextStyle(fontSize: 30.0)),
|
||||||
for (var repository in _transBC)
|
SizedBox(height: 12),
|
||||||
ListTile(
|
for (var repository in _transBC)
|
||||||
contentPadding: const EdgeInsets.all(5.0),
|
ListTile(
|
||||||
leading:
|
contentPadding: const EdgeInsets.all(5.0),
|
||||||
Text(repository[3], style: TextStyle(fontSize: 14.0)),
|
leading: Text(repository[3],
|
||||||
title: Text(
|
style: TextStyle(fontSize: 14.0)),
|
||||||
repository[1].toString() +
|
title: Text(
|
||||||
'\n' +
|
repository[1].toString() +
|
||||||
truncate(repository[2], 17,
|
'\n' +
|
||||||
omission: "...",
|
truncate(repository[2], 17,
|
||||||
position: TruncatePosition.end),
|
omission: "...",
|
||||||
style: TextStyle(fontSize: 14.0)),
|
position: TruncatePosition.end),
|
||||||
subtitle:
|
style: TextStyle(fontSize: 14.0)),
|
||||||
Text(repository[5], style: TextStyle(fontSize: 14.0)),
|
subtitle: Text(repository[5],
|
||||||
dense: true,
|
style: TextStyle(fontSize: 14.0)),
|
||||||
onTap: () {
|
dense: true,
|
||||||
historyProvider.isPubkey(repository[2]);
|
onTap: () {
|
||||||
}),
|
this._outputPubkey.text = repository[2];
|
||||||
if (result.isLoading)
|
_historyProvider.isPubkey(repository[2]);
|
||||||
Row(
|
// notifyListeners();
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
}),
|
||||||
children: <Widget>[
|
if (result.isLoading)
|
||||||
CircularProgressIndicator(),
|
Row(
|
||||||
],
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
),
|
children: <Widget>[
|
||||||
],
|
CircularProgressIndicator(),
|
||||||
));
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
onNotification: (t) {
|
||||||
|
// print(scrollController.position.pixels);
|
||||||
|
// print(scrollController.position.maxScrollExtent);
|
||||||
|
if (t is ScrollEndNotification &&
|
||||||
|
scrollController.position.pixels >=
|
||||||
|
scrollController.position.maxScrollExtent * 0.8) {
|
||||||
|
fetchMore(opts);
|
||||||
|
// notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: A new Flutter project.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# 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
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.0+13
|
version: 0.0.0+14
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue