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';
|
2020-06-20 07:10:00 +00:00
|
|
|
import 'package:cake_wallet/view_model/dashboard_view_model.dart';
|
2020-07-06 20:09:03 +00:00
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
2020-05-29 15:10:11 +00:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart';
|
2020-07-21 17:22:41 +00:00
|
|
|
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:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
class DashboardPage extends BasePage {
|
2020-06-20 07:10:00 +00:00
|
|
|
DashboardPage({@required this.walletViewModel});
|
|
|
|
|
2020-04-14 18:15:47 +00:00
|
|
|
@override
|
2020-07-21 17:22:41 +00:00
|
|
|
Color get backgroundLightColor => PaletteDark.backgroundColor;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-07-21 17:22:41 +00:00
|
|
|
Color get backgroundDarkColor => PaletteDark.backgroundColor;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-07-06 20:09:03 +00:00
|
|
|
Widget trailing(BuildContext context) {
|
2020-07-21 17:22:41 +00:00
|
|
|
final menuButton = Image.asset('assets/images/menu.png',
|
|
|
|
color: Colors.white);
|
2020-07-06 20:09:03 +00:00
|
|
|
|
|
|
|
return Container(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: SizedBox(
|
2020-07-21 17:22:41 +00:00
|
|
|
width: 20,
|
2020-07-06 20:09:03 +00:00
|
|
|
child: FlatButton(
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
padding: EdgeInsets.all(0),
|
|
|
|
onPressed: () async {
|
|
|
|
await showDialog<void>(
|
2020-07-21 17:22:41 +00:00
|
|
|
builder: (_) => MenuWidget(
|
|
|
|
name: walletViewModel.name,
|
|
|
|
subname: walletViewModel.subname,
|
|
|
|
type: walletViewModel.type),
|
|
|
|
context: context);
|
2020-07-06 20:09:03 +00:00
|
|
|
},
|
|
|
|
child: menuButton),
|
|
|
|
),
|
2020-05-29 15:10:11 +00:00
|
|
|
);
|
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;
|
2020-07-21 17:22:41 +00:00
|
|
|
final sendImage = Image.asset('assets/images/upload.png');
|
|
|
|
final exchangeImage = Image.asset('assets/images/transfer.png');
|
|
|
|
final receiveImage = Image.asset('assets/images/download.png');
|
|
|
|
final controller = PageController(initialPage: 0);
|
|
|
|
|
|
|
|
var pages = <Widget>[];
|
|
|
|
bool _isEffectsInstalled = false;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
|
|
|
|
2020-07-21 17:22:41 +00:00
|
|
|
_setEffects();
|
|
|
|
|
|
|
|
return SafeArea(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: PageView.builder(
|
|
|
|
controller: controller,
|
|
|
|
itemCount: pages.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return pages[index];
|
|
|
|
}
|
2020-05-29 15:10:11 +00:00
|
|
|
)
|
2020-07-21 17:22:41 +00:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
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),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 45,
|
|
|
|
right: 45,
|
|
|
|
bottom: 24
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Flexible(
|
|
|
|
child: ActionButton(
|
|
|
|
image: sendImage,
|
|
|
|
title: S.of(context).send,
|
|
|
|
route: Routes.send,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
child: ActionButton(
|
|
|
|
image: exchangeImage,
|
|
|
|
title: S.of(context).exchange,
|
|
|
|
route: Routes.exchange
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
child: ActionButton(
|
|
|
|
image: receiveImage,
|
|
|
|
title: S.of(context).receive,
|
|
|
|
route: Routes.receive,
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
);
|
2020-07-06 20:09:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-21 17:22:41 +00:00
|
|
|
void _setEffects() {
|
|
|
|
if (_isEffectsInstalled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pages.add(BalancePage(dashboardViewModel: walletViewModel));
|
|
|
|
pages.add(Center(
|
|
|
|
child: Text(
|
|
|
|
'SECOND PAGE',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white
|
2020-04-14 18:15:47 +00:00
|
|
|
),
|
2020-07-21 17:22:41 +00:00
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
controller.addListener(() {
|
|
|
|
walletViewModel.currentPage = controller.page;
|
|
|
|
});
|
|
|
|
|
|
|
|
reaction((_) => walletViewModel.currentPage, (double currentPage) {
|
|
|
|
if (controller.page != currentPage) {
|
|
|
|
controller.jumpTo(currentPage);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
_isEffectsInstalled = true;
|
|
|
|
}
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|