feature: consultant registration

This commit is contained in:
mso7nueh
2024-10-14 15:07:07 +03:00
parent 1462334155
commit 78be72372c
12 changed files with 244 additions and 143 deletions

View File

@@ -16,18 +16,28 @@ class RegisterConsultantCubit extends Cubit<RegisterConsultantState> {
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<File> files) async {
await consultantRepository.uploadPhotos(files: files);
Future<List<String>> uploadPhotos(List<File> files) async {
return await consultantRepository.uploadPhotos(files: files);
}
}

View File

@@ -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;
}

View File

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

View File

@@ -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<LastStepScreen> {
setState(() {
checkboxState = !checkboxState;
});
context.read<RegisterConsultantCubit>().updateConsultantProfileModel(context.read<RegisterConsultantCubit>().state.consultant, checkboxState);
},
activeColor: appTheme.blueA400,
contentPadding: const EdgeInsets.symmetric(horizontal: 16),

View File

@@ -76,77 +76,95 @@ class _StepperBecomeConsultantScreenState extends State<StepperBecomeConsultantS
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,
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(

View File

@@ -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<String, dynamic> json) => _$ProfileModelFromJson(json);

View File

@@ -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<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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.

View File

@@ -23,6 +23,7 @@ _$ProfileModelImpl _$$ProfileModelImplFromJson(Map<String, dynamic> 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<String, dynamic> _$$ProfileModelImplToJson(_$ProfileModelImpl instance) =>
@@ -36,6 +37,7 @@ Map<String, dynamic> _$$ProfileModelImplToJson(_$ProfileModelImpl instance) =>
'is_public_profile': instance.isPublicProfile,
'slug': instance.slug,
'profile_photo_url': instance.profilePhotoUrl,
'role': instance.role,
};
_$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson(

View File

@@ -19,6 +19,7 @@ class SettingsCubit extends Cubit<SettingsState> {
emit(SettingsState.loaded(
profileSettings: await settingsRepository.getProfileSettings(),
profileDetails: await profileRepository.getMyProfileDetails(),
profile: await profileRepository.getMyProfile(),
));
} catch (e) {
emit(SettingsState.error(errorMessage: e.toString()));

View File

@@ -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({

View File

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

View File

@@ -56,8 +56,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
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<SettingsScreen> {
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<SettingsScreen> {
updatesNotificationsSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
},
),
),
@@ -242,10 +245,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
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<SettingsScreen> {
fillDiaryNotificationsSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
},
),
),
@@ -271,10 +274,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
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<SettingsScreen> {
moodSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
},
),
),
@@ -300,10 +303,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
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<SettingsScreen> {
bedTimeSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
},
),
),