Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: EWM-286 jdenticon user avatar #512

Merged
merged 15 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
"selectAccount": "Select account",
"grantPermissions": "Grant permissions",
"changeAccount": "Change account",
"changeColor": "Change color",
"originWord": "Origin",
"requestedPermissions": "Requested permissions",
"allowWord": "Allow",
Expand Down Expand Up @@ -568,5 +569,6 @@
"accountAddedSheetContinue": "Continue without switching",
"invalidReceiverAddress": "Invalid receiver address",
"deleteBookmarksQuestion": "Are you sure you want\nto delete all bookmarks?",
"deleteBookmarksDescription": "All bookmarks will be permanently deleted"
"deleteBookmarksDescription": "All bookmarks will be permanently deleted",
"save": "Save"
}
10 changes: 6 additions & 4 deletions assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
"selectAccount": "Select account",
"grantPermissions": "Grant permissions",
"changeAccount": "Change account",
"changeColor": "Change color",
"originWord": "Origin",
"requestedPermissions": "Requested permissions",
"allowWord": "Allow",
Expand Down Expand Up @@ -506,9 +507,9 @@
"approximatelySign": "~",
"currentBalanceLabel": "Current balance",
"untrastedTokenWarning": "This token is not published in the official assets repository. Add it with caution if you trust the source.",
"phishingExplicitWarning":"Token has the symbol from the trusted list but a different root contract address. Be careful: it may be a phishing attempt.",
"phishingSameSymbolWarning":"You already have a token with the same symbol. Be careful: it may be a phishing attempt.",
"phishingSuggestionWarning":"You have already added a token with the same symbol before, however the new one is in the official assets repository. This may be a new version and you might consider deleting the previous one.",
"phishingExplicitWarning": "Token has the symbol from the trusted list but a different root contract address. Be careful: it may be a phishing attempt.",
"phishingSameSymbolWarning": "You already have a token with the same symbol. Be careful: it may be a phishing attempt.",
"phishingSuggestionWarning": "You have already added a token with the same symbol before, however the new one is in the official assets repository. This may be a new version and you might consider deleting the previous one.",
"expand": "Expand",
"collapse": "Collapse",
"metadata": "Metadata",
Expand Down Expand Up @@ -568,5 +569,6 @@
"accountAddedSheetContinue": "Continue without switching",
"invalidReceiverAddress": "Invalid receiver address",
"deleteBookmarksQuestion": "Are you sure you want\nto delete all bookmarks?",
"deleteBookmarksDescription": "All bookmarks will be permanently deleted"
"deleteBookmarksDescription": "All bookmarks will be permanently deleted",
"save": "Save"
}
49 changes: 49 additions & 0 deletions ios/Pods/Local Podspecs/flutter_inappwebview_ios.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions lib/app/service/identify/accounts_colors_collection.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:app/app/service/identify/identy_colors.dart';
import 'package:app/app/service/secure_storage_service.dart';

class AccountsColorsCollection {
AccountsColorsCollection(
this._secureStorageService,
this._initialColor,
);

final _map = <String, IdentifyColor>{};

final SecureStorageService _secureStorageService;

final IdentifyColor _initialColor;

Future<void> setColor(String key, IdentifyColor identifyColor) async {
_map[key] = identifyColor;

try {
await _secureStorageService.addValue<int>(
key,
identifyColor.color.value,
);
} finally {}
}

Future<IdentifyColor> getColor(String key) async {
try {
return _map[key] ??= IdentifyColor.byInt(
await _secureStorageService.getValue<int>(key),
) ??
_initialColor;
} catch (_) {
return _initialColor;
}
}
}
14 changes: 14 additions & 0 deletions lib/app/service/identify/i_identify_icons_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:app/app/service/identify/accounts_colors_collection.dart';
import 'package:app/app/service/identify/identy_colors.dart';

abstract interface class IIdentifyIconsService {
abstract final List<IdentifyColor> availableColors;

Stream<AccountsColorsCollection> get accountsColorsStream;

IdentifyColor get initialColor;

void setColor(String key, IdentifyColor color);

Future<IdentifyColor> getColor(String key);
}
46 changes: 46 additions & 0 deletions lib/app/service/identify/identify_icons_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:app/app/service/identify/accounts_colors_collection.dart';
import 'package:app/app/service/identify/i_identify_icons_service.dart';
import 'package:app/app/service/identify/identy_colors.dart';
import 'package:app/app/service/secure_storage_service.dart';
import 'package:injectable/injectable.dart';
import 'package:rxdart/rxdart.dart';

@LazySingleton(as: IIdentifyIconsService)
class IdentifyIconsService implements IIdentifyIconsService {
IdentifyIconsService(this._secureStorageService);

@override
final availableColors = IdentifyColor.values;

final SecureStorageService _secureStorageService;

final _initialIndex = 1;

late final _accountsColorsSubject =
BehaviorSubject<AccountsColorsCollection>.seeded(
AccountsColorsCollection(
_secureStorageService,
availableColors[_initialIndex],
),
);

@override
Stream<AccountsColorsCollection> get accountsColorsStream =>
_accountsColorsSubject.stream;

@override
IdentifyColor get initialColor => availableColors[_initialIndex];

AccountsColorsCollection get _accountsColors => _accountsColorsSubject.value;

@override
void setColor(String key, IdentifyColor identifyColor) {
_accountsColors.setColor(key, identifyColor);
_accountsColorsSubject.add(_accountsColors);
}

@override
Future<IdentifyColor> getColor(String key) {
return _accountsColors.getColor(key);
}
}
28 changes: 28 additions & 0 deletions lib/app/service/identify/identy_colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dart:ui';

enum IdentifyColor {
// jdenticon web 0x7c3cdeff transform to Flutter color:
purple(Color(0xff7c3cde)),
// jdenticon web 0x3c6adeff transform to Flutter color:
blue(Color(0xff3c6ade)),
// jdenticon web 0x80de3cff transform to Flutter color:
green(Color(0xff80de3c)),
// jdenticon web 0xfe76dfff transform to Flutter color:
pink(Color(0xfffe76df)),
// jdenticon web 0xff6f2fff transform to Flutter color:
orange(Color(0xffff6f2f));

const IdentifyColor(this.color);

final Color color;

static IdentifyColor? byInt(int? value) {
for (final ic in IdentifyColor.values) {
if (ic.color.value == value) {
return ic;
}
}

return null;
}
}
4 changes: 2 additions & 2 deletions lib/app/service/secure_storage_service.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:injectable/injectable.dart';

@lazySingleton
class SecureStorageService {
SecureStorageService();

final FlutterSecureStorage _storage = const FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
);
Expand Down
7 changes: 7 additions & 0 deletions lib/di/di.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:app/generated/generated.dart';
import 'package:app/utils/utils.dart';
import 'package:app/widgets/user_avatar/user_avatar.dart';
import 'package:elementary_helper/elementary_helper.dart';
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
Expand Down Expand Up @@ -38,10 +38,8 @@ class AccountListItem extends StatelessWidget {
padding: const EdgeInsets.all(DimensSizeV2.d16),
child: SeparatedRow(
children: [
Image.asset(
Assets.images.userAvatar.userAvatar.path,
width: DimensSizeV2.d40,
height: DimensSizeV2.d40,
UserAvatar(
address: address,
),
Expanded(
child: SeparatedColumn(
Expand Down
Loading
Loading