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