Skip to content

Commit 01da8ad

Browse files
committed
Add day 45
1 parent 9c52bc6 commit 01da8ad

File tree

2 files changed

+134
-3
lines changed

2 files changed

+134
-3
lines changed

lib/main.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import 'package:example/pages/animated_container.dart';
2-
import 'package:example/pages/github_users.dart';
3-
import 'package:example/pages/no_connection.dart';
2+
import 'package:example/pages/new_collection.dart';
3+
import 'package:example/pages/staggered_gridview.dart';
4+
import 'package:example/pages/verification.dart';
45
import 'package:flutter/material.dart';
56

67
void main() => runApp(
78
MaterialApp(
89
debugShowCheckedModeBanner: false,
9-
home: GithubUsers(),
10+
home: NewCollection(),
1011
)
1112
);
1213

lib/pages/new_collection.dart

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import 'package:flutter/material.dart';
2+
3+
class NewCollection extends StatefulWidget {
4+
const NewCollection({ Key? key }) : super(key: key);
5+
6+
@override
7+
_NewCollectionState createState() => _NewCollectionState();
8+
}
9+
10+
class _NewCollectionState extends State<NewCollection> {
11+
PageController? _pageController;
12+
int currentIndex = 0;
13+
14+
@override
15+
void initState() {
16+
_pageController = PageController(
17+
initialPage: 0
18+
);
19+
super.initState();
20+
}
21+
22+
@override
23+
void dispose() {
24+
_pageController!.dispose();
25+
super.dispose();
26+
}
27+
28+
@override
29+
Widget build(BuildContext context) {
30+
return Scaffold(
31+
body: Container(
32+
child: Column(
33+
crossAxisAlignment: CrossAxisAlignment.start,
34+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
35+
children: [
36+
Column(
37+
crossAxisAlignment: CrossAxisAlignment.start,
38+
children: [
39+
Padding(
40+
padding: const EdgeInsets.only(right: 20.0, left: 20.0, top: 80.0),
41+
child: Column(
42+
crossAxisAlignment: CrossAxisAlignment.start,
43+
children: [
44+
Text("Collection", style: TextStyle(fontSize: 25, color: Colors.grey.shade500),),
45+
Text("Winter 2021", style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold),),
46+
],
47+
),
48+
),
49+
Row(
50+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
51+
children: [
52+
Container(
53+
padding: EdgeInsets.all(20),
54+
child: Row(
55+
children: _buildIndicator(),
56+
),
57+
),
58+
Padding(
59+
padding: const EdgeInsets.all(20.0),
60+
child: MaterialButton(
61+
height: 50,
62+
minWidth: 50,
63+
padding: EdgeInsets.symmetric(horizontal: 10),
64+
color: Colors.black,
65+
shape: RoundedRectangleBorder(
66+
borderRadius: BorderRadius.circular(50),
67+
),
68+
onPressed: () {
69+
_pageController!.nextPage(duration: Duration(milliseconds: 500), curve: Curves.ease);
70+
setState(() {
71+
});
72+
},
73+
child: Icon(Icons.arrow_forward_ios, color: Colors.white, size: 20,),
74+
),
75+
),
76+
],
77+
),
78+
],
79+
),
80+
Container(
81+
height: MediaQuery.of(context).size.height * 0.7,
82+
width: MediaQuery.of(context).size.width,
83+
child: PageView(
84+
onPageChanged: (int page) {
85+
setState(() {
86+
currentIndex = page;
87+
});
88+
},
89+
controller: _pageController,
90+
children: <Widget>[
91+
Image.network('https://images.unsplash.com/photo-1525457136159-8878648a7ad0?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTN8fHdpbnRlciUyMGNsb3RoaW5nfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60', fit: BoxFit.cover,),
92+
Image.network('https://images.unsplash.com/photo-1549902529-a515e31f0c1c?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjR8fHdpbnRlciUyMGNsb3RoaW5nfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60', fit: BoxFit.cover,),
93+
Image.network('https://images.unsplash.com/photo-1611080922224-2e0c006a4943?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1yZWxhdGVkfDEyfHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=800&q=60', fit: BoxFit.cover,),
94+
Image.network('https://images.unsplash.com/flagged/photo-1574876668890-2ff765c77cda?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTU3fHx3aW50ZXIlMjBjbG90aGluZ3xlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60', fit: BoxFit.cover,),
95+
Image.network('https://images.unsplash.com/photo-1575919988855-f727358015b4?ixid=MnwxMjA3fDB8MHxzZWFyY2h8Njd8fHdpbnRlciUyMGNsb3RoaW5nfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60', fit: BoxFit.cover,),
96+
],
97+
),
98+
),
99+
]
100+
)
101+
),
102+
);
103+
}
104+
105+
_indicator(bool isActive) {
106+
return AnimatedContainer(
107+
duration: Duration(milliseconds: 300),
108+
height: 6,
109+
width: isActive ? 50 : 10,
110+
margin: EdgeInsets.only(right: 5),
111+
decoration: BoxDecoration(
112+
color: isActive ? Colors.black : Colors.grey.shade500,
113+
borderRadius: BorderRadius.circular(5)
114+
),
115+
);
116+
}
117+
118+
List<Widget> _buildIndicator() {
119+
List<Widget> indicators = [];
120+
for (int i = 0; i<5; i++) {
121+
if (currentIndex == i) {
122+
indicators.add(_indicator(true));
123+
} else {
124+
indicators.add(_indicator(false));
125+
}
126+
}
127+
128+
return indicators;
129+
}
130+
}

0 commit comments

Comments
 (0)