forked from md-siam/package_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onboarding.dart
121 lines (113 loc) · 3.38 KB
/
onboarding.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
import 'package:flutter/material.dart';
import 'package:onboarding/onboarding.dart';
import 'data.dart';
class MyOnboarding extends StatefulWidget {
const MyOnboarding({Key? key}) : super(key: key);
@override
State<MyOnboarding> createState() => _MyOnboardingState();
}
class _MyOnboardingState extends State<MyOnboarding> {
late int index;
late Material materialButton;
@override
void initState() {
super.initState();
materialButton = _skipButton();
index = 0;
}
Material _skipButton({void Function(int)? setIndex}) {
return Material(
borderRadius: defaultSkipButtonBorderRadius,
color: defaultSkipButtonColor,
child: InkWell(
borderRadius: defaultSkipButtonBorderRadius,
onTap: () {
if (setIndex != null) {
index = 2;
setIndex(2);
}
},
child: const Padding(
padding: defaultSkipButtonPadding,
child: Text(
'Skip',
style: defaultSkipButtonTextStyle,
),
),
),
);
}
Material get _signupButton {
return Material(
borderRadius: defaultProceedButtonBorderRadius,
color: defaultProceedButtonColor,
child: InkWell(
borderRadius: defaultProceedButtonBorderRadius,
onTap: () {},
child: const Padding(
padding: defaultProceedButtonPadding,
child: Text(
'Sign up',
style: defaultProceedButtonTextStyle,
),
),
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Onboarding',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
backgroundColor: background,
body: Onboarding(
pages: onboardingPagesList,
onPageChange: (int pageIndex) {
index = pageIndex;
},
startPageIndex: 0,
footerBuilder: (context, dragDistance, pagesLength, setIndex) {
return DecoratedBox(
decoration: BoxDecoration(
color: background,
border: Border.all(
width: 0.0,
color: background,
),
),
child: ColoredBox(
color: background,
child: Padding(
padding: const EdgeInsets.all(45.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomIndicator(
netDragPercent: dragDistance,
pagesLength: pagesLength,
indicator: Indicator(
indicatorDesign: IndicatorDesign.polygon(
polygonDesign: PolygonDesign(
polygon: DesignType.polygon_square,
polygonSpacer: 14.0),
),
)),
index == pagesLength - 1
? _signupButton
: _skipButton(setIndex: setIndex)
],
),
),
),
);
},
),
),
);
}
}