From 2f1d6425dc5bfbf5dddac4480f7f448b29902888 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 31 Jul 2024 15:44:04 +0300 Subject: [PATCH] refactor(registration): remove username --- .../user_registration_model.dart | 1 - .../user_registration_model.freezed.dart | 31 +++---------------- .../user_registration_model.g.dart | 2 -- .../widgets/blog_post_widget.dart | 15 +++++++++ .../registration_cubit.dart | 1 - .../pages/credentials_screen.dart | 15 --------- .../pages/registration_screen.dart | 16 ++-------- 7 files changed, 22 insertions(+), 59 deletions(-) diff --git a/lib/data/models/userRegistrationModel/user_registration_model.dart b/lib/data/models/userRegistrationModel/user_registration_model.dart index a86d064..7a7fb3f 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.dart +++ b/lib/data/models/userRegistrationModel/user_registration_model.dart @@ -6,7 +6,6 @@ part 'user_registration_model.g.dart'; @freezed class UserRegistrationSheet with _$UserRegistrationSheet { const factory UserRegistrationSheet({ - required String name, @JsonKey(name: 'first_name') required String firstName, @JsonKey(name: 'last_name') required String lastName, required String email, diff --git a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart index 70f656f..4a15327 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart +++ b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart @@ -21,7 +21,6 @@ UserRegistrationSheet _$UserRegistrationSheetFromJson( /// @nodoc mixin _$UserRegistrationSheet { - String get name => throw _privateConstructorUsedError; @JsonKey(name: 'first_name') String get firstName => throw _privateConstructorUsedError; @JsonKey(name: 'last_name') @@ -82,8 +81,7 @@ abstract class $UserRegistrationSheetCopyWith<$Res> { _$UserRegistrationSheetCopyWithImpl<$Res, UserRegistrationSheet>; @useResult $Res call( - {String name, - @JsonKey(name: 'first_name') String firstName, + {@JsonKey(name: 'first_name') String firstName, @JsonKey(name: 'last_name') String lastName, String email, String password, @@ -126,7 +124,6 @@ class _$UserRegistrationSheetCopyWithImpl<$Res, @pragma('vm:prefer-inline') @override $Res call({ - Object? name = null, Object? firstName = null, Object? lastName = null, Object? email = null, @@ -156,10 +153,6 @@ class _$UserRegistrationSheetCopyWithImpl<$Res, Object? activityCoefficient = null, }) { return _then(_value.copyWith( - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, firstName: null == firstName ? _value.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -282,8 +275,7 @@ abstract class _$$UserRegistrationSheetImplCopyWith<$Res> @override @useResult $Res call( - {String name, - @JsonKey(name: 'first_name') String firstName, + {@JsonKey(name: 'first_name') String firstName, @JsonKey(name: 'last_name') String lastName, String email, String password, @@ -324,7 +316,6 @@ class __$$UserRegistrationSheetImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? name = null, Object? firstName = null, Object? lastName = null, Object? email = null, @@ -354,10 +345,6 @@ class __$$UserRegistrationSheetImplCopyWithImpl<$Res> Object? activityCoefficient = null, }) { return _then(_$UserRegistrationSheetImpl( - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, firstName: null == firstName ? _value.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -474,8 +461,7 @@ class __$$UserRegistrationSheetImplCopyWithImpl<$Res> @JsonSerializable() class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { const _$UserRegistrationSheetImpl( - {required this.name, - @JsonKey(name: 'first_name') required this.firstName, + {@JsonKey(name: 'first_name') required this.firstName, @JsonKey(name: 'last_name') required this.lastName, required this.email, required this.password, @@ -507,8 +493,6 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { factory _$UserRegistrationSheetImpl.fromJson(Map json) => _$$UserRegistrationSheetImplFromJson(json); - @override - final String name; @override @JsonKey(name: 'first_name') final String firstName; @@ -585,7 +569,7 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { @override String toString() { - return 'UserRegistrationSheet(name: $name, firstName: $firstName, lastName: $lastName, email: $email, password: $password, passwordConfirmation: $passwordConfirmation, termsAccepted: $termsAccepted, birthdate: $birthdate, gender: $gender, location: $location, responseBody: $responseBody, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAllergy: $aboutAllergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, activityCoefficient: $activityCoefficient)'; + return 'UserRegistrationSheet(firstName: $firstName, lastName: $lastName, email: $email, password: $password, passwordConfirmation: $passwordConfirmation, termsAccepted: $termsAccepted, birthdate: $birthdate, gender: $gender, location: $location, responseBody: $responseBody, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAllergy: $aboutAllergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, activityCoefficient: $activityCoefficient)'; } @override @@ -593,7 +577,6 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { return identical(this, other) || (other.runtimeType == runtimeType && other is _$UserRegistrationSheetImpl && - (identical(other.name, name) || other.name == name) && (identical(other.firstName, firstName) || other.firstName == firstName) && (identical(other.lastName, lastName) || @@ -648,7 +631,6 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { @override int get hashCode => Object.hashAll([ runtimeType, - name, firstName, lastName, email, @@ -695,8 +677,7 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { abstract class _UserRegistrationSheet implements UserRegistrationSheet { const factory _UserRegistrationSheet( - {required final String name, - @JsonKey(name: 'first_name') required final String firstName, + {@JsonKey(name: 'first_name') required final String firstName, @JsonKey(name: 'last_name') required final String lastName, required final String email, required final String password, @@ -733,8 +714,6 @@ abstract class _UserRegistrationSheet implements UserRegistrationSheet { factory _UserRegistrationSheet.fromJson(Map json) = _$UserRegistrationSheetImpl.fromJson; - @override - String get name; @override @JsonKey(name: 'first_name') String get firstName; diff --git a/lib/data/models/userRegistrationModel/user_registration_model.g.dart b/lib/data/models/userRegistrationModel/user_registration_model.g.dart index 6ca8a1c..9500e91 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.g.dart +++ b/lib/data/models/userRegistrationModel/user_registration_model.g.dart @@ -9,7 +9,6 @@ part of 'user_registration_model.dart'; _$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson( Map json) => _$UserRegistrationSheetImpl( - name: json['name'] as String, firstName: json['first_name'] as String, lastName: json['last_name'] as String, email: json['email'] as String, @@ -43,7 +42,6 @@ _$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson( Map _$$UserRegistrationSheetImplToJson( _$UserRegistrationSheetImpl instance) => { - 'name': instance.name, 'first_name': instance.firstName, 'last_name': instance.lastName, 'email': instance.email, diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index 6bf0f7e..abfba97 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -87,6 +87,21 @@ class _BlogPostWidgetState extends State { _iconButton(Icons.mode_comment_outlined), SizedBox(width: 8), _iconButton(Icons.reply_rounded), + Spacer(), + Icon( + Icons.visibility_rounded, + size: 16, + color: appTheme.gray500, + ), + SizedBox(width: 4), + Text( + '0', + style: TextStyle( + fontSize: 12, + color: appTheme.gray500, + fontWeight: FontWeight.w400, + ), + ), ], ), ), diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index dcad030..cbb2e16 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -13,7 +13,6 @@ class RegistrationCubit extends Cubit { : super( RegistrationState( sheet: UserRegistrationSheet( - name: '', firstName: '', lastName: '', email: '', diff --git a/lib/features/registration/presentation/pages/credentials_screen.dart b/lib/features/registration/presentation/pages/credentials_screen.dart index 7fa37be..dc9d548 100644 --- a/lib/features/registration/presentation/pages/credentials_screen.dart +++ b/lib/features/registration/presentation/pages/credentials_screen.dart @@ -16,8 +16,6 @@ class CredentialsScreen extends StatefulWidget { class _CredentialsScreenState extends State { final emailController = TextEditingController(); - final nameController = TextEditingController(); - final passwordController = TextEditingController(); final passwordConfirmationController = TextEditingController(); @@ -26,7 +24,6 @@ class _CredentialsScreenState extends State { void initState() { super.initState(); emailController.text = widget.sheet.email; - nameController.text = widget.sheet.name; passwordController.text = widget.sheet.password; passwordConfirmationController.text = widget.sheet.passwordConfirmation; } @@ -52,18 +49,6 @@ class _CredentialsScreenState extends State { }, ), SizedBox(height: 16), - Text("username".tr), - SizedBox(height: 4), - CustomTextFormField( - controller: nameController, - hintText: 'Введите имя пользователя', - textInputAction: TextInputAction.next, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue)); - }, - ), - SizedBox(height: 16), Text("password".tr), SizedBox(height: 4), CustomTextFormField( diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index 82e3135..e95639a 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -177,7 +177,7 @@ class _RegistrationScreenState extends State { Future canGoNext(RegistrationState state) async { switch (step) { case 2: - List errors = validateCredentialsFields(state.sheet.email, state.sheet.name, state.sheet.password, state.sheet.passwordConfirmation); + List errors = validateCredentialsFields(state.sheet.email, state.sheet.password, state.sheet.passwordConfirmation); if (errors.isEmpty) { return true; } else { @@ -347,7 +347,7 @@ class _RegistrationScreenState extends State { return errors; } - List validateCredentialsFields(String email, String name, String password, String passwordConfirmation) { + List validateCredentialsFields(String email, String password, String passwordConfirmation) { List errors = []; if (!isEmail(email)) { @@ -358,18 +358,6 @@ class _RegistrationScreenState extends State { errors.add('email_empty'.tr); } - if (name.length < 6) { - errors.add('name_short'.tr); - } - - if (name.isEmpty) { - errors.add('name_empty'.tr); - } - - if (password.isEmpty) { - errors.add('name_empty'.tr); - } - if (password.length < 6) { errors.add('password_short'.tr); }