1+ import 'package:flutter/cupertino.dart' ;
12import 'package:flutter/material.dart' ;
2- import 'package:getwidget/components/loader/gf_loader.dart' ;
3- import 'package:getwidget/getwidget.dart' ;
43
54class GFIntroBottomNavigation extends StatelessWidget {
6- const GFIntroBottomNavigation (
7- {Key key,
8- this .rightText = 'NEXT' ,
9- this .pageNumber = 0 ,
10- this .onNext,
11- this .showDivider = true ,
12- this .dividerColor = Colors .grey,
13- this .dividerHeight = 1 ,
14- this .dividerThickness = 0.0 ,
15- this .child,
16- this .padding = const EdgeInsets .all (8 ),
17- this .margin = const EdgeInsets .all (8 ),
18- this .pagesCount = 4 ,
19- this .skipText = 'SKIP' ,
20- this .onSkipTap,
21- this .skipWidget,
22- this .nextWidget,
23- this .pageCount = 1 })
24- : super (key: key);
5+ const GFIntroBottomNavigation ({
6+ Key key,
7+ this .rightText = 'NEXT' ,
8+ this .pageNumber = 0 ,
9+ this .onNext,
10+ this .showDivider = true ,
11+ this .dividerColor = Colors .grey,
12+ this .dividerHeight = 1 ,
13+ this .dividerThickness = 0.0 ,
14+ this .child,
15+ this .padding = const EdgeInsets .all (8 ),
16+ this .margin = const EdgeInsets .all (8 ),
17+ this .pagesCount = 3 ,
18+ this .skipText = 'SKIP' ,
19+ this .onSkipTap,
20+ this .skipWidget,
21+ this .rightWidget,
22+ this .dotShape,
23+ this .defaultColor,
24+ this .activeColor,
25+ this .dotHeight,
26+ this .dotWidth,
27+ this .dotMargin,
28+ this .skipStyle,
29+ this .rightStyle,
30+ this .onDoneTap,
31+ this .doneText = 'GO' ,
32+ }) : super (key: key);
2533
2634 final String rightText;
2735 final int pageNumber;
@@ -34,73 +42,117 @@ class GFIntroBottomNavigation extends StatelessWidget {
3442 final int pagesCount;
3543 final String skipText;
3644 final VoidCallback onSkipTap;
45+ final VoidCallback onDoneTap;
3746 final EdgeInsets padding;
3847 final EdgeInsets margin;
3948 final Widget skipWidget;
40- final Widget nextWidget;
41- final int pageCount;
49+ final Widget rightWidget;
50+ final TextStyle skipStyle;
51+ final TextStyle rightStyle;
52+ final String doneText;
53+
54+ ///dot
55+ final BoxShape dotShape;
56+ final Color defaultColor;
57+ final Color activeColor;
58+ final double dotHeight;
59+ final double dotWidth;
60+ final EdgeInsets dotMargin;
4261
4362 @override
4463 Widget build (BuildContext context) => Container (
45- child: Column (
46- mainAxisAlignment: MainAxisAlignment .end,
47- children: < Widget > [
48- showDivider
49- ? Divider (
50- height: dividerHeight,
51- thickness: dividerThickness,
52- color: dividerColor,
53- )
54- : Container (),
55- Container (
56- padding: padding,
57- margin: margin,
58- child: Row (
59- mainAxisAlignment: MainAxisAlignment .spaceBetween,
60- children: < Widget > [
61- GestureDetector (
62- behavior: HitTestBehavior .translucent,
63- child: Padding (
64- padding: const EdgeInsets .only (
65- top: 8 ,
66- bottom: 8 ,
67- left: 24 ,
68- right: 32 ,
69- ),
70- child: skipWidget ?? Text (skipText)),
71- onTap: onSkipTap,
72- ),
73- SizedBox (
74- height: 40 ,
75- width: 100 ,
76- child: ListView .builder (
77- scrollDirection: Axis .horizontal,
78- itemCount: pageCount,
79- itemBuilder: (context, index) => Container (
80- width: 12 ,
81- height: 12 ,
82- decoration: BoxDecoration (
83- shape: BoxShape .circle,
84- color: pageCount == 0
85- ? const Color (0xff3adecb )
86- : const Color (0xffd3d3d3 ),
64+ child: DefaultTextStyle (
65+ style: const TextStyle (
66+ color: Colors .black,
67+ fontSize: 16 ,
68+ ),
69+ child: Column (
70+ mainAxisAlignment: MainAxisAlignment .end,
71+ children: < Widget > [
72+ showDivider
73+ ? Divider (
74+ height: dividerHeight,
75+ thickness: dividerThickness,
76+ color: dividerColor,
77+ )
78+ : Container (),
79+ Container (
80+ padding: padding,
81+ margin: margin,
82+ child: Row (
83+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
84+ children: < Widget > [
85+ GestureDetector (
86+ behavior: HitTestBehavior .translucent,
87+ child: Padding (
88+ padding: const EdgeInsets .only (
89+ top: 8 ,
90+ bottom: 8 ,
91+ left: 24 ,
92+ right: 32 ,
93+ ),
94+ child: skipWidget ??
95+ Text (
96+ skipText,
97+ style: skipStyle ??
98+ const TextStyle (
99+ color: Colors .black,
100+ fontSize: 16 ,
101+ ),
102+ )),
103+ onTap: onSkipTap,
104+ ),
105+ Expanded (
106+ child: Container (
107+ child: Stack (
108+ children: [
109+ Row (
110+ mainAxisAlignment: MainAxisAlignment .center,
111+ children: getDotsList (),
112+ )
113+ ],
87114 ),
88115 ),
89116 ),
90- ),
91- GestureDetector (
92- behavior: HitTestBehavior .translucent,
93- child: Padding (
94- padding: const EdgeInsets .only (
95- top: 8 , bottom: 8 , left: 32 , right: 24 ),
96- child: nextWidget ?? Text (rightText),
117+ GestureDetector (
118+ behavior: HitTestBehavior .translucent,
119+ child: Padding (
120+ padding: const EdgeInsets .only (
121+ top: 8 , bottom: 8 , left: 32 , right: 24 ),
122+ child: rightWidget ??
123+ Text (
124+ pageNumber == pagesCount ? doneText : rightText,
125+ style: rightStyle ??
126+ const TextStyle (
127+ color: Colors .black,
128+ fontSize: 16 ,
129+ )),
130+ ),
131+ onTap: pageNumber == pagesCount ? onDoneTap : onNext,
97132 ),
98- onTap: onNext,
99- ),
100- ],
101- ),
102- )
103- ],
133+ ],
134+ ),
135+ )
136+ ],
137+ ),
104138 ),
105139 );
140+
141+ List <Widget > getDotsList () {
142+ final List <Widget > list = [];
143+ for (int i = 1 ; i <= pagesCount; i++ ) {
144+ list.add (Container (
145+ width: dotWidth ?? 12 ,
146+ height: dotHeight ?? 12 ,
147+ margin: dotMargin ?? const EdgeInsets .symmetric (horizontal: 4 ),
148+ decoration: BoxDecoration (
149+ shape: dotShape ?? BoxShape .rectangle,
150+ color: pageNumber == i
151+ ? activeColor ?? Colors .blue
152+ : defaultColor ?? Colors .grey.withOpacity (0.5 ),
153+ ),
154+ ));
155+ }
156+ return list;
157+ }
106158}
0 commit comments