From 1ba86506f09014b77e4198255b2ae9522d3f9b31 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Fri, 31 Jul 2020 22:55:26 +0300 Subject: [PATCH] CAKE-20 | changed dots indicator on smooth page indicator (dashboard page); deleted page_view_store --- lib/di.dart | 5 +-- lib/src/screens/dashboard/dashboard_page.dart | 40 ++++++------------- lib/store/dashboard/page_view_store.dart | 19 --------- .../dashboard/dashboard_view_model.dart | 9 +---- pubspec.lock | 14 +++---- pubspec.yaml | 2 +- 6 files changed, 23 insertions(+), 66 deletions(-) delete mode 100644 lib/store/dashboard/page_view_store.dart diff --git a/lib/di.dart b/lib/di.dart index 40ae92396..dabb7c4e4 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -65,7 +65,6 @@ import 'package:cake_wallet/store/templates/send_template_store.dart'; import 'package:cake_wallet/store/templates/exchange_template_store.dart'; import 'package:cake_wallet/src/domain/common/template.dart'; import 'package:cake_wallet/src/domain/exchange/exchange_template.dart'; -import 'package:cake_wallet/store/dashboard/page_view_store.dart'; final getIt = GetIt.instance; @@ -121,7 +120,6 @@ Future setup( TradeFilterStore(wallet: getIt.get().wallet)); getIt.registerSingleton(TransactionFilterStore()); getIt.registerSingleton(FiatConvertationStore()); - getIt.registerSingleton(PageViewStore()); getIt.registerSingleton( SendTemplateStore(templateSource: templates)); getIt.registerSingleton( @@ -169,8 +167,7 @@ Future setup( appStore: getIt.get(), tradesStore: getIt.get(), tradeFilterStore: getIt.get(), - transactionFilterStore: getIt.get(), - pageViewStore: getIt.get() + transactionFilterStore: getIt.get() )); getIt.registerFactory(() => AuthService( diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 7623891f4..2c0a02319 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -6,15 +6,13 @@ import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart'; import 'package:cake_wallet/palette.dart'; -import 'package:dots_indicator/dots_indicator.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/action_button.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; -import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:mobx/mobx.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; +import 'package:smooth_page_indicator/smooth_page_indicator.dart'; class DashboardPage extends BasePage { DashboardPage({ @@ -95,20 +93,18 @@ class DashboardPage extends BasePage { padding: EdgeInsets.only( bottom: 24 ), - child: Observer( - builder: (_) { - return DotsIndicator( - dotsCount: pages.length, - position: walletViewModel.currentPage, - decorator: DotsDecorator( - color: PaletteDark.cyanBlue, - activeColor: Colors.white, - size: Size(6, 6), - activeSize: Size(6, 6), - ), - ); - } - ), + child: SmoothPageIndicator( + controller: controller, + count: pages.length, + effect: ColorTransitionEffect( + spacing: 6.0, + radius: 6.0, + dotWidth: 6.0, + dotHeight: 6.0, + dotColor: PaletteDark.cyanBlue, + activeDotColor: Colors.white + ), + ) ), Container( width: double.infinity, @@ -159,16 +155,6 @@ class DashboardPage extends BasePage { pages.add(BalancePage(dashboardViewModel: walletViewModel)); pages.add(TransactionsPage(dashboardViewModel: walletViewModel)); - controller.addListener(() { - walletViewModel.pageViewStore.setCurrentPage(controller.page); - }); - - reaction((_) => walletViewModel.currentPage, (double currentPage) { - if (controller.page != currentPage) { - controller.jumpTo(currentPage); - } - }); - _isEffectsInstalled = true; } } diff --git a/lib/store/dashboard/page_view_store.dart b/lib/store/dashboard/page_view_store.dart deleted file mode 100644 index 30b938519..000000000 --- a/lib/store/dashboard/page_view_store.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:mobx/mobx.dart'; - -part 'page_view_store.g.dart'; - -class PageViewStore = PageViewStoreBase with _$PageViewStore; - -abstract class PageViewStoreBase with Store { - PageViewStoreBase() { - setCurrentPage(1); - } - - @observable - double currentPage; - - @action - void setCurrentPage(double currentPage) { - this.currentPage = currentPage; - } -} \ No newline at end of file diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 64530b655..65deb5f92 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -22,7 +22,6 @@ import 'package:cake_wallet/store/dashboard/trades_store.dart'; import 'package:cake_wallet/store/dashboard/trade_filter_store.dart'; import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart'; import 'package:cake_wallet/view_model/dashboard/formatted_item_list.dart'; -import 'package:cake_wallet/store/dashboard/page_view_store.dart'; part 'dashboard_view_model.g.dart'; @@ -34,8 +33,7 @@ abstract class DashboardViewModelBase with Store { this.appStore, this.tradesStore, this.tradeFilterStore, - this.transactionFilterStore, - this.pageViewStore}) { + this.transactionFilterStore}) { name = appStore.wallet?.name; wallet ??= appStore.wallet; @@ -69,9 +67,6 @@ abstract class DashboardViewModelBase with Store { @observable String subname; - @computed - double get currentPage => pageViewStore.currentPage; - @computed String get address => wallet.address; @@ -130,8 +125,6 @@ abstract class DashboardViewModelBase with Store { TransactionFilterStore transactionFilterStore; - PageViewStore pageViewStore; - ReactionDisposer _reaction; void _onWalletChange(WalletBase wallet) { diff --git a/pubspec.lock b/pubspec.lock index f8e7304da..344397bf6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -267,13 +267,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.7" - dots_indicator: - dependency: "direct main" - description: - name: dots_indicator - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" dotted_border: dependency: "direct main" description: @@ -803,6 +796,13 @@ packages: description: flutter source: sdk version: "0.0.99" + smooth_page_indicator: + dependency: "direct main" + description: + name: smooth_page_indicator + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" source_gen: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bda604b55..d99925e2e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,7 +50,7 @@ dependencies: devicelocale: ^0.2.1 auto_size_text: ^2.1.0 dotted_border: ^1.0.5 - dots_indicator: ^1.2.0 + smooth_page_indicator: ^0.2.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.