-
Notifications
You must be signed in to change notification settings - Fork 0
/
OnBoardingPage.dart
203 lines (194 loc) · 6.27 KB
/
OnBoardingPage.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:introduction_screen/introduction_screen.dart';
class OnBoardingPage extends StatefulWidget {
@override
_OnBoardingPageState createState() => _OnBoardingPageState();
}
class _OnBoardingPageState extends State<OnBoardingPage> {
final introKey = GlobalKey<IntroductionScreenState>();
void _onIntroEnd(context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DrawerHome(),
),
);
/*Navigator.of(context).push(
MaterialPageRoute(builder: (_) => HomePage()),
);*/
}
Widget _buildFullscreenImage() {
return Image.asset(
'assets/rafiki_01search.jpg',
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
);
}
Widget _buildImage(String assetName, [double width = 350]) {
return Image.asset('assets/pics/$assetName', width: width);
}
@override
Widget build(BuildContext context) {
const bodyStyle = TextStyle(fontSize: 19.0);
const pageDecoration = PageDecoration(
titleTextStyle: TextStyle(fontSize: 28.0, fontWeight: FontWeight.w700),
bodyTextStyle: bodyStyle,
bodyPadding: EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0),
pageColor: Colors.white,
imagePadding: EdgeInsets.zero,
);
return IntroductionScreen(
key: introKey,
globalBackgroundColor: Colors.white,
globalHeader: Align(
alignment: Alignment.topRight,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.only(top: 16, right: 16),
child: _buildImage('flutter.png', 100),
),
),
),
/*globalFooter: SizedBox(
width: double.infinity,
height: 60,
child: ElevatedButton(
child: const Text(
'Let\'s go right away!',
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
),
onPressed: () => _onIntroEnd(context),
),
),*/
pages: [
PageViewModel(
title: "Fractional shares",
body:
"Instead of having to buy an entire share, invest any amount you want.",
image: _buildImage('rafiki_01search.png'),
decoration: pageDecoration,
),
PageViewModel(
title: "Learn as you go",
body:
"Download the Stockpile app and master the market with our mini-lesson.",
image: _buildImage('rafiki_02park.png'),
decoration: pageDecoration,
),
PageViewModel(
title: "Kids and teens",
body:
"Kids and teens can track their stocks 24/7 and place trades that you approve.",
image: _buildImage('rafiki_03start.png'),
decoration: pageDecoration,
),
PageViewModel(
title: "Full Screen Page",
body:
"Pages can be full screen as well.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc id euismod lectus, non tempor felis. Nam rutrum rhoncus est ac venenatis.",
image: _buildFullscreenImage(),
decoration: pageDecoration.copyWith(
contentMargin: const EdgeInsets.symmetric(horizontal: 16),
fullScreen: true,
bodyFlex: 2,
imageFlex: 3,
),
),
PageViewModel(
title: "Another title page",
body: "Another beautiful body text for this example onboarding",
image: _buildImage('img2.jpg'),
footer: ElevatedButton(
onPressed: () {
introKey.currentState?.animateScroll(0);
},
child: const Text(
'FooButton',
style: TextStyle(color: Colors.white),
),
style: ElevatedButton.styleFrom(
primary: green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
decoration: pageDecoration,
),
PageViewModel(
title: "Title of last page - reversed",
bodyWidget: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text("Click on ", style: bodyStyle),
Icon(Icons.edit),
Text(" to edit a post", style: bodyStyle),
],
),
decoration: pageDecoration.copyWith(
bodyFlex: 2,
imageFlex: 4,
bodyAlignment: Alignment.bottomCenter,
imageAlignment: Alignment.topCenter,
),
image: _buildImage('img1.jpg'),
reverse: true,
),
],
onDone: () => _onIntroEnd(context),
//onSkip: () => _onIntroEnd(context), // You can override onSkip callback
showSkipButton: false,
skipOrBackFlex: 0,
nextFlex: 0,
showBackButton: true,
//rtl: true, // Display as right-to-left
back: const Icon(
Icons.chevron_left_rounded,
color: active,
),
skip: const Text(
'Skip',
style: TextStyle(fontWeight: FontWeight.w600, color: active),
),
next: const Icon(
Icons.chevron_right_rounded,
color: active,
),
done: const Text(
'Fertig',
style: TextStyle(fontWeight: FontWeight.w600, color: active),
),
curve: Curves.fastLinearToSlowEaseIn,
controlsMargin: const EdgeInsets.all(20),
controlsPadding: kIsWeb
? const EdgeInsets.all(12.0)
: const EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 4.0),
dotsDecorator: const DotsDecorator(
size: Size(10.0, 10.0),
color: grey200,
activeSize: Size(22.0, 10.0),
activeColor: active,
activeShape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(25.0)),
),
),
dotsContainerDecorator: ShapeDecoration(
color: white, //Colors.black87,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
shadows: <BoxShadow>[
BoxShadow(
color: black.withOpacity(0.15),
blurRadius: 20,
),
],
),
);
}
}