Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit de7d769

Browse files
Add home page
1 parent 8f51b96 commit de7d769

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

‎lib/main.dart

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import 'package:day35/animation/FadeAnimation.dart';
2+
import 'package:day35/models/service.dart';
3+
import 'package:flutter/material.dart';
4+
5+
void main () {
6+
runApp(MaterialApp(
7+
home: HomePage(),
8+
debugShowCheckedModeBanner: false,
9+
));
10+
}
11+
12+
class HomePage extends StatefulWidget {
13+
const HomePage({ Key? key }) : super(key: key);
14+
15+
@override
16+
_HomePageState createState() => _HomePageState();
17+
}
18+
19+
class _HomePageState extends State<HomePage> {
20+
List<Service> services = [
21+
Service('Cleaning', 'https://img.icons8.com/external-vitaliy-gorbachev-flat-vitaly-gorbachev/2x/external-cleaning-labour-day-vitaliy-gorbachev-flat-vitaly-gorbachev.png'),
22+
Service('Plumber', 'https://img.icons8.com/external-vitaliy-gorbachev-flat-vitaly-gorbachev/2x/external-plumber-labour-day-vitaliy-gorbachev-flat-vitaly-gorbachev.png'),
23+
Service('Electrician', 'https://img.icons8.com/external-wanicon-flat-wanicon/2x/external-multimeter-car-service-wanicon-flat-wanicon.png'),
24+
Service('Painter', 'https://img.icons8.com/external-itim2101-flat-itim2101/2x/external-painter-male-occupation-avatar-itim2101-flat-itim2101.png'),
25+
Service('Carpenter', 'https://img.icons8.com/fluency/2x/drill.png'),
26+
Service('Gardener', 'https://img.icons8.com/external-itim2101-flat-itim2101/2x/external-gardener-male-occupation-avatar-itim2101-flat-itim2101.png'),
27+
Service('Tailor', 'https://img.icons8.com/fluency/2x/sewing-machine.png'),
28+
Service('Maid', 'https://img.icons8.com/color/2x/housekeeper-female.png'),
29+
Service('Driver', 'https://img.icons8.com/external-sbts2018-lineal-color-sbts2018/2x/external-driver-women-profession-sbts2018-lineal-color-sbts2018.png'),
30+
Service('Cook', 'https://img.icons8.com/external-wanicon-flat-wanicon/2x/external-cooking-daily-routine-wanicon-flat-wanicon.png'),
31+
];
32+
33+
int selectedService = -1;
34+
35+
@override
36+
Widget build(BuildContext context) {
37+
return Scaffold(
38+
backgroundColor: Colors.white,
39+
floatingActionButton: selectedService >= 0 ? FloatingActionButton(
40+
onPressed: () {},
41+
child: Icon(Icons.arrow_forward_ios, size: 20,),
42+
backgroundColor: Colors.blue,
43+
) : null,
44+
body: NestedScrollView(
45+
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
46+
return <Widget>[
47+
SliverToBoxAdapter(
48+
child: FadeAnimation(1.2, Padding(
49+
padding: EdgeInsets.only(top: 120.0, right: 20.0, left: 20.0),
50+
child: Text(
51+
'Which service \ndo you need?',
52+
style: TextStyle(
53+
fontSize: 40,
54+
color: Colors.grey.shade900,
55+
fontWeight: FontWeight.bold,
56+
),
57+
),
58+
),
59+
))
60+
];
61+
},
62+
body: Padding(
63+
padding: EdgeInsets.all(20.0),
64+
child: Column(
65+
crossAxisAlignment: CrossAxisAlignment.start,
66+
children: <Widget>[
67+
Expanded(
68+
child: GridView.builder(
69+
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
70+
crossAxisCount: 2,
71+
childAspectRatio: 1.0,
72+
crossAxisSpacing: 20.0,
73+
mainAxisSpacing: 20.0,
74+
),
75+
physics: NeverScrollableScrollPhysics(),
76+
itemCount: services.length,
77+
itemBuilder: (BuildContext context, int index) {
78+
return FadeAnimation((1.0 + index) / 4, serviceCard(services[index].imageURL, services[index].name, index));
79+
}
80+
),
81+
),
82+
]
83+
),
84+
),
85+
)
86+
);
87+
}
88+
89+
serviceCard(String image, String name, int index) {
90+
return GestureDetector(
91+
onTap: () {
92+
setState(() {
93+
if (selectedService == index)
94+
selectedService = -1;
95+
else
96+
selectedService = index;
97+
});
98+
},
99+
child: AnimatedContainer(
100+
duration: Duration(milliseconds: 300),
101+
padding: EdgeInsets.all(10.0),
102+
decoration: BoxDecoration(
103+
color: selectedService == index ? Colors.blue.shade50 : Colors.grey.shade100,
104+
border: Border.all(
105+
color: selectedService == index ? Colors.blue : Colors.blue.withOpacity(0),
106+
width: 2.0,
107+
),
108+
borderRadius: BorderRadius.circular(20.0),
109+
),
110+
child: Column(
111+
mainAxisAlignment: MainAxisAlignment.center,
112+
children: <Widget>[
113+
Image.network(image, height: 80),
114+
SizedBox(height: 20,),
115+
Text(name, style: TextStyle(fontSize: 20),)
116+
]
117+
),
118+
),
119+
);
120+
}
121+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /