1
+ import 'package:flutter/material.dart' ;
2
+ import 'package:food_app/animations/FadeAnimation.dart' ;
3
+
4
+ class HomePage extends StatefulWidget {
5
+ @override
6
+ _HomePageState createState () => _HomePageState ();
7
+ }
8
+
9
+ class _HomePageState extends State <HomePage > {
10
+ @override
11
+ Widget build (BuildContext context) {
12
+ return Scaffold (
13
+ backgroundColor: Colors .grey[100 ],
14
+ appBar: AppBar (
15
+ backgroundColor: Colors .grey[100 ],
16
+ elevation: 0 ,
17
+ brightness: Brightness .light,
18
+ leading: Icon (null ),
19
+ actions: < Widget > [
20
+ IconButton (
21
+ onPressed: () {},
22
+ icon: Icon (Icons .shopping_basket, color: Colors .grey[800 ],),
23
+ )
24
+ ],
25
+ ),
26
+ body: SafeArea (
27
+ child: Column (
28
+ crossAxisAlignment: CrossAxisAlignment .start,
29
+ children: < Widget > [
30
+ Padding (
31
+ padding: EdgeInsets .symmetric (horizontal: 20.0 ),
32
+ child: Column (
33
+ crossAxisAlignment: CrossAxisAlignment .start,
34
+ children: < Widget > [
35
+ FadeAnimation (1 , Text ('Food Delivery' , style: TextStyle (color: Colors .grey[80 ], fontWeight: FontWeight .bold, fontSize: 30 ),)),
36
+ SizedBox (height: 20 ,),
37
+ Container (
38
+ height: 50 ,
39
+ child: ListView (
40
+ scrollDirection: Axis .horizontal,
41
+ children: < Widget > [
42
+ FadeAnimation (1 , makeCategory (isActive: true , title: 'Pizaa' )),
43
+ FadeAnimation (1.3 , makeCategory (isActive: false , title: 'Burgers' )),
44
+ FadeAnimation (1.4 , makeCategory (isActive: false , title: 'Kebab' )),
45
+ FadeAnimation (1.5 , makeCategory (isActive: false , title: 'Desert' )),
46
+ FadeAnimation (1.6 , makeCategory (isActive: false , title: 'Salad' )),
47
+ ],
48
+ ),
49
+ ),
50
+ SizedBox (height: 10 ,),
51
+ ],
52
+ ),
53
+ ),
54
+ FadeAnimation (1 , Padding (
55
+ padding: EdgeInsets .all (20 ),
56
+ child: Text ('Free Delivery' , style: TextStyle (color: Colors .grey[700 ], fontSize: 20 , fontWeight: FontWeight .bold),),
57
+ )),
58
+ Expanded (
59
+ child: Padding (
60
+ padding: EdgeInsets .symmetric (horizontal: 20.0 ),
61
+ child: ListView (
62
+ scrollDirection: Axis .horizontal,
63
+ children: < Widget > [
64
+ FadeAnimation (1.4 , makeItem (image: 'assets/images/one.jpg' )),
65
+ FadeAnimation (1.5 , makeItem (image: 'assets/images/two.jpg' )),
66
+ FadeAnimation (1.6 , makeItem (image: 'assets/images/three.jpg' )),
67
+ ],
68
+ ),
69
+ ),
70
+ ),
71
+ SizedBox (
72
+ height: 30 ,
73
+ )
74
+ ],
75
+ ),
76
+ ),
77
+ );
78
+ }
79
+
80
+ Widget makeCategory ({isActive, title}) {
81
+ return AspectRatio (
82
+ aspectRatio: isActive ? 3 : 2.5 / 1 ,
83
+ child: Container (
84
+ margin: EdgeInsets .only (right: 10 ),
85
+ decoration: BoxDecoration (
86
+ color: isActive ? Colors .yellow[700 ] : Colors .white,
87
+ borderRadius: BorderRadius .circular (50 ),
88
+ ),
89
+ child: Align (
90
+ child: Text (title, style: TextStyle (color: isActive ? Colors .white : Colors .grey[500 ], fontSize: 18 , fontWeight: isActive ? FontWeight .bold : FontWeight .w100),),
91
+ ),
92
+ ),
93
+ );
94
+ }
95
+
96
+ Widget makeItem ({image}) {
97
+ return AspectRatio (
98
+ aspectRatio: 1 / 1.5 ,
99
+ child: GestureDetector (
100
+ child: Container (
101
+ margin: EdgeInsets .only (right: 20 ),
102
+ decoration: BoxDecoration (
103
+ borderRadius: BorderRadius .circular (20 ),
104
+ image: DecorationImage (
105
+ image: AssetImage (image),
106
+ fit: BoxFit .cover,
107
+ )
108
+ ),
109
+ child: Container (
110
+ decoration: BoxDecoration (
111
+ borderRadius: BorderRadius .circular (20 ),
112
+ gradient: LinearGradient (
113
+ begin: Alignment .bottomCenter,
114
+ stops: [.2 , .9 ],
115
+ colors: [
116
+ Colors .black.withOpacity (.9 ),
117
+ Colors .black.withOpacity (.3 ),
118
+ ]
119
+ )
120
+ ),
121
+ child: Padding (
122
+ padding: EdgeInsets .all (20.0 ),
123
+ child: Column (
124
+ crossAxisAlignment: CrossAxisAlignment .start,
125
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
126
+ children: < Widget > [
127
+ Align (
128
+ alignment: Alignment .topRight,
129
+ child: Icon (Icons .favorite, color: Colors .white,),
130
+ ),
131
+ Column (
132
+ crossAxisAlignment: CrossAxisAlignment .start,
133
+ children: < Widget > [
134
+ Text ("\$ 15.00" , style: TextStyle (color: Colors .white, fontSize: 40 , fontWeight: FontWeight .bold),),
135
+ SizedBox (height: 10 ,),
136
+ Text ("Vegetarian Pizza" , style: TextStyle (color: Colors .white, fontSize: 20 ),)
137
+ ],
138
+ )
139
+ ],
140
+ ),
141
+ ),
142
+ ),
143
+ ),
144
+ ),
145
+ );
146
+ }
147
+ }
0 commit comments