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:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:window_size/window_size.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
|
||||
const bool enableSentry = true;
|
||||
|
||||
|
@ -79,6 +80,8 @@ Future<void> main() async {
|
|||
}
|
||||
// log.d(await configBox.get('endpoint'));
|
||||
|
||||
const indexerEndpoint = "http://192.168.1.72:8080/v1/graphql";
|
||||
|
||||
HttpOverrides.global = MyHttpOverrides();
|
||||
|
||||
if (kReleaseMode && enableSentry) {
|
||||
|
@ -95,7 +98,7 @@ Future<void> main() async {
|
|||
await SentryFlutter.init((options) {
|
||||
options.dsn =
|
||||
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
||||
}, appRunner: () => runApp(const Gecko()));
|
||||
}, appRunner: () => runApp(const Gecko(indexerEndpoint)));
|
||||
|
||||
// runZoned<Future<void>>(
|
||||
// () async {
|
||||
|
@ -112,16 +115,27 @@ Future<void> main() async {
|
|||
} else {
|
||||
print('Debug mode enabled: No sentry alerte');
|
||||
|
||||
runApp(const Gecko());
|
||||
runApp(const 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: [
|
||||
|
@ -136,41 +150,44 @@ class Gecko extends StatelessWidget {
|
|||
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
|
||||
ChangeNotifierProvider(create: (_) => SubstrateSdk())
|
||||
],
|
||||
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,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 'dart:async';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/queries_indexer.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/models/wallet_data.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/myWallets/unlocking_wallet.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:provider/provider.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
|
@ -25,6 +27,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
TextEditingController nameController = TextEditingController();
|
||||
late bool isDefaultWallet;
|
||||
bool canValidateNameBool = false;
|
||||
Map<String, String?> walletNameIndexer = {};
|
||||
|
||||
Future<NewWallet>? get badWallet => null;
|
||||
|
||||
|
@ -170,12 +173,18 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
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':
|
||||
{
|
||||
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':
|
||||
|
@ -420,6 +429,139 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
|
||||
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 = {};
|
||||
|
|
|
@ -100,10 +100,18 @@ class WalletOptions extends StatelessWidget {
|
|||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
walletName(
|
||||
context, walletProvider, _walletOptions),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
_walletOptions.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 +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) {
|
||||
final String shortPubkey = getShortPubkey(walletProvider.address.text);
|
||||
return GestureDetector(
|
||||
|
|
|
@ -263,17 +263,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: _walletOptions.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,
|
||||
|
|
Loading…
Reference in New Issue