CAKE-20 | changed dots indicator on smooth page indicator (dashboard page); deleted page_view_store

This commit is contained in:
Oleksandr Sobol 2020-07-31 22:55:26 +03:00
parent 861a2840ce
commit 1ba86506f0
6 changed files with 23 additions and 66 deletions

View file

@ -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/store/templates/exchange_template_store.dart';
import 'package:cake_wallet/src/domain/common/template.dart'; import 'package:cake_wallet/src/domain/common/template.dart';
import 'package:cake_wallet/src/domain/exchange/exchange_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; final getIt = GetIt.instance;
@ -121,7 +120,6 @@ Future setup(
TradeFilterStore(wallet: getIt.get<AppStore>().wallet)); TradeFilterStore(wallet: getIt.get<AppStore>().wallet));
getIt.registerSingleton<TransactionFilterStore>(TransactionFilterStore()); getIt.registerSingleton<TransactionFilterStore>(TransactionFilterStore());
getIt.registerSingleton<FiatConvertationStore>(FiatConvertationStore()); getIt.registerSingleton<FiatConvertationStore>(FiatConvertationStore());
getIt.registerSingleton<PageViewStore>(PageViewStore());
getIt.registerSingleton<SendTemplateStore>( getIt.registerSingleton<SendTemplateStore>(
SendTemplateStore(templateSource: templates)); SendTemplateStore(templateSource: templates));
getIt.registerSingleton<ExchangeTemplateStore>( getIt.registerSingleton<ExchangeTemplateStore>(
@ -169,8 +167,7 @@ Future setup(
appStore: getIt.get<AppStore>(), appStore: getIt.get<AppStore>(),
tradesStore: getIt.get<TradesStore>(), tradesStore: getIt.get<TradesStore>(),
tradeFilterStore: getIt.get<TradeFilterStore>(), tradeFilterStore: getIt.get<TradeFilterStore>(),
transactionFilterStore: getIt.get<TransactionFilterStore>(), transactionFilterStore: getIt.get<TransactionFilterStore>()
pageViewStore: getIt.get<PageViewStore>()
)); ));
getIt.registerFactory<AuthService>(() => AuthService( getIt.registerFactory<AuthService>(() => AuthService(

View file

@ -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/base_page.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart';
import 'package:cake_wallet/palette.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/action_button.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.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/address_page.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_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/src/screens/dashboard/widgets/sync_indicator.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.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 { class DashboardPage extends BasePage {
DashboardPage({ DashboardPage({
@ -95,20 +93,18 @@ class DashboardPage extends BasePage {
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: 24 bottom: 24
), ),
child: Observer( child: SmoothPageIndicator(
builder: (_) { controller: controller,
return DotsIndicator( count: pages.length,
dotsCount: pages.length, effect: ColorTransitionEffect(
position: walletViewModel.currentPage, spacing: 6.0,
decorator: DotsDecorator( radius: 6.0,
color: PaletteDark.cyanBlue, dotWidth: 6.0,
activeColor: Colors.white, dotHeight: 6.0,
size: Size(6, 6), dotColor: PaletteDark.cyanBlue,
activeSize: Size(6, 6), activeDotColor: Colors.white
), ),
); )
}
),
), ),
Container( Container(
width: double.infinity, width: double.infinity,
@ -159,16 +155,6 @@ class DashboardPage extends BasePage {
pages.add(BalancePage(dashboardViewModel: walletViewModel)); pages.add(BalancePage(dashboardViewModel: walletViewModel));
pages.add(TransactionsPage(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; _isEffectsInstalled = true;
} }
} }

View file

@ -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;
}
}

View file

@ -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/trade_filter_store.dart';
import 'package:cake_wallet/store/dashboard/transaction_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/view_model/dashboard/formatted_item_list.dart';
import 'package:cake_wallet/store/dashboard/page_view_store.dart';
part 'dashboard_view_model.g.dart'; part 'dashboard_view_model.g.dart';
@ -34,8 +33,7 @@ abstract class DashboardViewModelBase with Store {
this.appStore, this.appStore,
this.tradesStore, this.tradesStore,
this.tradeFilterStore, this.tradeFilterStore,
this.transactionFilterStore, this.transactionFilterStore}) {
this.pageViewStore}) {
name = appStore.wallet?.name; name = appStore.wallet?.name;
wallet ??= appStore.wallet; wallet ??= appStore.wallet;
@ -69,9 +67,6 @@ abstract class DashboardViewModelBase with Store {
@observable @observable
String subname; String subname;
@computed
double get currentPage => pageViewStore.currentPage;
@computed @computed
String get address => wallet.address; String get address => wallet.address;
@ -130,8 +125,6 @@ abstract class DashboardViewModelBase with Store {
TransactionFilterStore transactionFilterStore; TransactionFilterStore transactionFilterStore;
PageViewStore pageViewStore;
ReactionDisposer _reaction; ReactionDisposer _reaction;
void _onWalletChange(WalletBase wallet) { void _onWalletChange(WalletBase wallet) {

View file

@ -267,13 +267,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.7" 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: dotted_border:
dependency: "direct main" dependency: "direct main"
description: description:
@ -803,6 +796,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.99" 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: source_gen:
dependency: transitive dependency: transitive
description: description:

View file

@ -50,7 +50,7 @@ dependencies:
devicelocale: ^0.2.1 devicelocale: ^0.2.1
auto_size_text: ^2.1.0 auto_size_text: ^2.1.0
dotted_border: ^1.0.5 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. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.