refacto: ContactsList and SearchResult Widget
This commit is contained in:
parent
875341a804
commit
c6cfb4e548
|
@ -8,6 +8,7 @@ import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/models/queries_indexer.dart';
|
import 'package:gecko/models/queries_indexer.dart';
|
||||||
import 'package:gecko/models/widgets_keys.dart';
|
import 'package:gecko/models/widgets_keys.dart';
|
||||||
import 'package:gecko/providers/cesium_plus.dart';
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
|
import 'package:gecko/providers/search.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:gecko/screens/wallet_view.dart';
|
import 'package:gecko/screens/wallet_view.dart';
|
||||||
|
@ -159,6 +160,7 @@ class DuniterIndexer with ChangeNotifier {
|
||||||
WalletsProfilesProvider walletsProfiles =
|
WalletsProfilesProvider walletsProfiles =
|
||||||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||||
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
||||||
|
final searchProvider = Provider.of<SearchProvider>(context, listen: false);
|
||||||
if (indexerEndpoint == '') {
|
if (indexerEndpoint == '') {
|
||||||
return const Text('Aucun résultat');
|
return const Text('Aucun résultat');
|
||||||
}
|
}
|
||||||
|
@ -207,6 +209,9 @@ class DuniterIndexer with ChangeNotifier {
|
||||||
.putIfAbsent(profile['pubkey'], () => profile['name']);
|
.putIfAbsent(profile['pubkey'], () => profile['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchProvider.resultLenght = identities.length;
|
||||||
|
// TODO: Find a way to reload a provider here, in Widget build...
|
||||||
|
|
||||||
double avatarSize = 55;
|
double avatarSize = 55;
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: ListView(children: <Widget>[
|
child: ListView(children: <Widget>[
|
||||||
|
|
|
@ -7,6 +7,7 @@ class SearchProvider with ChangeNotifier {
|
||||||
List searchResult = [];
|
List searchResult = [];
|
||||||
final cacheDuring = 20 * 60 * 1000; //First number is minutes
|
final cacheDuring = 20 * 60 * 1000; //First number is minutes
|
||||||
int cacheTime = 0;
|
int cacheTime = 0;
|
||||||
|
int resultLenght = 0;
|
||||||
|
|
||||||
void reload() {
|
void reload() {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
|
@ -92,7 +92,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
// sub.nodeConnected = false;
|
// sub.nodeConnected = false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO: fix random bad network status on startup
|
|
||||||
HomeProvider homeProvider =
|
HomeProvider homeProvider =
|
||||||
Provider.of<HomeProvider>(context, listen: false);
|
Provider.of<HomeProvider>(context, listen: false);
|
||||||
Connectivity()
|
Connectivity()
|
||||||
|
|
|
@ -62,7 +62,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/chests/${currentChest.imageName}',
|
'assets/chests/${currentChest.imageName}',
|
||||||
height: 40,
|
height: 32,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 17),
|
const SizedBox(width: 17),
|
||||||
Text(currentChest.name!,
|
Text(currentChest.name!,
|
||||||
|
|
|
@ -2,18 +2,11 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
|
||||||
import 'package:gecko/models/widgets_keys.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/duniter_indexer.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/wallet_view.dart';
|
|
||||||
import 'package:gecko/widgets/balance.dart';
|
|
||||||
import 'package:gecko/widgets/bottom_app_bar.dart';
|
import 'package:gecko/widgets/bottom_app_bar.dart';
|
||||||
import 'package:gecko/widgets/name_by_address.dart';
|
import 'package:gecko/widgets/contacts_list.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ContactsScreen extends StatelessWidget {
|
class ContactsScreen extends StatelessWidget {
|
||||||
|
@ -24,15 +17,9 @@ class ContactsScreen extends StatelessWidget {
|
||||||
WalletsProfilesProvider walletsProfilesClass =
|
WalletsProfilesProvider walletsProfilesClass =
|
||||||
Provider.of<WalletsProfilesProvider>(context, listen: true);
|
Provider.of<WalletsProfilesProvider>(context, listen: true);
|
||||||
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
||||||
|
|
||||||
double avatarSize = 55;
|
double avatarSize = 55;
|
||||||
|
|
||||||
final myContacts = contactsBox.toMap().values.toList();
|
final myContacts = contactsBox.toMap().values.toList();
|
||||||
|
|
||||||
// for (var element in myContacts) {
|
|
||||||
// log.d('yooo: ${element.pubkey} ${element.username}');
|
|
||||||
// }
|
|
||||||
|
|
||||||
myContacts.sort((p1, p2) {
|
myContacts.sort((p1, p2) {
|
||||||
return Comparable.compare(p1.username?.toLowerCase() ?? 'zz',
|
return Comparable.compare(p1.username?.toLowerCase() ?? 'zz',
|
||||||
p2.username?.toLowerCase() ?? 'zz');
|
p2.username?.toLowerCase() ?? 'zz');
|
||||||
|
@ -52,85 +39,11 @@ class ContactsScreen extends StatelessWidget {
|
||||||
bottomNavigationBar: const GeckoBottomAppBar(),
|
bottomNavigationBar: const GeckoBottomAppBar(),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
Padding(
|
ContactsList(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
myContacts: myContacts,
|
||||||
child: Column(
|
avatarSize: avatarSize,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
walletsProfilesClass: walletsProfilesClass,
|
||||||
children: <Widget>[
|
duniterIndexer: duniterIndexer),
|
||||||
const SizedBox(height: 20),
|
|
||||||
if (myContacts.isEmpty)
|
|
||||||
Text('noContacts'.tr())
|
|
||||||
else
|
|
||||||
Expanded(
|
|
||||||
child: ListView(children: <Widget>[
|
|
||||||
for (G1WalletsList g1Wallet in myContacts)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
||||||
child: ListTile(
|
|
||||||
key: keySearchResult('keyID++'),
|
|
||||||
horizontalTitleGap: 40,
|
|
||||||
contentPadding: const EdgeInsets.all(5),
|
|
||||||
leading: defaultAvatar(avatarSize),
|
|
||||||
title: Row(children: <Widget>[
|
|
||||||
Text(getShortPubkey(g1Wallet.address),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontFamily: 'Monospace',
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
textAlign: TextAlign.center),
|
|
||||||
]),
|
|
||||||
trailing: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 110,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Balance(
|
|
||||||
address:
|
|
||||||
g1Wallet.address,
|
|
||||||
size: 16),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
subtitle: Row(children: <Widget>[
|
|
||||||
NameByAddress(
|
|
||||||
wallet:
|
|
||||||
WalletData(address: g1Wallet.address))
|
|
||||||
]),
|
|
||||||
dense: false,
|
|
||||||
isThreeLine: false,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
walletsProfilesClass.address =
|
|
||||||
g1Wallet.address;
|
|
||||||
return WalletViewScreen(
|
|
||||||
address: g1Wallet.address,
|
|
||||||
username:
|
|
||||||
duniterIndexer.walletNameIndexer[
|
|
||||||
g1Wallet.address] ??
|
|
||||||
'',
|
|
||||||
avatar: g1WalletsBox
|
|
||||||
.get(g1Wallet.address)
|
|
||||||
?.avatar,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
CommonElements().offlineInfo(context),
|
CommonElements().offlineInfo(context),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
|
|
@ -90,7 +90,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
onChanged: (v) async => {
|
onChanged: (v) async => {
|
||||||
await getClipBoard(),
|
await getClipBoard(),
|
||||||
setState(() {}),
|
// setState(() {}),
|
||||||
searchProvider.reload()
|
searchProvider.reload()
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
@ -99,6 +99,23 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||||
prefixIconConstraints: const BoxConstraints(
|
prefixIconConstraints: const BoxConstraints(
|
||||||
minHeight: 32,
|
minHeight: 32,
|
||||||
),
|
),
|
||||||
|
suffixIcon: searchProvider.searchController.text == ''
|
||||||
|
? null
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: (() async => {
|
||||||
|
searchProvider.searchController.text = '',
|
||||||
|
await getClipBoard(),
|
||||||
|
searchProvider.reload(),
|
||||||
|
}),
|
||||||
|
icon: Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
size: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
prefixIcon: const Padding(
|
prefixIcon: const Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 17),
|
padding: EdgeInsets.symmetric(horizontal: 17),
|
||||||
child: Image(
|
child: Image(
|
||||||
|
|
|
@ -2,19 +2,12 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
|
||||||
import 'package:gecko/models/widgets_keys.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/duniter_indexer.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:gecko/providers/search.dart';
|
import 'package:gecko/providers/search.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/wallet_view.dart';
|
|
||||||
import 'package:gecko/widgets/balance.dart';
|
|
||||||
import 'package:gecko/widgets/bottom_app_bar.dart';
|
import 'package:gecko/widgets/bottom_app_bar.dart';
|
||||||
import 'package:gecko/widgets/name_by_address.dart';
|
import 'package:gecko/widgets/search_result_list.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class SearchResultScreen extends StatelessWidget {
|
class SearchResultScreen extends StatelessWidget {
|
||||||
|
@ -28,6 +21,13 @@ class SearchResultScreen extends StatelessWidget {
|
||||||
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
||||||
|
|
||||||
double avatarSize = 55;
|
double avatarSize = 55;
|
||||||
|
// List<G1WalletsList> myContacts = contactsBox.toMap().values.toList();
|
||||||
|
// myContacts = myContacts
|
||||||
|
// .where((map) =>
|
||||||
|
// (map.username ?? '').contains(searchProvider.searchController.text))
|
||||||
|
// .toList();
|
||||||
|
|
||||||
|
// final searchProvider.resultLenght.toString();
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
@ -48,126 +48,42 @@ class SearchResultScreen extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
RichText(
|
Center(
|
||||||
text: TextSpan(
|
child: Column(
|
||||||
style: TextStyle(
|
children: <Widget>[
|
||||||
fontSize: 18,
|
Text(
|
||||||
color: Colors.grey[700],
|
"resultsFor".tr(),
|
||||||
),
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
children: <TextSpan>[
|
|
||||||
TextSpan(
|
|
||||||
text: "resultsFor".tr(),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: '"${searchProvider.searchController.text}"',
|
|
||||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
|
||||||
),
|
),
|
||||||
|
Text(
|
||||||
|
'"${searchProvider.searchController.text}"',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontStyle: FontStyle.italic, fontSize: 21),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// const SizedBox(height: 40),
|
||||||
|
// Text(
|
||||||
|
// 'Dans mes contacts'.tr(args: [currencyName]),
|
||||||
|
// style: const TextStyle(fontSize: 20),
|
||||||
|
// ),
|
||||||
|
// ContactsList(
|
||||||
|
// myContacts: myContacts,
|
||||||
|
// avatarSize: avatarSize,
|
||||||
|
// walletsProfilesClass: walletsProfilesClass,
|
||||||
|
// duniterIndexer: duniterIndexer),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
Text(
|
Text(
|
||||||
'inBlockchainResult'.tr(args: [currencyName]),
|
'inBlockchainResult'.tr(args: [currencyName]),
|
||||||
style: const TextStyle(fontSize: 20),
|
style: const TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
FutureBuilder(
|
SearchResult(
|
||||||
future: searchProvider.searchAddress(),
|
searchProvider: searchProvider,
|
||||||
builder: (context, AsyncSnapshot<List?> snapshot) {
|
duniterIndexer: duniterIndexer,
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
avatarSize: avatarSize,
|
||||||
if (snapshot.data?.isEmpty ?? true) {
|
walletsProfilesClass: walletsProfilesClass),
|
||||||
return duniterIndexer.searchIdentity(
|
|
||||||
context, searchProvider.searchController.text);
|
|
||||||
// const Text('Aucun résultat');
|
|
||||||
} else {
|
|
||||||
return Expanded(
|
|
||||||
child: ListView(children: <Widget>[
|
|
||||||
for (G1WalletsList g1Wallet
|
|
||||||
in snapshot.data ?? [])
|
|
||||||
Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 5),
|
|
||||||
child: ListTile(
|
|
||||||
key: keySearchResult(g1Wallet.address),
|
|
||||||
horizontalTitleGap: 40,
|
|
||||||
contentPadding: const EdgeInsets.all(5),
|
|
||||||
leading: defaultAvatar(avatarSize),
|
|
||||||
title: Row(children: <Widget>[
|
|
||||||
Text(getShortPubkey(g1Wallet.address),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontFamily: 'Monospace',
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
textAlign: TextAlign.center),
|
|
||||||
]),
|
|
||||||
trailing: Column(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 110,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.center,
|
|
||||||
children: [
|
|
||||||
Balance(
|
|
||||||
address: g1Wallet
|
|
||||||
.address,
|
|
||||||
size: 16),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
subtitle: Row(children: <Widget>[
|
|
||||||
NameByAddress(
|
|
||||||
wallet: WalletData(
|
|
||||||
address: g1Wallet.address),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
dense: false,
|
|
||||||
isThreeLine: false,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
walletsProfilesClass.address =
|
|
||||||
g1Wallet.address;
|
|
||||||
return WalletViewScreen(
|
|
||||||
address: g1Wallet.address,
|
|
||||||
username: duniterIndexer
|
|
||||||
.walletNameIndexer[
|
|
||||||
g1Wallet.address] ??
|
|
||||||
'',
|
|
||||||
avatar: g1WalletsBox
|
|
||||||
.get(g1Wallet.address)
|
|
||||||
?.avatar,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return const Center(
|
|
||||||
heightFactor: 5,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 3,
|
|
||||||
backgroundColor: yellowC,
|
|
||||||
color: orangeC,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// Text(
|
|
||||||
// _searchProvider.searchResult.toString(),
|
|
||||||
// )
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
CommonElements().offlineInfo(context),
|
CommonElements().offlineInfo(context),
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/models/widgets_keys.dart';
|
||||||
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
|
import 'package:gecko/providers/duniter_indexer.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
|
import 'package:gecko/screens/wallet_view.dart';
|
||||||
|
import 'package:gecko/widgets/balance.dart';
|
||||||
|
import 'package:gecko/widgets/name_by_address.dart';
|
||||||
|
|
||||||
|
class ContactsList extends StatelessWidget {
|
||||||
|
const ContactsList({
|
||||||
|
Key? key,
|
||||||
|
required this.myContacts,
|
||||||
|
required this.avatarSize,
|
||||||
|
required this.walletsProfilesClass,
|
||||||
|
required this.duniterIndexer,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final List<G1WalletsList> myContacts;
|
||||||
|
final double avatarSize;
|
||||||
|
final WalletsProfilesProvider walletsProfilesClass;
|
||||||
|
final DuniterIndexer duniterIndexer;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
if (myContacts.isEmpty)
|
||||||
|
Text('noContacts'.tr())
|
||||||
|
else
|
||||||
|
Expanded(
|
||||||
|
child: ListView(children: <Widget>[
|
||||||
|
for (G1WalletsList g1Wallet in myContacts)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: ListTile(
|
||||||
|
key: keySearchResult('keyID++'),
|
||||||
|
horizontalTitleGap: 40,
|
||||||
|
contentPadding: const EdgeInsets.all(5),
|
||||||
|
leading: defaultAvatar(avatarSize),
|
||||||
|
title: Row(children: <Widget>[
|
||||||
|
Text(getShortPubkey(g1Wallet.address),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontFamily: 'Monospace',
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
textAlign: TextAlign.center),
|
||||||
|
]),
|
||||||
|
trailing: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 110,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Balance(
|
||||||
|
address: g1Wallet.address,
|
||||||
|
size: 16),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
subtitle: Row(children: <Widget>[
|
||||||
|
NameByAddress(
|
||||||
|
wallet: WalletData(address: g1Wallet.address))
|
||||||
|
]),
|
||||||
|
dense: false,
|
||||||
|
isThreeLine: false,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
walletsProfilesClass.address = g1Wallet.address;
|
||||||
|
return WalletViewScreen(
|
||||||
|
address: g1Wallet.address,
|
||||||
|
username: duniterIndexer.walletNameIndexer[
|
||||||
|
g1Wallet.address] ??
|
||||||
|
'',
|
||||||
|
avatar: g1WalletsBox
|
||||||
|
.get(g1Wallet.address)
|
||||||
|
?.avatar,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/models/widgets_keys.dart';
|
||||||
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
|
import 'package:gecko/providers/duniter_indexer.dart';
|
||||||
|
import 'package:gecko/providers/search.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
|
import 'package:gecko/screens/wallet_view.dart';
|
||||||
|
import 'package:gecko/widgets/balance.dart';
|
||||||
|
import 'package:gecko/widgets/name_by_address.dart';
|
||||||
|
|
||||||
|
class SearchResult extends StatelessWidget {
|
||||||
|
const SearchResult({
|
||||||
|
Key? key,
|
||||||
|
required this.searchProvider,
|
||||||
|
required this.duniterIndexer,
|
||||||
|
required this.avatarSize,
|
||||||
|
required this.walletsProfilesClass,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final SearchProvider searchProvider;
|
||||||
|
final DuniterIndexer duniterIndexer;
|
||||||
|
final double avatarSize;
|
||||||
|
final WalletsProfilesProvider walletsProfilesClass;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: searchProvider.searchAddress(),
|
||||||
|
builder: (context, AsyncSnapshot<List?> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
if (snapshot.data?.isEmpty ?? true) {
|
||||||
|
return duniterIndexer.searchIdentity(
|
||||||
|
context, searchProvider.searchController.text);
|
||||||
|
// const Text('Aucun résultat');
|
||||||
|
} else {
|
||||||
|
return Expanded(
|
||||||
|
child: ListView(children: <Widget>[
|
||||||
|
for (G1WalletsList g1Wallet in snapshot.data ?? [])
|
||||||
|
resultTile(g1Wallet, context),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return const Center(
|
||||||
|
heightFactor: 5,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 3,
|
||||||
|
backgroundColor: yellowC,
|
||||||
|
color: orangeC,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Padding resultTile(G1WalletsList g1Wallet, BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
child: ListTile(
|
||||||
|
key: keySearchResult(g1Wallet.address),
|
||||||
|
horizontalTitleGap: 40,
|
||||||
|
contentPadding: const EdgeInsets.all(5),
|
||||||
|
leading: defaultAvatar(avatarSize),
|
||||||
|
title: Row(children: <Widget>[
|
||||||
|
Text(getShortPubkey(g1Wallet.address),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontFamily: 'Monospace',
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
textAlign: TextAlign.center),
|
||||||
|
]),
|
||||||
|
trailing:
|
||||||
|
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 110,
|
||||||
|
child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||||
|
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
|
Balance(address: g1Wallet.address, size: 16),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
subtitle: Row(children: <Widget>[
|
||||||
|
NameByAddress(
|
||||||
|
wallet: WalletData(address: g1Wallet.address),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
dense: false,
|
||||||
|
isThreeLine: false,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
walletsProfilesClass.address = g1Wallet.address;
|
||||||
|
return WalletViewScreen(
|
||||||
|
address: g1Wallet.address,
|
||||||
|
username:
|
||||||
|
duniterIndexer.walletNameIndexer[g1Wallet.address] ?? '',
|
||||||
|
avatar: g1WalletsBox.get(g1Wallet.address)?.avatar,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue