order contacts by usernames
This commit is contained in:
parent
c6d5b30090
commit
d9aa66e1ec
|
@ -5,6 +5,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
import 'package:gecko/models/queries_indexer.dart';
|
import 'package:gecko/models/queries_indexer.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/cesium_plus.dart';
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
|
@ -207,6 +208,13 @@ class DuniterIndexer with ChangeNotifier {
|
||||||
walletNameIndexer[address] =
|
walletNameIndexer[address] =
|
||||||
result.data?['account_by_pk']?['identity']?['name'];
|
result.data?['account_by_pk']?['identity']?['name'];
|
||||||
|
|
||||||
|
g1WalletsBox.put(
|
||||||
|
address,
|
||||||
|
G1WalletsList(
|
||||||
|
pubkey: address, username: walletNameIndexer[address]));
|
||||||
|
|
||||||
|
// log.d(g1WalletsBox.toMap().values.first.username);
|
||||||
|
|
||||||
if (walletNameIndexer[address] == null) {
|
if (walletNameIndexer[address] == null) {
|
||||||
if (wallet == null) {
|
if (wallet == null) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
|
|
|
@ -187,29 +187,29 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
walletOptions.idtyStatus(context, address,
|
walletOptions.idtyStatus(context, address,
|
||||||
isOwner: false, color: Colors.black),
|
isOwner: false, color: Colors.black),
|
||||||
getCerts(context, address, 14),
|
getCerts(context, address, 14),
|
||||||
if (username == null &&
|
// if (username == null &&
|
||||||
g1WalletsBox.get(address)?.username != null)
|
// g1WalletsBox.get(address)?.username != null)
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 230,
|
// width: 230,
|
||||||
child: Text(
|
// child: Text(
|
||||||
g1WalletsBox.get(address)?.username ?? '',
|
// g1WalletsBox.get(address)?.username ?? '',
|
||||||
style: const TextStyle(
|
// style: const TextStyle(
|
||||||
fontSize: 27,
|
// fontSize: 27,
|
||||||
color: Color(0xff814C00),
|
// color: Color(0xff814C00),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
if (username != null)
|
// if (username != null)
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 230,
|
// width: 230,
|
||||||
child: Text(
|
// child: Text(
|
||||||
username,
|
// username,
|
||||||
style: const TextStyle(
|
// style: const TextStyle(
|
||||||
fontSize: 27,
|
// fontSize: 27,
|
||||||
color: Color(0xff814C00),
|
// color: Color(0xff814C00),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
const SizedBox(height: 55),
|
const SizedBox(height: 55),
|
||||||
]),
|
]),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
@ -229,12 +229,12 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
return contactsBox.containsKey(address);
|
return contactsBox.containsKey(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addContact(G1WalletsList profile) {
|
Future addContact(G1WalletsList profile) async {
|
||||||
log.d(profile.username);
|
// log.d(profile.username);
|
||||||
if (isContact(profile.pubkey!)) {
|
if (isContact(profile.pubkey!)) {
|
||||||
contactsBox.delete(profile.pubkey);
|
await contactsBox.delete(profile.pubkey);
|
||||||
} else {
|
} else {
|
||||||
contactsBox.put(profile.pubkey, profile);
|
await contactsBox.put(profile.pubkey, profile);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ContactsScreen extends StatelessWidget {
|
||||||
CesiumPlusProvider cesiumPlusProvider =
|
CesiumPlusProvider cesiumPlusProvider =
|
||||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||||
WalletsProfilesProvider walletsProfilesClass =
|
WalletsProfilesProvider walletsProfilesClass =
|
||||||
Provider.of<WalletsProfilesProvider>(context, listen: false);
|
Provider.of<WalletsProfilesProvider>(context, listen: true);
|
||||||
HomeProvider homeProvider =
|
HomeProvider homeProvider =
|
||||||
Provider.of<HomeProvider>(context, listen: false);
|
Provider.of<HomeProvider>(context, listen: false);
|
||||||
DuniterIndexer duniterIndexer =
|
DuniterIndexer duniterIndexer =
|
||||||
|
@ -32,11 +32,15 @@ class ContactsScreen extends StatelessWidget {
|
||||||
double avatarSize = 55;
|
double avatarSize = 55;
|
||||||
|
|
||||||
final myContacts = contactsBox.toMap().values.toList();
|
final myContacts = contactsBox.toMap().values.toList();
|
||||||
// myContacts.sort((a, b) {
|
|
||||||
// final aa = a.username?.toLowerCase() ?? '';
|
// for (var element in myContacts) {
|
||||||
// final bb = b.username?.toLowerCase() ?? '';
|
// log.d('yooo: ${element.pubkey} ${element.username}');
|
||||||
// return aa.compareTo(bb);
|
// }
|
||||||
// });
|
|
||||||
|
myContacts.sort((p1, p2) {
|
||||||
|
return Comparable.compare(p1.username?.toLowerCase() ?? 'zz',
|
||||||
|
p2.username?.toLowerCase() ?? 'zz');
|
||||||
|
});
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
|
|
@ -60,10 +60,14 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
Consumer<WalletsProfilesProvider>(
|
Consumer<WalletsProfilesProvider>(
|
||||||
builder: (context, walletProfile, _) {
|
builder: (context, walletProfile, _) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
final newContact =
|
G1WalletsList? newContact;
|
||||||
G1WalletsList(pubkey: pubkey!, username: username);
|
g1WalletsBox.toMap().forEach((key, value) {
|
||||||
walletProfile.addContact(newContact);
|
if (key == pubkey) newContact = value;
|
||||||
|
});
|
||||||
|
// G1WalletsList(pubkey: pubkey!, username: username);
|
||||||
|
await walletProfile.addContact(
|
||||||
|
newContact ?? G1WalletsList(pubkey: pubkey!));
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
walletProfile.isContact(pubkey!)
|
walletProfile.isContact(pubkey!)
|
||||||
|
|
Loading…
Reference in New Issue