Add Cs+ data
This commit is contained in:
parent
6e744f3289
commit
91bf7a653e
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -1,5 +1,6 @@
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/cesiumPlus.dart';
|
||||||
import 'package:gecko/models/generateWallets.dart';
|
import 'package:gecko/models/generateWallets.dart';
|
||||||
import 'package:gecko/models/history.dart';
|
import 'package:gecko/models/history.dart';
|
||||||
import 'package:gecko/models/home.dart';
|
import 'package:gecko/models/home.dart';
|
||||||
|
@ -24,6 +25,7 @@ Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
HomeProvider _homeProvider = HomeProvider();
|
HomeProvider _homeProvider = HomeProvider();
|
||||||
await _homeProvider.getAppPath();
|
await _homeProvider.getAppPath();
|
||||||
|
await _homeProvider.createDefaultAvatar();
|
||||||
appVersion = await _homeProvider.getAppVersion();
|
appVersion = await _homeProvider.getAppVersion();
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
@ -88,7 +90,8 @@ class Gecko extends StatelessWidget {
|
||||||
ChangeNotifierProvider(create: (_) => HistoryProvider('')),
|
ChangeNotifierProvider(create: (_) => HistoryProvider('')),
|
||||||
ChangeNotifierProvider(create: (_) => MyWalletsProvider()),
|
ChangeNotifierProvider(create: (_) => MyWalletsProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => GenerateWalletsProvider()),
|
ChangeNotifierProvider(create: (_) => GenerateWalletsProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => WalletOptionsProvider())
|
ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
|
||||||
|
ChangeNotifierProvider(create: (_) => CesiumPlusProvider())
|
||||||
],
|
],
|
||||||
child: GraphQLProvider(
|
child: GraphQLProvider(
|
||||||
client: _client,
|
client: _client,
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
class CesiumPlusProvider with ChangeNotifier {
|
||||||
|
// String pubkey = '';
|
||||||
|
// CesiumPlusProvider(this.pubkey);
|
||||||
|
var decodedBytes;
|
||||||
|
var avatar64;
|
||||||
|
TextEditingController cesiumName = TextEditingController();
|
||||||
|
int iAvatar = 0;
|
||||||
|
bool isComplete = false;
|
||||||
|
|
||||||
|
Future<List> _buildQuery(_pubkey) async {
|
||||||
|
var queryGetAvatar = json.encode({
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"should": [
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
'_id': {"query": _pubkey, "boost": 2}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"prefix": {'_id': _pubkey}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"highlight": {
|
||||||
|
"fields": {"title": {}, "tags": {}}
|
||||||
|
},
|
||||||
|
"from": 0,
|
||||||
|
"size": 100,
|
||||||
|
"_source": [
|
||||||
|
"title",
|
||||||
|
"avatar",
|
||||||
|
"avatar._content_type",
|
||||||
|
"description",
|
||||||
|
"city",
|
||||||
|
"address",
|
||||||
|
"socials.url",
|
||||||
|
"creationTime",
|
||||||
|
"membersCount",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"indices_boost": {"user": 100, "page": 1, "group": 0.01}
|
||||||
|
});
|
||||||
|
|
||||||
|
String cesiumPod = "https://g1.data.le-sou.org";
|
||||||
|
String requestUrl = "/user,page,group/profile,record/_search";
|
||||||
|
String podRequest = cesiumPod + requestUrl;
|
||||||
|
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
};
|
||||||
|
|
||||||
|
return [podRequest, queryGetAvatar, headers];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> getName(String _pubkey) async {
|
||||||
|
String _name;
|
||||||
|
|
||||||
|
List queryOptions = await _buildQuery(_pubkey);
|
||||||
|
final response = await http.post(queryOptions[0],
|
||||||
|
body: queryOptions[1], headers: queryOptions[2]);
|
||||||
|
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||||
|
final responseJson = json.decode(response.body);
|
||||||
|
if (responseJson['hits']['hits'].toString() == '[]') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
final bool avatarExist =
|
||||||
|
responseJson['hits']['hits'][0]['_source'].containsKey("title");
|
||||||
|
if (!avatarExist) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
_name = responseJson['hits']['hits'][0]['_source']['title'];
|
||||||
|
print(_name);
|
||||||
|
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List> getAvatar(String _pubkey) async {
|
||||||
|
List queryOptions = await _buildQuery(_pubkey);
|
||||||
|
final response = await http.post(queryOptions[0],
|
||||||
|
body: queryOptions[1], headers: queryOptions[2]);
|
||||||
|
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||||
|
final responseJson = json.decode(response.body);
|
||||||
|
if (responseJson['hits']['hits'].toString() == '[]') {
|
||||||
|
return [File(appPath.path + '/default_avatar.png')];
|
||||||
|
}
|
||||||
|
final bool avatarExist =
|
||||||
|
responseJson['hits']['hits'][0]['_source'].containsKey("avatar");
|
||||||
|
if (!avatarExist) {
|
||||||
|
return [File(appPath.path + '/default_avatar.png')];
|
||||||
|
}
|
||||||
|
final _avatar =
|
||||||
|
responseJson['hits']['hits'][0]['_source']['avatar']['_content'];
|
||||||
|
|
||||||
|
var avatarFile =
|
||||||
|
File('${(await getTemporaryDirectory()).path}/avatar$iAvatar.png');
|
||||||
|
// final bool _isAvatarExist = await avatarFile.exists();
|
||||||
|
// if (_isAvatarExist) {
|
||||||
|
// await avatarFile.delete();
|
||||||
|
// }
|
||||||
|
await avatarFile.writeAsBytes(base64.decode(_avatar));
|
||||||
|
iAvatar++;
|
||||||
|
isComplete = true;
|
||||||
|
|
||||||
|
return [avatarFile];
|
||||||
|
}
|
||||||
|
|
||||||
|
// isNameComplete() {
|
||||||
|
// while (isComplete == false) {
|
||||||
|
// print(isComplete);
|
||||||
|
// Duration(milliseconds: 50);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ class HistoryProvider with ChangeNotifier {
|
||||||
// String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug
|
// String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug
|
||||||
String pubkey = '';
|
String pubkey = '';
|
||||||
HistoryProvider(this.pubkey);
|
HistoryProvider(this.pubkey);
|
||||||
final TextEditingController _outputPubkey = new TextEditingController();
|
final TextEditingController outputPubkey = new TextEditingController();
|
||||||
bool isTheEnd = false;
|
bool isTheEnd = false;
|
||||||
List transBC;
|
List transBC;
|
||||||
bool isFirstBuild = true;
|
bool isFirstBuild = true;
|
||||||
|
@ -33,7 +33,7 @@ class HistoryProvider with ChangeNotifier {
|
||||||
return 'false';
|
return 'false';
|
||||||
}
|
}
|
||||||
if (barcode != null) {
|
if (barcode != null) {
|
||||||
this._outputPubkey.text = barcode;
|
this.outputPubkey.text = barcode;
|
||||||
isPubkey(barcode);
|
isPubkey(barcode);
|
||||||
} else {
|
} else {
|
||||||
return 'false';
|
return 'false';
|
||||||
|
@ -54,7 +54,7 @@ class HistoryProvider with ChangeNotifier {
|
||||||
print("C'est une pubkey !!!");
|
print("C'est une pubkey !!!");
|
||||||
|
|
||||||
this.pubkey = pubkey;
|
this.pubkey = pubkey;
|
||||||
this._outputPubkey.text = pubkey;
|
this.outputPubkey.text = pubkey;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
return pubkey;
|
return pubkey;
|
||||||
|
@ -149,8 +149,6 @@ class HistoryProvider with ChangeNotifier {
|
||||||
snackNode(context) {
|
snackNode(context) {
|
||||||
if (isFirstBuild) {
|
if (isFirstBuild) {
|
||||||
String _message;
|
String _message;
|
||||||
print('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
|
|
||||||
print(endPointGVA);
|
|
||||||
if (endPointGVA == 'HS') {
|
if (endPointGVA == 'HS') {
|
||||||
_message =
|
_message =
|
||||||
"Aucun noeud Duniter disponible, veuillez réessayer ultérieurement";
|
"Aucun noeud Duniter disponible, veuillez réessayer ultérieurement";
|
||||||
|
@ -165,12 +163,12 @@ class HistoryProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetdHistory() {
|
void resetdHistory() {
|
||||||
this._outputPubkey.text = '';
|
this.outputPubkey.text = '';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
num removeDecimalZero(double n) {
|
num removeDecimalZero(double n) {
|
||||||
String result = n.toStringAsFixed(n.truncateToDouble() == n ? 0 : 1);
|
String result = n.toStringAsFixed(n.truncateToDouble() == n ? 0 : 2);
|
||||||
return num.parse(result);
|
return num.parse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
|
@ -63,6 +64,16 @@ class HomeProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future createDefaultAvatar() async {
|
||||||
|
File defaultAvatar = File(appPath.path + '/default_avatar.png');
|
||||||
|
final bool isAvatarExist = await defaultAvatar.exists();
|
||||||
|
if (!isAvatarExist) {
|
||||||
|
final byteData = await rootBundle.load('assets/icon_user.png');
|
||||||
|
await defaultAvatar.writeAsBytes(byteData.buffer
|
||||||
|
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
T getRandomElement<T>(List<T> list) {
|
T getRandomElement<T>(List<T> list) {
|
||||||
final random = new Random();
|
final random = new Random();
|
||||||
var i = random.nextInt(list.length);
|
var i = random.nextInt(list.length);
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/cesiumPlus.dart';
|
||||||
import 'package:gecko/models/queries.dart';
|
import 'package:gecko/models/queries.dart';
|
||||||
import 'package:gecko/models/history.dart';
|
import 'package:gecko/models/history.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -16,6 +20,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
// HistoryProvider _historyProvider;
|
// HistoryProvider _historyProvider;
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
FocusNode _pubkeyFocus = FocusNode();
|
FocusNode _pubkeyFocus = FocusNode();
|
||||||
|
List cesiumData;
|
||||||
|
|
||||||
FetchMore fetchMore;
|
FetchMore fetchMore;
|
||||||
FetchMoreOptions opts;
|
FetchMoreOptions opts;
|
||||||
|
@ -49,7 +54,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(children: <Widget>[
|
body: Column(children: <Widget>[
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 20),
|
||||||
TextField(
|
TextField(
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
focusNode: _pubkeyFocus,
|
focusNode: _pubkeyFocus,
|
||||||
|
@ -80,6 +85,8 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
historyQuery(context) {
|
historyQuery(context) {
|
||||||
_pubkeyFocus.unfocus();
|
_pubkeyFocus.unfocus();
|
||||||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||||
|
CesiumPlusProvider _cesiumPlusProvider =
|
||||||
|
Provider.of<CesiumPlusProvider>(context);
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
@ -122,6 +129,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
opts = _historyProvider.checkQueryResult(result, opts);
|
opts = _historyProvider.checkQueryResult(result, opts);
|
||||||
|
|
||||||
// Build history list
|
// Build history list
|
||||||
|
// _cesiumPlusProvider.cesiumName.text = "NAMEE";
|
||||||
return NotificationListener(
|
return NotificationListener(
|
||||||
child: Expanded(
|
child: Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
|
@ -131,13 +139,51 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
if (_historyProvider.pubkey != '')
|
if (_historyProvider.pubkey != '')
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(width: 70.0, height: 0.0),
|
Container(
|
||||||
|
padding: const EdgeInsets.only(left: 30),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: _cesiumPlusProvider
|
||||||
|
.getAvatar(_historyProvider.pubkey),
|
||||||
|
initialData: [
|
||||||
|
File(appPath.path + '/default_avatar.png')
|
||||||
|
],
|
||||||
|
builder: (BuildContext context,
|
||||||
|
AsyncSnapshot<List> _avatar) {
|
||||||
|
cesiumData = _avatar.data;
|
||||||
|
// _cesiumPlusProvider.isComplete = true;
|
||||||
|
if (_avatar.connectionState !=
|
||||||
|
ConnectionState.done) {
|
||||||
|
return Image.file(
|
||||||
|
File(appPath.path +
|
||||||
|
'/default_avatar.png'),
|
||||||
|
height: 65);
|
||||||
|
}
|
||||||
|
if (_avatar.hasError) {
|
||||||
|
return Image.file(
|
||||||
|
File(appPath.path +
|
||||||
|
'/default_avatar.png'),
|
||||||
|
height: 65);
|
||||||
|
}
|
||||||
|
if (_avatar.hasData) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.all(0.0),
|
||||||
|
child: Image.file(_avatar.data[0],
|
||||||
|
height: 65));
|
||||||
|
}
|
||||||
|
return Image.file(
|
||||||
|
File(appPath.path +
|
||||||
|
'/default_avatar.png'),
|
||||||
|
height: 65);
|
||||||
|
})),
|
||||||
Text(balance.toString() + ' Ğ1',
|
Text(balance.toString() + ' Ğ1',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: 30.0)),
|
style: TextStyle(fontSize: 30.0)),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(right: 15),
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
30, 0, 15, 0), // .only(right: 15),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(Icons.payments),
|
icon: Icon(Icons.payments),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -150,7 +196,22 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
iconSize: 30,
|
iconSize: 30,
|
||||||
color: Color(0xFFB16E16)))
|
color: Color(0xFFB16E16)))
|
||||||
]),
|
]),
|
||||||
SizedBox(height: 15),
|
SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
// padding: const EdgeInsets.,
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: _cesiumPlusProvider
|
||||||
|
.getName(_historyProvider.pubkey),
|
||||||
|
initialData: '',
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return Text(snapshot.data);
|
||||||
|
}))
|
||||||
|
]),
|
||||||
|
SizedBox(height: 20),
|
||||||
const Divider(
|
const Divider(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
height: 5,
|
height: 5,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
}),
|
}),
|
||||||
title: SizedBox(
|
title: SizedBox(
|
||||||
height: 22,
|
height: 22,
|
||||||
child: Text('Confirmez ce portefeuille'),
|
child: Text('Enregistrer ce portefeuille'),
|
||||||
)),
|
)),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
|
|
|
@ -157,6 +157,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
SizedBox(width: 20),
|
||||||
Column(children: <Widget>[
|
Column(children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 30,
|
width: 30,
|
||||||
|
|
|
@ -574,6 +574,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.6"
|
version: "0.9.6"
|
||||||
|
sync_http:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: sync_http
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -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.1+0
|
version: 0.0.1+2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
@ -31,6 +31,7 @@ dependencies:
|
||||||
package_info: ^0.4.3+2
|
package_info: ^0.4.3+2
|
||||||
printing: ^4.0.0
|
printing: ^4.0.0
|
||||||
shared_preferences: ^0.5.12+4
|
shared_preferences: ^0.5.12+4
|
||||||
|
sync_http: ^0.2.0
|
||||||
|
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
|
@ -53,3 +54,4 @@ flutter:
|
||||||
- assets/icon/gecko_final.png
|
- assets/icon/gecko_final.png
|
||||||
- assets/
|
- assets/
|
||||||
- assets/OpenSans-Regular.ttf
|
- assets/OpenSans-Regular.ttf
|
||||||
|
- assets/icon_user.png
|
||||||
|
|
Loading…
Reference in New Issue