CWA-198 | added buttons to dashboard page

Oleksandr Sobol committed Apr 15, 2020 at 21:09 UTC b7198f4f6c858259e97e7a9d05e831aebb966d15
2 files changed +127
lib/src/screens/dashboard/dashboard_page.dart
+9
@@ -25,6 +25,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
25 import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
26 import 'package:cake_wallet/src/widgets/picker.dart';
27 import 'package:cake_wallet/src/screens/dashboard/widgets/wallet_card.dart';
28 +import 'package:cake_wallet/src/screens/dashboard/widgets/buttons_widget.dart';
29
30 class DashboardPage extends BasePage {
31 final _bodyKey = GlobalKey();
@@ -137,6 +138,14 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
138 Padding(
139 padding: EdgeInsets.only(left: 20, top: 78),
140 child: WalletCard(),
141 + ),
142 + Padding(
143 + padding: EdgeInsets.only(top: 28),
144 + child: ButtonsWidget(),
145 + ),
146 + Expanded(
147 + child: Container(
148 + )
149 )
150 ],
151 ),
lib/src/screens/dashboard/widgets/buttons_widget.dart new
+118
@@ -0,0 +1,118 @@
1 +import 'dart:async';
2 +import 'package:flutter/material.dart';
3 +import 'package:cake_wallet/palette.dart';
4 +import 'package:cake_wallet/generated/i18n.dart';
5 +import 'package:cake_wallet/routes.dart';
6 +
7 +class ButtonsWidget extends StatefulWidget {
8 + @override
9 + ButtonsWidgetState createState() => ButtonsWidgetState();
10 +}
11 +
12 +class ButtonsWidgetState extends State<ButtonsWidget> {
13 + final sendImage = Image.asset('assets/images/send.png');
14 + final exchangeImage = Image.asset('assets/images/exchange.png');
15 + final buyImage = Image.asset('assets/images/coins.png');
16 +
17 + double height;
18 + bool isDraw;
19 +
20 + @override
21 + void initState() {
22 + height = 0;
23 + isDraw = false;
24 + super.initState();
25 + WidgetsBinding.instance.addPostFrameCallback(afterLayout);
26 + }
27 +
28 + void afterLayout(dynamic _) {
29 + setState(() => height = 108);
30 + Timer(Duration(milliseconds: 250), () =>
31 + setState(() => isDraw = true)
32 + );
33 + }
34 +
35 + @override
36 + Widget build(BuildContext context) {
37 + return Container(
38 + height: 108,
39 + padding: EdgeInsets.only(left: 44, right: 44),
40 + alignment: Alignment.bottomCenter,
41 + child: AnimatedContainer(
42 + height: height,
43 + duration: Duration(milliseconds: 500),
44 + curve: Curves.fastOutSlowIn,
45 + child: isDraw
46 + ? Row(
47 + children: <Widget>[
48 + Flexible(
49 + child: actionButton(
50 + image: sendImage,
51 + title: S.of(context).send,
52 + route: Routes.send
53 + )
54 + ),
55 + Flexible(
56 + child: actionButton(
57 + image: exchangeImage,
58 + title: S.of(context).exchange,
59 + route: Routes.exchange
60 + )
61 + ),
62 + Flexible(
63 + child: actionButton(
64 + image: buyImage,
65 + title: 'Buy',
66 + route: ''
67 + )
68 + )
69 + ],
70 + )
71 + : Offstage(),
72 + ),
73 + );
74 + }
75 +
76 + Widget actionButton({
77 + @required Image image,
78 + @required String title,
79 + @required String route}) {
80 +
81 + return Container(
82 + width: double.infinity,
83 + child: Column(
84 + mainAxisAlignment: MainAxisAlignment.start,
85 + crossAxisAlignment: CrossAxisAlignment.center,
86 + children: <Widget>[
87 + GestureDetector(
88 + onTap: () {
89 + if (route.isNotEmpty) {
90 + Navigator.of(context, rootNavigator: true).pushNamed(route);
91 + }
92 + },
93 + child: Container(
94 + height: 48,
95 + width: 48,
96 + alignment: Alignment.center,
97 + decoration: BoxDecoration(
98 + color: Colors.white,
99 + shape: BoxShape.circle
100 + ),
101 + child: image,
102 + ),
103 + ),
104 + Padding(
105 + padding: EdgeInsets.only(top: 10),
106 + child: Text(
107 + title,
108 + style: TextStyle(
109 + fontSize: 16,
110 + color: PaletteDark.walletCardText
111 + ),
112 + ),
113 + )
114 + ],
115 + ),
116 + );
117 + }
118 +}
\ No newline at end of file