cake_wallet/lib/src/screens/dashboard/dashboard_page.dart

148 lines
4.8 KiB
Dart
Raw Normal View History

2020-07-06 20:09:03 +00:00
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
2020-01-04 19:31:52 +00:00
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
2020-07-06 20:09:03 +00:00
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/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: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';
2020-01-04 19:31:52 +00:00
2020-07-06 20:09:03 +00:00
class DashboardPage extends BasePage {
DashboardPage({
@required this.walletViewModel,
@required this.addressListViewModel,
});
2020-06-20 07:10:00 +00:00
2020-04-14 18:15:47 +00:00
@override
Color get backgroundLightColor => Colors.transparent;
2020-01-04 19:31:52 +00:00
@override
Color get backgroundDarkColor => Colors.transparent;
@override
Widget Function(BuildContext, Widget) get rootWrapper =>
2020-09-01 11:18:07 +00:00
(BuildContext context, Widget scaffold) => Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
2020-09-01 11:18:07 +00:00
Theme.of(context).accentColor,
Theme.of(context).scaffoldBackgroundColor,
Theme.of(context).primaryColor,
], begin: Alignment.topRight, end: Alignment.bottomLeft)),
child: scaffold);
2020-01-04 19:31:52 +00:00
@override
bool get resizeToAvoidBottomPadding => false;
@override
2020-09-01 11:18:07 +00:00
Widget get endDrawer => MenuWidget(walletViewModel);
@override
Widget middle(BuildContext context) {
return SyncIndicator(dashboardViewModel: walletViewModel);
}
2020-01-04 19:31:52 +00:00
@override
2020-07-06 20:09:03 +00:00
Widget trailing(BuildContext context) {
2020-09-01 11:18:07 +00:00
final menuButton =
Image.asset('assets/images/menu.png', color: Colors.white);
2020-07-06 20:09:03 +00:00
return Container(
2020-09-01 11:18:07 +00:00
alignment: Alignment.centerRight,
width: 40,
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
onPressed: () => onOpenEndDrawer(),
child: menuButton));
2020-07-06 20:09:03 +00:00
}
2020-04-14 18:15:47 +00:00
2020-07-06 20:09:03 +00:00
final DashboardViewModel walletViewModel;
final WalletAddressListViewModel addressListViewModel;
final sendImage = Image.asset('assets/images/upload.png',
height: 22.24, width: 24, color: Colors.white);
final exchangeImage = Image.asset('assets/images/transfer.png',
height: 24.27, width: 22.25, color: Colors.white);
final receiveImage = Image.asset('assets/images/download.png',
height: 22.24, width: 24, color: Colors.white);
final controller = PageController(initialPage: 1);
var pages = <Widget>[];
bool _isEffectsInstalled = false;
2020-07-06 20:09:03 +00:00
@override
Widget body(BuildContext context) {
_setEffects();
return SafeArea(
2020-09-01 11:18:07 +00:00
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: PageView.builder(
2020-09-01 11:18:07 +00:00
controller: controller,
itemCount: pages.length,
2020-09-09 14:13:44 +00:00
itemBuilder: (context, index) => pages[index])),
2020-09-01 11:18:07 +00:00
Padding(
padding: EdgeInsets.only(bottom: 24),
child: SmoothPageIndicator(
controller: controller,
2020-09-01 11:18:07 +00:00
count: pages.length,
effect: ColorTransitionEffect(
2020-09-01 11:18:07 +00:00
spacing: 6.0,
radius: 6.0,
dotWidth: 6.0,
dotHeight: 6.0,
dotColor: Theme.of(context).indicatorColor,
activeDotColor: Colors.white),
)),
Container(
width: double.infinity,
2020-09-14 19:07:44 +00:00
padding: EdgeInsets.only(
left: 45,
right: 45,
bottom: 24
),
2020-09-01 11:18:07 +00:00
child: Row(
children: <Widget>[
Flexible(
child: ActionButton(
image: sendImage,
title: S.of(context).send,
route: Routes.send,
alignment: Alignment.centerLeft,
),
2020-09-01 11:18:07 +00:00
),
Flexible(
child: ActionButton(
image: exchangeImage,
title: S.of(context).exchange,
2020-09-14 19:07:44 +00:00
route: Routes.exchange
),
),
2020-09-01 11:18:07 +00:00
],
),
)
],
));
2020-07-06 20:09:03 +00:00
}
void _setEffects() {
if (_isEffectsInstalled) {
return;
}
pages.add(AddressPage(addressListViewModel: addressListViewModel));
pages.add(BalancePage(dashboardViewModel: walletViewModel));
pages.add(TransactionsPage(dashboardViewModel: walletViewModel));
_isEffectsInstalled = true;
}
2020-01-04 19:31:52 +00:00
}