forked from samarthagarwal/FlutterScreens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage1.dart
142 lines (136 loc) · 4.52 KB
/
page1.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_ui_challenges/core/presentation/res/assets.dart';
import 'package:flutter_ui_challenges/src/widgets/swiper_pagination.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class IntroThreePage extends StatefulWidget {
static final String path = "lib/src/pages/onboarding/intro3.dart";
@override
_IntroThreePageState createState() => _IntroThreePageState();
}
class _IntroThreePageState extends State<IntroThreePage> {
final SwiperController _swiperController = SwiperController();
final int _pageCount = 3;
int _currentIndex = 0;
final List<String> titles = [
"Lorem ipsum dolor \nsit amet, consectetur adipiscing \n elit placerat. ",
"Aliquam eget justo \n nec arcu ultricies elementum \n id at metus. ",
"Nulla facilisi. \nFusce non tempus risus.\n Sed ultrices scelerisque sem,"
];
final List<Color> pageBgs = [
Colors.blue.shade300,
Colors.grey.shade600,
Colors.cyan.shade300
];
@override
Widget build(BuildContext context){
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children: <Widget>[
Center(child: Container(
height: 300,
margin: const EdgeInsets.only(left: 8.0, right: 8.0),
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(5.0)
),
),),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(child: Swiper(
index: _currentIndex,
controller: _swiperController,
itemCount: _pageCount,
onIndexChanged: (index) {
setState(() {
_currentIndex = index;
});
},
loop: false,
itemBuilder: (context, index){
return _buildPage(title: titles[index], icon: images[index+2], pageBg: pageBgs[index]);
},
pagination: SwiperPagination(
builder: CustomPaginationBuilder(
activeSize: Size(10.0, 20.0),
size: Size(10.0, 15.0),
color: Colors.grey.shade600
)
),
)),
SizedBox(height: 10.0),
_buildButtons(),
],
),
],
),
);
}
Widget _buildButtons(){
return Container(
margin: const EdgeInsets.only(right: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlatButton(
textColor: Colors.grey.shade600,
child: Text("Skip"),
onPressed: (){
Navigator.of(context).pushReplacementNamed('home');
},
),
IconButton(
icon: Icon(_currentIndex < _pageCount - 1 ? Icons.arrow_forward_ios : FontAwesomeIcons.check),
onPressed: () async {
if(_currentIndex < _pageCount - 1)
_swiperController.next();
else {
Navigator.of(context).pushReplacementNamed('home');
}
},
)
],
),
);
}
Widget _buildPage({String title, String icon, Color pageBg}) {
final TextStyle titleStyle = TextStyle(
fontWeight: FontWeight.w500,
fontSize: 20.0,
color: Colors.white
);
return Container(
width: double.infinity,
margin: const EdgeInsets.fromLTRB(16.0, 50.0,16.0,40.0),
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: pageBg
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 20.0),
Text(title, textAlign: TextAlign.center, style: titleStyle,),
SizedBox(height: 30.0),
Expanded(
child:ClipOval(child: Container(
height: 300,
width: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(icon),
fit: BoxFit.cover
)
),
)) ,
),
SizedBox(height: 50.0),
],
),
);
}
}