forked from amatshiye/flutter_countries_assessment
/
about.dart
123 lines (118 loc) · 3.85 KB
/
about.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
import 'package:countries_info/images/images.dart';
import 'package:countries_info/theme/colors.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:url_launcher/url_launcher.dart' as urlLauncher;
class AboutPage extends StatelessWidget {
static const String _website = "https://palota.co.za";
static const String _email = "jobs@palota.co.za";
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
AppColors.blue,
AppColors.cyan,
AppColors.green,
],
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
AppImages.logoWhite,
width: MediaQuery.of(context).size.width * 0.5,
),
Text(
'This is a simple Flutter project prepared by Palota to be used for assessment purposes.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6.copyWith(
color: Colors.white,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 48,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24.0),
),
textColor: Colors.white,
color: AppColors.blue,
child: Text("Open Website"),
onPressed: () => _openWebsite(),
),
),
SizedBox(
height: 16,
),
SizedBox(
height: 48,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24.0),
),
child: Text("E-Mail Us"),
onPressed: () => _launchEmail(),
),
),
],
),
_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;
return Text(
"v${packageInfo.version} (${packageInfo.buildNumber})",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyText1.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
);
} else {
return SizedBox();
}
},
);
}
Future<bool> _openWebsite() async {
if (await urlLauncher.canLaunch(_website)) {
return urlLauncher.launch(_website);
} else {
return false;
}
}
Future<bool> _launchEmail() async {
final emailLink = "mailto:$_email";
if (await urlLauncher.canLaunch(emailLink)) {
return urlLauncher.launch(emailLink);
} else {
return false;
}
}
}