Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #215 from MXCzkEVM/local_backup
Browse files Browse the repository at this point in the history
fix: other chains dapps & instant loading
  • Loading branch information
reasje authored May 23, 2024
2 parents 25950de + bae86cd commit 63adc6a
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 452 deletions.
9 changes: 7 additions & 2 deletions lib/features/dapps/domain/dapp_store_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ class DappStoreUseCase extends ReactiveUseCase {

late final ValueStream<List<Dapp>> dapps = reactive([]);

loadLocalDApps() async {
Future<void> loadDapps() async {
loadLocalDApps();
await loadRemoteDApps();
}

Future<void> loadLocalDApps() async {
final result = await _repository.dappStoreRepository.getAllDappsFromLocal();
update(dapps, result);
}

Future<void> getAllDapps() async {
Future<void> loadRemoteDApps() async {
final result = await _repository.dappStoreRepository.getAllDapps();

update(dapps, result);
Expand Down
3 changes: 0 additions & 3 deletions lib/features/dapps/helpers/reorder_helper.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'dart:async';

import 'package:datadashwallet/features/dapps/presentation/responsive_layout/dapp_utils.dart';
import 'package:flutter/material.dart';
import 'package:mxc_logic/mxc_logic.dart';

import '../domain/domain.dart';
Expand Down
8 changes: 4 additions & 4 deletions lib/features/dapps/presentation/dapps_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:datadashwallet/common/common.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:datadashwallet/features/common/common.dart';
import 'package:datadashwallet/features/dapps/dapps.dart';
import 'package:datadashwallet/features/settings/settings.dart';
import 'package:datadashwallet/features/wallet/wallet.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -29,7 +28,8 @@ class DAppsPage extends HookConsumerWidget {
return MxcPage(
layout: LayoutType.column,
useContentPadding: false,
childrenPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
childrenPadding: const EdgeInsets.symmetric(
horizontal: Sizes.spaceSmall, vertical: Sizes.spaceNormal),
backgroundColor: ColorsTheme.of(context).screenBackground,
presenter: ref.watch(presenter),
appBar: Column(
Expand All @@ -44,7 +44,7 @@ class DAppsPage extends HookConsumerWidget {
leading: IconButton(
key: const ValueKey('settingsButton'),
icon: const Icon(MxcIcons.settings),
iconSize: 32,
iconSize: Sizes.space2XLarge,
onPressed: () {
Navigator.of(context).push(
route(
Expand All @@ -57,7 +57,7 @@ class DAppsPage extends HookConsumerWidget {
action: IconButton(
key: const ValueKey('walletButton'),
icon: const Icon(MxcIcons.wallet),
iconSize: 32,
iconSize: Sizes.space2XLarge,
onPressed: () => Navigator.of(context).replaceAll(
route(const WalletPage()),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/features/dapps/presentation/dapps_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class DAppsPagePresenter extends CompletePresenter<DAppsState> {
listen(_chainConfigurationUseCase.selectedNetwork, (value) {
if (value != null) {
if (state.network != null && state.network!.chainId != value.chainId) {
DappUtils.loadingOnce = true;
notify(() => state.loading = true);
reorderHelper.resetDappsMerge();
}
notify(() => state.network = value);
Expand Down Expand Up @@ -157,7 +159,7 @@ class DAppsPagePresenter extends CompletePresenter<DAppsState> {

void initializeDapps() async {
try {
await _dappStoreUseCase.getAllDapps();
await _dappStoreUseCase.loadDapps();
} catch (e, s) {
addError(e, s);
}
Expand All @@ -171,7 +173,8 @@ class DAppsPagePresenter extends CompletePresenter<DAppsState> {

void addBookmark() async => bookmarksHelper.addBookmark();

void updateBookmarkFavIcon(Bookmark item) async => bookmarksHelper.updateBookmarkFavIcon(item);
void updateBookmarkFavIcon(Bookmark item) async =>
bookmarksHelper.updateBookmarkFavIcon(item);

void onPageChage(int index) => notify(() => state.pageIndex = index);

Expand Down
36 changes: 3 additions & 33 deletions lib/features/dapps/presentation/responsive_layout/card_item.dart
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

class CardCrossAxisCount {
static const int mobile = 4;
static const int tablet = 5;
static const int mobile = 6;
static const int tablet = 7;
}

class CardMainAxisCount {
static const int mobile = 3;
static const int tablet = 4;
}


class CardSizes {
static Widget large({required Widget child}) {
return StaggeredGridTile.count(
crossAxisCellCount: 4,
mainAxisCellCount: 2,
child: child,
);
}

static Widget medium({required Widget child}) {
return StaggeredGridTile.count(
crossAxisCellCount: 2,
mainAxisCellCount: 2,
child: child,
);
}

static Widget small({required Widget child}) {
return StaggeredGridTile.count(
crossAxisCellCount: 1,
mainAxisCellCount: 1,
child: child,
);
}
static const int tablet = 5;
}
Loading

0 comments on commit 63adc6a

Please sign in to comment.