mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-26 12:58:51 +00:00
Can set location & email visibility
This commit is contained in:
parent
f995003306
commit
4f72b59265
@ -79,6 +79,7 @@ class ServerConfigurationHelper {
|
||||
maxFirstNameLength: accountInformationPolicy["max_first_name_length"],
|
||||
minLastNameLength: accountInformationPolicy["min_last_name_length"],
|
||||
maxLastNameLength: accountInformationPolicy["max_last_name_length"],
|
||||
maxLocationLength: accountInformationPolicy["max_location_length"],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -40,33 +40,37 @@ class SettingsHelper {
|
||||
allowPostsFromFriends: response["allow_posts_from_friends"],
|
||||
allowComunicEmails: response["allow_comunic_mails"],
|
||||
publicFriendsList: response["public_friends_list"],
|
||||
publicEmail: response["public_email"],
|
||||
virtualDirectory: response["virtual_directory"],
|
||||
personalWebsite: response["personnal_website"],
|
||||
publicNote: response["publicNote"],
|
||||
location: response["location"],
|
||||
);
|
||||
}
|
||||
|
||||
/// Apply new general settings
|
||||
static Future<void> updateGeneralSettings(GeneralSettings settings) async {
|
||||
(await APIRequest(uri: "settings/set_general", needLogin: true, args: {
|
||||
"firstName": settings.firstName,
|
||||
"lastName": settings.lastName,
|
||||
"allow_comunic_mails": settings.allowComunicEmails ? "true" : "false",
|
||||
"isPublic": settings.pageVisibility != UserPageVisibility.PRIVATE
|
||||
? "true"
|
||||
: "false",
|
||||
"isOpen":
|
||||
settings.pageVisibility == UserPageVisibility.OPEN ? "true" : "false",
|
||||
"allowComments": settings.allowComments ? "true" : "false",
|
||||
"allowPostsFromFriends":
|
||||
settings.allowPostsFromFriends ? "true" : "false",
|
||||
"publicFriendsList": settings.publicFriendsList ? "true" : "false",
|
||||
"personnalWebsite": settings.personalWebsite,
|
||||
"virtualDirectory": settings.virtualDirectory,
|
||||
"publicNote": settings.publicNote,
|
||||
}).exec())
|
||||
.assertOk();
|
||||
}
|
||||
static Future<void> updateGeneralSettings(GeneralSettings settings) async =>
|
||||
await APIRequest.withLogin("settings/set_general", args: {
|
||||
"firstName": settings.firstName,
|
||||
"lastName": settings.lastName,
|
||||
"allow_comunic_mails": settings.allowComunicEmails ? "true" : "false",
|
||||
"isPublic": settings.pageVisibility != UserPageVisibility.PRIVATE
|
||||
? "true"
|
||||
: "false",
|
||||
"isOpen": settings.pageVisibility == UserPageVisibility.OPEN
|
||||
? "true"
|
||||
: "false",
|
||||
"allowComments": settings.allowComments ? "true" : "false",
|
||||
"allowPostsFromFriends":
|
||||
settings.allowPostsFromFriends ? "true" : "false",
|
||||
"publicFriendsList": settings.publicFriendsList ? "true" : "false",
|
||||
"personnalWebsite": settings.personalWebsite,
|
||||
"virtualDirectory": settings.virtualDirectory,
|
||||
"publicNote": settings.publicNote,
|
||||
})
|
||||
.addBool("email_public", settings.publicEmail)
|
||||
.addString("location", settings.location ?? "")
|
||||
.execWithThrow();
|
||||
|
||||
/// Check out whether a virtual directory is available for a user or not
|
||||
///
|
||||
|
@ -14,9 +14,11 @@ class GeneralSettings {
|
||||
bool allowPostsFromFriends;
|
||||
bool allowComunicEmails;
|
||||
bool publicFriendsList;
|
||||
bool publicEmail;
|
||||
String virtualDirectory;
|
||||
String personalWebsite;
|
||||
String publicNote;
|
||||
String location;
|
||||
|
||||
GeneralSettings({
|
||||
@required this.email,
|
||||
@ -27,9 +29,11 @@ class GeneralSettings {
|
||||
@required this.allowPostsFromFriends,
|
||||
@required this.allowComunicEmails,
|
||||
@required this.publicFriendsList,
|
||||
@required this.publicEmail,
|
||||
@required this.virtualDirectory,
|
||||
@required this.personalWebsite,
|
||||
@required this.publicNote,
|
||||
@required this.location,
|
||||
}) : assert(email != null),
|
||||
assert(firstName != null),
|
||||
assert(lastName != null),
|
||||
@ -38,6 +42,7 @@ class GeneralSettings {
|
||||
assert(allowPostsFromFriends != null),
|
||||
assert(allowComunicEmails != null),
|
||||
assert(publicFriendsList != null),
|
||||
assert(publicEmail != null),
|
||||
assert(virtualDirectory != null),
|
||||
assert(personalWebsite != null),
|
||||
assert(publicNote != null);
|
||||
|
@ -117,16 +117,19 @@ class AccountInformationPolicy {
|
||||
final int maxFirstNameLength;
|
||||
final int minLastNameLength;
|
||||
final int maxLastNameLength;
|
||||
final int maxLocationLength;
|
||||
|
||||
const AccountInformationPolicy({
|
||||
@required this.minFirstNameLength,
|
||||
@required this.maxFirstNameLength,
|
||||
@required this.minLastNameLength,
|
||||
@required this.maxLastNameLength,
|
||||
@required this.maxLocationLength,
|
||||
}) : assert(minFirstNameLength != null),
|
||||
assert(maxFirstNameLength != null),
|
||||
assert(minLastNameLength != null),
|
||||
assert(maxLastNameLength != null);
|
||||
assert(maxLastNameLength != null),
|
||||
assert(maxLocationLength != null);
|
||||
}
|
||||
|
||||
class ServerConfig {
|
||||
|
@ -164,6 +164,7 @@ class _GeneralAccountSettingsScreenState
|
||||
_updateSettings();
|
||||
},
|
||||
switchValue: _settings.allowPostsFromFriends,
|
||||
titleMaxLines: 2,
|
||||
),
|
||||
|
||||
// Make friends list public
|
||||
@ -176,6 +177,16 @@ class _GeneralAccountSettingsScreenState
|
||||
switchValue: _settings.publicFriendsList,
|
||||
),
|
||||
|
||||
// Make email address public
|
||||
SettingsTile.switchTile(
|
||||
title: tr("Make your email address public"),
|
||||
onToggle: (v) {
|
||||
_settings.publicEmail = v;
|
||||
_updateSettings();
|
||||
},
|
||||
switchValue: _settings.publicEmail,
|
||||
),
|
||||
|
||||
// Personal website
|
||||
TextEditSettingsTile(
|
||||
title: tr("Personal website URL (optional)"),
|
||||
@ -188,6 +199,18 @@ class _GeneralAccountSettingsScreenState
|
||||
allowEmptyValues: true,
|
||||
),
|
||||
|
||||
// Location
|
||||
TextEditSettingsTile(
|
||||
title: tr("Location (optional)"),
|
||||
currValue: _settings.location ?? "",
|
||||
onChanged: (v) {
|
||||
_settings.location = v;
|
||||
_updateSettings();
|
||||
},
|
||||
maxLength: srvConfig.accountInformationPolicy.maxLocationLength,
|
||||
allowEmptyValues: true,
|
||||
),
|
||||
|
||||
// Public notes
|
||||
TextEditSettingsTile(
|
||||
title: tr("Public note (optional)"),
|
||||
|
Loading…
Reference in New Issue
Block a user