-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout.dart
More file actions
175 lines (164 loc) · 5.81 KB
/
about.dart
File metadata and controls
175 lines (164 loc) · 5.81 KB
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
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_spotify_africa_assessment/colors.dart';
import 'package:flutter_spotify_africa_assessment/features/about/presentation/components/animated_gradient_hero.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart' as url_launcher;
class AboutPage extends StatefulWidget {
static const String _website = "https://palota.co.za";
static const String _email = "jobs@palota.co.za";
static const String _spotifyTerms =
"https://www.spotify.com/us/legal/end-user-agreement/";
const AboutPage({Key? key}) : super(key: key);
@override
State<AboutPage> createState() => _AboutPageState();
}
class _AboutPageState extends State<AboutPage>
with SingleTickerProviderStateMixin {
late Animation<double> animation;
late AnimationController controller;
@override
void initState() {
super.initState();
controller =
AnimationController(duration: const Duration(seconds: 60), vsync: this);
animation = Tween<double>(begin: 0, end: 2 * pi).animate(controller);
controller.repeat();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
pinned: true,
snap: false,
floating: false,
expandedHeight: MediaQuery.of(context).size.width * 0.75,
flexibleSpace: FlexibleSpaceBar(
background: AnimatedGradientHero(
animation: animation,
),
),
),
SliverPadding(
padding: const EdgeInsets.only(
bottom: 16,
left: 32,
right: 32,
),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed([
Padding(
padding: const EdgeInsets.symmetric(
vertical: 24,
),
child: Text(
'This is a simple Flutter project prepared by Palota to be used for assessment purposes.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.normal, color: Colors.white60),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 16,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
OutlinedButton(
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.cyan,
),
onPressed: () =>
_openUrl(Uri.parse(AboutPage._website)),
child: const Text("Open Website"),
),
const SizedBox(
height: 8,
),
OutlinedButton(
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
),
onPressed: () => _launchEmail(),
child: const Text("E-Mail Us"),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 24,
),
child: Column(
children: [
Text(
"Music playlist and category data in this assessment belongs to Spotify and is used under Spotify's terms and conditions",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodySmall,
),
TextButton(
onPressed: () =>
_openUrl(Uri.parse(AboutPage._spotifyTerms)),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
),
child: Text(
"Spotify Terms and Conditions",
style: Theme.of(context).textTheme.bodyMedium,
),
)
],
),
),
_buildVersionText(context),
]),
),
),
],
),
);
}
Widget _buildVersionText(BuildContext context) {
return FutureBuilder(
future: PackageInfo.fromPlatform(),
builder: (BuildContext ctx, AsyncSnapshot<PackageInfo> snapshot) {
if (snapshot.hasData) {
final PackageInfo packageInfo = snapshot.data as PackageInfo;
return Text(
"v${packageInfo.version} (${packageInfo.buildNumber})",
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(fontWeight: FontWeight.bold, color: Colors.grey),
);
} else {
return const SizedBox();
}
},
);
}
Future<bool> _openUrl(Uri url) async {
if (await url_launcher.canLaunchUrl(url)) {
return url_launcher.launchUrl(url);
} else {
return false;
}
}
Future<bool> _launchEmail() async {
Uri emailLink = Uri.parse("mailto:${AboutPage._email}");
if (await url_launcher.canLaunchUrl(emailLink)) {
return url_launcher.canLaunchUrl(emailLink);
} else {
return false;
}
}
}