From 90aca5132afcd9dcbebafbe47784d0c2bf1bce30 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 30 Apr 2021 18:55:45 +0200 Subject: [PATCH] Create new settings section --- lib/ui/routes/settings/about_settings.dart | 45 +++++++++++++++++++ .../settings/account_settings_route.dart | 11 ++++- .../routes/settings/application_settings.dart | 29 ------------ 3 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 lib/ui/routes/settings/about_settings.dart diff --git a/lib/ui/routes/settings/about_settings.dart b/lib/ui/routes/settings/about_settings.dart new file mode 100644 index 0000000..b96c79b --- /dev/null +++ b/lib/ui/routes/settings/about_settings.dart @@ -0,0 +1,45 @@ +import 'package:comunic/helpers/server_config_helper.dart'; +import 'package:comunic/ui/widgets/copy_icon.dart'; +import 'package:comunic/utils/flutter_utils.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:comunic/utils/ui_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:settings_ui/settings_ui.dart'; +import 'package:url_launcher/url_launcher.dart'; + +/// About application settings +/// +/// @author Pierre Hubert + +class AboutApplicationSettings extends StatelessWidget { + @override + Widget build(BuildContext context) => SettingsList( + sections: [ + _buildGeneralSection(context), + ], + ); + + /// General section + SettingsSection _buildGeneralSection(BuildContext context) => SettingsSection( + tiles: [ + SettingsTile( + title: tr("Privacy policy"), + onPressed: (c) => launch(srvConfig.privacyPolicyURL), + ), + SettingsTile( + title: tr("Terms of Use"), + onPressed: (c) => launch(srvConfig.termsURL), + ), + SettingsTile( + title: tr("Contact us"), + subtitle: srvConfig.contactEmail, + trailing: CopyIcon(srvConfig.contactEmail), + ), + SettingsTile( + title: tr("About this application"), + subtitle: isIOS ? null : tr("Learn more about us"), + onPressed: (_) => showAboutAppDialog(context), + ) + ], + ); +} diff --git a/lib/ui/routes/settings/account_settings_route.dart b/lib/ui/routes/settings/account_settings_route.dart index 6719047..0f5ded7 100644 --- a/lib/ui/routes/settings/account_settings_route.dart +++ b/lib/ui/routes/settings/account_settings_route.dart @@ -1,3 +1,4 @@ +import 'package:comunic/ui/routes/settings/about_settings.dart'; import 'package:comunic/ui/routes/settings/account_image_settings.dart'; import 'package:comunic/ui/routes/settings/account_privacy_settings.dart'; import 'package:comunic/ui/routes/settings/account_security_settings.dart'; @@ -132,13 +133,21 @@ class __AccountSettingsBodyState extends State<_AccountSettingsBody> { onBuild: () => AccountPrivacySettings(), ), - // Privacy settings + // Application settings _SettingsSection( title: tr("Application settings"), subtitle: tr("Manage local application settings"), icon: Icons.smartphone, onBuild: () => ApplicationSettings(), ), + + // About settings + _SettingsSection( + title: tr("About this application"), + subtitle: tr("Learn more about us"), + icon: Icons.info, + onBuild: () => AboutApplicationSettings(), + ), ]; @override diff --git a/lib/ui/routes/settings/application_settings.dart b/lib/ui/routes/settings/application_settings.dart index 036a579..20e5f0f 100644 --- a/lib/ui/routes/settings/application_settings.dart +++ b/lib/ui/routes/settings/application_settings.dart @@ -1,14 +1,11 @@ import 'package:comunic/helpers/preferences_helper.dart'; -import 'package:comunic/helpers/server_config_helper.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; -import 'package:comunic/ui/widgets/copy_icon.dart'; import 'package:comunic/ui/widgets/settings/header_spacer_section.dart'; import 'package:comunic/utils/flutter_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; import 'package:flutter/material.dart'; import 'package:settings_ui/settings_ui.dart'; -import 'package:url_launcher/url_launcher.dart'; /// Application settings /// @@ -37,7 +34,6 @@ class _ApplicationSettingsState extends State { sections: [ HeadSpacerSection(), _buildAppearanceSection(), - _buildGeneralSection(), _buildDebugSection() ], ); @@ -57,31 +53,6 @@ class _ApplicationSettingsState extends State { ], ); - /// General section - SettingsSection _buildGeneralSection() => SettingsSection( - title: tr("General"), - tiles: [ - SettingsTile( - title: tr("Privacy policy"), - onPressed: (c) => launch(srvConfig.privacyPolicyURL), - ), - SettingsTile( - title: tr("Terms of Use"), - onPressed: (c) => launch(srvConfig.termsURL), - ), - SettingsTile( - title: tr("Contact us"), - subtitle: srvConfig.contactEmail, - trailing: CopyIcon(srvConfig.contactEmail), - ), - SettingsTile( - title: tr("About this application"), - subtitle: isIOS ? null : tr("Learn more about us"), - onPressed: (_) => showAboutAppDialog(context), - ) - ], - ); - /// Debug section SettingsSection _buildDebugSection() => SettingsSection( title: tr("Debug features"),