diff --git a/lib/ui/ui_helpers.dart b/lib/ui/ui_helpers.dart index 7a94f6049a5a330f5563a313f3276e2e4f57b255..75909d04545f1d24186f2cdf113e89a1c438816f 100644 --- a/lib/ui/ui_helpers.dart +++ b/lib/ui/ui_helpers.dart @@ -68,12 +68,13 @@ void copyToClipboard( const Color defAvatarBgColor = Colors.grey; const Color defAvatarColor = Colors.white; -const double defAvatarSize = 24; +const double defAvatarStoreSize = 44; +const double defAvatarUiSize = 24; Widget avatar(Uint8List? rawAvatar, {Color color = defAvatarColor, Color bgColor = defAvatarBgColor, - double avatarSize = defAvatarSize}) { + double avatarSize = defAvatarUiSize}) { return rawAvatar != null && rawAvatar.isNotEmpty ? CircleAvatar( radius: avatarSize, @@ -119,7 +120,7 @@ String humanizeContact(String publicAddress, Contact contact, [bool addKey = false, bool minimal = false, String Function(String s) trf = tr]) { - if (extractPublicKey(contact.pubKey) == extractPublicKey(publicAddress)) { + if (isMe(contact, publicAddress)) { return trf('your_wallet'); } else { final String pubKey = humanizePubKey(contact.pubKey); @@ -135,6 +136,9 @@ String humanizeContact(String publicAddress, Contact contact, } } +bool isMe(Contact contact, String publicAddress) => + extractPublicKey(contact.pubKey) == extractPublicKey(publicAddress); + String humanizePubKey(String rawAddress, [bool minimal = false]) { final String address = extractPublicKey(rawAddress); return minimal @@ -247,16 +251,18 @@ double parseToDoubleLocalized( String localizeNumber(BuildContext context, double amount) => NumberFormat.decimalPattern(eo(currentLocale(context))).format(amount); -Future<Contact> contactFromResultSearch(Map<String, dynamic> record) async { +Future<Contact> contactFromResultSearch(Map<String, dynamic> record, + {bool resize = true}) async { final Map<String, dynamic> source = record['_source'] as Map<String, dynamic>; - final Uint8List? avatarBase64 = await _getAvatarFromResults(source); + final Uint8List? avatarBase64 = await _getAvatarFromResults(source, resize); return Contact( pubKey: record['_id'] as String, name: source['title'] as String, avatar: avatarBase64); } -Future<Uint8List?> _getAvatarFromResults(Map<String, dynamic> source) async { +Future<Uint8List?> _getAvatarFromResults( + Map<String, dynamic> source, bool resize) async { Uint8List? avatarBase64; if (source['avatar'] != null) { final Map<String, dynamic> avatar = @@ -265,7 +271,8 @@ Future<Uint8List?> _getAvatarFromResults(Map<String, dynamic> source) async { 'data:${avatar['_content_type']};base64,${avatar['_content']}'); } if (avatarBase64 != null && avatarBase64.isNotEmpty) { - final Uint8List? avatarBase64resized = await resizeAvatar(avatarBase64); + final Uint8List? avatarBase64resized = + resize ? await resizeAvatar(avatarBase64) : avatarBase64; return avatarBase64resized; } else { return null; @@ -274,7 +281,7 @@ Future<Uint8List?> _getAvatarFromResults(Map<String, dynamic> source) async { Future<Uint8List?> resizeAvatar(Uint8List avatarBase64) async { final ByteData? bytes = - await resizeImage(avatarBase64, height: defAvatarSize.toInt() * 2); + await resizeImage(avatarBase64, height: defAvatarStoreSize.toInt() * 2); return bytes != null ? Uint8List.view(bytes.buffer) : null; } @@ -379,10 +386,12 @@ class _SlidableContactTile extends State<SlidableContactTile> { @override void initState() { super.initState(); - _start(); + // Disable for now + // _start(); } // Based in https://github.com/letsar/flutter_slidable/issues/288 + // ignore: unused_element Future<void> _start() async { if (widget.index == 0 && !context.read<AppCubit>().wasTutorialShown(tutorialId)) {