-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy path31.modern_onboarding_view.dart
133 lines (122 loc) · 4.36 KB
/
31.modern_onboarding_view.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../utils/colors.dart';
class ModernOnboardingNotifier extends ChangeNotifier {
int _currentPageIndex = 0;
int get currentPageIndex => _currentPageIndex;
void setPageIndex({required int newIndex}) {
_currentPageIndex = newIndex;
notifyListeners();
}
}
class ModernOnboardingView extends StatefulWidget {
const ModernOnboardingView({super.key});
@override
State<ModernOnboardingView> createState() => _ModernOnboardingViewState();
}
class _ModernOnboardingViewState extends State<ModernOnboardingView> {
ModernOnboardingNotifier modernOnboardingNotifier({required bool renderUI}) =>
Provider.of<ModernOnboardingNotifier>(context, listen: renderUI);
@override
Widget build(BuildContext context) {
int currentPageIndex =
modernOnboardingNotifier(renderUI: true).currentPageIndex;
Widget onboardingBlock({required Color color}) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 500,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25), color: color),
),
);
}
Widget dotIndicator() {
customDot({required int index}) {
bool isCurrentIndex = currentPageIndex == index;
return Padding(
padding: const EdgeInsets.only(right: 8),
child: CircleAvatar(
radius: isCurrentIndex ? 8 : 6,
backgroundColor: isCurrentIndex
? KConstantColors.blueColor
: KConstantColors.bgColorFaint,
),
);
}
return SizedBox(
width: 100,
height: 50,
child: ListView.builder(
itemCount: 5,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return customDot(index: index);
}),
);
}
return SafeArea(
child: Scaffold(
backgroundColor: KConstantColors.bgColor,
body: Container(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 500,
width: 500,
child: PageView(
onPageChanged: (index) {
modernOnboardingNotifier(renderUI: false)
.setPageIndex(newIndex: index);
},
children: [
onboardingBlock(color: KConstantColors.blueColor),
onboardingBlock(color: KConstantColors.redColor),
onboardingBlock(color: KConstantColors.purpleColor),
onboardingBlock(color: KConstantColors.bgColorFaint),
onboardingBlock(color: KConstantColors.whiteColor),
],
),
),
SizedBox(height: 5),
dotIndicator(),
SizedBox(height: 5),
Text("Welcome back",
style: KConstantTextstyles.bold(fontSize: 46)),
Text("You've been missed here!",
style: KConstantTextstyles.light(fontSize: 16)),
SizedBox(height: 30),
Container(
height: 50,
width: 400,
child: Center(
child: Text("Continue",
style: KConstantTextstyles.bold(fontSize: 16))),
decoration: BoxDecoration(
color: KConstantColors.blueColor,
borderRadius: BorderRadius.circular(25)),
),
SizedBox(height: 10),
Container(
height: 50,
width: 300,
child: Center(
child: Text("Take a tour",
style: KConstantTextstyles.bold(fontSize: 16))),
decoration: BoxDecoration(
color: KConstantColors.purpleColor,
borderRadius: BorderRadius.circular(25)),
)
],
),
),
),
),
);
}
}