1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 06:19:22 +00:00

Create new settings section

This commit is contained in:
Pierre HUBERT 2021-04-30 18:55:45 +02:00
parent 3c8bdd380f
commit 90aca5132a
3 changed files with 55 additions and 30 deletions

View File

@ -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),
)
],
);
}

View File

@ -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

View File

@ -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<ApplicationSettings> {
sections: [
HeadSpacerSection(),
_buildAppearanceSection(),
_buildGeneralSection(),
_buildDebugSection()
],
);
@ -57,31 +53,6 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
],
);
/// 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"),