11import 'package:flutter/material.dart' ;
22import 'package:getwidget/components/intro_screen/gf__intro_bottom_navigation.dart' ;
3+ import 'package:getwidget/components/intro_screen/gf_intro_bubble_slide.dart' ;
34import 'package:getwidget/components/intro_screen/gf_intro_slide.dart' ;
45import 'package:getwidget/types/gf_intro_type.dart' ;
56
@@ -9,13 +10,15 @@ class GFIntroScreen extends StatefulWidget {
910 this .slides,
1011 this .pageController,
1112 this .gfIntroBottomNavigation,
12- this .type})
13+ this .type,
14+ this .color = Colors .white})
1315 : super (key: key);
1416
1517 final List <Widget > slides;
1618 final GFIntroType type;
1719 final PageController pageController;
1820 final GFIntroBottomNavigation gfIntroBottomNavigation;
21+ final Color color;
1922
2023 @override
2124 _GFIntroScreenState createState () => _GFIntroScreenState ();
@@ -24,6 +27,7 @@ class GFIntroScreen extends StatefulWidget {
2427class _GFIntroScreenState extends State <GFIntroScreen > {
2528 PageController _pageController = PageController (initialPage: 0 );
2629 int page = 0 ;
30+ List <Widget > pages;
2731
2832 @override
2933 void initState () {
@@ -41,59 +45,68 @@ class _GFIntroScreenState extends State<GFIntroScreen> {
4145 }
4246
4347 @override
44- Widget build (BuildContext context) => Center (
45- child: Container (
46- width: widget.type == GFIntroType .fullWidth
47- ? MediaQuery .of (context).size.width
48- : MediaQuery .of (context).size.width * 0.885 ,
49- height: widget.type != GFIntroType .fullWidth
50- ? MediaQuery .of (context).size.height / 2
51- : MediaQuery .of (context).size.height,
52- margin: widget.type != GFIntroType .fullWidth
53- ? const EdgeInsets .only (left: 20 , right: 20 )
54- : const EdgeInsets .only (left: 0 , right: 0 ),
55- padding: widget.type == GFIntroType .fullWidth
56- ? const EdgeInsets .all (0 )
57- : const EdgeInsets .all (0 ),
58- decoration: BoxDecoration (
59- color: Colors .transparent,
60- borderRadius: widget.type == GFIntroType .fullWidth
61- ? BorderRadius .circular (0 )
62- : widget.type == GFIntroType .rounded
63- ? BorderRadius .circular (20 )
64- : BorderRadius .zero,
65- ),
66- child: Column (
67- mainAxisAlignment: MainAxisAlignment .center,
68- crossAxisAlignment: CrossAxisAlignment .center,
69- children: < Widget > [
70- Expanded (
48+ Widget build (BuildContext context) => widget.type == GFIntroType .bubble
49+ ? buildBubbleType ()
50+ : Center (
51+ child: Container (
52+ width: widget.type == GFIntroType .fullWidth
53+ ? MediaQuery .of (context).size.width
54+ : MediaQuery .of (context).size.width * 0.885 ,
55+ height: widget.type != GFIntroType .fullWidth
56+ ? MediaQuery .of (context).size.height / 2
57+ : MediaQuery .of (context).size.height,
58+ margin: widget.type != GFIntroType .fullWidth
59+ ? const EdgeInsets .only (left: 20 , right: 20 )
60+ : const EdgeInsets .only (left: 0 , right: 0 ),
61+ padding: widget.type == GFIntroType .fullWidth
62+ ? const EdgeInsets .all (0 )
63+ : const EdgeInsets .all (0 ),
64+ decoration: BoxDecoration (
65+ color: widget.color,
66+ borderRadius: widget.type == GFIntroType .fullWidth
67+ ? BorderRadius .circular (0 )
68+ : widget.type == GFIntroType .rounded
69+ ? BorderRadius .circular (24 )
70+ : BorderRadius .zero,
71+ ),
72+ child: Column (
73+ mainAxisAlignment: MainAxisAlignment .center,
74+ crossAxisAlignment: CrossAxisAlignment .center,
75+ children: < Widget > [
76+ Expanded (
77+ child: ClipRRect (
78+ borderRadius: widget.type == GFIntroType .rounded
79+ ? const BorderRadius .only (
80+ topLeft: Radius .circular (24 ),
81+ topRight: Radius .circular (24 ))
82+ : BorderRadius .zero,
7183 child: PageView (
72- controller: _pageController,
73- children: widget.slides ?? slides (),
74- )),
75- widget.gfIntroBottomNavigation ??
76- GFIntroBottomNavigation (
77- onNext: () {
78- _pageController.nextPage (
79- duration: const Duration (milliseconds: 500 ),
80- curve: Curves .linear);
81- },
82- pagesCount: widget.slides ?? slides ().length,
83- pageNumber: page,
84- )
85- ],
84+ controller: _pageController,
85+ children: widget.slides ?? slides (),
86+ ),
87+ )),
88+ widget.gfIntroBottomNavigation ??
89+ GFIntroBottomNavigation (
90+ onNext: () {
91+ _pageController.nextPage (
92+ duration: const Duration (milliseconds: 500 ),
93+ curve: Curves .linear);
94+ },
95+ pagesCount: widget.slides ?? slides ().length,
96+ pageNumber: page,
97+ )
98+ ],
99+ ),
86100 ),
87- ),
88- );
101+ );
89102
90103 List <Widget > slides () {
91104 final List <Widget > list = [];
92105 list.add (const GFIntroSlide (
93106 backgroundColor: Colors .white,
94107 title: 'First' ,
95- imageHeight: 200 ,
96- imageWidth: 200 ,
108+ imageHeight: 100 ,
109+ imageWidth: 100 ,
97110 image: NetworkImage ('https://www.gstatic.com/webp/gallery/3.jpg' ),
98111 ));
99112 list.add (const GFIntroSlide (
@@ -126,4 +139,35 @@ class _GFIntroScreenState extends State<GFIntroScreen> {
126139 ));
127140 return list;
128141 }
142+
143+ Widget buildBubbleType () => SafeArea (
144+ child: Container (
145+ height: MediaQuery .of (context).size.height,
146+ width: MediaQuery .of (context).size.width,
147+ child: PageView (
148+ physics: const ScrollPhysics (),
149+ children: bubbleSlides (),
150+ controller: _pageController,
151+ ),
152+ ),
153+ );
154+
155+ List <Widget > bubbleSlides () {
156+ final List <Widget > list = [];
157+ list.add (GFIntroBubbleSlide (
158+ onNext: () => nextSlider,
159+ alignment: Alignment .topLeft,
160+ ));
161+ list.add (GFIntroBubbleSlide (
162+ onNext: () => nextSlider,
163+ alignment: Alignment .topRight,
164+ ));
165+ return list;
166+ }
167+
168+ // ignore: type_annotate_public_apis, always_declare_return_types
169+ nextSlider () {
170+ _pageController.nextPage (
171+ duration: const Duration (milliseconds: 300 ), curve: Curves .linear);
172+ }
129173}
0 commit comments