Skip to content

Commit 633f85c

Browse files
author
srinivas
committed
added intro & slide page in GFIntroScreen
1 parent 3ed19f2 commit 633f85c

File tree

4 files changed

+146
-6
lines changed

4 files changed

+146
-6
lines changed

lib/components/intro_screen/gf__intro_bottom_navigation.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GFIntroBottomNavigation extends StatelessWidget {
1919
this.onSkipTap,
2020
this.skipWidget,
2121
this.rightWidget,
22-
this.dotShape,
22+
this.dotShape = BoxShape.rectangle,
2323
this.defaultColor,
2424
this.activeColor,
2525
this.dotHeight,
@@ -121,14 +121,16 @@ class GFIntroBottomNavigation extends StatelessWidget {
121121
top: 8, bottom: 8, left: 32, right: 24),
122122
child: rightWidget ??
123123
Text(
124-
pageNumber == pagesCount ? doneText : rightText,
124+
pageNumber == pagesCount - 1
125+
? doneText
126+
: rightText,
125127
style: rightStyle ??
126128
const TextStyle(
127129
color: Colors.black,
128130
fontSize: 16,
129131
)),
130132
),
131-
onTap: pageNumber == pagesCount ? onDoneTap : onNext,
133+
onTap: pageNumber == pagesCount - 1 ? onDoneTap : onNext,
132134
),
133135
],
134136
),
@@ -140,13 +142,13 @@ class GFIntroBottomNavigation extends StatelessWidget {
140142

141143
List<Widget> getDotsList() {
142144
final List<Widget> list = [];
143-
for (int i = 1; i <= pagesCount; i++) {
145+
for (int i = 0; i < pagesCount; i++) {
144146
list.add(Container(
145147
width: dotWidth ?? 12,
146148
height: dotHeight ?? 12,
147149
margin: dotMargin ?? const EdgeInsets.symmetric(horizontal: 4),
148150
decoration: BoxDecoration(
149-
shape: dotShape ?? BoxShape.rectangle,
151+
shape: dotShape,
150152
color: pageNumber == i
151153
? activeColor ?? Colors.blue
152154
: defaultColor ?? Colors.grey.withOpacity(0.5),

lib/components/intro_screen/gf_intro.dart

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:getwidget/components/intro_screen/gf__intro_bottom_navigation.dart';
3+
import 'package:getwidget/components/intro_screen/gf_intro_slide.dart';
4+
5+
class GFIntroScreen extends StatefulWidget {
6+
@override
7+
_GFIntroScreenState createState() => _GFIntroScreenState();
8+
}
9+
10+
class _GFIntroScreenState extends State<GFIntroScreen> {
11+
final PageController _pageController = PageController(initialPage: 0);
12+
int page = 0;
13+
14+
@override
15+
void initState() {
16+
_pageController.addListener(() {
17+
if (mounted) {
18+
setState(() {
19+
page = _pageController.page.round();
20+
});
21+
}
22+
});
23+
super.initState();
24+
}
25+
26+
@override
27+
Widget build(BuildContext context) => Container(
28+
child: Column(
29+
children: <Widget>[
30+
Expanded(
31+
child: PageView(
32+
controller: _pageController,
33+
children: slides(),
34+
)),
35+
GFIntroBottomNavigation(
36+
onNext: () {
37+
if (mounted) {
38+
setState(() {
39+
page = _pageController.page.round() + 1;
40+
_pageController.nextPage(
41+
duration: const Duration(milliseconds: 200),
42+
curve: Curves.linear);
43+
});
44+
}
45+
},
46+
pagesCount: slides().length,
47+
pageNumber: page,
48+
)
49+
],
50+
),
51+
);
52+
53+
List<Widget> slides() {
54+
final List<Widget> list = [];
55+
list.add(const GFIntroSlide(
56+
title: 'First',
57+
imageHeight: 200,
58+
imageWidth: 200,
59+
image: NetworkImage(
60+
'https://rukminim1.flixcart.com/image/832/832/kcc9q4w0/television/g/g/g/samsung-ua32t4010arxxl-ua32t4010arxxl-original-imafthw74azys6rp.jpeg?q=70'),
61+
));
62+
list.add(const GFIntroSlide(
63+
title: 'Second',
64+
imageHeight: 200,
65+
imageWidth: 200,
66+
image: NetworkImage(
67+
'https://rukminim1.flixcart.com/image/832/832/kcc9q4w0/television/g/g/g/samsung-ua32t4010arxxl-ua32t4010arxxl-original-imafthw74azys6rp.jpeg?q=70'),
68+
));
69+
list.add(const GFIntroSlide(
70+
title: 'Third',
71+
imageHeight: 200,
72+
imageWidth: 200,
73+
image: NetworkImage(
74+
'https://rukminim1.flixcart.com/image/832/832/kcc9q4w0/television/g/g/g/samsung-ua32t4010arxxl-ua32t4010arxxl-original-imafthw74azys6rp.jpeg?q=70'),
75+
));
76+
list.add(const GFIntroSlide(
77+
title: 'Fourth',
78+
imageHeight: 200,
79+
imageWidth: 200,
80+
image: NetworkImage(
81+
'https://rukminim1.flixcart.com/image/832/832/kcc9q4w0/television/g/g/g/samsung-ua32t4010arxxl-ua32t4010arxxl-original-imafthw74azys6rp.jpeg?q=70'),
82+
));
83+
list.add(const GFIntroSlide(
84+
title: 'Fifth',
85+
imageHeight: 200,
86+
imageWidth: 200,
87+
image: NetworkImage(
88+
'https://rukminim1.flixcart.com/image/832/832/kcc9q4w0/television/g/g/g/samsung-ua32t4010arxxl-ua32t4010arxxl-original-imafthw74azys6rp.jpeg?q=70'),
89+
));
90+
return list;
91+
}
92+
}
Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
11
import 'package:flutter/material.dart';
2+
import 'package:getwidget/colors/gf_color.dart';
3+
import 'package:getwidget/components/image/gf_image_overlay.dart';
24

35
class GFIntroSlide extends StatelessWidget {
6+
const GFIntroSlide(
7+
{Key key,
8+
@required this.image,
9+
this.imageHeight = 100,
10+
this.imageWidth = 100,
11+
this.title,
12+
this.subTitle,
13+
this.titleStyle = const TextStyle(fontSize: 20, color: GFColors.DARK),
14+
this.subTitleStyle = const TextStyle(fontSize: 16, color: GFColors.DARK),
15+
this.backgroundColor = GFColors.PRIMARY})
16+
: super(key: key);
17+
final double imageHeight;
18+
final double imageWidth;
19+
final ImageProvider image;
20+
final String title;
21+
final TextStyle titleStyle;
22+
final String subTitle;
23+
final TextStyle subTitleStyle;
24+
final Color backgroundColor;
25+
426
@override
5-
Widget build(BuildContext context) => Container();
27+
Widget build(BuildContext context) => Container(
28+
color: backgroundColor,
29+
child: Column(
30+
mainAxisAlignment: MainAxisAlignment.center,
31+
crossAxisAlignment: CrossAxisAlignment.center,
32+
children: <Widget>[
33+
GFImageOverlay(
34+
height: imageHeight, width: imageWidth, image: image),
35+
const SizedBox(
36+
height: 20,
37+
),
38+
Text(
39+
title ?? 'Title',
40+
style: titleStyle,
41+
),
42+
const SizedBox(
43+
height: 40,
44+
),
45+
Text(
46+
subTitle ?? 'Sub Title',
47+
style: subTitleStyle,
48+
)
49+
],
50+
),
51+
);
652
}

0 commit comments

Comments
 (0)