Merge branch 'implementIndexer'
This commit is contained in:
commit
0781f26bc1
|
@ -17,6 +17,8 @@ format:
|
|||
- if: $CI_COMMIT_TAG || $CI_MERGE_REQUEST_ID
|
||||
- when: manual
|
||||
stage: format
|
||||
script:
|
||||
- flutter format --set-exit-if-changed lib
|
||||
|
||||
build_and_test:
|
||||
extends: .env
|
||||
|
@ -30,25 +32,6 @@ build_and_test:
|
|||
- redshift
|
||||
script:
|
||||
- flutter analyze
|
||||
# - flutter test
|
||||
|
||||
lint:
|
||||
extends: .env
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
|
||||
when: manual
|
||||
- if: $CI_COMMIT_TAG || $CI_MERGE_REQUEST_ID
|
||||
- when: manual
|
||||
stage: quality
|
||||
|
||||
audit_dependencies:
|
||||
extends: .env
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
|
||||
when: manual
|
||||
- if: $CI_COMMIT_TAG || $CI_MERGE_REQUEST_ID
|
||||
- when: manual
|
||||
stage: quality
|
||||
|
||||
releases:test:
|
||||
extends: .env
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[
|
||||
"https://duniter-indexer.coinduf.eu/v1/graphql",
|
||||
"http://192.168.1.72:8080/v1/graphql"
|
||||
]
|
|
@ -51,3 +51,5 @@ String currencyName = 'ĞD';
|
|||
|
||||
// Debug
|
||||
const debugPin = true;
|
||||
|
||||
String indexerEndpoint = '';
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'package:gecko/providers/cesium_plus.dart';
|
|||
import 'package:gecko/models/chest_data.dart';
|
||||
import 'package:gecko/providers/chest_provider.dart';
|
||||
import 'package:gecko/models/g1_wallets_list.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/generate_wallets.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
|
@ -43,6 +44,7 @@ import 'package:responsive_framework/responsive_framework.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:window_size/window_size.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
|
||||
const bool enableSentry = true;
|
||||
|
||||
|
@ -55,6 +57,7 @@ Future<void> main() async {
|
|||
}
|
||||
|
||||
HomeProvider _homeProvider = HomeProvider();
|
||||
DuniterIndexer _duniterIndexer = DuniterIndexer();
|
||||
await _homeProvider.initHive();
|
||||
appVersion = await _homeProvider.getAppVersion();
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
|
@ -79,6 +82,11 @@ Future<void> main() async {
|
|||
}
|
||||
// log.d(await configBox.get('endpoint'));
|
||||
|
||||
await _duniterIndexer.getValidIndexerEndpoint();
|
||||
// _duniterIndexer.indexerEndpoint = "http://192.168.1.72:8080/v1/graphql";
|
||||
// _duniterIndexer.indexerEndpoint =
|
||||
// "https://duniter-indexer.coinduf.eu/v1/graphql";
|
||||
|
||||
HttpOverrides.global = MyHttpOverrides();
|
||||
|
||||
if (kReleaseMode && enableSentry) {
|
||||
|
@ -95,7 +103,7 @@ Future<void> main() async {
|
|||
await SentryFlutter.init((options) {
|
||||
options.dsn =
|
||||
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
||||
}, appRunner: () => runApp(const Gecko()));
|
||||
}, appRunner: () => runApp(Gecko(indexerEndpoint)));
|
||||
|
||||
// runZoned<Future<void>>(
|
||||
// () async {
|
||||
|
@ -112,16 +120,27 @@ Future<void> main() async {
|
|||
} else {
|
||||
print('Debug mode enabled: No sentry alerte');
|
||||
|
||||
runApp(const Gecko());
|
||||
runApp(Gecko(indexerEndpoint));
|
||||
}
|
||||
}
|
||||
|
||||
class Gecko extends StatelessWidget {
|
||||
const Gecko({Key? key}) : super(key: key);
|
||||
const Gecko(this.indexerEndpoint, {Key? key}) : super(key: key);
|
||||
final String? indexerEndpoint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
final _httpLink = HttpLink(
|
||||
indexerEndpoint!,
|
||||
);
|
||||
|
||||
final _client = ValueNotifier(
|
||||
GraphQLClient(
|
||||
cache: GraphQLCache(),
|
||||
link: _httpLink,
|
||||
),
|
||||
);
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
|
@ -134,43 +153,47 @@ class Gecko extends StatelessWidget {
|
|||
ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
|
||||
ChangeNotifierProvider(create: (_) => SearchProvider()),
|
||||
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
|
||||
ChangeNotifierProvider(create: (_) => SubstrateSdk())
|
||||
ChangeNotifierProvider(create: (_) => SubstrateSdk()),
|
||||
ChangeNotifierProvider(create: (_) => DuniterIndexer())
|
||||
],
|
||||
child: MaterialApp(
|
||||
builder: (context, widget) => ResponsiveWrapper.builder(
|
||||
BouncingScrollWrapper.builder(context, widget!),
|
||||
maxWidth: 1200,
|
||||
minWidth: 480,
|
||||
defaultScale: true,
|
||||
breakpoints: [
|
||||
const ResponsiveBreakpoint.resize(480, name: MOBILE),
|
||||
const ResponsiveBreakpoint.autoScale(800, name: TABLET),
|
||||
const ResponsiveBreakpoint.resize(1000, name: DESKTOP),
|
||||
],
|
||||
background: Container(color: backgroundColor)),
|
||||
title: 'Ğecko',
|
||||
theme: ThemeData(
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: Color(0xffFFD58D),
|
||||
foregroundColor: Color(0xFF000000),
|
||||
child: GraphQLProvider(
|
||||
client: _client,
|
||||
child: MaterialApp(
|
||||
builder: (context, widget) => ResponsiveWrapper.builder(
|
||||
BouncingScrollWrapper.builder(context, widget!),
|
||||
maxWidth: 1200,
|
||||
minWidth: 480,
|
||||
defaultScale: true,
|
||||
breakpoints: [
|
||||
const ResponsiveBreakpoint.resize(480, name: MOBILE),
|
||||
const ResponsiveBreakpoint.autoScale(800, name: TABLET),
|
||||
const ResponsiveBreakpoint.resize(1000, name: DESKTOP),
|
||||
],
|
||||
background: Container(color: backgroundColor)),
|
||||
title: 'Ğecko',
|
||||
theme: ThemeData(
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: Color(0xffFFD58D),
|
||||
foregroundColor: Color(0xFF000000),
|
||||
),
|
||||
primaryColor: const Color(0xffFFD58D),
|
||||
textTheme: const TextTheme(
|
||||
bodyText1: TextStyle(fontSize: 16),
|
||||
bodyText2: TextStyle(fontSize: 18),
|
||||
).apply(
|
||||
bodyColor: const Color(0xFF000000),
|
||||
),
|
||||
colorScheme:
|
||||
ColorScheme.fromSwatch().copyWith(secondary: Colors.grey[850]),
|
||||
),
|
||||
primaryColor: const Color(0xffFFD58D),
|
||||
textTheme: const TextTheme(
|
||||
bodyText1: TextStyle(fontSize: 16),
|
||||
bodyText2: TextStyle(fontSize: 18),
|
||||
).apply(
|
||||
bodyColor: const Color(0xFF000000),
|
||||
),
|
||||
colorScheme:
|
||||
ColorScheme.fromSwatch().copyWith(secondary: Colors.grey[850]),
|
||||
home: const HomeScreen(),
|
||||
initialRoute: "/",
|
||||
routes: {
|
||||
'/mywallets': (context) => const WalletsHome(),
|
||||
'/search': (context) => const SearchScreen(),
|
||||
'/searchResult': (context) => const SearchResultScreen(),
|
||||
},
|
||||
),
|
||||
home: const HomeScreen(),
|
||||
initialRoute: "/",
|
||||
routes: {
|
||||
'/mywallets': (context) => const WalletsHome(),
|
||||
'/search': (context) => const SearchScreen(),
|
||||
'/searchResult': (context) => const SearchResultScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
const String getNameByAddressQ = r'''
|
||||
query ($address: String!) {
|
||||
account_by_pk(id: $address) {
|
||||
identity {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
const String searchAddressByNameQ = r'''
|
||||
query ($name: String!) {
|
||||
search_identity(args: {name: $name}) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
const String getHistoryByAddressQ = r'''
|
||||
query ($address: String!) {
|
||||
account_by_pk(id: "5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn") {
|
||||
transactions_issued {
|
||||
receiver_id
|
||||
amount
|
||||
created_at
|
||||
created_on
|
||||
}
|
||||
transactions_received {
|
||||
issuer_id
|
||||
amount
|
||||
created_at
|
||||
created_on
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
const String getHistoryByAddressQ2 = r'''
|
||||
query ($address: String!) {
|
||||
{
|
||||
transaction(where: {_or: [{issuer_id: {_eq: $address}},
|
||||
{receiver_id: {_eq: $address}}]}, order_by: {created_at: desc})
|
||||
{
|
||||
amount
|
||||
created_at
|
||||
issuer_id
|
||||
receiver_id
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
const String getHistoryByAddressQ3 = r'''
|
||||
query ($address: String!) {
|
||||
transaction_connection(where:
|
||||
{_or: [
|
||||
{issuer_id: {_eq: $address}},
|
||||
{receiver_id: {_eq: $address}}
|
||||
]},
|
||||
order_by: {created_at: desc}) {
|
||||
edges {
|
||||
node {
|
||||
amount
|
||||
created_at
|
||||
issuer_id
|
||||
receiver_id
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
// To parse indexer date format
|
||||
// log.d(DateTime.parse("2022-06-13T16:51:24.001+00:00").toString());
|
|
@ -0,0 +1,260 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/queries_indexer.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/providers/cesium_plus.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
import 'package:gecko/screens/wallet_view.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DuniterIndexer with ChangeNotifier {
|
||||
Map<String, String?> walletNameIndexer = {};
|
||||
|
||||
void reload() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future checkIndexerEndpoint() async {
|
||||
final oldEndpoint = indexerEndpoint;
|
||||
while (true) {
|
||||
await Future.delayed(const Duration(seconds: 30));
|
||||
final _client = HttpClient();
|
||||
_client.connectionTimeout = const Duration(milliseconds: 1000);
|
||||
try {
|
||||
final request = await _client.postUrl(Uri.parse(oldEndpoint));
|
||||
final response = await request.close();
|
||||
if (response.statusCode != 200) {
|
||||
log.d('INDEXER IS OFFILINE');
|
||||
indexerEndpoint = '';
|
||||
} else {
|
||||
// log.d('Indexer is online');
|
||||
indexerEndpoint = oldEndpoint;
|
||||
}
|
||||
} catch (e) {
|
||||
log.d('INDEXER IS OFFILINE');
|
||||
indexerEndpoint = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getValidIndexerEndpoint() async {
|
||||
List _listEndpoints = await rootBundle
|
||||
.loadString('config/indexer_endpoints.json')
|
||||
.then((jsonStr) => jsonDecode(jsonStr));
|
||||
// _listEndpoints.shuffle();
|
||||
|
||||
int i = 0;
|
||||
// String _endpoint = '';
|
||||
int _statusCode = 0;
|
||||
|
||||
final _client = HttpClient();
|
||||
_client.connectionTimeout = const Duration(milliseconds: 1000);
|
||||
|
||||
do {
|
||||
int listLenght = _listEndpoints.length;
|
||||
if (i >= listLenght) {
|
||||
log.e('NO VALID INDEXER ENDPOINT FOUND');
|
||||
indexerEndpoint = '';
|
||||
break;
|
||||
}
|
||||
log.d(
|
||||
(i + 1).toString() + 'n indexer endpoint try: ${_listEndpoints[i]}');
|
||||
|
||||
if (i != 0) {
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
}
|
||||
|
||||
try {
|
||||
final request = await _client.postUrl(Uri.parse(_listEndpoints[i]));
|
||||
final response = await request.close();
|
||||
|
||||
indexerEndpoint = _listEndpoints[i];
|
||||
_statusCode = response.statusCode;
|
||||
i++;
|
||||
} on TimeoutException catch (_) {
|
||||
log.e('This endpoint is timeout, next');
|
||||
_statusCode = 50;
|
||||
i++;
|
||||
continue;
|
||||
} on SocketException catch (_) {
|
||||
log.e('This endpoint is a bad endpoint, next');
|
||||
_statusCode = 70;
|
||||
i++;
|
||||
continue;
|
||||
} on Exception {
|
||||
log.e('Unknown error');
|
||||
_statusCode = 60;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
} while (_statusCode != 200);
|
||||
|
||||
log.i('INDEXER: ' + indexerEndpoint);
|
||||
return indexerEndpoint;
|
||||
}
|
||||
|
||||
Widget getNameByAddress(BuildContext context, String address,
|
||||
[WalletData? wallet,
|
||||
double size = 20,
|
||||
bool canEdit = false,
|
||||
Color _color = Colors.black,
|
||||
FontWeight fontWeight = FontWeight.w400,
|
||||
FontStyle fontStyle = FontStyle.italic]) {
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
if (indexerEndpoint == '') {
|
||||
if (wallet == null) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
if (canEdit) {
|
||||
return _walletOptions.walletName(context, wallet, size, _color);
|
||||
} else {
|
||||
return _walletOptions.walletNameController(context, wallet, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Query(
|
||||
options: QueryOptions(
|
||||
document: gql(
|
||||
getNameByAddressQ), // this is the query string you just created
|
||||
variables: {
|
||||
'address': address,
|
||||
},
|
||||
// pollInterval: const Duration(seconds: 10),
|
||||
),
|
||||
builder: (QueryResult result,
|
||||
{VoidCallback? refetch, FetchMore? fetchMore}) {
|
||||
if (result.hasException) {
|
||||
return Text(result.exception.toString());
|
||||
}
|
||||
|
||||
if (result.isLoading) {
|
||||
return const Text('Loading');
|
||||
}
|
||||
|
||||
walletNameIndexer[address] =
|
||||
result.data?['account_by_pk']?['identity']?['name'];
|
||||
|
||||
if (walletNameIndexer[address] == null) {
|
||||
if (wallet == null) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
if (canEdit) {
|
||||
return _walletOptions.walletName(context, wallet, size, _color);
|
||||
} else {
|
||||
return _walletOptions.walletNameController(
|
||||
context, wallet, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Text(
|
||||
_color == Colors.grey[700]!
|
||||
? '(${walletNameIndexer[address]!})'
|
||||
: walletNameIndexer[address]!,
|
||||
style: TextStyle(
|
||||
fontSize: size,
|
||||
color: _color,
|
||||
fontWeight: fontWeight,
|
||||
fontStyle: fontStyle,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget searchIdentity(BuildContext context, String name) {
|
||||
// WalletOptionsProvider _walletOptions =
|
||||
// Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
CesiumPlusProvider _cesiumPlusProvider =
|
||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||
WalletsProfilesProvider _walletsProfiles =
|
||||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
if (indexerEndpoint == '') {
|
||||
return const Text('Aucun résultat');
|
||||
}
|
||||
|
||||
return Query(
|
||||
options: QueryOptions(
|
||||
document: gql(
|
||||
searchAddressByNameQ), // this is the query string you just created
|
||||
variables: {
|
||||
'name': name,
|
||||
},
|
||||
// pollInterval: const Duration(seconds: 10),
|
||||
),
|
||||
builder: (QueryResult result,
|
||||
{VoidCallback? refetch, FetchMore? fetchMore}) {
|
||||
if (result.hasException) {
|
||||
return Text(result.exception.toString());
|
||||
}
|
||||
|
||||
if (result.isLoading) {
|
||||
return const Text('Loading');
|
||||
}
|
||||
|
||||
final List identities = result.data?['search_identity'] ?? [];
|
||||
|
||||
if (identities.isEmpty) {
|
||||
return const Text('Aucun résultat');
|
||||
}
|
||||
|
||||
int keyID = 0;
|
||||
double _avatarSize = 55;
|
||||
return Expanded(
|
||||
child: ListView(children: <Widget>[
|
||||
for (Map profile in identities)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: ListTile(
|
||||
key: Key('searchResult${keyID++}'),
|
||||
horizontalTitleGap: 40,
|
||||
contentPadding: const EdgeInsets.all(5),
|
||||
leading: _cesiumPlusProvider.defaultAvatar(_avatarSize),
|
||||
title: Row(children: <Widget>[
|
||||
Text(getShortPubkey(profile['id']),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Monospace',
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [balance(context, profile['id'], 16)]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
Text(profile['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
dense: false,
|
||||
isThreeLine: false,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
_walletsProfiles.address = profile['id'];
|
||||
return WalletViewScreen(
|
||||
pubkey: profile['id'],
|
||||
username:
|
||||
g1WalletsBox.get(profile['id'])?.id?.username,
|
||||
avatar: g1WalletsBox.get(profile['id'])?.avatar,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
),
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
|
@ -127,6 +128,9 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
|
||||
Widget idtyStatus(BuildContext context, String address,
|
||||
{bool isOwner = false, Color color = Colors.black}) {
|
||||
DuniterIndexer _duniterIndexer =
|
||||
Provider.of<DuniterIndexer>(context, listen: false);
|
||||
|
||||
_showText(String text,
|
||||
[double size = 18, bool _bold = false, bool smooth = true]) {
|
||||
log.d(text);
|
||||
|
@ -170,12 +174,32 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
case 'ConfirmedByOwner':
|
||||
{
|
||||
return _showText('Identité confirmé');
|
||||
return isOwner
|
||||
? _showText('Identité confirmé')
|
||||
: _duniterIndexer.getNameByAddress(
|
||||
context,
|
||||
address,
|
||||
null,
|
||||
20,
|
||||
true,
|
||||
Colors.grey[700]!,
|
||||
FontWeight.w500,
|
||||
FontStyle.italic);
|
||||
}
|
||||
|
||||
case 'Validated':
|
||||
{
|
||||
return _showText('Membre validé !', 18, true);
|
||||
return isOwner
|
||||
? _showText('Membre validé !', 18, true)
|
||||
: _duniterIndexer.getNameByAddress(
|
||||
context,
|
||||
address,
|
||||
null,
|
||||
20,
|
||||
true,
|
||||
Colors.black,
|
||||
FontWeight.w600,
|
||||
FontStyle.normal);
|
||||
}
|
||||
|
||||
case 'expired':
|
||||
|
@ -420,6 +444,84 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
|
||||
return _address;
|
||||
}
|
||||
|
||||
Widget walletNameController(BuildContext context, WalletData wallet,
|
||||
[double size = 20]) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
log.d('aaaaaaaaaaaaaaaaaaaaa: ${wallet.name}');
|
||||
nameController.text = wallet.name!;
|
||||
// _walletOptions.reloadBuild();
|
||||
// });
|
||||
|
||||
return SizedBox(
|
||||
width: 260,
|
||||
child: Stack(children: <Widget>[
|
||||
TextField(
|
||||
key: const Key('walletName'),
|
||||
autofocus: false,
|
||||
focusNode: walletNameFocus,
|
||||
enabled: isEditing,
|
||||
controller: nameController,
|
||||
minLines: 1,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
key: const Key('renameWallet'),
|
||||
onTap: () async {
|
||||
// _isNewNameValid =
|
||||
// walletProvider.editWalletName(wallet.id(), isCesium: false);
|
||||
await editWalletName(context, wallet.id());
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 25,
|
||||
height: 25),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget walletName(BuildContext context, WalletData wallet,
|
||||
[double size = 20, Color color = Colors.black]) {
|
||||
return SizedBox(
|
||||
width: 260,
|
||||
child:
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||
Text(
|
||||
wallet.name!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, double> balanceCache = {};
|
||||
|
|
|
@ -306,7 +306,6 @@ Future<void> infoPopup(BuildContext context, String title) async {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// Widget geckoAppBar() {
|
||||
// return AppBar(
|
||||
// toolbarHeight: 60 * ratio,
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:connectivity_plus/connectivity_plus.dart';
|
|||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/stateful_wrapper.dart';
|
||||
import 'package:gecko/providers/chest_provider.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
|
@ -145,6 +146,9 @@ class HomeScreen extends StatelessWidget {
|
|||
}
|
||||
});
|
||||
}
|
||||
DuniterIndexer _duniterIndexer =
|
||||
Provider.of<DuniterIndexer>(ctx, listen: false);
|
||||
_duniterIndexer.checkIndexerEndpoint();
|
||||
});
|
||||
},
|
||||
child: isWalletsExists ? geckHome(context) : welcomeHome(context)
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
|
@ -31,6 +32,8 @@ class WalletOptions extends StatelessWidget {
|
|||
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||
HomeProvider _homeProvider =
|
||||
Provider.of<HomeProvider>(context, listen: false);
|
||||
DuniterIndexer _duniterIndexer =
|
||||
Provider.of<DuniterIndexer>(context, listen: false);
|
||||
|
||||
log.d(_walletOptions.address.text);
|
||||
|
||||
|
@ -100,10 +103,18 @@ class WalletOptions extends StatelessWidget {
|
|||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
walletName(
|
||||
context, walletProvider, _walletOptions),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
_duniterIndexer.getNameByAddress(
|
||||
context,
|
||||
walletProvider.address.text,
|
||||
wallet,
|
||||
27,
|
||||
false,
|
||||
Colors.black,
|
||||
FontWeight.w400,
|
||||
FontStyle.normal),
|
||||
// SizedBox(height: isTall ? 5 : 0),
|
||||
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
balance(
|
||||
context, walletProvider.address.text, 21),
|
||||
const SizedBox(width: 30),
|
||||
|
@ -247,63 +258,6 @@ class WalletOptions extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Widget walletName(BuildContext context, WalletOptionsProvider walletProvider,
|
||||
WalletOptionsProvider _walletOptions) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_walletOptions.nameController.text = wallet.name!;
|
||||
// _walletOptions.reloadBuild();
|
||||
});
|
||||
|
||||
return SizedBox(
|
||||
width: 260,
|
||||
child: Stack(children: <Widget>[
|
||||
TextField(
|
||||
key: const Key('walletName'),
|
||||
autofocus: false,
|
||||
focusNode: walletProvider.walletNameFocus,
|
||||
enabled: walletProvider.isEditing,
|
||||
controller: walletProvider.nameController,
|
||||
minLines: 1,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? 27 : 23,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
key: const Key('renameWallet'),
|
||||
onTap: () async {
|
||||
// _isNewNameValid =
|
||||
// walletProvider.editWalletName(wallet.id(), isCesium: false);
|
||||
await walletProvider.editWalletName(context, wallet.id());
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
walletProvider.walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
walletProvider.isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 25,
|
||||
height: 25),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) {
|
||||
final String shortPubkey = getShortPubkey(walletProvider.address.text);
|
||||
return GestureDetector(
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/chest_data.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
|
@ -136,6 +137,8 @@ class WalletsHome extends StatelessWidget {
|
|||
Provider.of<MyWalletsProvider>(context);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
DuniterIndexer _duniterIndexer =
|
||||
Provider.of<DuniterIndexer>(context, listen: false);
|
||||
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
||||
|
||||
if (!isWalletsExists) {
|
||||
|
@ -263,17 +266,27 @@ class WalletsHome extends StatelessWidget {
|
|||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: Text(
|
||||
_repository.name!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: _repository.id()[1] ==
|
||||
defaultWallet.id()[1]
|
||||
? const Color(0xffF9F9F1)
|
||||
: Colors.black,
|
||||
fontStyle: FontStyle.italic),
|
||||
),
|
||||
child: _duniterIndexer.getNameByAddress(
|
||||
context,
|
||||
_repository.address!,
|
||||
_repository,
|
||||
17,
|
||||
true,
|
||||
_repository.id()[1] == defaultWallet.id()[1]
|
||||
? const Color(0xffF9F9F1)
|
||||
: Colors.black),
|
||||
|
||||
// Text(
|
||||
// _repository.name!,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: 17.0,
|
||||
// color: _repository.id()[1] ==
|
||||
// defaultWallet.id()[1]
|
||||
// ? const Color(0xffF9F9F1)
|
||||
// : Colors.black,
|
||||
// fontStyle: FontStyle.italic),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
// dense: true,
|
||||
|
|
|
@ -6,7 +6,8 @@ import 'package:gecko/screens/common_elements.dart';
|
|||
import 'package:gecko/screens/onBoarding/8.dart';
|
||||
|
||||
class OnboardingStepSeven extends StatelessWidget {
|
||||
const OnboardingStepSeven({Key? key, this.scanDerivation = false}) : super(key: key);
|
||||
const OnboardingStepSeven({Key? key, this.scanDerivation = false})
|
||||
: super(key: key);
|
||||
final bool scanDerivation;
|
||||
|
||||
@override
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:gecko/globals.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/providers/cesium_plus.dart';
|
||||
import 'package:gecko/models/g1_wallets_list.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
|
@ -26,6 +27,8 @@ class SearchResultScreen extends StatelessWidget {
|
|||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
HomeProvider _homeProvider =
|
||||
Provider.of<HomeProvider>(context, listen: false);
|
||||
DuniterIndexer _duniterIndexer =
|
||||
Provider.of<DuniterIndexer>(context, listen: false);
|
||||
|
||||
int keyID = 0;
|
||||
double _avatarSize = 55;
|
||||
|
@ -78,7 +81,10 @@ class SearchResultScreen extends StatelessWidget {
|
|||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
log.d(snapshot.data);
|
||||
if (snapshot.data?.isEmpty ?? true) {
|
||||
return const Text('Aucun résultat');
|
||||
return _duniterIndexer.searchIdentity(
|
||||
context, _searchProvider.searchController.text);
|
||||
|
||||
// const Text('Aucun résultat');
|
||||
} else {
|
||||
return Expanded(
|
||||
child: ListView(children: <Widget>[
|
||||
|
@ -91,53 +97,8 @@ class SearchResultScreen extends StatelessWidget {
|
|||
key: Key('searchResult${keyID++}'),
|
||||
horizontalTitleGap: 40,
|
||||
contentPadding: const EdgeInsets.all(5),
|
||||
leading:
|
||||
// g1WalletsBox.get(g1Wallet.pubkey)
|
||||
// ?.avatar !=
|
||||
// null
|
||||
// ?
|
||||
_cesiumPlusProvider
|
||||
.defaultAvatar(_avatarSize),
|
||||
// : FutureBuilder(
|
||||
// future: _cesiumPlusProvider.getAvatar(
|
||||
// g1Wallet.pubkey, _avatarSize),
|
||||
// builder: (BuildContext context,
|
||||
// AsyncSnapshot<Image?> _avatar) {
|
||||
// if (_avatar.connectionState !=
|
||||
// ConnectionState.done ||
|
||||
// _avatar.hasError) {
|
||||
// return Stack(children: [
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize),
|
||||
// Positioned(
|
||||
// top: 8,
|
||||
// right: 0,
|
||||
// width: 12,
|
||||
// height: 12,
|
||||
// child: CircularProgressIndicator(
|
||||
// strokeWidth: 1,
|
||||
// color: orangeC,
|
||||
// ),
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
// if (_avatar.hasData) {
|
||||
// final _w =
|
||||
// g1WalletsBox.get(g1Wallet.pubkey);
|
||||
// if (_w != null) {
|
||||
// _w.avatar = _avatar.data;
|
||||
// }
|
||||
// return ClipOval(child: _avatar.data);
|
||||
// } else {
|
||||
// g1WalletsBox
|
||||
// .get(g1Wallet.pubkey)!
|
||||
// .avatar =
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// return _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// }
|
||||
// }),
|
||||
leading: _cesiumPlusProvider
|
||||
.defaultAvatar(_avatarSize),
|
||||
title: Row(children: <Widget>[
|
||||
Text(getShortPubkey(g1Wallet.pubkey!),
|
||||
style: const TextStyle(
|
||||
|
@ -154,11 +115,8 @@ class SearchResultScreen extends StatelessWidget {
|
|||
context, g1Wallet.pubkey!, 16)
|
||||
]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
Text(g1Wallet.id?.username ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
_duniterIndexer.getNameByAddress(
|
||||
context, g1Wallet.pubkey!)
|
||||
]),
|
||||
dense: false,
|
||||
isThreeLine: false,
|
||||
|
|
|
@ -11,8 +11,7 @@ class TemplateScreen extends StatelessWidget {
|
|||
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: backgroundColor,
|
||||
|
||||
backgroundColor: backgroundColor,
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 60 * ratio,
|
||||
title: const SizedBox(
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
|||
# 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
|
||||
|
||||
version: 0.0.8+9
|
||||
version: 0.0.9+2
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
@ -29,6 +29,7 @@ dependencies:
|
|||
flutter_logs: ^2.1.4
|
||||
flutter_svg: ^0.22.0
|
||||
graphql_flutter: ^5.1.1-beta.3
|
||||
|
||||
hive: ^2.0.4
|
||||
hive_flutter: ^1.1.0
|
||||
http: ^0.13.4
|
||||
|
@ -98,7 +99,7 @@ flutter:
|
|||
|
||||
assets:
|
||||
- images/
|
||||
- config/gdev_endpoints.json
|
||||
- config/
|
||||
- assets/
|
||||
- assets/home/
|
||||
- assets/avatars/
|
||||
|
|
|
@ -13,10 +13,6 @@ APK_FILENAME="${APPNAME}-${VERSION}+${BUILD}.apk"
|
|||
|
||||
echo "artifact name: ${APK_FILENAME}"
|
||||
|
||||
## Build Rust dependancies
|
||||
echo "Compile Rust binding..."
|
||||
cargo make
|
||||
|
||||
# Build APK
|
||||
echo "Build APK..."
|
||||
#flutter clean
|
||||
|
|
Loading…
Reference in New Issue