From 14623341551b4a7fcaa62dd3b8d8dc473033b9c3 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 11 Oct 2024 17:40:00 +0300 Subject: [PATCH 1/3] feature: add consultant --- android/app/build.gradle | 2 +- .../models/consultant_profile_model.dart | 18 +- .../consultant_profile_model.freezed.dart | 143 +++---- .../models/consultant_profile_model.g.dart | 46 ++- .../register_consultant_cubit.dart | 5 +- .../pages/additional_settings_screen.dart | 19 + .../certificates_and_diplomas_screen.dart | 68 ++-- .../pages/photo_or_scans_screen.dart | 32 +- .../pages/social_networks_screen.dart | 86 ++++- .../stepper_become_consultant_screen.dart | 360 +++++++++--------- .../repositories/consultant_repository.dart | 2 +- .../services/consultant_service.dart | 3 +- .../services/consultant_service.g.dart | 5 +- pubspec.yaml | 1 + 14 files changed, 480 insertions(+), 310 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 81f74f06..46a74368 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,7 +7,7 @@ plugins { android { namespace = "com.eatvioapp.app" compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion + ndkVersion = "25.1.8937393" compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.dart index 4cbde94f..2298d812 100644 --- a/lib/features/consultant/become_consultant/models/consultant_profile_model.dart +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.dart @@ -7,10 +7,10 @@ part 'consultant_profile_model.g.dart'; @freezed class ConsultantProfileModel with _$ConsultantProfileModel { const factory ConsultantProfileModel({ - @JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, - @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, - @JsonKey(name: 'cert_photos') List? photos, - @JsonKey(name: 'completed_courses') List? certificates, + @JsonKey(name: 'has_medical_education', includeIfNull: false) bool? hasMedicalEducation, + @JsonKey(name: 'social_links', includeIfNull: false) SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos', includeIfNull: false) List? photos, + @JsonKey(name: 'completed_courses', includeIfNull: false) List? certificates, }) = _ConsultantProfileModel; factory ConsultantProfileModel.fromJson(Map json) => _$ConsultantProfileModelFromJson(json); @@ -19,11 +19,11 @@ class ConsultantProfileModel with _$ConsultantProfileModel { @freezed class SocialLinksModel with _$SocialLinksModel { const factory SocialLinksModel({ - @JsonKey(name: 'vk_link') String? vkLink, - @JsonKey(name: 'tg_link') String? tgLink, - @JsonKey(name: 'fb_link') String? fbLink, - @JsonKey(name: 'insta_link') String? instaLink, - @JsonKey(name: 'personal_site_link') String? personalSiteLink, + @JsonKey(name: 'vk_link', includeIfNull: false) String? vkLink, + @JsonKey(name: 'tg_link', includeIfNull: false) String? tgLink, + @JsonKey(name: 'fb_link', includeIfNull: false) String? fbLink, + @JsonKey(name: 'insta_link', includeIfNull: false) String? instaLink, + @JsonKey(name: 'personal_site_link', includeIfNull: false) String? personalSiteLink, }) = _SocialLinksModel; factory SocialLinksModel.fromJson(Map json) => _$SocialLinksModelFromJson(json); diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart index 3abdd043..d320c937 100644 --- a/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart @@ -21,13 +21,13 @@ ConsultantProfileModel _$ConsultantProfileModelFromJson( /// @nodoc mixin _$ConsultantProfileModel { - @JsonKey(name: 'has_medical_education') + @JsonKey(name: 'has_medical_education', includeIfNull: false) bool? get hasMedicalEducation => throw _privateConstructorUsedError; - @JsonKey(name: 'social_links') + @JsonKey(name: 'social_links', includeIfNull: false) SocialLinksModel? get socialLinks => throw _privateConstructorUsedError; - @JsonKey(name: 'cert_photos') + @JsonKey(name: 'cert_photos', includeIfNull: false) List? get photos => throw _privateConstructorUsedError; - @JsonKey(name: 'completed_courses') + @JsonKey(name: 'completed_courses', includeIfNull: false) List? get certificates => throw _privateConstructorUsedError; @@ -48,10 +48,12 @@ abstract class $ConsultantProfileModelCopyWith<$Res> { _$ConsultantProfileModelCopyWithImpl<$Res, ConsultantProfileModel>; @useResult $Res call( - {@JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, - @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, - @JsonKey(name: 'cert_photos') List? photos, - @JsonKey(name: 'completed_courses') + {@JsonKey(name: 'has_medical_education', includeIfNull: false) + bool? hasMedicalEducation, + @JsonKey(name: 'social_links', includeIfNull: false) + SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos', includeIfNull: false) List? photos, + @JsonKey(name: 'completed_courses', includeIfNull: false) List? certificates}); $SocialLinksModelCopyWith<$Res>? get socialLinks; @@ -123,10 +125,12 @@ abstract class _$$ConsultantProfileModelImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, - @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, - @JsonKey(name: 'cert_photos') List? photos, - @JsonKey(name: 'completed_courses') + {@JsonKey(name: 'has_medical_education', includeIfNull: false) + bool? hasMedicalEducation, + @JsonKey(name: 'social_links', includeIfNull: false) + SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos', includeIfNull: false) List? photos, + @JsonKey(name: 'completed_courses', includeIfNull: false) List? certificates}); @override @@ -178,10 +182,12 @@ class __$$ConsultantProfileModelImplCopyWithImpl<$Res> @JsonSerializable() class _$ConsultantProfileModelImpl implements _ConsultantProfileModel { const _$ConsultantProfileModelImpl( - {@JsonKey(name: 'has_medical_education') this.hasMedicalEducation, - @JsonKey(name: 'social_links') this.socialLinks, - @JsonKey(name: 'cert_photos') final List? photos, - @JsonKey(name: 'completed_courses') + {@JsonKey(name: 'has_medical_education', includeIfNull: false) + this.hasMedicalEducation, + @JsonKey(name: 'social_links', includeIfNull: false) this.socialLinks, + @JsonKey(name: 'cert_photos', includeIfNull: false) + final List? photos, + @JsonKey(name: 'completed_courses', includeIfNull: false) final List? certificates}) : _photos = photos, _certificates = certificates; @@ -190,14 +196,14 @@ class _$ConsultantProfileModelImpl implements _ConsultantProfileModel { _$$ConsultantProfileModelImplFromJson(json); @override - @JsonKey(name: 'has_medical_education') + @JsonKey(name: 'has_medical_education', includeIfNull: false) final bool? hasMedicalEducation; @override - @JsonKey(name: 'social_links') + @JsonKey(name: 'social_links', includeIfNull: false) final SocialLinksModel? socialLinks; final List? _photos; @override - @JsonKey(name: 'cert_photos') + @JsonKey(name: 'cert_photos', includeIfNull: false) List? get photos { final value = _photos; if (value == null) return null; @@ -208,7 +214,7 @@ class _$ConsultantProfileModelImpl implements _ConsultantProfileModel { final List? _certificates; @override - @JsonKey(name: 'completed_courses') + @JsonKey(name: 'completed_courses', includeIfNull: false) List? get certificates { final value = _certificates; if (value == null) return null; @@ -264,27 +270,30 @@ class _$ConsultantProfileModelImpl implements _ConsultantProfileModel { abstract class _ConsultantProfileModel implements ConsultantProfileModel { const factory _ConsultantProfileModel( - {@JsonKey(name: 'has_medical_education') final bool? hasMedicalEducation, - @JsonKey(name: 'social_links') final SocialLinksModel? socialLinks, - @JsonKey(name: 'cert_photos') final List? photos, - @JsonKey(name: 'completed_courses') - final List? - certificates}) = _$ConsultantProfileModelImpl; + {@JsonKey(name: 'has_medical_education', includeIfNull: false) + final bool? hasMedicalEducation, + @JsonKey(name: 'social_links', includeIfNull: false) + final SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos', includeIfNull: false) + final List? photos, + @JsonKey(name: 'completed_courses', includeIfNull: false) + final List? certificates}) = + _$ConsultantProfileModelImpl; factory _ConsultantProfileModel.fromJson(Map json) = _$ConsultantProfileModelImpl.fromJson; @override - @JsonKey(name: 'has_medical_education') + @JsonKey(name: 'has_medical_education', includeIfNull: false) bool? get hasMedicalEducation; @override - @JsonKey(name: 'social_links') + @JsonKey(name: 'social_links', includeIfNull: false) SocialLinksModel? get socialLinks; @override - @JsonKey(name: 'cert_photos') + @JsonKey(name: 'cert_photos', includeIfNull: false) List? get photos; @override - @JsonKey(name: 'completed_courses') + @JsonKey(name: 'completed_courses', includeIfNull: false) List? get certificates; /// Create a copy of ConsultantProfileModel @@ -301,15 +310,15 @@ SocialLinksModel _$SocialLinksModelFromJson(Map json) { /// @nodoc mixin _$SocialLinksModel { - @JsonKey(name: 'vk_link') + @JsonKey(name: 'vk_link', includeIfNull: false) String? get vkLink => throw _privateConstructorUsedError; - @JsonKey(name: 'tg_link') + @JsonKey(name: 'tg_link', includeIfNull: false) String? get tgLink => throw _privateConstructorUsedError; - @JsonKey(name: 'fb_link') + @JsonKey(name: 'fb_link', includeIfNull: false) String? get fbLink => throw _privateConstructorUsedError; - @JsonKey(name: 'insta_link') + @JsonKey(name: 'insta_link', includeIfNull: false) String? get instaLink => throw _privateConstructorUsedError; - @JsonKey(name: 'personal_site_link') + @JsonKey(name: 'personal_site_link', includeIfNull: false) String? get personalSiteLink => throw _privateConstructorUsedError; /// Serializes this SocialLinksModel to a JSON map. @@ -329,11 +338,12 @@ abstract class $SocialLinksModelCopyWith<$Res> { _$SocialLinksModelCopyWithImpl<$Res, SocialLinksModel>; @useResult $Res call( - {@JsonKey(name: 'vk_link') String? vkLink, - @JsonKey(name: 'tg_link') String? tgLink, - @JsonKey(name: 'fb_link') String? fbLink, - @JsonKey(name: 'insta_link') String? instaLink, - @JsonKey(name: 'personal_site_link') String? personalSiteLink}); + {@JsonKey(name: 'vk_link', includeIfNull: false) String? vkLink, + @JsonKey(name: 'tg_link', includeIfNull: false) String? tgLink, + @JsonKey(name: 'fb_link', includeIfNull: false) String? fbLink, + @JsonKey(name: 'insta_link', includeIfNull: false) String? instaLink, + @JsonKey(name: 'personal_site_link', includeIfNull: false) + String? personalSiteLink}); } /// @nodoc @@ -391,11 +401,12 @@ abstract class _$$SocialLinksModelImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'vk_link') String? vkLink, - @JsonKey(name: 'tg_link') String? tgLink, - @JsonKey(name: 'fb_link') String? fbLink, - @JsonKey(name: 'insta_link') String? instaLink, - @JsonKey(name: 'personal_site_link') String? personalSiteLink}); + {@JsonKey(name: 'vk_link', includeIfNull: false) String? vkLink, + @JsonKey(name: 'tg_link', includeIfNull: false) String? tgLink, + @JsonKey(name: 'fb_link', includeIfNull: false) String? fbLink, + @JsonKey(name: 'insta_link', includeIfNull: false) String? instaLink, + @JsonKey(name: 'personal_site_link', includeIfNull: false) + String? personalSiteLink}); } /// @nodoc @@ -446,29 +457,30 @@ class __$$SocialLinksModelImplCopyWithImpl<$Res> @JsonSerializable() class _$SocialLinksModelImpl implements _SocialLinksModel { const _$SocialLinksModelImpl( - {@JsonKey(name: 'vk_link') this.vkLink, - @JsonKey(name: 'tg_link') this.tgLink, - @JsonKey(name: 'fb_link') this.fbLink, - @JsonKey(name: 'insta_link') this.instaLink, - @JsonKey(name: 'personal_site_link') this.personalSiteLink}); + {@JsonKey(name: 'vk_link', includeIfNull: false) this.vkLink, + @JsonKey(name: 'tg_link', includeIfNull: false) this.tgLink, + @JsonKey(name: 'fb_link', includeIfNull: false) this.fbLink, + @JsonKey(name: 'insta_link', includeIfNull: false) this.instaLink, + @JsonKey(name: 'personal_site_link', includeIfNull: false) + this.personalSiteLink}); factory _$SocialLinksModelImpl.fromJson(Map json) => _$$SocialLinksModelImplFromJson(json); @override - @JsonKey(name: 'vk_link') + @JsonKey(name: 'vk_link', includeIfNull: false) final String? vkLink; @override - @JsonKey(name: 'tg_link') + @JsonKey(name: 'tg_link', includeIfNull: false) final String? tgLink; @override - @JsonKey(name: 'fb_link') + @JsonKey(name: 'fb_link', includeIfNull: false) final String? fbLink; @override - @JsonKey(name: 'insta_link') + @JsonKey(name: 'insta_link', includeIfNull: false) final String? instaLink; @override - @JsonKey(name: 'personal_site_link') + @JsonKey(name: 'personal_site_link', includeIfNull: false) final String? personalSiteLink; @override @@ -514,30 +526,31 @@ class _$SocialLinksModelImpl implements _SocialLinksModel { abstract class _SocialLinksModel implements SocialLinksModel { const factory _SocialLinksModel( - {@JsonKey(name: 'vk_link') final String? vkLink, - @JsonKey(name: 'tg_link') final String? tgLink, - @JsonKey(name: 'fb_link') final String? fbLink, - @JsonKey(name: 'insta_link') final String? instaLink, - @JsonKey(name: 'personal_site_link') + {@JsonKey(name: 'vk_link', includeIfNull: false) final String? vkLink, + @JsonKey(name: 'tg_link', includeIfNull: false) final String? tgLink, + @JsonKey(name: 'fb_link', includeIfNull: false) final String? fbLink, + @JsonKey(name: 'insta_link', includeIfNull: false) + final String? instaLink, + @JsonKey(name: 'personal_site_link', includeIfNull: false) final String? personalSiteLink}) = _$SocialLinksModelImpl; factory _SocialLinksModel.fromJson(Map json) = _$SocialLinksModelImpl.fromJson; @override - @JsonKey(name: 'vk_link') + @JsonKey(name: 'vk_link', includeIfNull: false) String? get vkLink; @override - @JsonKey(name: 'tg_link') + @JsonKey(name: 'tg_link', includeIfNull: false) String? get tgLink; @override - @JsonKey(name: 'fb_link') + @JsonKey(name: 'fb_link', includeIfNull: false) String? get fbLink; @override - @JsonKey(name: 'insta_link') + @JsonKey(name: 'insta_link', includeIfNull: false) String? get instaLink; @override - @JsonKey(name: 'personal_site_link') + @JsonKey(name: 'personal_site_link', includeIfNull: false) String? get personalSiteLink; /// Create a copy of SocialLinksModel diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart index ab86917a..e611c201 100644 --- a/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart @@ -23,13 +23,21 @@ _$ConsultantProfileModelImpl _$$ConsultantProfileModelImplFromJson( ); Map _$$ConsultantProfileModelImplToJson( - _$ConsultantProfileModelImpl instance) => - { - 'has_medical_education': instance.hasMedicalEducation, - 'social_links': instance.socialLinks, - 'cert_photos': instance.photos, - 'completed_courses': instance.certificates, - }; + _$ConsultantProfileModelImpl instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('has_medical_education', instance.hasMedicalEducation); + writeNotNull('social_links', instance.socialLinks); + writeNotNull('cert_photos', instance.photos); + writeNotNull('completed_courses', instance.certificates); + return val; +} _$SocialLinksModelImpl _$$SocialLinksModelImplFromJson( Map json) => @@ -42,14 +50,22 @@ _$SocialLinksModelImpl _$$SocialLinksModelImplFromJson( ); Map _$$SocialLinksModelImplToJson( - _$SocialLinksModelImpl instance) => - { - 'vk_link': instance.vkLink, - 'tg_link': instance.tgLink, - 'fb_link': instance.fbLink, - 'insta_link': instance.instaLink, - 'personal_site_link': instance.personalSiteLink, - }; + _$SocialLinksModelImpl instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('vk_link', instance.vkLink); + writeNotNull('tg_link', instance.tgLink); + writeNotNull('fb_link', instance.fbLink); + writeNotNull('insta_link', instance.instaLink); + writeNotNull('personal_site_link', instance.personalSiteLink); + return val; +} _$CertificatesModelImpl _$$CertificatesModelImplFromJson( Map json) => diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart index b60cab68..78a76708 100644 --- a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart @@ -12,7 +12,10 @@ class RegisterConsultantCubit extends Cubit { required this.consultantRepository, }) : super( RegisterConsultantState( - consultant: ConsultantProfileModel(), + consultant: ConsultantProfileModel( + socialLinks: SocialLinksModel(), + hasMedicalEducation: true, + ), ), ); diff --git a/lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart index ac8b4e11..e51aff3a 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart @@ -1,6 +1,8 @@ +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class AdditionalSettingsScreen extends StatefulWidget { const AdditionalSettingsScreen({super.key}); @@ -13,6 +15,18 @@ class _AdditionalSettingsScreenState extends State { bool publishDiplomasAndCertificatesInProfile = true; bool haveMedicalDegree = true; + @override + void initState() { + if (context.read().state.consultant.hasMedicalEducation != null) { + haveMedicalDegree = context + .read() + .state + .consultant + .hasMedicalEducation!; + } + super.initState(); + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -50,6 +64,11 @@ class _AdditionalSettingsScreenState extends State { setState(() { haveMedicalDegree = !haveMedicalDegree; }); + context.read().updateConsultantProfileModel( + context.read().state.consultant.copyWith( + hasMedicalEducation: haveMedicalDegree, + ), + ); }, ), ], diff --git a/lib/features/consultant/become_consultant/presentation/pages/certificates_and_diplomas_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/certificates_and_diplomas_screen.dart index 1eb412f7..27a4aa71 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/certificates_and_diplomas_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/certificates_and_diplomas_screen.dart @@ -1,10 +1,12 @@ import 'package:eatvio_app/features/consultant/become_consultant/entities/diploma_entity.dart'; -import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/models/consultant_profile_model.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:flutter/scheduler.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class CertificatesAndDiplomasScreen extends StatefulWidget { const CertificatesAndDiplomasScreen({super.key}); @@ -24,6 +26,27 @@ class _CertificatesAndDiplomasScreenState extends State().state.consultant.certificates != null) { + diplomasList = context + .read() + .state + .consultant + .certificates! + .map( + (e) => DiplomaEntity( + date: DateTime.tryParse(e.date), + textEditingController: TextEditingController(text: e.title), + enableDeleteButton: true, + ), + ) + .toList(); + diplomasList.last.enableDeleteButton = false; + } + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -113,6 +136,7 @@ class _CertificatesAndDiplomasScreenState extends State( context: context, builder: (BuildContext context) => Container( @@ -166,34 +191,7 @@ class _CertificatesAndDiplomasScreenState extends State().updateConsultantProfileModel( + context.read().state.consultant.copyWith( + certificates: diplomasList.map((e) => CertificatesModel(title: e.textEditingController.text, date: e.date.toString())).toList().sublist( + 0, + diplomasList.length - 1, + ), + ), + ); } } diff --git a/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart index 5f7abbef..51684b88 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart @@ -1,7 +1,9 @@ import 'dart:io'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; class PhotoOrScansScreen extends StatefulWidget { @@ -12,7 +14,14 @@ class PhotoOrScansScreen extends StatefulWidget { } class _PhotoOrScansScreenState extends State { - List images = []; + List imagesPaths = []; + + @override + void initState() { + super.initState(); + imagesPaths = + context.read().state.consultant.photos != null ? [...context.read().state.consultant.photos!] : []; + } @override Widget build(BuildContext context) { @@ -42,15 +51,17 @@ class _PhotoOrScansScreenState extends State { mainAxisSpacing: 8, ), itemBuilder: (BuildContext context, int index) { - if (index == images.length) { + if (index == imagesPaths.length) { return InkWell( borderRadius: BorderRadius.circular(20), onTap: () async { final picker = ImagePicker(); List? newImages = await picker.pickMultiImage(); + List newImagesPaths = newImages.map((e) => e.path).toList(); setState(() { - images = [...images, ...newImages]; + imagesPaths = [...imagesPaths, ...newImagesPaths]; }); + _saveState(); }, child: Ink( decoration: BoxDecoration( @@ -78,7 +89,7 @@ class _PhotoOrScansScreenState extends State { image: DecorationImage( fit: BoxFit.fitHeight, image: FileImage( - File(images[index].path), + File(imagesPaths[index]), ), ), ), @@ -89,8 +100,9 @@ class _PhotoOrScansScreenState extends State { child: InkWell( onTap: () { setState(() { - images.removeAt(index); + imagesPaths.removeAt(index); }); + _saveState(); }, customBorder: CircleBorder(), child: Ink( @@ -112,10 +124,18 @@ class _PhotoOrScansScreenState extends State { ); } }, - itemCount: images.length + 1, + itemCount: imagesPaths.length + 1, ), ], ), ); } + + _saveState() { + context.read().updateConsultantProfileModel( + context.read().state.consultant.copyWith( + photos: imagesPaths, + ), + ); + } } diff --git a/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart index 0de6e609..52e45d84 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart @@ -1,6 +1,9 @@ +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; class SocialNetworksScreen extends StatefulWidget { const SocialNetworksScreen({super.key}); @@ -10,6 +13,40 @@ class SocialNetworksScreen extends StatefulWidget { } class _SocialNetworksScreenState extends State { + final vkController = TextEditingController(); + final telegramController = TextEditingController(); + final webSiteController = TextEditingController(); + + var maskFormatter = new MaskTextInputFormatter( + mask: 'https://########################################', + filter: { + '#': RegExp(r"(\w+)"), + }, + type: MaskAutoCompletionType.lazy, + ); + var maskTgFormatter = new MaskTextInputFormatter( + mask: 'https://tg.me/########################################', + filter: { + '#': RegExp(r"(\w+)"), + }, + type: MaskAutoCompletionType.lazy, + ); + var maskVkFormatter = new MaskTextInputFormatter( + mask: 'https://vk.com/########################################', + filter: { + '#': RegExp(r"(\w+)"), + }, + type: MaskAutoCompletionType.lazy, + ); + + @override + void initState() { + super.initState(); + vkController.text = context.read().state.consultant.socialLinks!.vkLink ?? ''; + telegramController.text = context.read().state.consultant.socialLinks!.tgLink ?? ''; + webSiteController.text = context.read().state.consultant.socialLinks!.personalSiteLink ?? ''; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -46,7 +83,12 @@ class _SocialNetworksScreenState extends State { SizedBox( width: MediaQuery.of(context).size.width - 92, child: CustomTextFormField( - hintText: 'ВКонтакте', + hintText: 'vk.com/', + controller: vkController, + inputFormatters: [maskVkFormatter], + onChanged: (value) { + setLinksState(vkLink: value); + }, ), ), ], @@ -71,7 +113,12 @@ class _SocialNetworksScreenState extends State { SizedBox( width: MediaQuery.of(context).size.width - 92, child: CustomTextFormField( - hintText: 'Telegram', + hintText: 'tg.me/', + inputFormatters: [maskTgFormatter], + controller: telegramController, + onChanged: (value) { + setLinksState(tgLink: value); + }, ), ), ], @@ -96,7 +143,12 @@ class _SocialNetworksScreenState extends State { SizedBox( width: MediaQuery.of(context).size.width - 92, child: CustomTextFormField( - hintText: 'Личный сайт', + hintText: 'https://', + inputFormatters: [maskFormatter], + controller: webSiteController, + onChanged: (value) { + setLinksState(personalSiteLink: value); + }, ), ), ], @@ -105,4 +157,32 @@ class _SocialNetworksScreenState extends State { ), ); } + + setLinksState({ + String? tgLink, + String? vkLink, + String? personalSiteLink, + }) { + context.read().updateConsultantProfileModel( + context.read().state.consultant.copyWith( + socialLinks: context.read().state.consultant.socialLinks?.copyWith( + tgLink: tgLink == null + ? context.read().state.consultant.socialLinks?.tgLink + : tgLink.isEmpty + ? null + : tgLink, + vkLink: vkLink == null + ? context.read().state.consultant.socialLinks?.vkLink + : vkLink.isEmpty + ? null + : vkLink, + personalSiteLink: personalSiteLink == null + ? context.read().state.consultant.socialLinks?.personalSiteLink + : personalSiteLink.isEmpty + ? null + : personalSiteLink, + ), + ), + ); + } } diff --git a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart index bd2f3d0b..57c11b07 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart @@ -1,13 +1,16 @@ import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/certificates_and_diplomas_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/last_step_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart'; +import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; class StepperBecomeConsultantScreen extends StatefulWidget { @@ -21,197 +24,202 @@ class _StepperBecomeConsultantScreenState extends State(); @override Widget build(BuildContext context) { - return Scaffold( - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: Row( - children: [ - Container( - height: 48, - width: MediaQuery.of(context).size.width * 0.2, - padding: EdgeInsets.only(left: 16, right: 4), - child: FloatingActionButton.extended( - heroTag: 'backButtonRegistration', - highlightElevation: 0, - focusElevation: 0, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - backgroundColor: Color(0xFFEAF2FD), - onPressed: () async { - setState(() { - pageController.previousPage( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - ); - }); - }, - label: Icon( - Icons.arrow_back_ios_new_rounded, - color: appTheme.blueA400, - ), - ), - ), - Container( - height: 48, - width: MediaQuery.of(context).size.width * 0.8, - padding: EdgeInsets.only(left: 4, right: 16), - child: FloatingActionButton.extended( - heroTag: 'nextButtonRegistration', - highlightElevation: 0, - elevation: 0, - focusElevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - backgroundColor: appTheme.blueA400, - onPressed: () async { - if (step == 6) { - await showModalBottomSheet( - useRootNavigator: true, - showDragHandle: true, - context: context, - builder: (context) => Container( - padding: EdgeInsets.all(16), - width: MediaQuery.of(context).size.width, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Спасибо!\nВаши данные отправлены на модерацию', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - height: 1, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: 16), - Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: appTheme.blueA400, - shape: BoxShape.circle, - ), - child: Icon( - size: 32, - Icons.done, - color: Colors.white, - ), - ), - const SizedBox(height: 16), - Text( - 'В течении трех рабочих дней Вам придет уведомление о смене статуса', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - height: 1, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 16), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Ink( - width: MediaQuery.of(context).size.width - 32, - height: 52, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: appTheme.blueA400, - ), - child: Center( - child: Text( - 'Закрыть', - style: TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - ), - ), - ), - ], - ), - ), - ); - } else { + return BlocProvider( + create: (context) => registrationConsultantCubit, + child: Scaffold( + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButton: Row( + children: [ + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.2, + padding: EdgeInsets.only(left: 16, right: 4), + child: FloatingActionButton.extended( + heroTag: 'backButtonRegistration', + highlightElevation: 0, + focusElevation: 0, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + backgroundColor: Color(0xFFEAF2FD), + onPressed: () async { setState(() { - pageController.nextPage( + pageController.previousPage( duration: const Duration(milliseconds: 350), curve: Curves.easeInOut, ); }); - } - }, - label: Text( - 'Продолжить', - style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), + }, + label: Icon( + Icons.arrow_back_ios_new_rounded, + color: appTheme.blueA400, + ), ), ), - ), - ], - ), - appBar: AppBar( - automaticallyImplyLeading: false, - leading: Builder( - builder: (context) => IconButton( - icon: Icon(Icons.close_rounded), - onPressed: () => GoRouter.of(context).pop(), - ), - ), - centerTitle: true, - title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), - actions: [ - Padding( - padding: const EdgeInsets.only(right: 16), - child: Text('шаг $step из 6'), - ), - ], - bottom: PreferredSize( - preferredSize: Size(MediaQuery.of(context).size.width, 32), - child: Padding( - padding: const EdgeInsets.all(16), - child: TweenAnimationBuilder( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - tween: Tween( - begin: 1 / 6, - end: progressValue, + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.8, + padding: EdgeInsets.only(left: 4, right: 16), + child: FloatingActionButton.extended( + heroTag: 'nextButtonRegistration', + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + backgroundColor: appTheme.blueA400, + onPressed: () async { + if (step == 6) { + await registrationConsultantCubit.registerConsultant(); + await showModalBottomSheet( + useRootNavigator: true, + showDragHandle: true, + context: context, + builder: (context) => Container( + padding: EdgeInsets.all(16), + width: MediaQuery.of(context).size.width, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Спасибо!\nВаши данные отправлены на модерацию', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + height: 1, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: appTheme.blueA400, + shape: BoxShape.circle, + ), + child: Icon( + size: 32, + Icons.done, + color: Colors.white, + ), + ), + const SizedBox(height: 16), + Text( + 'В течении трех рабочих дней Вам придет уведомление о смене статуса', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + height: 1, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 16), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Ink( + width: MediaQuery.of(context).size.width - 32, + height: 52, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Закрыть', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } else { + setState(() { + pageController.nextPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + } + }, + label: Text( + 'Продолжить', + style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), + ), ), - builder: (context, value, _) => LinearProgressIndicator( - value: value, - borderRadius: BorderRadius.circular(16), - minHeight: 8, - backgroundColor: Colors.grey.shade100, - valueColor: AlwaysStoppedAnimation(appTheme.blueA400), + ), + ], + ), + appBar: AppBar( + automaticallyImplyLeading: false, + leading: Builder( + builder: (context) => IconButton( + icon: Icon(Icons.close_rounded), + onPressed: () => GoRouter.of(context).pop(), + ), + ), + centerTitle: true, + title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), + actions: [ + Padding( + padding: const EdgeInsets.only(right: 16), + child: Text('шаг $step из 6'), + ), + ], + bottom: PreferredSize( + preferredSize: Size(MediaQuery.of(context).size.width, 32), + child: Padding( + padding: const EdgeInsets.all(16), + child: TweenAnimationBuilder( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + tween: Tween( + begin: 1 / 6, + end: progressValue, + ), + builder: (context, value, _) => LinearProgressIndicator( + value: value, + borderRadius: BorderRadius.circular(16), + minHeight: 8, + backgroundColor: Colors.grey.shade100, + valueColor: AlwaysStoppedAnimation(appTheme.blueA400), + ), ), ), ), ), - ), - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - onPageChanged: (index) { - setState(() { - step = index + 1; - progressValue = step / 6; - }); - }, - children: [ - CertificatesAndDiplomasScreen(), - PhotoOrScansScreen(), - AdditionalSettingsScreen(), - SocialNetworksScreen(), - RegistrationAsScreen(), - LastStepScreen(), - ], + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + onPageChanged: (index) { + setState(() { + step = index + 1; + progressValue = step / 6; + }); + }, + children: [ + CertificatesAndDiplomasScreen(), + PhotoOrScansScreen(), + AdditionalSettingsScreen(), + SocialNetworksScreen(), + RegistrationAsScreen(), + LastStepScreen(), + ], + ), ), ); } diff --git a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart index 35594b96..f0ea7897 100644 --- a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart +++ b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart @@ -16,7 +16,7 @@ class ConsultantRepository { }) async { try { return await consultantService.consultantRegistration( - consultantModel: consultant.toJson(), + consultantModel: consultant, ); } catch (e) { print(e); diff --git a/lib/features/consultant/become_consultant/services/consultant_service.dart b/lib/features/consultant/become_consultant/services/consultant_service.dart index ecfe5e14..4479122f 100644 --- a/lib/features/consultant/become_consultant/services/consultant_service.dart +++ b/lib/features/consultant/become_consultant/services/consultant_service.dart @@ -1,4 +1,5 @@ import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/models/consultant_profile_model.dart'; import 'package:retrofit/retrofit.dart'; part 'consultant_service.g.dart'; @@ -9,7 +10,7 @@ abstract class ConsultantService { @POST('/api/consultant_request/registration') Future consultantRegistration({ - @Body() required Map consultantModel, + @Body() required ConsultantProfileModel consultantModel, }); @POST('/api/consultant_request/photos/upload') diff --git a/lib/features/consultant/become_consultant/services/consultant_service.g.dart b/lib/features/consultant/become_consultant/services/consultant_service.g.dart index 41bc384c..870c1d5d 100644 --- a/lib/features/consultant/become_consultant/services/consultant_service.g.dart +++ b/lib/features/consultant/become_consultant/services/consultant_service.g.dart @@ -23,12 +23,11 @@ class _ConsultantService implements ConsultantService { @override Future consultantRegistration( - {required Map consultantModel}) async { + {required ConsultantProfileModel consultantModel}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; - final _data = {}; - _data.addAll(consultantModel); + final _data = consultantModel; final _options = _setStreamType(Options( method: 'POST', headers: _headers, diff --git a/pubspec.yaml b/pubspec.yaml index de3084db..d87c49e8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,7 @@ dependencies: audioplayers: ^6.1.0 intl: ^0.19.0 rive: ^0.13.14 + mask_text_input_formatter: ^2.9.0 dev_dependencies: build_runner: ^2.4.13 From 78be72372c685f28d3dd88e62cb07f9186cbcd80 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 14 Oct 2024 15:07:07 +0300 Subject: [PATCH 2/3] feature: consultant registration --- .../register_consultant_cubit.dart | 18 ++- .../register_consultant_state.dart | 1 + .../register_consultant_state.freezed.dart | 34 ++++- .../presentation/pages/last_step_screen.dart | 3 + .../stepper_become_consultant_screen.dart | 144 ++++++++++-------- .../profile/models/profile_model.dart | 1 + .../profile/models/profile_model.freezed.dart | 35 ++++- .../profile/models/profile_model.g.dart | 2 + .../bloc/settings_cubit/settings_cubit.dart | 1 + .../bloc/settings_cubit/settings_state.dart | 1 + .../settings_state.freezed.dart | 76 +++++---- .../presentation/pages/settings_screen.dart | 71 ++++----- 12 files changed, 244 insertions(+), 143 deletions(-) diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart index 78a76708..be228de2 100644 --- a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart @@ -16,18 +16,28 @@ class RegisterConsultantCubit extends Cubit { socialLinks: SocialLinksModel(), hasMedicalEducation: true, ), + acceptOffer: false, ), ); - updateConsultantProfileModel(ConsultantProfileModel consultant) { - emit(RegisterConsultantState(consultant: consultant)); + updateConsultantProfileModel(ConsultantProfileModel consultant, [bool acceptOffer = false]) { + emit(RegisterConsultantState(consultant: consultant, acceptOffer: acceptOffer)); } registerConsultant() async { + if (state.consultant.photos != null) { + updateConsultantProfileModel( + state.consultant.copyWith( + photos: await uploadPhotos( + state.consultant.photos!.map((e) => File(e)).toList(), + ), + ), + ); + } await consultantRepository.registerConsultant(consultant: state.consultant); } - uploadPhotos(List files) async { - await consultantRepository.uploadPhotos(files: files); + Future> uploadPhotos(List files) async { + return await consultantRepository.uploadPhotos(files: files); } } diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart index cb8cafe6..5f318efe 100644 --- a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart @@ -7,5 +7,6 @@ part 'register_consultant_state.freezed.dart'; abstract class RegisterConsultantState with _$RegisterConsultantState { const factory RegisterConsultantState({ required ConsultantProfileModel consultant, + required bool acceptOffer, }) = _RegisterConsultantState; } diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart index f516e7bf..1bd087fe 100644 --- a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart @@ -17,6 +17,7 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$RegisterConsultantState { ConsultantProfileModel get consultant => throw _privateConstructorUsedError; + bool get acceptOffer => throw _privateConstructorUsedError; /// Create a copy of RegisterConsultantState /// with the given fields replaced by the non-null parameter values. @@ -31,7 +32,7 @@ abstract class $RegisterConsultantStateCopyWith<$Res> { $Res Function(RegisterConsultantState) then) = _$RegisterConsultantStateCopyWithImpl<$Res, RegisterConsultantState>; @useResult - $Res call({ConsultantProfileModel consultant}); + $Res call({ConsultantProfileModel consultant, bool acceptOffer}); $ConsultantProfileModelCopyWith<$Res> get consultant; } @@ -53,12 +54,17 @@ class _$RegisterConsultantStateCopyWithImpl<$Res, @override $Res call({ Object? consultant = null, + Object? acceptOffer = null, }) { return _then(_value.copyWith( consultant: null == consultant ? _value.consultant : consultant // ignore: cast_nullable_to_non_nullable as ConsultantProfileModel, + acceptOffer: null == acceptOffer + ? _value.acceptOffer + : acceptOffer // ignore: cast_nullable_to_non_nullable + as bool, ) as $Val); } @@ -82,7 +88,7 @@ abstract class _$$RegisterConsultantStateImplCopyWith<$Res> __$$RegisterConsultantStateImplCopyWithImpl<$Res>; @override @useResult - $Res call({ConsultantProfileModel consultant}); + $Res call({ConsultantProfileModel consultant, bool acceptOffer}); @override $ConsultantProfileModelCopyWith<$Res> get consultant; @@ -104,12 +110,17 @@ class __$$RegisterConsultantStateImplCopyWithImpl<$Res> @override $Res call({ Object? consultant = null, + Object? acceptOffer = null, }) { return _then(_$RegisterConsultantStateImpl( consultant: null == consultant ? _value.consultant : consultant // ignore: cast_nullable_to_non_nullable as ConsultantProfileModel, + acceptOffer: null == acceptOffer + ? _value.acceptOffer + : acceptOffer // ignore: cast_nullable_to_non_nullable + as bool, )); } } @@ -117,14 +128,17 @@ class __$$RegisterConsultantStateImplCopyWithImpl<$Res> /// @nodoc class _$RegisterConsultantStateImpl implements _RegisterConsultantState { - const _$RegisterConsultantStateImpl({required this.consultant}); + const _$RegisterConsultantStateImpl( + {required this.consultant, required this.acceptOffer}); @override final ConsultantProfileModel consultant; + @override + final bool acceptOffer; @override String toString() { - return 'RegisterConsultantState(consultant: $consultant)'; + return 'RegisterConsultantState(consultant: $consultant, acceptOffer: $acceptOffer)'; } @override @@ -133,11 +147,13 @@ class _$RegisterConsultantStateImpl implements _RegisterConsultantState { (other.runtimeType == runtimeType && other is _$RegisterConsultantStateImpl && (identical(other.consultant, consultant) || - other.consultant == consultant)); + other.consultant == consultant) && + (identical(other.acceptOffer, acceptOffer) || + other.acceptOffer == acceptOffer)); } @override - int get hashCode => Object.hash(runtimeType, consultant); + int get hashCode => Object.hash(runtimeType, consultant, acceptOffer); /// Create a copy of RegisterConsultantState /// with the given fields replaced by the non-null parameter values. @@ -151,11 +167,13 @@ class _$RegisterConsultantStateImpl implements _RegisterConsultantState { abstract class _RegisterConsultantState implements RegisterConsultantState { const factory _RegisterConsultantState( - {required final ConsultantProfileModel consultant}) = - _$RegisterConsultantStateImpl; + {required final ConsultantProfileModel consultant, + required final bool acceptOffer}) = _$RegisterConsultantStateImpl; @override ConsultantProfileModel get consultant; + @override + bool get acceptOffer; /// Create a copy of RegisterConsultantState /// with the given fields replaced by the non-null parameter values. diff --git a/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart index 89e3e2d4..d24f205a 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart @@ -1,6 +1,8 @@ import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:url_launcher/url_launcher.dart'; class LastStepScreen extends StatefulWidget { @@ -46,6 +48,7 @@ class _LastStepScreenState extends State { setState(() { checkboxState = !checkboxState; }); + context.read().updateConsultantProfileModel(context.read().state.consultant, checkboxState); }, activeColor: appTheme.blueA400, contentPadding: const EdgeInsets.symmetric(horizontal: 16), diff --git a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart index 57c11b07..7bc05885 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart @@ -76,77 +76,95 @@ class _StepperBecomeConsultantScreenState extends State Container( - padding: EdgeInsets.all(16), - width: MediaQuery.of(context).size.width, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Спасибо!\nВаши данные отправлены на модерацию', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - height: 1, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: 16), - Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: appTheme.blueA400, - shape: BoxShape.circle, - ), - child: Icon( - size: 32, - Icons.done, - color: Colors.white, - ), - ), - const SizedBox(height: 16), - Text( - 'В течении трех рабочих дней Вам придет уведомление о смене статуса', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - height: 1, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 16), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Ink( - width: MediaQuery.of(context).size.width - 32, - height: 52, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: appTheme.blueA400, + if (registrationConsultantCubit.state.acceptOffer) { + await registrationConsultantCubit.registerConsultant(); + await showModalBottomSheet( + useRootNavigator: true, + showDragHandle: true, + context: context, + builder: (context) => Container( + padding: EdgeInsets.all(16), + width: MediaQuery.of(context).size.width, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Спасибо!\nВаши данные отправлены на модерацию', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + height: 1, + fontWeight: FontWeight.w600, ), - child: Center( - child: Text( - 'Закрыть', - style: TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w600, + ), + const SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: appTheme.blueA400, + shape: BoxShape.circle, + ), + child: Icon( + size: 32, + Icons.done, + color: Colors.white, + ), + ), + const SizedBox(height: 16), + Text( + 'В течении трех рабочих дней Вам придет уведомление о смене статуса', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + height: 1, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 16), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Ink( + width: MediaQuery.of(context).size.width - 32, + height: 52, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Закрыть', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), ), ), ), ), + ], + ), + ), + ); + } else { + showDialog( + context: context, + builder: (context) => AlertDialog( + actionsPadding: const EdgeInsets.symmetric(horizontal: 4), + content: Text('Примите договор публичной офёрты'), + actions: [ + TextButton( + child: const Text('Ок'), + onPressed: () { + Navigator.of(context).pop(); + }, ), ], ), - ), - ); + ); + } } else { setState(() { pageController.nextPage( diff --git a/lib/features/profile/models/profile_model.dart b/lib/features/profile/models/profile_model.dart index d209e6d7..12580fea 100644 --- a/lib/features/profile/models/profile_model.dart +++ b/lib/features/profile/models/profile_model.dart @@ -16,6 +16,7 @@ class ProfileModel with _$ProfileModel { @JsonKey(name: "is_public_profile") required bool isPublicProfile, @JsonKey(name: "slug") required String slug, @JsonKey(name: "profile_photo_url") required String profilePhotoUrl, + required String role, }) = _ProfileModel; factory ProfileModel.fromJson(Map json) => _$ProfileModelFromJson(json); diff --git a/lib/features/profile/models/profile_model.freezed.dart b/lib/features/profile/models/profile_model.freezed.dart index 94b860a3..844e51af 100644 --- a/lib/features/profile/models/profile_model.freezed.dart +++ b/lib/features/profile/models/profile_model.freezed.dart @@ -38,6 +38,7 @@ mixin _$ProfileModel { String get slug => throw _privateConstructorUsedError; @JsonKey(name: "profile_photo_url") String get profilePhotoUrl => throw _privateConstructorUsedError; + String get role => throw _privateConstructorUsedError; /// Serializes this ProfileModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -64,7 +65,8 @@ abstract class $ProfileModelCopyWith<$Res> { @JsonKey(name: "updated_at") DateTime? updatedAt, @JsonKey(name: "is_public_profile") bool isPublicProfile, @JsonKey(name: "slug") String slug, - @JsonKey(name: "profile_photo_url") String profilePhotoUrl}); + @JsonKey(name: "profile_photo_url") String profilePhotoUrl, + String role}); } /// @nodoc @@ -91,6 +93,7 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> Object? isPublicProfile = null, Object? slug = null, Object? profilePhotoUrl = null, + Object? role = null, }) { return _then(_value.copyWith( id: null == id @@ -129,6 +132,10 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> ? _value.profilePhotoUrl : profilePhotoUrl // ignore: cast_nullable_to_non_nullable as String, + role: null == role + ? _value.role + : role // ignore: cast_nullable_to_non_nullable + as String, ) as $Val); } } @@ -150,7 +157,8 @@ abstract class _$$ProfileModelImplCopyWith<$Res> @JsonKey(name: "updated_at") DateTime? updatedAt, @JsonKey(name: "is_public_profile") bool isPublicProfile, @JsonKey(name: "slug") String slug, - @JsonKey(name: "profile_photo_url") String profilePhotoUrl}); + @JsonKey(name: "profile_photo_url") String profilePhotoUrl, + String role}); } /// @nodoc @@ -175,6 +183,7 @@ class __$$ProfileModelImplCopyWithImpl<$Res> Object? isPublicProfile = null, Object? slug = null, Object? profilePhotoUrl = null, + Object? role = null, }) { return _then(_$ProfileModelImpl( id: null == id @@ -213,6 +222,10 @@ class __$$ProfileModelImplCopyWithImpl<$Res> ? _value.profilePhotoUrl : profilePhotoUrl // ignore: cast_nullable_to_non_nullable as String, + role: null == role + ? _value.role + : role // ignore: cast_nullable_to_non_nullable + as String, )); } } @@ -229,7 +242,8 @@ class _$ProfileModelImpl implements _ProfileModel { @JsonKey(name: "updated_at") this.updatedAt, @JsonKey(name: "is_public_profile") required this.isPublicProfile, @JsonKey(name: "slug") required this.slug, - @JsonKey(name: "profile_photo_url") required this.profilePhotoUrl}); + @JsonKey(name: "profile_photo_url") required this.profilePhotoUrl, + required this.role}); factory _$ProfileModelImpl.fromJson(Map json) => _$$ProfileModelImplFromJson(json); @@ -261,10 +275,12 @@ class _$ProfileModelImpl implements _ProfileModel { @override @JsonKey(name: "profile_photo_url") final String profilePhotoUrl; + @override + final String role; @override String toString() { - return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl)'; + return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role)'; } @override @@ -285,13 +301,14 @@ class _$ProfileModelImpl implements _ProfileModel { other.isPublicProfile == isPublicProfile) && (identical(other.slug, slug) || other.slug == slug) && (identical(other.profilePhotoUrl, profilePhotoUrl) || - other.profilePhotoUrl == profilePhotoUrl)); + other.profilePhotoUrl == profilePhotoUrl) && + (identical(other.role, role) || other.role == role)); } @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, name, email, emailVerifiedAt, - createdAt, updatedAt, isPublicProfile, slug, profilePhotoUrl); + createdAt, updatedAt, isPublicProfile, slug, profilePhotoUrl, role); /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. @@ -319,8 +336,8 @@ abstract class _ProfileModel implements ProfileModel { @JsonKey(name: "updated_at") final DateTime? updatedAt, @JsonKey(name: "is_public_profile") required final bool isPublicProfile, @JsonKey(name: "slug") required final String slug, - @JsonKey(name: "profile_photo_url") - required final String profilePhotoUrl}) = _$ProfileModelImpl; + @JsonKey(name: "profile_photo_url") required final String profilePhotoUrl, + required final String role}) = _$ProfileModelImpl; factory _ProfileModel.fromJson(Map json) = _$ProfileModelImpl.fromJson; @@ -352,6 +369,8 @@ abstract class _ProfileModel implements ProfileModel { @override @JsonKey(name: "profile_photo_url") String get profilePhotoUrl; + @override + String get role; /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. diff --git a/lib/features/profile/models/profile_model.g.dart b/lib/features/profile/models/profile_model.g.dart index 28e10ccf..7a0c1876 100644 --- a/lib/features/profile/models/profile_model.g.dart +++ b/lib/features/profile/models/profile_model.g.dart @@ -23,6 +23,7 @@ _$ProfileModelImpl _$$ProfileModelImplFromJson(Map json) => isPublicProfile: json['is_public_profile'] as bool, slug: json['slug'] as String, profilePhotoUrl: json['profile_photo_url'] as String, + role: json['role'] as String, ); Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => @@ -36,6 +37,7 @@ Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => 'is_public_profile': instance.isPublicProfile, 'slug': instance.slug, 'profile_photo_url': instance.profilePhotoUrl, + 'role': instance.role, }; _$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson( diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart index ce448c88..488524e8 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart @@ -19,6 +19,7 @@ class SettingsCubit extends Cubit { emit(SettingsState.loaded( profileSettings: await settingsRepository.getProfileSettings(), profileDetails: await profileRepository.getMyProfileDetails(), + profile: await profileRepository.getMyProfile(), )); } catch (e) { emit(SettingsState.error(errorMessage: e.toString())); diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart index 41977b39..34922051 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart @@ -13,6 +13,7 @@ abstract class SettingsState with _$SettingsState { const factory SettingsState.loaded({ required ProfileSettingsModel profileSettings, required ProfileDetailsModel profileDetails, + required ProfileModel profile, }) = SettingsStateLoaded; const factory SettingsState.error({ diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart index f19981b6..a812e217 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart @@ -21,7 +21,7 @@ mixin _$SettingsState { TResult Function() $default, { required TResult Function() loading, required TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails) + ProfileDetailsModel profileDetails, ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) => @@ -31,7 +31,7 @@ mixin _$SettingsState { TResult? Function()? $default, { TResult? Function()? loading, TResult? Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) => @@ -41,7 +41,7 @@ mixin _$SettingsState { TResult Function()? $default, { TResult Function()? loading, TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -139,7 +139,7 @@ class _$SettingsStateImpl implements _SettingsState { TResult Function() $default, { required TResult Function() loading, required TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails) + ProfileDetailsModel profileDetails, ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { @@ -152,7 +152,7 @@ class _$SettingsStateImpl implements _SettingsState { TResult? Function()? $default, { TResult? Function()? loading, TResult? Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -165,7 +165,7 @@ class _$SettingsStateImpl implements _SettingsState { TResult Function()? $default, { TResult Function()? loading, TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -263,7 +263,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading { TResult Function() $default, { required TResult Function() loading, required TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails) + ProfileDetailsModel profileDetails, ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { @@ -276,7 +276,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading { TResult? Function()? $default, { TResult? Function()? loading, TResult? Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -289,7 +289,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading { TResult Function()? $default, { TResult Function()? loading, TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -350,10 +350,12 @@ abstract class _$$SettingsStateLoadedImplCopyWith<$Res> { @useResult $Res call( {ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails}); + ProfileDetailsModel profileDetails, + ProfileModel profile}); $ProfileSettingsModelCopyWith<$Res> get profileSettings; $ProfileDetailsModelCopyWith<$Res> get profileDetails; + $ProfileModelCopyWith<$Res> get profile; } /// @nodoc @@ -371,6 +373,7 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res> $Res call({ Object? profileSettings = null, Object? profileDetails = null, + Object? profile = null, }) { return _then(_$SettingsStateLoadedImpl( profileSettings: null == profileSettings @@ -381,6 +384,10 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res> ? _value.profileDetails : profileDetails // ignore: cast_nullable_to_non_nullable as ProfileDetailsModel, + profile: null == profile + ? _value.profile + : profile // ignore: cast_nullable_to_non_nullable + as ProfileModel, )); } @@ -403,22 +410,36 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res> return _then(_value.copyWith(profileDetails: value)); }); } + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProfileModelCopyWith<$Res> get profile { + return $ProfileModelCopyWith<$Res>(_value.profile, (value) { + return _then(_value.copyWith(profile: value)); + }); + } } /// @nodoc class _$SettingsStateLoadedImpl implements SettingsStateLoaded { const _$SettingsStateLoadedImpl( - {required this.profileSettings, required this.profileDetails}); + {required this.profileSettings, + required this.profileDetails, + required this.profile}); @override final ProfileSettingsModel profileSettings; @override final ProfileDetailsModel profileDetails; + @override + final ProfileModel profile; @override String toString() { - return 'SettingsState.loaded(profileSettings: $profileSettings, profileDetails: $profileDetails)'; + return 'SettingsState.loaded(profileSettings: $profileSettings, profileDetails: $profileDetails, profile: $profile)'; } @override @@ -429,11 +450,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded { (identical(other.profileSettings, profileSettings) || other.profileSettings == profileSettings) && (identical(other.profileDetails, profileDetails) || - other.profileDetails == profileDetails)); + other.profileDetails == profileDetails) && + (identical(other.profile, profile) || other.profile == profile)); } @override - int get hashCode => Object.hash(runtimeType, profileSettings, profileDetails); + int get hashCode => + Object.hash(runtimeType, profileSettings, profileDetails, profile); /// Create a copy of SettingsState /// with the given fields replaced by the non-null parameter values. @@ -450,11 +473,11 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded { TResult Function() $default, { required TResult Function() loading, required TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails) + ProfileDetailsModel profileDetails, ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { - return loaded(profileSettings, profileDetails); + return loaded(profileSettings, profileDetails, profile); } @override @@ -463,11 +486,11 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded { TResult? Function()? $default, { TResult? Function()? loading, TResult? Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(profileSettings, profileDetails); + return loaded?.call(profileSettings, profileDetails, profile); } @override @@ -476,13 +499,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded { TResult Function()? $default, { TResult Function()? loading, TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(profileSettings, profileDetails); + return loaded(profileSettings, profileDetails, profile); } return orElse(); } @@ -527,12 +550,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded { abstract class SettingsStateLoaded implements SettingsState { const factory SettingsStateLoaded( - {required final ProfileSettingsModel profileSettings, - required final ProfileDetailsModel profileDetails}) = - _$SettingsStateLoadedImpl; + {required final ProfileSettingsModel profileSettings, + required final ProfileDetailsModel profileDetails, + required final ProfileModel profile}) = _$SettingsStateLoadedImpl; ProfileSettingsModel get profileSettings; ProfileDetailsModel get profileDetails; + ProfileModel get profile; /// Create a copy of SettingsState /// with the given fields replaced by the non-null parameter values. @@ -614,7 +638,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError { TResult Function() $default, { required TResult Function() loading, required TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails) + ProfileDetailsModel profileDetails, ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { @@ -627,7 +651,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError { TResult? Function()? $default, { TResult? Function()? loading, TResult? Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -640,7 +664,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError { TResult Function()? $default, { TResult Function()? loading, TResult Function(ProfileSettingsModel profileSettings, - ProfileDetailsModel profileDetails)? + ProfileDetailsModel profileDetails, ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart index c0a8901b..e47a90fc 100644 --- a/lib/features/settings/presentation/pages/settings_screen.dart +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -56,8 +56,11 @@ class _SettingsScreenState extends State { const SizedBox(height: 12), _aboutEatvio(state), const SizedBox(height: 12), - _becomeConsultantButton(state), - const SizedBox(height: 8), + if (state.profile.role != 'consultant') + Padding( + padding: const EdgeInsets.only(bottom: 8), + child: _becomeConsultantButton(state), + ), _deleteAccountButton(state), ], ), @@ -213,10 +216,10 @@ class _SettingsScreenState extends State { updatesNotificationsSwitchState = !updatesNotificationsSwitchState; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - newUpdatesNotifications: updatesNotificationsSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + newUpdatesNotifications: updatesNotificationsSwitchState, + ), + ); }, title: 'Уведомление о новых обновлениях', trailing: CupertinoSwitch( @@ -227,10 +230,10 @@ class _SettingsScreenState extends State { updatesNotificationsSwitchState = newValue; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - newUpdatesNotifications: updatesNotificationsSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + newUpdatesNotifications: updatesNotificationsSwitchState, + ), + ); }, ), ), @@ -242,10 +245,10 @@ class _SettingsScreenState extends State { fillDiaryNotificationsSwitchState = !fillDiaryNotificationsSwitchState; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - diaryReminderNotifications: fillDiaryNotificationsSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + diaryReminderNotifications: fillDiaryNotificationsSwitchState, + ), + ); }, title: 'Напоминание о заполнении дневника', trailing: CupertinoSwitch( @@ -256,10 +259,10 @@ class _SettingsScreenState extends State { fillDiaryNotificationsSwitchState = newValue; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - diaryReminderNotifications: fillDiaryNotificationsSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + diaryReminderNotifications: fillDiaryNotificationsSwitchState, + ), + ); }, ), ), @@ -271,10 +274,10 @@ class _SettingsScreenState extends State { moodSwitchState = !moodSwitchState; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - isMoodFillable: moodSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + isMoodFillable: moodSwitchState, + ), + ); }, title: 'Указывать “настроение” в заполнение дневника', trailing: CupertinoSwitch( @@ -285,10 +288,10 @@ class _SettingsScreenState extends State { moodSwitchState = newValue; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - isMoodFillable: moodSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + isMoodFillable: moodSwitchState, + ), + ); }, ), ), @@ -300,10 +303,10 @@ class _SettingsScreenState extends State { bedTimeSwitchState = !bedTimeSwitchState; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - isBedtimeFillable: bedTimeSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + isBedtimeFillable: bedTimeSwitchState, + ), + ); }, title: 'Указывать “отход ко сну” в заполнение дневника', trailing: CupertinoSwitch( @@ -314,10 +317,10 @@ class _SettingsScreenState extends State { bedTimeSwitchState = newValue; }); settingsCubit.updateProfileSettings( - profileSettingsModel: state.profileSettings.copyWith( - isBedtimeFillable: bedTimeSwitchState, - ), - ); + profileSettingsModel: state.profileSettings.copyWith( + isBedtimeFillable: bedTimeSwitchState, + ), + ); }, ), ), From df290fa89b09a2d568357ff48e600cbe57dae16f Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 14 Oct 2024 16:23:43 +0300 Subject: [PATCH 3/3] =?UTF-8?q?feature(consultant):=20=D0=9D=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D1=82=D0=BE=D1=87=D0=BA?= =?UTF-8?q?=D1=83=20=D0=B2=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B5=20=D1=81?= =?UTF-8?q?=D0=B0=D0=B9=D1=82=D0=B0=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BB=D0=BE=D1=82=D0=B8=20=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D1=86=D0=B8=D1=8E=20=D0=BD=D0=B0=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=D0=BB=D0=BA=D1=83=20=D0=B7=D0=B0=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=D0=A3=D0=B1=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D1=84=D0=BE=D0=BA=D1=83=D1=81=20=D0=BD=D0=B0=204=20?= =?UTF-8?q?=D1=88=D0=B0=D0=B3=D0=B5=20(=D1=81=D0=BE=D1=86=D1=81=D0=B5?= =?UTF-8?q?=D1=82=D0=B8)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=20=D1=81=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5=D0=B3=D0=BE=20=D1=8D=D0=BA=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=D1=80=D0=B0=D0=B4=D0=B8=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D1=82=D1=82=D0=BE=D0=BD=20=D0=BD=D0=B0=205=20=D1=88=D0=B0?= =?UTF-8?q?=D0=B3=D0=B5=20=D0=B2=20=D1=81=D0=B8=D0=BD=D0=B8=D0=B9=20=D1=86?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=D0=BE=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B3=D0=B0=D0=BB=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=8E=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=D0=9B=D0=BE=D0=B0=D0=B4=D0=B8=D0=BD=D0=B3=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B5=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/lottie_animations/success.json | 1 + .../presentation/pages/photo_view_screen.dart | 14 +- .../pages/become_consultant_screen.dart | 7 +- .../pages/photo_or_scans_screen.dart | 105 +++++---- .../pages/registration_as_screen.dart | 2 + .../pages/social_networks_screen.dart | 6 +- .../stepper_become_consultant_screen.dart | 220 ++++++++++-------- pubspec.yaml | 2 + 8 files changed, 208 insertions(+), 149 deletions(-) create mode 100644 assets/lottie_animations/success.json diff --git a/assets/lottie_animations/success.json b/assets/lottie_animations/success.json new file mode 100644 index 00000000..7758fd87 --- /dev/null +++ b/assets/lottie_animations/success.json @@ -0,0 +1 @@ +{"v":"5.5.9","fr":24,"ip":0,"op":60,"w":800,"h":800,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[415,382,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-22,1],[0,0]],"o":[[0,0],[22,-1],[0,0]],"v":[[-134,56],[-74,108],[72,-56]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":55,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[85.449,85.449],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.853],"y":[1]},"o":{"x":[0.463],"y":[0]},"t":22,"s":[0]},{"t":36,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[0]},{"t":22,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":384,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[394,396,0],"ix":2},"a":{"a":0,"k":[-54.531,27.469,0],"ix":1},"s":{"a":0,"k":[152.399,152.399,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[262.938,262.938],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.6470588235294118,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-54.531,27.469],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.041],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":4,"s":[0]},{"i":{"x":[0.041],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":15,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.959],"y":[0]},"t":31,"s":[100]},{"t":42,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.093],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.093],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.907],"y":[0]},"t":27,"s":[100]},{"t":39,"s":[0]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":384,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[394,396,0],"ix":2},"a":{"a":0,"k":[-54.531,27.469,0],"ix":1},"s":{"a":0,"k":[170.654,170.654,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[262.938,262.938],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.9607843137254902,0.6509803921568628,0.13725490196078433,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-54.531,27.469],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":20,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":33,"s":[100]},{"t":47,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":2,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":17,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":29,"s":[100]},{"t":44,"s":[0]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":12,"s":[360]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":27,"s":[360]},{"t":39,"s":[0]}],"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":384,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[394,396,0],"ix":2},"a":{"a":0,"k":[-54.531,27.469,0],"ix":1},"s":{"a":0,"k":[191.952,191.952,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[262.938,262.938],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.6470588235294118,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":4,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-54.531,27.469],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":36,"s":[100]},{"t":50,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":21,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":32,"s":[100]},{"t":47,"s":[0]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":4,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":16,"s":[360]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[1],"y":[0]},"t":30,"s":[360]},{"t":42,"s":[0]}],"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":384,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[394,396,0],"ix":2},"a":{"a":0,"k":[-54.531,27.469,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0,0,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[0,0,100]},{"i":{"x":[0,0,0.667],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":16,"s":[141.835,141.835,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[1,1,0.333],"y":[0,0,0]},"t":27,"s":[141.835,141.835,100]},{"t":43,"s":[0,0,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[262.938,262.938],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.6470588235294118,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-54.531,27.469],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":384,"st":0,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/lib/features/chat/presentation/pages/photo_view_screen.dart b/lib/features/chat/presentation/pages/photo_view_screen.dart index 4bc71ee9..b7fce0c5 100644 --- a/lib/features/chat/presentation/pages/photo_view_screen.dart +++ b/lib/features/chat/presentation/pages/photo_view_screen.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; import 'package:eatvio_app/core/const.dart'; @@ -11,11 +13,13 @@ import 'package:url_launcher/url_launcher.dart'; class PhotoViewScreen extends StatefulWidget { final List imageUrls; final int index; + final bool isLocal; const PhotoViewScreen({ super.key, required this.imageUrls, required this.index, + this.isLocal = false, }); @override @@ -47,9 +51,13 @@ class _PhotoViewScreenState extends State { scrollPhysics: const BouncingScrollPhysics(), builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( - imageProvider: CachedNetworkImageProvider( - widget.imageUrls[index], - ), + imageProvider: widget.isLocal + ? FileImage( + File(widget.imageUrls[index]), + ) as ImageProvider + : CachedNetworkImageProvider( + widget.imageUrls[index], + ), initialScale: PhotoViewComputedScale.contained, minScale: PhotoViewComputedScale.contained, heroAttributes: PhotoViewHeroAttributes( diff --git a/lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart index bf7ec475..c2807492 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart @@ -24,7 +24,12 @@ class _BecomeConsultantScreenState extends State { ), body: Padding( padding: const EdgeInsets.all(16), - child: Text('Для регистрации потребуется следующий список документов, подготовьте их заранее'), + child: Text( + ' Чтобы стать консультантом необходимо пройти короткую регистрацию. Подготовьте свои дипломы и/или сертификаты в формате jpg, они Вам пригодятся для проверки и подтверждения. Также необходимо будет указать ссылки на Ваши соц. сети и указать тип лица (физ. лицо или юр. лицо). На данный момент доступна регистрация в качестве физ. лица.\n\n Внутри Итвио разница между обычным пользователем и консультантом заключается в дополнительных возможностях последнего создавать публичные диеты, рецепты и планы питания; участвовать в ежемесячных рейтингах.', + style: TextStyle( + fontSize: 16, + ), + ), ), bottomSheet: _startRegistrationButton(), ); diff --git a/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart index 51684b88..eae359c2 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart @@ -1,5 +1,7 @@ import 'dart:io'; +import 'package:dismissible_page/dismissible_page.dart'; +import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; @@ -75,51 +77,66 @@ class _PhotoOrScansScreenState extends State { ), ); } else { - return InkWell( - onTap: () {}, - borderRadius: BorderRadius.circular(20), - child: Stack( - clipBehavior: Clip.none, - children: [ - Ink( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(20), + return Hero( + tag: imagesPaths[index], + child: Material( + borderRadius: BorderRadius.circular(20), + child: InkWell( + onTap: () { + context.pushTransparentRoute( + rootNavigator: true, + PhotoViewScreen( + imageUrls: imagesPaths, + isLocal: true, + index: index, ), - image: DecorationImage( - fit: BoxFit.fitHeight, - image: FileImage( - File(imagesPaths[index]), - ), - ), - ), - ), - Positioned( - right: -12, - top: -12, - child: InkWell( - onTap: () { - setState(() { - imagesPaths.removeAt(index); - }); - _saveState(); - }, - customBorder: CircleBorder(), - child: Ink( - padding: EdgeInsets.all(4), + ); + }, + borderRadius: BorderRadius.circular(20), + child: Stack( + clipBehavior: Clip.none, + children: [ + Ink( decoration: BoxDecoration( - color: Color(0xFFF1F2F6), - shape: BoxShape.circle, - ), - child: Icon( - size: 20, - Icons.close, - color: Colors.black, + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + image: DecorationImage( + fit: BoxFit.fitHeight, + image: FileImage( + File(imagesPaths[index]), + ), + ), ), ), - ), + Positioned( + right: -12, + top: -12, + child: InkWell( + onTap: () { + setState(() { + imagesPaths.removeAt(index); + }); + _saveState(); + }, + customBorder: CircleBorder(), + child: Ink( + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xFFF1F2F6), + shape: BoxShape.circle, + ), + child: Icon( + size: 20, + Icons.close, + color: Colors.black, + ), + ), + ), + ), + ], ), - ], + ), ), ); } @@ -133,9 +150,9 @@ class _PhotoOrScansScreenState extends State { _saveState() { context.read().updateConsultantProfileModel( - context.read().state.consultant.copyWith( - photos: imagesPaths, - ), - ); + context.read().state.consultant.copyWith( + photos: imagesPaths, + ), + ); } } diff --git a/lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart index 9f6ee8e3..764f1653 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class RegistrationAsScreen extends StatefulWidget { @@ -42,6 +43,7 @@ class _RegistrationAsScreenState extends State { height: 1, ), ), + activeColor: appTheme.blueA400, onChanged: (value) {}, contentPadding: EdgeInsets.symmetric(horizontal: 8), ), diff --git a/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart index 52e45d84..fb62e42d 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart @@ -20,21 +20,21 @@ class _SocialNetworksScreenState extends State { var maskFormatter = new MaskTextInputFormatter( mask: 'https://########################################', filter: { - '#': RegExp(r"(\w+)"), + '#': RegExp(r"[a-zA-Z. ]+"), }, type: MaskAutoCompletionType.lazy, ); var maskTgFormatter = new MaskTextInputFormatter( mask: 'https://tg.me/########################################', filter: { - '#': RegExp(r"(\w+)"), + '#': RegExp(r"[a-zA-Z. ]+"), }, type: MaskAutoCompletionType.lazy, ); var maskVkFormatter = new MaskTextInputFormatter( mask: 'https://vk.com/########################################', filter: { - '#': RegExp(r"(\w+)"), + '#': RegExp(r"[a-zA-Z. ]+"), }, type: MaskAutoCompletionType.lazy, ); diff --git a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart index 7bc05885..3d970a01 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart @@ -12,6 +12,7 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:lottie/lottie.dart'; class StepperBecomeConsultantScreen extends StatefulWidget { const StepperBecomeConsultantScreen({super.key}); @@ -25,6 +26,7 @@ class _StepperBecomeConsultantScreenState extends State(); + bool isLoading = false; @override Widget build(BuildContext context) { @@ -73,108 +75,130 @@ class _StepperBecomeConsultantScreenState extends State Container( - padding: EdgeInsets.all(16), - width: MediaQuery.of(context).size.width, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Спасибо!\nВаши данные отправлены на модерацию', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - height: 1, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: 16), - Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: appTheme.blueA400, - shape: BoxShape.circle, - ), - child: Icon( - size: 32, - Icons.done, - color: Colors.white, - ), - ), - const SizedBox(height: 16), - Text( - 'В течении трех рабочих дней Вам придет уведомление о смене статуса', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - height: 1, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 16), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Ink( - width: MediaQuery.of(context).size.width - 32, - height: 52, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: appTheme.blueA400, - ), - child: Center( - child: Text( - 'Закрыть', - style: TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w600, + backgroundColor: isLoading ? Colors.grey : appTheme.blueA400, + onPressed: isLoading + ? null + : () async { + if (step == 6) { + if (registrationConsultantCubit.state.acceptOffer) { + setState(() { + isLoading = true; + }); + try { + await registrationConsultantCubit.registerConsultant(); + await showModalBottomSheet( + useRootNavigator: true, + showDragHandle: true, + context: context, + builder: (context) => Container( + padding: EdgeInsets.all(16), + width: MediaQuery.of(context).size.width, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Спасибо!\nВаши данные отправлены на модерацию', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + height: 1, + fontWeight: FontWeight.w600, + ), ), - ), + const SizedBox(height: 16), + Lottie.asset( + 'assets/lottie_animations/success.json', + width: 160, + height: 160, + ), + const SizedBox(height: 16), + Text( + 'В течении трех рабочих дней Вам придет уведомление о смене статуса', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + height: 1, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 16), + InkWell( + onTap: () { + Navigator.of(context).pop(); + GoRouter.of(context).pop(); + }, + child: Ink( + width: MediaQuery.of(context).size.width - 32, + height: 52, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Закрыть', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ), + ], ), ), + ); + } catch (e) { + showDialog( + context: context, + builder: (context) => AlertDialog( + actionsPadding: const EdgeInsets.symmetric(horizontal: 4), + content: Text(e.toString()), + actions: [ + TextButton( + child: const Text('Ок'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + } finally { + setState(() { + isLoading = false; + }); + } + } else { + showDialog( + context: context, + builder: (context) => AlertDialog( + actionsPadding: const EdgeInsets.symmetric(horizontal: 4), + content: Text('Примите договор публичной офёрты'), + actions: [ + TextButton( + child: const Text('Ок'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], ), - ], - ), - ), - ); - } else { - showDialog( - context: context, - builder: (context) => AlertDialog( - actionsPadding: const EdgeInsets.symmetric(horizontal: 4), - content: Text('Примите договор публичной офёрты'), - actions: [ - TextButton( - child: const Text('Ок'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ), - ); - } - } else { - setState(() { - pageController.nextPage( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - ); - }); - } - }, - label: Text( + ); + } + } else { + FocusManager.instance.primaryFocus?.unfocus(); + setState(() { + pageController.nextPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + } + }, + label: isLoading ? CircularProgressIndicator() : Text( 'Продолжить', style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), ), diff --git a/pubspec.yaml b/pubspec.yaml index d87c49e8..9383ed5a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: intl: ^0.19.0 rive: ^0.13.14 mask_text_input_formatter: ^2.9.0 + lottie: ^3.1.3 dev_dependencies: build_runner: ^2.4.13 @@ -67,6 +68,7 @@ flutter: - assets/audio/ - assets/icons/ - assets/rive_animations/ + - assets/lottie_animations/ flutter_intl: enabled: true