refactor(registration): remove username

This commit is contained in:
mso7nueh
2024-07-31 15:44:04 +03:00
parent 9cfd59b36f
commit 2f1d6425dc
7 changed files with 22 additions and 59 deletions

View File

@@ -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,

View File

@@ -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<String, dynamic> 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<String, dynamic> json) =
_$UserRegistrationSheetImpl.fromJson;
@override
String get name;
@override
@JsonKey(name: 'first_name')
String get firstName;

View File

@@ -9,7 +9,6 @@ part of 'user_registration_model.dart';
_$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson(
Map<String, dynamic> 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<String, dynamic> _$$UserRegistrationSheetImplToJson(
_$UserRegistrationSheetImpl instance) =>
<String, dynamic>{
'name': instance.name,
'first_name': instance.firstName,
'last_name': instance.lastName,
'email': instance.email,

View File

@@ -87,6 +87,21 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
_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,
),
),
],
),
),

View File

@@ -13,7 +13,6 @@ class RegistrationCubit extends Cubit<RegistrationState> {
: super(
RegistrationState(
sheet: UserRegistrationSheet(
name: '',
firstName: '',
lastName: '',
email: '',

View File

@@ -16,8 +16,6 @@ class CredentialsScreen extends StatefulWidget {
class _CredentialsScreenState extends State<CredentialsScreen> {
final emailController = TextEditingController();
final nameController = TextEditingController();
final passwordController = TextEditingController();
final passwordConfirmationController = TextEditingController();
@@ -26,7 +24,6 @@ class _CredentialsScreenState extends State<CredentialsScreen> {
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<CredentialsScreen> {
},
),
SizedBox(height: 16),
Text("username".tr),
SizedBox(height: 4),
CustomTextFormField(
controller: nameController,
hintText: 'Введите имя пользователя',
textInputAction: TextInputAction.next,
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue));
},
),
SizedBox(height: 16),
Text("password".tr),
SizedBox(height: 4),
CustomTextFormField(

View File

@@ -177,7 +177,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
Future<bool> canGoNext(RegistrationState state) async {
switch (step) {
case 2:
List<String> errors = validateCredentialsFields(state.sheet.email, state.sheet.name, state.sheet.password, state.sheet.passwordConfirmation);
List<String> 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<RegistrationScreen> {
return errors;
}
List<String> validateCredentialsFields(String email, String name, String password, String passwordConfirmation) {
List<String> validateCredentialsFields(String email, String password, String passwordConfirmation) {
List<String> errors = [];
if (!isEmail(email)) {
@@ -358,18 +358,6 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
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);
}