2023-03-22 11:38:18 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-11-16 00:24:40 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_md/brand_md.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:package_info/package_info.dart';
|
2021-03-18 07:26:54 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2022-12-31 06:04:25 +00:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
|
2023-03-22 11:38:18 +00:00
|
|
|
@RoutePage()
|
2022-10-03 23:32:35 +00:00
|
|
|
class AboutApplicationPage extends StatelessWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const AboutApplicationPage({super.key});
|
2020-12-02 09:16:23 +00:00
|
|
|
|
|
|
|
@override
|
2023-02-23 14:49:14 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final bool isReady = context.watch<ServerInstallationCubit>().state
|
|
|
|
is ServerInstallationFinished;
|
|
|
|
|
|
|
|
return BrandHeroScreen(
|
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
|
|
|
heroTitle: 'about_application_page.title'.tr(),
|
|
|
|
children: [
|
|
|
|
FutureBuilder(
|
|
|
|
future: _packageVersion(),
|
2023-03-27 17:02:44 +00:00
|
|
|
builder: (final context, final snapshot) => Text(
|
2023-02-23 14:49:14 +00:00
|
|
|
'about_application_page.application_version_text'
|
|
|
|
.tr(args: [snapshot.data.toString()]),
|
2023-03-27 17:02:44 +00:00
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
2023-02-23 14:49:14 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isReady)
|
|
|
|
FutureBuilder(
|
|
|
|
future: _apiVersion(),
|
2023-03-27 17:02:44 +00:00
|
|
|
builder: (final context, final snapshot) => Text(
|
2023-02-23 14:49:14 +00:00
|
|
|
'about_application_page.api_version_text'
|
|
|
|
.tr(args: [snapshot.data.toString()]),
|
2023-03-27 17:02:44 +00:00
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
2022-10-04 10:34:56 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
// Button to call showAboutDialog
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => showAboutDialog(
|
|
|
|
context: context,
|
|
|
|
applicationName: 'SelfPrivacy',
|
|
|
|
applicationLegalese: '© 2022 SelfPrivacy',
|
|
|
|
// Link to privacy policy
|
2022-06-05 22:40:34 +00:00
|
|
|
children: [
|
2022-12-31 06:04:25 +00:00
|
|
|
TextButton(
|
2023-02-23 14:49:14 +00:00
|
|
|
onPressed: () => launchUrl(
|
2023-05-15 09:22:06 +00:00
|
|
|
Uri.parse('https://selfprivacy.org/privacy-policy/'),
|
2023-02-23 14:49:14 +00:00
|
|
|
mode: LaunchMode.externalApplication,
|
2022-12-31 06:04:25 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
child: Text('about_application_page.privacy_policy'.tr()),
|
2022-12-31 06:04:25 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
],
|
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
child: const Text('Show about dialog'),
|
2020-12-02 09:16:23 +00:00
|
|
|
),
|
2023-02-23 14:49:14 +00:00
|
|
|
const SizedBox(height: 8),
|
|
|
|
const Divider(height: 0),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
const BrandMarkdown(
|
|
|
|
fileName: 'about',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2020-12-02 09:16:23 +00:00
|
|
|
|
2022-07-25 14:06:55 +00:00
|
|
|
Future<String> _packageVersion() async {
|
2022-06-09 04:36:22 +00:00
|
|
|
String packageVersion = 'unknown';
|
|
|
|
try {
|
|
|
|
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
packageVersion = packageInfo.version;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return packageVersion;
|
2020-12-02 09:16:23 +00:00
|
|
|
}
|
2022-07-25 14:06:55 +00:00
|
|
|
|
|
|
|
Future<String> _apiVersion() async {
|
|
|
|
String apiVersion = 'unknown';
|
|
|
|
try {
|
|
|
|
apiVersion = await ServerApi().getApiVersion() ?? apiVersion;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiVersion;
|
|
|
|
}
|
2020-12-02 09:16:23 +00:00
|
|
|
}
|