Skip to content

Commit 584ee1e

Browse files
committedDec 7, 2023
update splash screen redesign
1 parent 95f061c commit 584ee1e

File tree

1 file changed

+64
-66
lines changed

1 file changed

+64
-66
lines changed
 

‎lib/screens/splash/components/body.dart

+64-66
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:async';
22
import 'package:flutter/material.dart';
33
import 'package:shop_app/constants.dart';
44
import 'package:shop_app/screens/sign_in/sign_in_screen.dart';
5-
import 'package:shop_app/size_config.dart';
65
import '../components/splash_content.dart';
76
import '../../../components/default_button.dart';
87

@@ -16,91 +15,91 @@ class _BodyState extends State<Body> {
1615
final PageController _pageController = PageController();
1716
List<Map<String, String>> splashData = [
1817
{
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",
2120
},
2221
{
23-
"text": "We help people connect with stores \naround the world!",
24-
"image": "assets/images/splash_2.png",
22+
"text": "Get Exclusive Deals",
23+
"image": "assets/images/splash_5.png",
2524
},
2625
{
27-
"text": "We show the easy way to shop. \nJust stay at home with us",
28-
"image": "assets/images/splash_3.png",
26+
"text": "Shop with Confidence",
27+
"image": "assets/images/splash_6.png",
2928
},
3029
];
3130

3231
@override
3332
void initState() {
3433
super.initState();
3534
_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 {
4939
timer.cancel();
5040
}
41+
_pageController.animateToPage(
42+
currentPage,
43+
duration: kAnimationDuration,
44+
curve: Curves.easeInOut,
45+
);
5146
});
5247
}
53-
Future<void> _preloadImages() async{
54-
for(var splashItem in splashData){
48+
49+
Future<void> _preloadImages() async {
50+
for (var splashItem in splashData) {
5551
await precacheImage(AssetImage(splashItem["image"]!), context);
5652
}
5753
}
54+
5855
@override
5956
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+
),
7473
),
7574
),
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+
),
8988
),
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+
),
10099
),
101100
),
102-
),
103-
],
101+
],
102+
),
104103
),
105104
);
106105
}
@@ -109,13 +108,12 @@ class _BodyState extends State<Body> {
109108
return AnimatedContainer(
110109
duration: kAnimationDuration,
111110
margin: EdgeInsets.only(right: 5),
112-
height: 6,
113-
width: currentPage == index ? 20 : 6,
111+
height: 10,
112+
width: currentPage == index ? 20 : 10,
114113
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),
117116
),
118117
);
119118
}
120119
}
121-

0 commit comments

Comments
 (0)
Please sign in to comment.