forked from eatvio/eatvio_app
Merge pull request 'BUILD 92' (#842) from main into test-flight
Reviewed-on: eatvio/eatvio_app#842
This commit is contained in:
@@ -31,3 +31,6 @@ abstract class OAuthVerificationConfirmResponse with _$OAuthVerificationConfirmR
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,6 @@ abstract class OAuthVerificationRequestResponse with _$OAuthVerificationRequestR
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
|||||||
import 'package:eatvio_app/features/auth/presentation/bloc/reset_password_cubit/reset_password_cubit.dart';
|
import 'package:eatvio_app/features/auth/presentation/bloc/reset_password_cubit/reset_password_cubit.dart';
|
||||||
import 'package:eatvio_app/features/auth/presentation/bloc/reset_password_cubit/reset_password_state.dart';
|
import 'package:eatvio_app/features/auth/presentation/bloc/reset_password_cubit/reset_password_state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
@@ -29,14 +30,9 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
child: BlocConsumer<ResetPasswordCubit, ResetPasswordState>(
|
child: BlocConsumer<ResetPasswordCubit, ResetPasswordState>(
|
||||||
builder: (BuildContext context, ResetPasswordState state) {
|
builder: (BuildContext context, ResetPasswordState state) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(title: widget.isAuth ? const Text('Смена пароля') : const Text('Восстановление пароля'), centerTitle: false),
|
||||||
title: widget.isAuth ? const Text('Смена пароля') : const Text('Восстановление пароля'),
|
|
||||||
centerTitle: false,
|
|
||||||
),
|
|
||||||
body: state is ResetPasswordStateLoadingResetPassword || state is ResetPasswordStateLoadingSendEmailCode
|
body: state is ResetPasswordStateLoadingResetPassword || state is ResetPasswordStateLoadingSendEmailCode
|
||||||
? const Center(
|
? const Center(child: CircularProgressIndicator())
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -45,63 +41,32 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
if (state is ResetPasswordStateCodeSendError || state is ResetPasswordStateEmpty) ...[
|
if (state is ResetPasswordStateCodeSendError || state is ResetPasswordStateEmpty) ...[
|
||||||
Text(
|
Text(
|
||||||
'${widget.isAuth ? '' : 'Забыли пароль? '}Укажите свой email,\nи мы пришлём код для сброса.',
|
'${widget.isAuth ? '' : 'Забыли пароль? '}Укажите свой email,\nи мы пришлём код для сброса.',
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
const Text(
|
const Text('E-mail', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||||
'E-mail',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(
|
CustomTextFormField(controller: emailController, hintText: 'Введите e-mail'),
|
||||||
controller: emailController,
|
|
||||||
hintText: 'Введите e-mail',
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
if (state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError) ...[
|
if (state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError) ...[
|
||||||
const Text(
|
const Text('Код', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||||
'Код',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(
|
CustomTextFormField(controller: codeController, hintText: 'Введите код'),
|
||||||
controller: codeController,
|
|
||||||
hintText: 'Введите код',
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const Text(
|
const Text('Пароль', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||||
'Пароль',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(
|
CustomTextFormField(
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
hintText: 'Введите новый пароль',
|
hintText: 'Введите новый пароль',
|
||||||
|
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r'\s'))],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const Text(
|
const Text('Подтвердите пароль', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||||
'Подтвердите пароль',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(
|
CustomTextFormField(
|
||||||
controller: passwordConfirmController,
|
controller: passwordConfirmController,
|
||||||
hintText: 'Введите новый пароль',
|
hintText: 'Введите новый пароль',
|
||||||
|
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r'\s'))],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@@ -109,11 +74,11 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
if (state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError) {
|
if (state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError) {
|
||||||
context.read<ResetPasswordCubit>().tryResetPassword(
|
context.read<ResetPasswordCubit>().tryResetPassword(
|
||||||
emailController.text,
|
emailController.text,
|
||||||
codeController.text,
|
codeController.text,
|
||||||
passwordController.text,
|
passwordController.text,
|
||||||
passwordConfirmController.text,
|
passwordConfirmController.text,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
context.read<ResetPasswordCubit>().trySendEmailCode(emailController.text);
|
context.read<ResetPasswordCubit>().trySendEmailCode(emailController.text);
|
||||||
}
|
}
|
||||||
@@ -122,20 +87,13 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
child: Ink(
|
child: Ink(
|
||||||
width: MediaQuery.of(context).size.width - 32,
|
width: MediaQuery.of(context).size.width - 32,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400),
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: appTheme.blueA400,
|
|
||||||
),
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError
|
state is ResetPasswordStateCodeSendSuccess || state is ResetPasswordStateResetPasswordError
|
||||||
? 'Сменить пароль'
|
? 'Сменить пароль'
|
||||||
: 'Сбросить пароль',
|
: 'Сбросить пароль',
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.white),
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -19,3 +19,6 @@ abstract class BarcodeService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -302,9 +302,19 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
String errorMessage = '';
|
||||||
|
if (e is String) {
|
||||||
|
errorMessage = e;
|
||||||
|
} else {
|
||||||
|
errorMessage = e.toString().replaceFirst('Exception: ', '').replaceFirst('Error: ', '');
|
||||||
|
}
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => const AlertDialog(title: Text('Ошибка при попытке регистрации')),
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Ошибка при регистрации'),
|
||||||
|
content: Text(errorMessage.isNotEmpty ? errorMessage : 'Регистрация не удалась'),
|
||||||
|
actions: [TextButton(onPressed: () => Navigator.pop(context), child: const Text('OK'))],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import 'package:gpassword/gpassword.dart';
|
|||||||
|
|
||||||
class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||||
final RegistrationRepositoryV2 registrationRepository;
|
final RegistrationRepositoryV2 registrationRepository;
|
||||||
RegistrationCubitV2({required this.registrationRepository}) : super(RegistrationStateV2());
|
RegistrationCubitV2({required this.registrationRepository}) : super(const RegistrationStateV2());
|
||||||
|
|
||||||
void setFirstName(String firstName) {
|
void setFirstName(String firstName) {
|
||||||
emit(state.copyWith(firstName: firstName));
|
emit(state.copyWith(firstName: firstName));
|
||||||
@@ -190,10 +190,12 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
|||||||
birthday: birthday,
|
birthday: birthday,
|
||||||
);
|
);
|
||||||
bool didApiComplainOnValidation = false;
|
bool didApiComplainOnValidation = false;
|
||||||
|
String errorMessage = '';
|
||||||
try {
|
try {
|
||||||
final token = await registrationRepository.register(registrationModel: registrationModel);
|
final token = await registrationRepository.register(registrationModel: registrationModel);
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
TokenStorage.saveTokenInStorage(token);
|
TokenStorage.saveTokenInStorage(token);
|
||||||
|
emit(state.copyWith(registrationError: null));
|
||||||
return (true, false);
|
return (true, false);
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
@@ -201,30 +203,56 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
|||||||
final emailErrors = errors?['email'] as List<dynamic>?;
|
final emailErrors = errors?['email'] as List<dynamic>?;
|
||||||
final phoneErrors = errors?['phone'] as List<dynamic>?;
|
final phoneErrors = errors?['phone'] as List<dynamic>?;
|
||||||
final dateOfBirth = errors?['date_of_birth'] as List<dynamic>?;
|
final dateOfBirth = errors?['date_of_birth'] as List<dynamic>?;
|
||||||
|
|
||||||
|
// Собираем все ошибки для отображения в диалоге
|
||||||
|
List<String> allErrors = [];
|
||||||
|
|
||||||
if (emailErrors != null && emailErrors.isNotEmpty) {
|
if (emailErrors != null && emailErrors.isNotEmpty) {
|
||||||
if (emailErrors.contains('Некорректный формат email')) {
|
for (var error in emailErrors) {
|
||||||
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Некорректный формат email'));
|
allErrors.add(error.toString());
|
||||||
didApiComplainOnValidation = true;
|
if (error.toString() == 'Некорректный формат email') {
|
||||||
}
|
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Некорректный формат email'));
|
||||||
if (emailErrors.contains('Такой Эл. почта уже существует.')) {
|
didApiComplainOnValidation = true;
|
||||||
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Такая Эл. почта уже существует.'));
|
}
|
||||||
didApiComplainOnValidation = true;
|
if (error.toString() == 'Такой Эл. почта уже существует.') {
|
||||||
|
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Такая Эл. почта уже существует.'));
|
||||||
|
didApiComplainOnValidation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (phoneErrors != null && phoneErrors.isNotEmpty) {
|
if (phoneErrors != null && phoneErrors.isNotEmpty) {
|
||||||
if (phoneErrors.contains('Такой phone уже существует.')) {
|
for (var error in phoneErrors) {
|
||||||
emit(state.copyWith(isPhoneValid: false, phoneDisplayError: 'Такой номер телефона уже существует.'));
|
allErrors.add(error.toString());
|
||||||
didApiComplainOnValidation = true;
|
if (error.toString() == 'Такой phone уже существует.') {
|
||||||
|
emit(state.copyWith(isPhoneValid: false, phoneDisplayError: 'Такой номер телефона уже существует.'));
|
||||||
|
didApiComplainOnValidation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dateOfBirth != null && dateOfBirth.isNotEmpty) {
|
if (dateOfBirth != null && dateOfBirth.isNotEmpty) {
|
||||||
if (dateOfBirth.contains('Некорректный формат даты рождения')) {
|
for (var error in dateOfBirth) {
|
||||||
emit(state.copyWith(isBirthdayValid: false, emailDisplayError: 'Некорректный формат даты рождения'));
|
allErrors.add(error.toString());
|
||||||
didApiComplainOnValidation = true;
|
if (error.toString() == 'Некорректный формат даты рождения') {
|
||||||
|
emit(state.copyWith(isBirthdayValid: false, dateOfBirthDisplayError: 'Некорректный формат даты рождения'));
|
||||||
|
didApiComplainOnValidation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Сохраняем все ошибки для отображения в диалоге
|
||||||
|
if (allErrors.isNotEmpty) {
|
||||||
|
errorMessage = allErrors.join('\n');
|
||||||
|
emit(state.copyWith(registrationError: errorMessage));
|
||||||
|
} else {
|
||||||
|
// Если нет конкретных ошибок, берем общее сообщение
|
||||||
|
final message = e.response?.data['message'] as String?;
|
||||||
|
errorMessage = message ?? 'Ошибка при регистрации';
|
||||||
|
emit(state.copyWith(registrationError: errorMessage));
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e.toString());
|
log(e.toString());
|
||||||
|
errorMessage = e.toString();
|
||||||
|
emit(state.copyWith(registrationError: errorMessage));
|
||||||
}
|
}
|
||||||
return (false, didApiComplainOnValidation);
|
return (false, didApiComplainOnValidation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ part 'registration_state.freezed.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
abstract class RegistrationStateV2 with _$RegistrationStateV2 {
|
abstract class RegistrationStateV2 with _$RegistrationStateV2 {
|
||||||
factory RegistrationStateV2({
|
const factory RegistrationStateV2({
|
||||||
@Default('') String firstName,
|
@Default('') String firstName,
|
||||||
@Default('') String lastName,
|
@Default('') String lastName,
|
||||||
@Default('') String email,
|
@Default('') String email,
|
||||||
@@ -28,5 +28,6 @@ abstract class RegistrationStateV2 with _$RegistrationStateV2 {
|
|||||||
@Default('') String emailDisplayError,
|
@Default('') String emailDisplayError,
|
||||||
@Default('') String phoneDisplayError,
|
@Default('') String phoneDisplayError,
|
||||||
@Default('') String dateOfBirthDisplayError,
|
@Default('') String dateOfBirthDisplayError,
|
||||||
|
String? registrationError,
|
||||||
}) = _RegistrationStateV2;
|
}) = _RegistrationStateV2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,8 @@ class _SecondStepContentState extends State<SecondStepContent> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
if (context.mounted && !hasValidationError) {
|
if (context.mounted) {
|
||||||
|
// Показываем bottom sheet всегда: при успехе или ошибке
|
||||||
showRegistrationBottomSheet(context, cubit, commonResult);
|
showRegistrationBottomSheet(context, cubit, commonResult);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -157,7 +158,7 @@ class _SecondStepContentState extends State<SecondStepContent> {
|
|||||||
child: RichText(
|
child: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: 'Нажимая “Зарегистрироваться”, Вы соглашаетесь \n',
|
text: 'Нажимая "Зарегистрироваться", Вы соглашаетесь \n',
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.black),
|
style: const TextStyle(fontSize: 12, color: Colors.black),
|
||||||
children: [
|
children: [
|
||||||
const TextSpan(text: 'c '),
|
const TextSpan(text: 'c '),
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class _RegistrationBottomSheetState extends State<RegistrationBottomSheet> {
|
|||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)),
|
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
AppRouter.navigatorKey.currentContext?.go(RouteConstants.verifyEmailScreen);
|
AppRouter.navigatorKey.currentContext?.go(RouteConstants.feedScreen);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
@@ -96,7 +96,12 @@ class _RegistrationBottomSheetState extends State<RegistrationBottomSheet> {
|
|||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
padding: const EdgeInsets.only(bottom: 16.0),
|
||||||
child: Text(s.error_desc, style: TextStyles.textMMediumAuto.copyWith(color: appTheme.darkGrey)),
|
child: Text(
|
||||||
|
widget.cubit.state.registrationError?.isNotEmpty == true
|
||||||
|
? widget.cubit.state.registrationError!
|
||||||
|
: s.error_desc,
|
||||||
|
style: TextStyles.textMMediumAuto.copyWith(color: appTheme.darkGrey),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: eatvio_app
|
name: eatvio_app
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
version: 1.3.10+90
|
version: 1.3.11+91
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1043,6 +1043,9 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,5 +77,8 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void main() {
|
|||||||
final mockCubit = MockRegistrationCubitV2();
|
final mockCubit = MockRegistrationCubitV2();
|
||||||
const testPassword = 'testPassword123';
|
const testPassword = 'testPassword123';
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(password: testPassword),
|
const RegistrationStateV2(password: testPassword),
|
||||||
);
|
);
|
||||||
final widget = PasswordField(cubit: mockCubit);
|
final widget = PasswordField(cubit: mockCubit);
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ void main() {
|
|||||||
// Arrange
|
// Arrange
|
||||||
final mockCubit = MockRegistrationCubitV2();
|
final mockCubit = MockRegistrationCubitV2();
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(password: 'test'),
|
const RegistrationStateV2(password: 'test'),
|
||||||
);
|
);
|
||||||
final widget = PasswordField(cubit: mockCubit);
|
final widget = PasswordField(cubit: mockCubit);
|
||||||
|
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('displays sex widget', (tester) async {
|
testWidgets('displays sex widget', (tester) async {
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: true,
|
isGenderValid: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: true,
|
isGenderValid: true,
|
||||||
@@ -64,14 +64,14 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('calls setGender when male is tapped', (tester) async {
|
testWidgets('calls setGender when male is tapped', (tester) async {
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: true,
|
isGenderValid: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: true,
|
isGenderValid: true,
|
||||||
@@ -94,14 +94,14 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('shows error when gender is invalid', (tester) async {
|
testWidgets('shows error when gender is invalid', (tester) async {
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: false,
|
isGenderValid: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
when(mockCubit.stream).thenAnswer((_) => Stream.value(
|
||||||
RegistrationStateV2(
|
const RegistrationStateV2(
|
||||||
step: 0,
|
step: 0,
|
||||||
gender: '',
|
gender: '',
|
||||||
isGenderValid: false,
|
isGenderValid: false,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ void main() {
|
|||||||
// Arrange
|
// Arrange
|
||||||
final mockCubit = MockRegistrationCubitV2();
|
final mockCubit = MockRegistrationCubitV2();
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(password: 'testPassword'),
|
const RegistrationStateV2(password: 'testPassword'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -74,7 +74,7 @@ void main() {
|
|||||||
// Arrange
|
// Arrange
|
||||||
final mockCubit = MockRegistrationCubitV2();
|
final mockCubit = MockRegistrationCubitV2();
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(),
|
const RegistrationStateV2(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget createTestWidgetError(Widget child, RegistrationCubitV2 cubit) {
|
Widget createTestWidgetError(Widget child, RegistrationCubitV2 cubit) {
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('displays step widget', (tester) async {
|
testWidgets('displays step widget', (tester) async {
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(step: 0),
|
const RegistrationStateV2(step: 0),
|
||||||
);
|
);
|
||||||
when(mockCubit.stream).thenAnswer((_) => Stream.value(RegistrationStateV2(step: 0)));
|
when(mockCubit.stream).thenAnswer((_) => Stream.value(const RegistrationStateV2(step: 0)));
|
||||||
|
|
||||||
await tester.pumpWidget(createTestWidget());
|
await tester.pumpWidget(createTestWidget());
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -55,9 +55,9 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('displays correct step number', (tester) async {
|
testWidgets('displays correct step number', (tester) async {
|
||||||
when(mockCubit.state).thenReturn(
|
when(mockCubit.state).thenReturn(
|
||||||
RegistrationStateV2(step: 2),
|
const RegistrationStateV2(step: 2),
|
||||||
);
|
);
|
||||||
when(mockCubit.stream).thenAnswer((_) => Stream.value(RegistrationStateV2(step: 2)));
|
when(mockCubit.stream).thenAnswer((_) => Stream.value(const RegistrationStateV2(step: 2)));
|
||||||
|
|
||||||
await tester.pumpWidget(createTestWidget());
|
await tester.pumpWidget(createTestWidget());
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
Reference in New Issue
Block a user