1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Improve account image settings

This commit is contained in:
Pierre HUBERT 2021-02-12 22:45:17 +01:00
parent 52cc8407d5
commit 24765789df
3 changed files with 36 additions and 51 deletions

View File

@ -414,7 +414,7 @@
"You can choose a new password.": "Vous pouvez choisir un nouveau mot de passe.", "You can choose a new password.": "Vous pouvez choisir un nouveau mot de passe.",
"You can reach us at contact@communiquons.org": "Vous pouvez nous contacter à l'adresse contact@communiquons.org", "You can reach us at contact@communiquons.org": "Vous pouvez nous contacter à l'adresse contact@communiquons.org",
"You can use this virtual directory.": "Vous pouvez utiliser ce répertoire virtuel.", "You can use this virtual directory.": "Vous pouvez utiliser ce répertoire virtuel.",
"You do not have any notification now.": "Vous n'avez pas de notifications pour l'intant.", "You do not have any notification now.": "Vous n'avez pas de notification pour l'intant.",
"You do not have any unread conversation yet...": "Vous n'avez aucune conversation non lue pour le moment...", "You do not have any unread conversation yet...": "Vous n'avez aucune conversation non lue pour le moment...",
"You must accept the Terms Of Service to continue.": "Vous devez accepter les Conditions d'utilisation pour continuer.", "You must accept the Terms Of Service to continue.": "Vous devez accepter les Conditions d'utilisation pour continuer.",
"You security questions have been successfully updated!": "Vos questions de sécurité ont été mises avec succès !", "You security questions have been successfully updated!": "Vos questions de sécurité ont été mises avec succès !",

View File

@ -1,9 +1,11 @@
import 'package:comunic/helpers/database/users_database_helper.dart'; import 'package:comunic/helpers/database/users_database_helper.dart';
import 'package:comunic/helpers/settings_helper.dart'; import 'package:comunic/helpers/settings_helper.dart';
import 'package:comunic/models/account_image_settings.dart'; import 'package:comunic/models/account_image_settings.dart';
import 'package:comunic/ui/dialogs/multi_choices_dialog.dart';
import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/ui/widgets/network_image_widget.dart'; import 'package:comunic/ui/widgets/network_image_widget.dart';
import 'package:comunic/ui/widgets/settings/header_spacer_section.dart'; import 'package:comunic/ui/widgets/settings/header_spacer_section.dart';
import 'package:comunic/ui/widgets/settings/multi_choices_settings_tile.dart';
import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/account_utils.dart';
import 'package:comunic/utils/files_utils.dart'; import 'package:comunic/utils/files_utils.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
@ -87,6 +89,27 @@ class _AccountImageSettingsScreenState
]; ];
} }
List<MultiChoiceEntry<AccountImageVisibilityLevels>> get _visibilityLevels =>
[
MultiChoiceEntry(
id: AccountImageVisibilityLevels.EVERYONE,
title: tr("Everyone"),
subtitle: tr(
"Your account image is visible by everyone, including users external to Comunic."),
),
MultiChoiceEntry(
id: AccountImageVisibilityLevels.COMUNIC_USERS,
title: tr("Connected users"),
subtitle: tr(
"Your account image is visible only to connected Comunic users."),
),
MultiChoiceEntry(
id: AccountImageVisibilityLevels.FRIENDS_ONLY,
title: tr("My friends"),
subtitle: tr("Your account image is visible only by your friends."),
),
];
/// When the user has an account image /// When the user has an account image
List<SettingsTile> _buildHasAccountImageTiles() { List<SettingsTile> _buildHasAccountImageTiles() {
return [ return [
@ -112,18 +135,16 @@ class _AccountImageSettingsScreenState
), ),
// Change account image visibility // Change account image visibility
SettingsTile( MultiChoicesSettingsTile(
title: tr("Change account image visibility"), title: tr("Account image visibility"),
onPressed: (_) => _chooseAccountImageVisibility(), choices: _visibilityLevels,
subtitle: tr("Current level: %level%", args: { currentValue: _settings.visibility,
"level": onChanged: (newLevel) async {
_settings.visibility == AccountImageVisibilityLevels.EVERYONE if (!await SettingsHelper.setAccountImageVisibilityLevel(newLevel))
? tr("Everyone") showSimpleSnack(context,
: _settings.visibility == tr("Could not update account image visibility level!"));
AccountImageVisibilityLevels.COMUNIC_USERS _key.currentState.refresh();
? tr("Comunic users") }),
: tr("My friends only"),
})),
// Delete account image // Delete account image
SettingsTile( SettingsTile(
@ -161,44 +182,6 @@ class _AccountImageSettingsScreenState
_key.currentState.refresh(); _key.currentState.refresh();
} }
/// Change account image visibility
void _chooseAccountImageVisibility() async {
final newLevel = await showDialog<AccountImageVisibilityLevels>(
context: context,
builder: (c) => AlertDialog(
title: Text(tr("Account image visiblity")),
content:
Text(tr("Please choose new account image visibility level:")),
actions: <Widget>[
MaterialButton(
child: Text(tr("Everyone")),
onPressed: () =>
Navigator.pop(c, AccountImageVisibilityLevels.EVERYONE),
),
MaterialButton(
child: Text(tr("Connected users")),
onPressed: () => Navigator.pop(
c, AccountImageVisibilityLevels.COMUNIC_USERS),
),
MaterialButton(
child: Text(tr("My friends")),
onPressed: () => Navigator.pop(
c, AccountImageVisibilityLevels.FRIENDS_ONLY),
)
],
));
if (newLevel == null) return;
if (!await SettingsHelper.setAccountImageVisibilityLevel(newLevel)) {
showSimpleSnack(
context, tr("Could not update account image visibility level!"));
return;
}
_key.currentState.refresh();
}
/// Delete user account image /// Delete user account image
void _deleteAccountImage() async { void _deleteAccountImage() async {
if (!await showConfirmDialog( if (!await showConfirmDialog(

View File

@ -11,6 +11,7 @@ import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
import 'package:comunic/ui/widgets/group_icon_widget.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart';
import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/ui/widgets/settings/header_spacer_section.dart';
import 'package:comunic/ui/widgets/settings/multi_choices_settings_tile.dart'; import 'package:comunic/ui/widgets/settings/multi_choices_settings_tile.dart';
import 'package:comunic/ui/widgets/settings/text_settings_edit_tile.dart'; import 'package:comunic/ui/widgets/settings/text_settings_edit_tile.dart';
import 'package:comunic/utils/files_utils.dart'; import 'package:comunic/utils/files_utils.dart';
@ -81,6 +82,7 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
Widget _buildContent() { Widget _buildContent() {
return SettingsList( return SettingsList(
sections: [ sections: [
HeadSpacerSection(),
_buildGeneralSection(), _buildGeneralSection(),
_buildAccessRestrictions(), _buildAccessRestrictions(),
_buildGroupLogoArea(), _buildGroupLogoArea(),