2022-03-25 14:23:14 +03:00
|
|
|
import 'dart:convert';
|
2022-06-05 17:33:17 +03:00
|
|
|
import 'dart:io';
|
2021-11-24 13:38:30 +03:00
|
|
|
|
2021-11-19 17:05:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2022-03-25 14:23:14 +03:00
|
|
|
import 'package:flutter/services.dart';
|
2022-09-07 14:59:44 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2021-11-24 13:38:30 +03:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
2022-06-05 13:26:40 +03:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2021-11-25 13:56:25 +03:00
|
|
|
|
2022-03-25 14:23:14 +03:00
|
|
|
import 'app/logging.dart';
|
2022-03-25 17:43:32 +03:00
|
|
|
import 'app/message.dart';
|
2022-08-04 09:23:07 +03:00
|
|
|
import 'app/state.dart';
|
2021-11-25 13:56:25 +03:00
|
|
|
import 'core/state.dart';
|
2022-01-27 14:34:29 +03:00
|
|
|
import 'desktop/state.dart';
|
2022-08-04 09:23:07 +03:00
|
|
|
import 'version.dart';
|
2022-03-31 12:50:40 +03:00
|
|
|
import 'widgets/responsive_dialog.dart';
|
2022-09-01 15:00:33 +03:00
|
|
|
import 'widgets/choice_filter_chip.dart';
|
2021-11-24 13:38:30 +03:00
|
|
|
|
2022-02-21 11:38:09 +03:00
|
|
|
final _log = Logger('about');
|
2021-11-19 17:05:57 +03:00
|
|
|
|
2021-11-24 13:38:30 +03:00
|
|
|
class AboutPage extends ConsumerWidget {
|
2022-05-12 10:56:55 +03:00
|
|
|
const AboutPage({super.key});
|
2021-11-19 17:05:57 +03:00
|
|
|
|
|
|
|
@override
|
2021-11-24 13:38:30 +03:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-03-15 20:04:26 +03:00
|
|
|
return ResponsiveDialog(
|
2022-06-02 15:53:29 +03:00
|
|
|
title: const Text('About'),
|
2022-03-15 20:04:26 +03:00
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2022-06-02 15:53:29 +03:00
|
|
|
Image.asset('assets/graphics/app-icon.png', scale: 1 / 0.75),
|
|
|
|
Padding(
|
2022-06-05 17:33:17 +03:00
|
|
|
padding: const EdgeInsets.only(top: 24.0),
|
2022-06-02 15:53:29 +03:00
|
|
|
child: Text(
|
2022-08-04 09:23:07 +03:00
|
|
|
Platform.isAndroid
|
|
|
|
? 'Yubico Authenticator Preview'
|
|
|
|
: 'Yubico Authenticator',
|
2022-06-02 15:53:29 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
2022-06-05 17:33:17 +03:00
|
|
|
const Text(version),
|
|
|
|
const Text(''),
|
2022-06-02 15:53:29 +03:00
|
|
|
const Text('Copyright © 2022 Yubico'),
|
|
|
|
const Text('All rights reserved'),
|
|
|
|
const Text(''),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2022-06-05 13:26:40 +03:00
|
|
|
children: [
|
2022-06-05 17:33:17 +03:00
|
|
|
TextButton(
|
2022-09-07 14:59:44 +03:00
|
|
|
child: Text(
|
|
|
|
AppLocalizations.of(context)!.general_terms_of_use,
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
launchUrl(
|
|
|
|
Uri.parse(
|
|
|
|
'https://www.yubico.com/support/terms-conditions/yubico-license-agreement/'),
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
2022-06-03 17:45:02 +03:00
|
|
|
),
|
2022-06-05 17:33:17 +03:00
|
|
|
TextButton(
|
2022-09-07 14:59:44 +03:00
|
|
|
child: Text(
|
|
|
|
AppLocalizations.of(context)!.general_privacy_policy,
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
launchUrl(
|
|
|
|
Uri.parse(
|
|
|
|
'https://www.yubico.com/support/terms-conditions/privacy-notice/'),
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
2022-06-03 17:45:02 +03:00
|
|
|
),
|
2022-06-02 15:53:29 +03:00
|
|
|
],
|
|
|
|
),
|
2022-06-05 17:33:17 +03:00
|
|
|
TextButton(
|
2022-09-07 14:59:44 +03:00
|
|
|
child: Text(
|
|
|
|
AppLocalizations.of(context)!.general_open_src_licenses,
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
|
|
|
onPressed: () {
|
2022-06-10 17:02:07 +03:00
|
|
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
|
|
|
builder: (BuildContext context) => const LicensePage(
|
|
|
|
applicationVersion: version,
|
|
|
|
),
|
|
|
|
settings: const RouteSettings(name: 'licenses'),
|
|
|
|
));
|
2022-06-05 17:33:17 +03:00
|
|
|
},
|
|
|
|
),
|
2022-06-02 15:53:29 +03:00
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 24.0, bottom: 8.0),
|
|
|
|
child: Divider(),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
child: Text(
|
2022-09-07 14:59:44 +03:00
|
|
|
AppLocalizations.of(context)!.general_help_and_feedback,
|
2022-06-02 15:53:29 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2022-06-05 13:26:40 +03:00
|
|
|
children: [
|
2022-06-05 17:33:17 +03:00
|
|
|
TextButton(
|
2022-09-07 14:59:44 +03:00
|
|
|
child: Text(
|
|
|
|
AppLocalizations.of(context)!.general_send_feedback,
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
launchUrl(
|
2022-06-10 15:38:41 +03:00
|
|
|
Uri.parse('https://forms.gle/nYPVWcFnqoprZX1S9'),
|
2022-06-05 17:33:17 +03:00
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
2022-06-03 17:45:02 +03:00
|
|
|
),
|
2022-06-05 17:33:17 +03:00
|
|
|
TextButton(
|
2022-09-07 14:59:44 +03:00
|
|
|
child: Text(
|
|
|
|
AppLocalizations.of(context)!.general_i_need_help,
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
launchUrl(
|
|
|
|
Uri.parse('https://support.yubico.com/support/home'),
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
2022-06-05 13:26:40 +03:00
|
|
|
),
|
2022-06-02 15:53:29 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 24.0, bottom: 8.0),
|
|
|
|
child: Divider(),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
child: Text(
|
2022-09-08 12:42:40 +03:00
|
|
|
AppLocalizations.of(context)!.general_troubleshooting,
|
2022-06-02 15:53:29 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
2022-03-25 14:23:14 +03:00
|
|
|
const LoggingPanel(),
|
|
|
|
if (isDesktop) ...[
|
2022-06-02 15:53:29 +03:00
|
|
|
const SizedBox(height: 12.0),
|
2022-09-01 15:00:33 +03:00
|
|
|
ActionChip(
|
|
|
|
avatar: const Icon(Icons.bug_report_outlined),
|
2022-09-08 12:42:40 +03:00
|
|
|
label:
|
|
|
|
Text(AppLocalizations.of(context)!.general_run_diagnostics),
|
2022-03-15 20:04:26 +03:00
|
|
|
onPressed: () async {
|
|
|
|
_log.info('Running diagnostics...');
|
|
|
|
final response =
|
|
|
|
await ref.read(rpcProvider).command('diagnose', []);
|
2022-05-17 10:10:23 +03:00
|
|
|
final data = response['diagnostics'] as List;
|
2022-06-05 17:33:17 +03:00
|
|
|
data.insert(0, {
|
|
|
|
'app_version': version,
|
|
|
|
'dart': Platform.version,
|
|
|
|
});
|
2022-03-25 14:23:14 +03:00
|
|
|
final text = const JsonEncoder.withIndent(' ').convert(data);
|
|
|
|
await Clipboard.setData(ClipboardData(text: text));
|
2022-05-12 09:34:51 +03:00
|
|
|
await ref.read(withContextProvider)(
|
|
|
|
(context) async {
|
2022-09-08 12:42:40 +03:00
|
|
|
showMessage(
|
|
|
|
context,
|
|
|
|
AppLocalizations.of(context)!
|
|
|
|
.general_diagnostics_copied);
|
2022-05-12 09:34:51 +03:00
|
|
|
},
|
|
|
|
);
|
2022-03-15 20:04:26 +03:00
|
|
|
},
|
|
|
|
),
|
2022-03-25 14:23:14 +03:00
|
|
|
]
|
2022-03-15 20:04:26 +03:00
|
|
|
],
|
2021-11-19 17:05:57 +03:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-03-25 14:23:14 +03:00
|
|
|
|
|
|
|
class LoggingPanel extends ConsumerWidget {
|
2022-05-12 10:56:55 +03:00
|
|
|
const LoggingPanel({super.key});
|
2022-03-25 14:23:14 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-09-01 15:00:33 +03:00
|
|
|
final logLevel = ref.watch(logLevelProvider);
|
|
|
|
return Wrap(
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
spacing: 4.0,
|
|
|
|
runSpacing: 8.0,
|
2022-03-25 14:23:14 +03:00
|
|
|
children: [
|
2022-09-01 15:00:33 +03:00
|
|
|
ChoiceFilterChip<Level>(
|
|
|
|
avatar: Icon(
|
|
|
|
Icons.insights,
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-06-02 15:53:29 +03:00
|
|
|
),
|
2022-09-01 15:00:33 +03:00
|
|
|
value: logLevel,
|
|
|
|
items: Levels.LEVELS,
|
|
|
|
selected: logLevel != Level.INFO,
|
|
|
|
labelBuilder: (value) => Text(
|
2022-09-08 12:42:40 +03:00
|
|
|
'${AppLocalizations.of(context)!.general_log_level}: ${value.name[0]}${value.name.substring(1).toLowerCase()}'),
|
2022-09-01 15:00:33 +03:00
|
|
|
itemBuilder: (value) =>
|
|
|
|
Text('${value.name[0]}${value.name.substring(1).toLowerCase()}'),
|
2022-03-25 14:23:14 +03:00
|
|
|
onChanged: (level) {
|
2022-09-01 15:00:33 +03:00
|
|
|
ref.read(logLevelProvider.notifier).setLogLevel(level);
|
2022-05-03 12:24:25 +03:00
|
|
|
_log.debug('Log level set to $level');
|
2022-09-08 12:42:40 +03:00
|
|
|
showMessage(context,
|
|
|
|
'${AppLocalizations.of(context)!.general_log_level_set_to} $level');
|
2022-03-25 14:23:14 +03:00
|
|
|
},
|
|
|
|
),
|
2022-09-01 15:00:33 +03:00
|
|
|
ActionChip(
|
|
|
|
avatar: const Icon(Icons.copy),
|
2022-09-08 12:42:40 +03:00
|
|
|
label: Text(AppLocalizations.of(context)!.general_copy_log),
|
2022-03-25 14:23:14 +03:00
|
|
|
onPressed: () async {
|
2022-05-17 10:10:23 +03:00
|
|
|
_log.info('Copying log to clipboard ($version)...');
|
2022-05-11 16:47:35 +03:00
|
|
|
final logs = await ref.read(logLevelProvider.notifier).getLogs();
|
|
|
|
await Clipboard.setData(ClipboardData(text: logs.join('\n')));
|
2022-05-12 09:34:51 +03:00
|
|
|
await ref.read(withContextProvider)(
|
|
|
|
(context) async {
|
2022-09-08 12:42:40 +03:00
|
|
|
showMessage(
|
|
|
|
context, AppLocalizations.of(context)!.general_log_copied);
|
2022-05-12 09:34:51 +03:00
|
|
|
},
|
|
|
|
);
|
2022-03-25 14:23:14 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|