Skip to content

Commit 34a9182

Browse files
author
srinivas
committed
added GFIntroScreen fields
1 parent 83316fd commit 34a9182

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

lib/components/intro_screen/gf__intro_bottom_navigation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GFIntroBottomNavigation extends StatelessWidget {
1414
this.child,
1515
this.padding = const EdgeInsets.all(8),
1616
this.margin = const EdgeInsets.all(8),
17-
this.pagesCount = 3,
17+
this.pagesCount = 0,
1818
this.skipText = 'SKIP',
1919
this.onSkipTap,
2020
this.skipWidget,

lib/components/intro_screen/gf_intro_screen.dart

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,27 @@ import 'package:getwidget/components/intro_screen/gf__intro_bottom_navigation.da
33
import 'package:getwidget/components/intro_screen/gf_intro_slide.dart';
44

55
class GFIntroScreen extends StatefulWidget {
6+
const GFIntroScreen(
7+
{Key key, this.slides, this.pageController, this.gfIntroBottomNavigation})
8+
: super(key: key);
9+
10+
final List<Widget> slides;
11+
final PageController pageController;
12+
final GFIntroBottomNavigation gfIntroBottomNavigation;
13+
614
@override
715
_GFIntroScreenState createState() => _GFIntroScreenState();
816
}
917

1018
class _GFIntroScreenState extends State<GFIntroScreen> {
11-
final PageController _pageController = PageController(initialPage: 0);
19+
PageController _pageController = PageController(initialPage: 0);
1220
int page = 0;
1321

1422
@override
1523
void initState() {
24+
if (widget.pageController != null) {
25+
_pageController = widget.pageController;
26+
}
1627
_pageController.addListener(() {
1728
if (mounted) {
1829
setState(() {
@@ -30,22 +41,18 @@ class _GFIntroScreenState extends State<GFIntroScreen> {
3041
Expanded(
3142
child: PageView(
3243
controller: _pageController,
33-
children: slides(),
44+
children: widget.slides ?? slides(),
3445
)),
35-
GFIntroBottomNavigation(
36-
onNext: () {
37-
if (mounted) {
38-
setState(() {
39-
page = _pageController.page.round() + 1;
46+
widget.gfIntroBottomNavigation ??
47+
GFIntroBottomNavigation(
48+
onNext: () {
4049
_pageController.nextPage(
4150
duration: const Duration(milliseconds: 500),
4251
curve: Curves.linear);
43-
});
44-
}
45-
},
46-
pagesCount: slides().length,
47-
pageNumber: page,
48-
)
52+
},
53+
pagesCount: widget.slides ?? slides().length,
54+
pageNumber: page,
55+
)
4956
],
5057
),
5158
);

0 commit comments

Comments
 (0)