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-04-14 18:15:47 +00:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/wallet_card.dart';
|
2020-04-16 18:41:04 +00:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/trade_history_panel.dart';
|
2020-05-29 15:10:11 +00:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.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-06 20:09:03 +00:00
|
|
|
Color get backgroundLightColor => Colors.transparent;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-07-06 20:09:03 +00:00
|
|
|
Color get backgroundDarkColor => Colors.transparent;
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-07-06 20:09:03 +00:00
|
|
|
Widget Function(BuildContext, Widget) get rootWrapper =>
|
|
|
|
(BuildContext context, Widget scaffold) => Container(
|
2020-05-29 15:10:11 +00:00
|
|
|
decoration: BoxDecoration(
|
2020-06-20 07:10:00 +00:00
|
|
|
gradient: LinearGradient(colors: [
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
Theme.of(context).primaryColor
|
2020-07-06 20:09:03 +00:00
|
|
|
], begin: Alignment.topLeft, end: Alignment.bottomRight)),
|
|
|
|
child: scaffold);
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-07-06 20:09:03 +00:00
|
|
|
Widget trailing(BuildContext context) {
|
2020-05-29 15:10:11 +00:00
|
|
|
final menuButton = Image.asset('assets/images/header.png',
|
2020-07-06 20:09:03 +00:00
|
|
|
color: Theme.of(context).primaryTextTheme.title.color);
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: SizedBox(
|
|
|
|
width: 24,
|
|
|
|
child: FlatButton(
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
padding: EdgeInsets.all(0),
|
|
|
|
onPressed: () async {
|
|
|
|
await showDialog<void>(
|
|
|
|
builder: (_) => MenuWidget(
|
|
|
|
name: walletViewModel.name,
|
|
|
|
subname: walletViewModel.subname,
|
|
|
|
type: walletViewModel.type),
|
|
|
|
context: context);
|
|
|
|
},
|
|
|
|
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;
|
|
|
|
final sendImage = Image.asset('assets/images/send.png');
|
|
|
|
final exchangeImage = Image.asset('assets/images/exchange.png');
|
|
|
|
final buyImage = Image.asset('assets/images/coins.png');
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
|
|
|
return LayoutBuilder(builder: (context, constraints) {
|
|
|
|
final transactionListMinHeight =
|
|
|
|
constraints.heightConstraints().maxHeight - 345 - 32;
|
|
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(children: [
|
|
|
|
Container(
|
|
|
|
height: 345,
|
|
|
|
child: Column(children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 24, top: 10),
|
|
|
|
child: WalletCard(walletVM: walletViewModel)),
|
2020-05-29 15:10:11 +00:00
|
|
|
Container(
|
2020-07-06 20:09:03 +00:00
|
|
|
padding: EdgeInsets.only(left: 44, right: 44, top: 32),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Flexible(
|
|
|
|
child: actionButton(
|
|
|
|
context: context,
|
|
|
|
image: sendImage,
|
|
|
|
title: S.of(context).send,
|
|
|
|
route: Routes.send)),
|
|
|
|
Flexible(
|
|
|
|
child: actionButton(
|
|
|
|
context: context,
|
|
|
|
image: exchangeImage,
|
|
|
|
title: S.of(context).exchange,
|
|
|
|
route: Routes.exchange)),
|
2020-05-29 15:10:11 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2020-07-06 20:09:03 +00:00
|
|
|
])),
|
|
|
|
SizedBox(height: 32),
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minHeight: transactionListMinHeight),
|
|
|
|
child: TradeHistoryPanel(dashboardViewModel: walletViewModel)),
|
|
|
|
// Column(children: [
|
|
|
|
// Text('1'),
|
|
|
|
// Text('2')
|
|
|
|
// ])
|
|
|
|
]));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget actionButton(
|
|
|
|
{BuildContext context,
|
|
|
|
@required Image image,
|
|
|
|
@required String title,
|
|
|
|
@required String route}) {
|
|
|
|
return Container(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
if (route.isNotEmpty) {
|
|
|
|
Navigator.of(context, rootNavigator: true).pushNamed(route);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: 48,
|
|
|
|
width: 48,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).primaryTextTheme.subhead.color,
|
|
|
|
shape: BoxShape.circle),
|
|
|
|
child: image,
|
2020-05-29 15:10:11 +00:00
|
|
|
),
|
2020-04-14 18:15:47 +00:00
|
|
|
),
|
2020-07-06 20:09:03 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 12),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Color.fromRGBO(140, 153, 201,
|
|
|
|
0.8) // Theme.of(context).primaryTextTheme.caption.color
|
2020-05-29 15:10:11 +00:00
|
|
|
),
|
|
|
|
),
|
2020-07-06 20:09:03 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|