mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Apply new min & max name policy
This commit is contained in:
		@@ -44,9 +44,13 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
 | 
			
		||||
 | 
			
		||||
  bool _showErrors = false;
 | 
			
		||||
 | 
			
		||||
  bool get _isFirstNameValid => _firstNameController.text.length > 3;
 | 
			
		||||
  bool get _isFirstNameValid =>
 | 
			
		||||
      _firstNameController.text.length >=
 | 
			
		||||
      srvConfig.accountInformationPolicy.minFirstNameLength;
 | 
			
		||||
 | 
			
		||||
  bool get _isLastNameValid => _lastNameController.text.length > 3;
 | 
			
		||||
  bool get _isLastNameValid =>
 | 
			
		||||
      _lastNameController.text.length >=
 | 
			
		||||
      srvConfig.accountInformationPolicy.minLastNameLength;
 | 
			
		||||
 | 
			
		||||
  bool get _isEmailValid => validateEmail(_emailController.text);
 | 
			
		||||
 | 
			
		||||
@@ -97,6 +101,8 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
 | 
			
		||||
                label: tr("First name"),
 | 
			
		||||
                onEdited: _updateUI,
 | 
			
		||||
                icon: Icon(Icons.perm_identity),
 | 
			
		||||
                maxLength:
 | 
			
		||||
                    srvConfig.accountInformationPolicy.maxFirstNameLength,
 | 
			
		||||
                error: _showErrors && !_isFirstNameValid
 | 
			
		||||
                    ? tr("Invalid first name!")
 | 
			
		||||
                    : null,
 | 
			
		||||
@@ -108,6 +114,7 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
 | 
			
		||||
                label: tr("Last name"),
 | 
			
		||||
                onEdited: _updateUI,
 | 
			
		||||
                icon: Icon(Icons.perm_identity),
 | 
			
		||||
                maxLength: srvConfig.accountInformationPolicy.maxLastNameLength,
 | 
			
		||||
                error: _showErrors && !_isLastNameValid
 | 
			
		||||
                    ? tr("Invalid last name!")
 | 
			
		||||
                    : null,
 | 
			
		||||
@@ -268,6 +275,7 @@ class _InputEntry extends StatelessWidget {
 | 
			
		||||
  final String error;
 | 
			
		||||
  final Widget icon;
 | 
			
		||||
  final TextInputType keyboard;
 | 
			
		||||
  final int maxLength;
 | 
			
		||||
 | 
			
		||||
  const _InputEntry({
 | 
			
		||||
    Key key,
 | 
			
		||||
@@ -278,6 +286,7 @@ class _InputEntry extends StatelessWidget {
 | 
			
		||||
    this.error,
 | 
			
		||||
    this.icon,
 | 
			
		||||
    this.keyboard,
 | 
			
		||||
    this.maxLength,
 | 
			
		||||
  })  : assert(controller != null),
 | 
			
		||||
        assert(label != null),
 | 
			
		||||
        assert(onEdited != null),
 | 
			
		||||
@@ -291,6 +300,7 @@ class _InputEntry extends StatelessWidget {
 | 
			
		||||
      onChanged: (s) => onEdited(),
 | 
			
		||||
      keyboardType: keyboard,
 | 
			
		||||
      obscureText: isPassword,
 | 
			
		||||
      maxLength: maxLength,
 | 
			
		||||
      decoration: InputDecoration(
 | 
			
		||||
        alignLabelWithHint: true,
 | 
			
		||||
        errorText: error,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
import 'package:comunic/enums/user_page_visibility.dart';
 | 
			
		||||
import 'package:comunic/helpers/serialization/user_list_serialization_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/server_config_helper.dart';
 | 
			
		||||
import 'package:comunic/helpers/settings_helper.dart';
 | 
			
		||||
import 'package:comunic/models/general_settings.dart';
 | 
			
		||||
import 'package:comunic/ui/dialogs/multi_choices_dialog.dart';
 | 
			
		||||
@@ -86,7 +87,9 @@ class _GeneralAccountSettingsScreenState
 | 
			
		||||
          _settings.firstName = s;
 | 
			
		||||
          _updateSettings();
 | 
			
		||||
        },
 | 
			
		||||
        checkInput: (s) => s.length >= 3,
 | 
			
		||||
        maxLength: srvConfig.accountInformationPolicy.maxFirstNameLength,
 | 
			
		||||
        checkInput: (s) =>
 | 
			
		||||
            s.length >= srvConfig.accountInformationPolicy.minFirstNameLength,
 | 
			
		||||
      ),
 | 
			
		||||
 | 
			
		||||
      // Last name
 | 
			
		||||
@@ -97,7 +100,9 @@ class _GeneralAccountSettingsScreenState
 | 
			
		||||
          _settings.lastName = s;
 | 
			
		||||
          _updateSettings();
 | 
			
		||||
        },
 | 
			
		||||
        checkInput: (s) => s.length >= 3,
 | 
			
		||||
        maxLength: srvConfig.accountInformationPolicy.maxLastNameLength,
 | 
			
		||||
        checkInput: (s) =>
 | 
			
		||||
            s.length >= srvConfig.accountInformationPolicy.minLastNameLength,
 | 
			
		||||
      ),
 | 
			
		||||
 | 
			
		||||
      // Emails settings
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user