CWA-198 | added buttons to dashboard page

This commit is contained in:
Oleksandr Sobol 2020-04-15 21:09:41 +03:00
parent fc8c632e21
commit b7198f4f6c
2 changed files with 127 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
import 'package:cake_wallet/src/widgets/picker.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/wallet_card.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/buttons_widget.dart';
class DashboardPage extends BasePage {
final _bodyKey = GlobalKey();
@ -137,6 +138,14 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
Padding(
padding: EdgeInsets.only(left: 20, top: 78),
child: WalletCard(),
),
Padding(
padding: EdgeInsets.only(top: 28),
child: ButtonsWidget(),
),
Expanded(
child: Container(
)
)
],
),

View file

@ -0,0 +1,118 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
class ButtonsWidget extends StatefulWidget {
@override
ButtonsWidgetState createState() => ButtonsWidgetState();
}
class ButtonsWidgetState extends State<ButtonsWidget> {
final sendImage = Image.asset('assets/images/send.png');
final exchangeImage = Image.asset('assets/images/exchange.png');
final buyImage = Image.asset('assets/images/coins.png');
double height;
bool isDraw;
@override
void initState() {
height = 0;
isDraw = false;
super.initState();
WidgetsBinding.instance.addPostFrameCallback(afterLayout);
}
void afterLayout(dynamic _) {
setState(() => height = 108);
Timer(Duration(milliseconds: 250), () =>
setState(() => isDraw = true)
);
}
@override
Widget build(BuildContext context) {
return Container(
height: 108,
padding: EdgeInsets.only(left: 44, right: 44),
alignment: Alignment.bottomCenter,
child: AnimatedContainer(
height: height,
duration: Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
child: isDraw
? Row(
children: <Widget>[
Flexible(
child: actionButton(
image: sendImage,
title: S.of(context).send,
route: Routes.send
)
),
Flexible(
child: actionButton(
image: exchangeImage,
title: S.of(context).exchange,
route: Routes.exchange
)
),
Flexible(
child: actionButton(
image: buyImage,
title: 'Buy',
route: ''
)
)
],
)
: Offstage(),
),
);
}
Widget actionButton({
@required Image image,
@required String title,
@required String route}) {
return Container(
width: double.infinity,
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: Colors.white,
shape: BoxShape.circle
),
child: image,
),
),
Padding(
padding: EdgeInsets.only(top: 10),
child: Text(
title,
style: TextStyle(
fontSize: 16,
color: PaletteDark.walletCardText
),
),
)
],
),
);
}
}