@@ -2,7 +2,6 @@ import 'dart:async';
2
2
import 'package:flutter/material.dart' ;
3
3
import 'package:shop_app/constants.dart' ;
4
4
import 'package:shop_app/screens/sign_in/sign_in_screen.dart' ;
5
- import 'package:shop_app/size_config.dart' ;
6
5
import '../components/splash_content.dart' ;
7
6
import '../../../components/default_button.dart' ;
8
7
@@ -16,91 +15,91 @@ class _BodyState extends State<Body> {
16
15
final PageController _pageController = PageController ();
17
16
List <Map <String , String >> splashData = [
18
17
{
19
- "text" : "Welcome to DoorStep, Let’s shop! " ,
20
- "image" : "assets/images/splash_1 .png" ,
18
+ "text" : "Discover Exciting Products " ,
19
+ "image" : "assets/images/splash_4 .png" ,
21
20
},
22
21
{
23
- "text" : "We help people connect with stores \n around the world! " ,
24
- "image" : "assets/images/splash_2 .png" ,
22
+ "text" : "Get Exclusive Deals " ,
23
+ "image" : "assets/images/splash_5 .png" ,
25
24
},
26
25
{
27
- "text" : "We show the easy way to shop. \n Just stay at home with us " ,
28
- "image" : "assets/images/splash_3 .png" ,
26
+ "text" : "Shop with Confidence " ,
27
+ "image" : "assets/images/splash_6 .png" ,
29
28
},
30
29
];
31
30
32
31
@override
33
32
void initState () {
34
33
super .initState ();
35
34
_preloadImages ();
36
- _pageController.addListener (() {
37
- setState (() {
38
- currentPage = _pageController.page! .round ();
39
- });
40
- });
41
-
42
- Timer .periodic (const Duration (seconds: 2 ),(timer){
43
- if (currentPage < splashData.length - 1 ){
44
- _pageController.nextPage (
45
- duration: kAnimationDuration,
46
- curve: Curves .easeInOut,
47
- );
48
- }else {
35
+ Timer .periodic (const Duration (seconds: 4 ), (timer) {
36
+ if (currentPage < splashData.length - 1 ) {
37
+ currentPage++ ;
38
+ } else {
49
39
timer.cancel ();
50
40
}
41
+ _pageController.animateToPage (
42
+ currentPage,
43
+ duration: kAnimationDuration,
44
+ curve: Curves .easeInOut,
45
+ );
51
46
});
52
47
}
53
- Future <void > _preloadImages () async {
54
- for (var splashItem in splashData){
48
+
49
+ Future <void > _preloadImages () async {
50
+ for (var splashItem in splashData) {
55
51
await precacheImage (AssetImage (splashItem["image" ]! ), context);
56
52
}
57
53
}
54
+
58
55
@override
59
56
Widget build (BuildContext context) {
60
- return SafeArea (
61
- child: Column (
62
- children: < Widget > [
63
- Expanded (
64
- flex: 3 ,
65
- child: PageView .builder (
66
- // physics: currentPage==0
67
- // ? NeverScrollableScrollPhysics()
68
- // : AlwaysScrollableScrollPhysics(),
69
- controller: _pageController,
70
- itemCount: splashData.length,
71
- itemBuilder: (context, index) => SplashContent (
72
- image: splashData[index]["image" ],
73
- text: splashData[index]['text' ],
57
+ return Container (
58
+ decoration: BoxDecoration (
59
+ color: kPrimaryColor,
60
+ ),
61
+ child: SafeArea (
62
+ child: Column (
63
+ children: < Widget > [
64
+ Expanded (
65
+ flex: 4 ,
66
+ child: PageView .builder (
67
+ controller: _pageController,
68
+ itemCount: splashData.length,
69
+ itemBuilder: (context, index) => SplashContent (
70
+ image: splashData[index]["image" ],
71
+ text: splashData[index]['text' ],
72
+ ),
74
73
),
75
74
),
76
- ),
77
- Expanded (
78
- flex : 2 ,
79
- child : Padding (
80
- padding : EdgeInsets . symmetric (horizontal : 20 ),
81
- child : Column (
82
- children : < Widget > [
83
- Spacer (),
84
- Row (
85
- mainAxisAlignment : MainAxisAlignment .center,
86
- children : List . generate (
87
- splashData.length ,
88
- (index) => buildDot (index : index ),
75
+ Expanded (
76
+ flex : 1 ,
77
+ child : Padding (
78
+ padding : EdgeInsets . symmetric (horizontal : 20 ),
79
+ child : Column (
80
+ children : < Widget > [
81
+ Spacer (),
82
+ Row (
83
+ mainAxisAlignment : MainAxisAlignment .center,
84
+ children : List . generate (
85
+ splashData.length,
86
+ (index) => buildDot (index : index) ,
87
+ ),
89
88
),
90
- ),
91
- Spacer (flex : 3 ),
92
- DefaultButton (
93
- text : "Continue" ,
94
- press : () {
95
- Navigator . pushNamed (context, SignInScreen .routeName);
96
- } ,
97
- ),
98
- Spacer () ,
99
- ] ,
89
+ Spacer (flex : 2 ),
90
+ DefaultButton (
91
+ text : "Get Started" ,
92
+ press : () {
93
+ Navigator . pushNamed (context, SignInScreen .routeName);
94
+ },
95
+ ) ,
96
+ Spacer ( ),
97
+ ] ,
98
+ ) ,
100
99
),
101
100
),
102
- ) ,
103
- ] ,
101
+ ] ,
102
+ ) ,
104
103
),
105
104
);
106
105
}
@@ -109,13 +108,12 @@ class _BodyState extends State<Body> {
109
108
return AnimatedContainer (
110
109
duration: kAnimationDuration,
111
110
margin: EdgeInsets .only (right: 5 ),
112
- height: 6 ,
113
- width: currentPage == index ? 20 : 6 ,
111
+ height: 10 ,
112
+ width: currentPage == index ? 20 : 10 ,
114
113
decoration: BoxDecoration (
115
- color: currentPage == index ? kPrimaryColor : Color (0xFFD8D8D8 ),
116
- borderRadius: BorderRadius .circular (3 ),
114
+ color: currentPage == index ? Colors .white : Color (0xFFD8D8D8 ),
115
+ borderRadius: BorderRadius .circular (5 ),
117
116
),
118
117
);
119
118
}
120
119
}
121
-
0 commit comments