Skip to content

Commit fb95182

Browse files
authored
Merge pull request #34 from JDI-Group/redesign
Redesign
2 parents 530df02 + 8dad1b2 commit fb95182

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

lib/features/common/contract/token_contract_use_case.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,23 @@ class TokenContractUseCase extends ReactiveUseCase {
135135
update(online, result);
136136
}
137137

138+
void resetBalanceAndPrice() async {
139+
for (int i = 0; i < tokensList.value.length; i++) {
140+
tokensList.value[i] = tokensList.value[i].copyWith(balance: 0.0, balancePrice: 0.0);
141+
}
142+
update(tokensList, tokensList.value);
143+
}
144+
138145
Future<void> getTokensBalance(
139146
List<Token>? tokenList,
140147
String walletAddress,
141-
bool shouldGetPrice,
142-
) async {
148+
bool shouldGetPrice, {
149+
bool resetBalance = false,
150+
}) async {
151+
if (resetBalance) {
152+
resetBalanceAndPrice();
153+
}
154+
143155
late List<Token> result;
144156
if (tokenList != null) {
145157
// Check if tokenList and enwList values are the same

lib/features/dapps/presentation/responsive_layout/dapps_layout/dapp_provider_header.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ class DAppProviderHeader extends HookConsumerWidget {
3131
children: [
3232
Text(
3333
providerTitle,
34-
style: FontTheme.of(context).subtitle2().copyWith(
35-
fontWeight: FontWeight.bold,
36-
color: ColorsTheme.of(context).textPrimary),
34+
style: FontTheme.of(context).body1().copyWith(
35+
fontWeight: FontWeight.bold,
36+
color: ColorsTheme.of(context).textPrimary,
37+
),
3738
),
3839
const Spacer(),
3940
InkWell(

lib/features/portfolio/presentation/portfolio_page_presenter.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class PortfolioPresenter extends CompletePresenter<PortfolioState> {
4444
listen(_accountUserCase.account, (value) {
4545
if (value != null) {
4646
notify(() => state.walletAddress = value.address);
47+
state.account = value;
4748
initializePortfolioPage();
4849
}
4950
});
@@ -64,6 +65,17 @@ class PortfolioPresenter extends CompletePresenter<PortfolioState> {
6465
initializePortfolioPage() {
6566
getNfts();
6667
getBuyEnabled();
68+
getWalletTokensBalance(null, true);
69+
}
70+
71+
void getWalletTokensBalance(
72+
List<Token>? tokenList, bool shouldGetPrice) async {
73+
_tokenContractUseCase.getTokensBalance(
74+
tokenList,
75+
state.account!.address,
76+
shouldGetPrice,
77+
resetBalance: true,
78+
);
6779
}
6880

6981
getNfts() async {

lib/features/portfolio/presentation/portfolio_page_state.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class PortfolioState with EquatableMixin {
1818

1919
bool buyEnabled = true;
2020

21+
Account? account;
22+
2123
@override
2224
List<Object?> get props =>
2325
[walletBalance, tokensList, walletAddress, switchTokensOrNFTs, nftList];

lib/features/wallet/presentation/wallet_page_presenter.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ class WalletPresenter extends CompletePresenter<WalletState> {
149149
break;
150150
// new balance
151151
case 'balance':
152-
final wannseeBalanceEvent =
153-
MoonchainBalanceEvenModel.fromJson(event.payload);
154152
getWalletTokensBalance(null, true);
155153
break;
156154
default:

0 commit comments

Comments
 (0)