Skip to content

Commit

Permalink
fix: change bg (#614)
Browse files Browse the repository at this point in the history
* fix: change bg

* fix logic with showing new tokens label

* hide label with 0 token

* fix comment

* ui hotfixes

---------

Co-authored-by: Andrey Malochka <[email protected]>
  • Loading branch information
AndreyMolochko and Andrey Malochka authored Nov 1, 2024
1 parent 57654c1 commit 7078f8b
Show file tree
Hide file tree
Showing 23 changed files with 166 additions and 139 deletions.
3 changes: 3 additions & 0 deletions assets/images/bg_main.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/homescreen_bg/1.5x/homescreen_bg.png
Binary file not shown.
Binary file removed assets/images/homescreen_bg/2x/homescreen_bg.png
Binary file not shown.
Binary file removed assets/images/homescreen_bg/3x/homescreen_bg.png
Binary file not shown.
Binary file removed assets/images/homescreen_bg/homescreen_bg.png
Binary file not shown.
11 changes: 6 additions & 5 deletions lib/app/service/storage_service/secure_storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ class SecureStorageService extends AbstractStorageService {

class StorageKey {
factory StorageKey.userWithNewWallet() =>
StorageKey._('sparx:userWithNewWallet');
StorageKey._('userWithNewWallet');

factory StorageKey.firstEntering() => StorageKey._('sparx:firstEntering');
factory StorageKey.showingNewTokensLabel(String masterKey) =>
StorageKey._('showingNewTokensLabel', masterKey);

factory StorageKey.showingManualBackupBadge(String masterKey) =>
StorageKey._('sparx:showingManualBackupBadge', masterKey);
StorageKey._('showingManualBackupBadge', masterKey);

factory StorageKey.accountColor(String key) =>
StorageKey._('sparx:accountColor', key);
StorageKey._('accountColor', key);

StorageKey._(this._baseKey, [this._entityKey]);

Expand All @@ -72,6 +73,6 @@ class StorageKey {
@override
String toString() {
if (_entityKey == null) return _baseKey;
return '$_baseKey:$_entityKey';
return 'sparx:$_baseKey:$_entityKey';
}
}
4 changes: 2 additions & 2 deletions lib/feature/network/view/network_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class NetworkIcon extends StatelessWidget {
child: Center(
child: SvgPicture.asset(
_path,
width: DimensSizeV2.d22,
height: DimensSizeV2.d22,
width: DimensSizeV2.d16,
height: DimensSizeV2.d16,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ class WelcomeScreenModel extends ElementaryModel {

Future<void> saveUserNew({required bool userWithNewWallet}) => _storageService
.addValue(StorageKey.userWithNewWallet(), userWithNewWallet);

Future<void> setFirstEntering() =>
_storageService.addValue(StorageKey.firstEntering(), true);
}
2 changes: 0 additions & 2 deletions lib/feature/onboarding/screen/welcome/welcome_screen_wm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ class WelcomeScreenWidgetModel

Future<void> onPressedCreateWallet() async {
unawaited(model.saveUserNew(userWithNewWallet: true));
unawaited(model.setFirstEntering());
_goNext(AppRoute.createSeedPassword.path);
}

void onPressedWalletLogin() {
unawaited(model.saveUserNew(userWithNewWallet: false));
unawaited(model.setFirstEntering());
_goNext(AppRoute.addExistingWallet.path);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/feature/root/view/root_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum RootTab {
IconData get icon => switch (this) {
RootTab.wallet => LucideIcons.wallet,
RootTab.browser => LucideIcons.compass,
RootTab.profile => LucideIcons.box,
RootTab.profile => LucideIcons.circleUser,
};

String get title => switch (this) {
Expand Down
25 changes: 17 additions & 8 deletions lib/feature/wallet/view/wallet_page_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ class WalletPageModel extends ElementaryModel {
return _storageService.cleanStorage(StorageKey.userWithNewWallet());
}

Future<bool?> isFirstEntering() async {
return _storageService.getValue(StorageKey.firstEntering());
}

Future<void> updateFirstEntering() async {
return _storageService.addValue(StorageKey.firstEntering(), false);
}

Future<bool?> isShowingBadge(KeyAccount account) async {
final masterPublicKey = _nekotonRepository.seedList
.findSeedByAnyPublicKey(account.publicKey)
Expand All @@ -45,6 +37,14 @@ class WalletPageModel extends ElementaryModel {
);
}

Future<bool?> isShowingNewTokens(KeyAccount account) async {
final address = account.address;

return _storageService.getValue(
StorageKey.showingNewTokensLabel(address.address),
);
}

Future<void> hideShowingBadge(KeyAccount account) async {
final masterPublicKey = _nekotonRepository.seedList
.findSeedByAnyPublicKey(account.publicKey)
Expand All @@ -57,4 +57,13 @@ class WalletPageModel extends ElementaryModel {
false,
);
}

Future<void> hideNewTokenLabels(KeyAccount account) async {
final address = account.address;

return _storageService.addValue(
StorageKey.showingNewTokensLabel(address.address),
false,
);
}
}
8 changes: 4 additions & 4 deletions lib/feature/wallet/view/wallet_page_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class WalletPageWidget extends ElementaryWidget<WalletPageWidgetModel> {
return Scaffold(
body: DoubleSourceBuilder<KeyAccount?, bool>(
firstSource: wm.currentAccount,
secondSource: wm.isFirstEntering,
builder: (_, currentAccount, isFirstEntering) {
secondSource: wm.isShowingNewTokens,
builder: (_, currentAccount, isShowingNewTokens) {
return currentAccount?.let(
(value) => StateNotifierBuilder(
listenableState: wm.isShowingBadge,
Expand All @@ -27,9 +27,9 @@ class WalletPageWidget extends ElementaryWidget<WalletPageWidgetModel> {
currentAccount: value,
scrollController: wm.scrollController,
isShowingBadge: isShowingBadge ?? false,
isFirstEntering: isFirstEntering ?? false,
isShowingNewTokens: isShowingNewTokens ?? false,
finishedBackupCallback: wm.hideShowingBadge,
checkTokensCallback: wm.hideNewTokensLabel,
confirmImportCallback: wm.hideNewTokensLabel,
),
),
) ??
Expand Down
23 changes: 11 additions & 12 deletions lib/feature/wallet/view/wallet_page_wm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@ class WalletPageWidgetModel

late final _currentAccount = createNotifierFromStream(model.currentAccount);
late final _isShowingBadgeNotifier = createNotifier<bool>();
late final _isFirstEnteringNotifier = createNotifier<bool>();
late final _isShowingNewTokensNotifier = createNotifier<bool>();

StreamSubscription<PressBottomNavigationEvent>? _pressWalletSubscribtion;

ListenableState<KeyAccount?> get currentAccount => _currentAccount;

ListenableState<bool> get isShowingBadge => _isShowingBadgeNotifier;

ListenableState<bool> get isFirstEntering => _isFirstEnteringNotifier;
ListenableState<bool> get isShowingNewTokens => _isShowingNewTokensNotifier;

@override
void initWidgetModel() {
super.initWidgetModel();
_pressWalletSubscribtion = primaryBus
.on<PressBottomNavigationEvent>()
.listen(_onPressWalletBottomNavigation);
_checkFirstEntering();
}

@override
Expand All @@ -67,7 +66,11 @@ class WalletPageWidgetModel
}

void hideNewTokensLabel() {
_isFirstEnteringNotifier.accept(false);
final account = currentAccount.value;
_isShowingNewTokensNotifier.accept(false);
if (account != null) {
model.hideNewTokenLabels(account);
}
}

void _onPressWalletBottomNavigation(PressBottomNavigationEvent event) {
Expand All @@ -92,6 +95,7 @@ class WalletPageWidgetModel
final isNewUser = await model.isNewUser();
if (isNewUser != null && account != null) {
if (isNewUser) {
_isShowingNewTokensNotifier.accept(true);
_isShowingBadgeNotifier.accept(true);
} else {
_isShowingBadgeNotifier.accept(false);
Expand All @@ -104,16 +108,11 @@ class WalletPageWidgetModel
_isShowingBadgeNotifier.accept(
await model.isShowingBadge(account) ?? true,
);
_isShowingNewTokensNotifier
.accept(await model.isShowingNewTokens(account) ?? true);
} else {
_isShowingBadgeNotifier.accept(true);
}
}

Future<void> _checkFirstEntering() async {
final isFirstEntering = await model.isFirstEntering() ?? false;
_isFirstEnteringNotifier.accept(isFirstEntering);
if (isFirstEntering) {
await model.updateFirstEntering();
_isShowingNewTokensNotifier.accept(true);
}
}
}
64 changes: 29 additions & 35 deletions lib/feature/wallet/view/wallet_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:ui';

import 'package:app/feature/wallet/wallet.dart';
import 'package:app/generated/generated.dart';
import 'package:app/generated/assets.gen.dart';
import 'package:flutter/material.dart';
import 'package:nekoton_repository/nekoton_repository.dart';
import 'package:ui_components_lib/ui_components_lib.dart';
Expand All @@ -9,18 +11,18 @@ class WalletView extends StatelessWidget {
required this.currentAccount,
required this.scrollController,
required this.isShowingBadge,
required this.isFirstEntering,
required this.isShowingNewTokens,
required this.finishedBackupCallback,
required this.checkTokensCallback,
required this.confirmImportCallback,
super.key,
});

final KeyAccount? currentAccount;
final ScrollController scrollController;
final bool isShowingBadge;
final bool isFirstEntering;
final bool isShowingNewTokens;
final VoidCallback finishedBackupCallback;
final VoidCallback checkTokensCallback;
final VoidCallback confirmImportCallback;

@override
Widget build(BuildContext context) {
Expand All @@ -45,8 +47,8 @@ class WalletView extends StatelessWidget {
WalletBottomPanel(
currentAccount: currentAccount!,
scrollController: scrollController,
isFirstEntering: isFirstEntering,
checkTokensCallback: checkTokensCallback,
isShowingNewTokens: isShowingNewTokens,
confirmImportCallback: confirmImportCallback,
),
SliverFillRemaining(
hasScrollBody: false,
Expand All @@ -72,38 +74,30 @@ class _Background extends StatefulWidget {
}

class _BackgroundState extends State<_Background> {
@override
void initState() {
widget.scrollController.addListener(_listener);
super.initState();
}

@override
void dispose() {
widget.scrollController.removeListener(_listener);
super.dispose();
}

@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final offset = widget.scrollController.hasClients
? widget.scrollController.offset
: 0.0;

return Positioned(
top: -offset,
left: 0,
width: size.width,
child: Image.asset(
Assets.images.homescreenBg.homescreenBg.path,
height: size.width,
width: size.width,
fit: BoxFit.contain,
alignment: Alignment.topCenter,
top: 1,
left: 1,
right: 1,
child: Stack(
alignment: Alignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: DimensSizeV2.d40),
child: SvgPicture.asset(Assets.images.bgMain.path),
),
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 55,
sigmaY: 55,
),
child: Container(
color: Colors.transparent,
),
),
],
),
);
}

void _listener() => setState(() {});
}
Loading

0 comments on commit 7078f8b

Please sign in to comment.