Indexer client implemented; Display identity name when exist
This commit is contained in:
parent
cdfa62aad5
commit
7f83965a8b
|
@ -43,6 +43,7 @@ import 'package:responsive_framework/responsive_framework.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
import 'package:window_size/window_size.dart';
|
import 'package:window_size/window_size.dart';
|
||||||
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
|
|
||||||
const bool enableSentry = true;
|
const bool enableSentry = true;
|
||||||
|
|
||||||
|
@ -79,6 +80,8 @@ Future<void> main() async {
|
||||||
}
|
}
|
||||||
// log.d(await configBox.get('endpoint'));
|
// log.d(await configBox.get('endpoint'));
|
||||||
|
|
||||||
|
const indexerEndpoint = "http://192.168.1.72:8080/v1/graphql";
|
||||||
|
|
||||||
HttpOverrides.global = MyHttpOverrides();
|
HttpOverrides.global = MyHttpOverrides();
|
||||||
|
|
||||||
if (kReleaseMode && enableSentry) {
|
if (kReleaseMode && enableSentry) {
|
||||||
|
@ -95,7 +98,7 @@ Future<void> main() async {
|
||||||
await SentryFlutter.init((options) {
|
await SentryFlutter.init((options) {
|
||||||
options.dsn =
|
options.dsn =
|
||||||
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
||||||
}, appRunner: () => runApp(const Gecko()));
|
}, appRunner: () => runApp(const Gecko(indexerEndpoint)));
|
||||||
|
|
||||||
// runZoned<Future<void>>(
|
// runZoned<Future<void>>(
|
||||||
// () async {
|
// () async {
|
||||||
|
@ -112,16 +115,27 @@ Future<void> main() async {
|
||||||
} else {
|
} else {
|
||||||
print('Debug mode enabled: No sentry alerte');
|
print('Debug mode enabled: No sentry alerte');
|
||||||
|
|
||||||
runApp(const Gecko());
|
runApp(const Gecko(indexerEndpoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Gecko extends StatelessWidget {
|
class Gecko extends StatelessWidget {
|
||||||
const Gecko({Key? key}) : super(key: key);
|
const Gecko(this.indexerEndpoint, {Key? key}) : super(key: key);
|
||||||
|
final String? indexerEndpoint;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
final _httpLink = HttpLink(
|
||||||
|
indexerEndpoint!,
|
||||||
|
);
|
||||||
|
|
||||||
|
final _client = ValueNotifier(
|
||||||
|
GraphQLClient(
|
||||||
|
cache: GraphQLCache(),
|
||||||
|
link: _httpLink,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -136,41 +150,44 @@ class Gecko extends StatelessWidget {
|
||||||
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
|
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => SubstrateSdk())
|
ChangeNotifierProvider(create: (_) => SubstrateSdk())
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: GraphQLProvider(
|
||||||
builder: (context, widget) => ResponsiveWrapper.builder(
|
client: _client,
|
||||||
BouncingScrollWrapper.builder(context, widget!),
|
child: MaterialApp(
|
||||||
maxWidth: 1200,
|
builder: (context, widget) => ResponsiveWrapper.builder(
|
||||||
minWidth: 480,
|
BouncingScrollWrapper.builder(context, widget!),
|
||||||
defaultScale: true,
|
maxWidth: 1200,
|
||||||
breakpoints: [
|
minWidth: 480,
|
||||||
const ResponsiveBreakpoint.resize(480, name: MOBILE),
|
defaultScale: true,
|
||||||
const ResponsiveBreakpoint.autoScale(800, name: TABLET),
|
breakpoints: [
|
||||||
const ResponsiveBreakpoint.resize(1000, name: DESKTOP),
|
const ResponsiveBreakpoint.resize(480, name: MOBILE),
|
||||||
],
|
const ResponsiveBreakpoint.autoScale(800, name: TABLET),
|
||||||
background: Container(color: backgroundColor)),
|
const ResponsiveBreakpoint.resize(1000, name: DESKTOP),
|
||||||
title: 'Ğecko',
|
],
|
||||||
theme: ThemeData(
|
background: Container(color: backgroundColor)),
|
||||||
appBarTheme: const AppBarTheme(
|
title: 'Ğecko',
|
||||||
color: Color(0xffFFD58D),
|
theme: ThemeData(
|
||||||
foregroundColor: Color(0xFF000000),
|
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),
|
home: const HomeScreen(),
|
||||||
textTheme: const TextTheme(
|
initialRoute: "/",
|
||||||
bodyText1: TextStyle(fontSize: 16),
|
routes: {
|
||||||
bodyText2: TextStyle(fontSize: 18),
|
'/mywallets': (context) => const WalletsHome(),
|
||||||
).apply(
|
'/search': (context) => const SearchScreen(),
|
||||||
bodyColor: const Color(0xFF000000),
|
'/searchResult': (context) => const SearchResultScreen(),
|
||||||
),
|
},
|
||||||
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(),
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
const String getNameByAddressQ = r'''
|
||||||
|
query ($address: String!) {
|
||||||
|
account_by_pk(id: $address) {
|
||||||
|
identity {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
''';
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/queries_indexer.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
@ -9,6 +10,7 @@ import 'package:gecko/screens/animated_text.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
import 'package:gecko/screens/transaction_in_progress.dart';
|
import 'package:gecko/screens/transaction_in_progress.dart';
|
||||||
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:image_cropper/image_cropper.dart';
|
import 'package:image_cropper/image_cropper.dart';
|
||||||
|
@ -25,6 +27,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
TextEditingController nameController = TextEditingController();
|
TextEditingController nameController = TextEditingController();
|
||||||
late bool isDefaultWallet;
|
late bool isDefaultWallet;
|
||||||
bool canValidateNameBool = false;
|
bool canValidateNameBool = false;
|
||||||
|
Map<String, String?> walletNameIndexer = {};
|
||||||
|
|
||||||
Future<NewWallet>? get badWallet => null;
|
Future<NewWallet>? get badWallet => null;
|
||||||
|
|
||||||
|
@ -170,12 +173,18 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
case 'ConfirmedByOwner':
|
case 'ConfirmedByOwner':
|
||||||
{
|
{
|
||||||
return _showText('Identité confirmé');
|
return isOwner
|
||||||
|
? _showText('Identité confirmé')
|
||||||
|
: getNameByAddress(context, address, null, 20, true,
|
||||||
|
Colors.grey[700]!, FontWeight.w500, FontStyle.italic);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'Validated':
|
case 'Validated':
|
||||||
{
|
{
|
||||||
return _showText('Membre validé !', 18, true);
|
return isOwner
|
||||||
|
? _showText('Membre validé !', 18, true)
|
||||||
|
: getNameByAddress(context, address, null, 20, true,
|
||||||
|
Colors.black, FontWeight.w600, FontStyle.normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'expired':
|
case 'expired':
|
||||||
|
@ -420,6 +429,139 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
|
|
||||||
return _address;
|
return _address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]) {
|
||||||
|
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 walletName(context, wallet, size, _color);
|
||||||
|
} else {
|
||||||
|
return 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 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 = {};
|
Map<String, double> balanceCache = {};
|
||||||
|
|
|
@ -100,10 +100,18 @@ class WalletOptions extends StatelessWidget {
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
walletName(
|
_walletOptions.getNameByAddress(
|
||||||
context, walletProvider, _walletOptions),
|
context,
|
||||||
SizedBox(height: isTall ? 5 : 0),
|
walletProvider.address.text,
|
||||||
|
wallet,
|
||||||
|
27,
|
||||||
|
false,
|
||||||
|
Colors.black,
|
||||||
|
FontWeight.w400,
|
||||||
|
FontStyle.normal),
|
||||||
// SizedBox(height: isTall ? 5 : 0),
|
// SizedBox(height: isTall ? 5 : 0),
|
||||||
|
|
||||||
|
SizedBox(height: isTall ? 5 : 0),
|
||||||
balance(
|
balance(
|
||||||
context, walletProvider.address.text, 21),
|
context, walletProvider.address.text, 21),
|
||||||
const SizedBox(width: 30),
|
const SizedBox(width: 30),
|
||||||
|
@ -247,63 +255,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) {
|
Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) {
|
||||||
final String shortPubkey = getShortPubkey(walletProvider.address.text);
|
final String shortPubkey = getShortPubkey(walletProvider.address.text);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
|
|
@ -263,17 +263,27 @@ class WalletsHome extends StatelessWidget {
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 5),
|
const EdgeInsets.symmetric(horizontal: 5),
|
||||||
child: Text(
|
child: _walletOptions.getNameByAddress(
|
||||||
_repository.name!,
|
context,
|
||||||
textAlign: TextAlign.center,
|
_repository.address!,
|
||||||
style: TextStyle(
|
_repository,
|
||||||
fontSize: 17.0,
|
17,
|
||||||
color: _repository.id()[1] ==
|
true,
|
||||||
defaultWallet.id()[1]
|
_repository.id()[1] == defaultWallet.id()[1]
|
||||||
? const Color(0xffF9F9F1)
|
? const Color(0xffF9F9F1)
|
||||||
: Colors.black,
|
: Colors.black),
|
||||||
fontStyle: FontStyle.italic),
|
|
||||||
),
|
// 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,
|
// dense: true,
|
||||||
|
|
Loading…
Reference in New Issue