mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-26 04:48:51 +00:00
Improve account image settings
This commit is contained in:
parent
52cc8407d5
commit
24765789df
@ -414,7 +414,7 @@
|
||||
"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 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 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 !",
|
||||
|
@ -1,9 +1,11 @@
|
||||
import 'package:comunic/helpers/database/users_database_helper.dart';
|
||||
import 'package:comunic/helpers/settings_helper.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/network_image_widget.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/files_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
|
||||
List<SettingsTile> _buildHasAccountImageTiles() {
|
||||
return [
|
||||
@ -112,18 +135,16 @@ class _AccountImageSettingsScreenState
|
||||
),
|
||||
|
||||
// Change account image visibility
|
||||
SettingsTile(
|
||||
title: tr("Change account image visibility"),
|
||||
onPressed: (_) => _chooseAccountImageVisibility(),
|
||||
subtitle: tr("Current level: %level%", args: {
|
||||
"level":
|
||||
_settings.visibility == AccountImageVisibilityLevels.EVERYONE
|
||||
? tr("Everyone")
|
||||
: _settings.visibility ==
|
||||
AccountImageVisibilityLevels.COMUNIC_USERS
|
||||
? tr("Comunic users")
|
||||
: tr("My friends only"),
|
||||
})),
|
||||
MultiChoicesSettingsTile(
|
||||
title: tr("Account image visibility"),
|
||||
choices: _visibilityLevels,
|
||||
currentValue: _settings.visibility,
|
||||
onChanged: (newLevel) async {
|
||||
if (!await SettingsHelper.setAccountImageVisibilityLevel(newLevel))
|
||||
showSimpleSnack(context,
|
||||
tr("Could not update account image visibility level!"));
|
||||
_key.currentState.refresh();
|
||||
}),
|
||||
|
||||
// Delete account image
|
||||
SettingsTile(
|
||||
@ -161,44 +182,6 @@ class _AccountImageSettingsScreenState
|
||||
_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
|
||||
void _deleteAccountImage() async {
|
||||
if (!await showConfirmDialog(
|
||||
|
@ -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/group_icon_widget.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/text_settings_edit_tile.dart';
|
||||
import 'package:comunic/utils/files_utils.dart';
|
||||
@ -81,6 +82,7 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
|
||||
Widget _buildContent() {
|
||||
return SettingsList(
|
||||
sections: [
|
||||
HeadSpacerSection(),
|
||||
_buildGeneralSection(),
|
||||
_buildAccessRestrictions(),
|
||||
_buildGroupLogoArea(),
|
||||
|
Loading…
Reference in New Issue
Block a user