forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main' into consultations
This commit is contained in:
@@ -5,7 +5,7 @@ part 'credentials_model.freezed.dart';
|
||||
part 'credentials_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CredentialsModel with _$CredentialsModel {
|
||||
abstract class CredentialsModel with _$CredentialsModel {
|
||||
const factory CredentialsModel({
|
||||
required String email,
|
||||
required String password,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'token_model.freezed.dart';
|
||||
part 'token_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class TokenModel with _$TokenModel {
|
||||
abstract class TokenModel with _$TokenModel {
|
||||
const factory TokenModel({
|
||||
required String token,
|
||||
}) = _TokenModel;
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'auth_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthState with _$AuthState {
|
||||
abstract class AuthState with _$AuthState {
|
||||
const factory AuthState() = _AuthState;
|
||||
|
||||
const factory AuthState.loading() = AuthStateLoading;
|
||||
|
||||
@@ -119,7 +119,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
children: [
|
||||
const Text('Нет аккаунта? '),
|
||||
GestureDetector(
|
||||
onTap: () => GoRouter.of(context).goNamed('webViewRegistrationScreen'),
|
||||
onTap: () => GoRouter.of(context).goNamed('registrationScreen'),
|
||||
child: Text(
|
||||
'Зарегистрироваться',
|
||||
style: TextStyle(
|
||||
|
||||
@@ -242,9 +242,11 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
||||
icon: Icons.reply_rounded,
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse('$baseUrl/ru/blog_post/${widget.blogPost.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/blog_post/${widget.blogPost.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -5,7 +5,7 @@ part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create
|
||||
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
||||
abstract class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
||||
const factory BlogPostCreateCredentialsModel({
|
||||
required String title,
|
||||
required String description,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'calendar_model.freezed.dart';
|
||||
part 'calendar_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CalendarModel with _$CalendarModel {
|
||||
abstract class CalendarModel with _$CalendarModel {
|
||||
const factory CalendarModel({
|
||||
required String date,
|
||||
@JsonKey(name: 'is_current_day_included_in_the_chosen_diet_progression') required bool isCurrentDayIncludedInTheChosenDietProgression,
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'cancel_plan_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CancelPlanState with _$CancelPlanState {
|
||||
abstract class CancelPlanState with _$CancelPlanState {
|
||||
|
||||
factory CancelPlanState() = _CancelPlanState;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ part 'cancelation_model.freezed.dart';
|
||||
part 'cancelation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CancelationModel with _$CancelationModel {
|
||||
abstract class CancelationModel with _$CancelationModel {
|
||||
factory CancelationModel({
|
||||
required String description,
|
||||
required int price,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'chat_message_model.freezed.dart';
|
||||
part 'chat_message_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatMessageModel with _$ChatMessageModel {
|
||||
abstract class ChatMessageModel with _$ChatMessageModel {
|
||||
const factory ChatMessageModel({
|
||||
required int id,
|
||||
required String data,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'chat_messages_model.freezed.dart';
|
||||
part 'chat_messages_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatMessagesModel with _$ChatMessagesModel {
|
||||
abstract class ChatMessagesModel with _$ChatMessagesModel {
|
||||
const factory ChatMessagesModel({
|
||||
@JsonKey(name: 'data') required List<ChatMessageModel> messagesList,
|
||||
required ChatMetaModel meta,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'chat_meta_model.freezed.dart';
|
||||
part 'chat_meta_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatMetaModel with _$ChatMetaModel {
|
||||
abstract class ChatMetaModel with _$ChatMetaModel {
|
||||
const factory ChatMetaModel({
|
||||
@JsonKey(name: "last_page") required int lastPage,
|
||||
}) = _ChatMetaModel;
|
||||
|
||||
@@ -7,7 +7,7 @@ part 'chat_room_model.freezed.dart';
|
||||
part 'chat_room_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatRoomModel with _$ChatRoomModel {
|
||||
abstract class ChatRoomModel with _$ChatRoomModel {
|
||||
const factory ChatRoomModel({
|
||||
required String id,
|
||||
@JsonKey(name: 'chat_room_setting') required ChatRoomSettingsModel chatRoomSettings,
|
||||
@@ -20,7 +20,7 @@ class ChatRoomModel with _$ChatRoomModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Users with _$Users {
|
||||
abstract class Users with _$Users {
|
||||
const factory Users({
|
||||
|
||||
@JsonKey(name: 'from_chat_user') required ChatUserModel sender,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'chat_room_pagination_model.freezed.dart';
|
||||
part 'chat_room_pagination_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
|
||||
abstract class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
|
||||
const factory ChatRoomPaginationModel({
|
||||
@JsonKey(name: "chatRooms") required ChatRooms chatRooms,
|
||||
@JsonKey(name: "number_of_unread_chat_rooms") required int unreadChatsCount,
|
||||
@@ -16,7 +16,7 @@ class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ChatRooms with _$ChatRooms {
|
||||
abstract class ChatRooms with _$ChatRooms {
|
||||
const factory ChatRooms({
|
||||
@JsonKey(name: "data") required List<ChatRoom> data,
|
||||
@JsonKey(name: "last_page") required int lastPage,
|
||||
@@ -27,7 +27,7 @@ class ChatRooms with _$ChatRooms {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ChatRoom with _$ChatRoom {
|
||||
abstract class ChatRoom with _$ChatRoom {
|
||||
const factory ChatRoom({
|
||||
@JsonKey(name: "id") required String id,
|
||||
@JsonKey(name: "room_name") required String roomName,
|
||||
@@ -48,7 +48,7 @@ ChatMessageModel? parseLastMessage(dynamic json) {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Users with _$Users {
|
||||
abstract class Users with _$Users {
|
||||
const factory Users({
|
||||
@JsonKey(name: "from_chat_user") required ChatUser fromChatUser,
|
||||
@JsonKey(name: "to_chat_user") required ChatUser toChatUser,
|
||||
@@ -58,7 +58,7 @@ class Users with _$Users {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ChatUser with _$ChatUser {
|
||||
abstract class ChatUser with _$ChatUser {
|
||||
const factory ChatUser({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "name") required String name,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'chat_room_settings_model.freezed.dart';
|
||||
part 'chat_room_settings_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatRoomSettingsModel with _$ChatRoomSettingsModel {
|
||||
abstract class ChatRoomSettingsModel with _$ChatRoomSettingsModel {
|
||||
const factory ChatRoomSettingsModel({
|
||||
required int id,
|
||||
@JsonKey(name: 'room_name') required String roomName,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'chat_user_model.freezed.dart';
|
||||
part 'chat_user_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatUserModel with _$ChatUserModel {
|
||||
abstract class ChatUserModel with _$ChatUserModel {
|
||||
const factory ChatUserModel({
|
||||
required int id,
|
||||
required String name,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'payment_model.freezed.dart';
|
||||
part 'payment_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentModel with _$PaymentModel {
|
||||
abstract class PaymentModel with _$PaymentModel {
|
||||
|
||||
factory PaymentModel({
|
||||
@JsonKey(name: 'checkout_url') required String paymentUrl,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'plan_complain_model.freezed.dart';
|
||||
part 'plan_complain_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PlanComplainModel with _$PlanComplainModel {
|
||||
abstract class PlanComplainModel with _$PlanComplainModel {
|
||||
|
||||
factory PlanComplainModel({
|
||||
@JsonKey(name: 'description') required String description,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'websocket_info_model.freezed.dart';
|
||||
part 'websocket_info_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class WebsocketInfoModel with _$WebsocketInfoModel {
|
||||
abstract class WebsocketInfoModel with _$WebsocketInfoModel {
|
||||
const factory WebsocketInfoModel({
|
||||
required String key,
|
||||
required String host,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'chats_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ChatsState with _$ChatsState {
|
||||
abstract class ChatsState with _$ChatsState {
|
||||
|
||||
factory ChatsState({
|
||||
@Default(BaseState.initial) BaseState state,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'complain_model.freezed.dart';
|
||||
part 'complain_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ComplainModel with _$ComplainModel {
|
||||
abstract class ComplainModel with _$ComplainModel {
|
||||
|
||||
const factory ComplainModel({
|
||||
@Default(null) String? description,
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'complaining_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ComplainingState with _$ComplainingState {
|
||||
abstract class ComplainingState with _$ComplainingState {
|
||||
|
||||
factory ComplainingState({
|
||||
@Default(false) bool isLoading,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'consultant_profile_model.freezed.dart';
|
||||
part 'consultant_profile_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultantProfileModel with _$ConsultantProfileModel {
|
||||
abstract class ConsultantProfileModel with _$ConsultantProfileModel {
|
||||
const factory ConsultantProfileModel({
|
||||
@JsonKey(name: 'has_medical_education', includeIfNull: false) bool? hasMedicalEducation,
|
||||
@JsonKey(name: 'social_links', includeIfNull: false) SocialLinksModel? socialLinks,
|
||||
@@ -17,7 +17,7 @@ class ConsultantProfileModel with _$ConsultantProfileModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SocialLinksModel with _$SocialLinksModel {
|
||||
abstract class SocialLinksModel with _$SocialLinksModel {
|
||||
const factory SocialLinksModel({
|
||||
@JsonKey(name: 'vk_link', includeIfNull: false) String? vkLink,
|
||||
@JsonKey(name: 'tg_link', includeIfNull: false) String? tgLink,
|
||||
@@ -30,7 +30,7 @@ class SocialLinksModel with _$SocialLinksModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CertificatesModel with _$CertificatesModel {
|
||||
abstract class CertificatesModel with _$CertificatesModel {
|
||||
const factory CertificatesModel({
|
||||
required String title,
|
||||
required String date,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'consultation_request_model.freezed.dart';
|
||||
part 'consultation_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultationRequestModel with _$ConsultationRequestModel {
|
||||
abstract class ConsultationRequestModel with _$ConsultationRequestModel {
|
||||
const factory ConsultationRequestModel({
|
||||
@JsonKey(name: 'rating_place') required int ratingPlace,
|
||||
@JsonKey(name: 'education_resource') required EducationModel educationModel,
|
||||
@@ -17,7 +17,7 @@ class ConsultationRequestModel with _$ConsultationRequestModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CertPhotosModel with _$CertPhotosModel {
|
||||
abstract class CertPhotosModel with _$CertPhotosModel {
|
||||
const factory CertPhotosModel({
|
||||
required String url,
|
||||
}) = _CertPhotosModel;
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'rating_model.freezed.dart';
|
||||
part 'rating_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class RatingModel with _$RatingModel {
|
||||
abstract class RatingModel with _$RatingModel {
|
||||
|
||||
factory RatingModel({
|
||||
required DateTime date,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'consultation_model.freezed.dart';
|
||||
part 'consultation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultationModel with _$ConsultationModel {
|
||||
abstract class ConsultationModel with _$ConsultationModel {
|
||||
factory ConsultationModel({
|
||||
required int id,
|
||||
@JsonKey(name: 'last_state') required ChosenPlanStateEnum chosenPlanState,
|
||||
@@ -28,7 +28,7 @@ class ConsultationModel with _$ConsultationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiaryModel with _$DiaryModel {
|
||||
abstract class DiaryModel with _$DiaryModel {
|
||||
factory DiaryModel({
|
||||
required int id,
|
||||
required DiaryStateEnum state,
|
||||
@@ -60,7 +60,7 @@ enum DiaryStateEnum {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ConsultationPaginationModel with _$ConsultationPaginationModel {
|
||||
abstract class ConsultationPaginationModel with _$ConsultationPaginationModel {
|
||||
factory ConsultationPaginationModel({required List<ConsultationModel> data}) = _ConsultationPaginationModel;
|
||||
|
||||
factory ConsultationPaginationModel.fromJson(Map<String, dynamic> json) => _$ConsultationPaginationModelFromJson(json);
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'consultations_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultationsState with _$ConsultationsState {
|
||||
abstract class ConsultationsState with _$ConsultationsState {
|
||||
|
||||
factory ConsultationsState({
|
||||
@Default(BaseState.initial) BaseState state,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'create_diet_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreateDietModel with _$CreateDietModel {
|
||||
abstract class CreateDietModel with _$CreateDietModel {
|
||||
const CreateDietModel._();
|
||||
|
||||
const factory CreateDietModel({
|
||||
|
||||
@@ -27,8 +27,11 @@ import 'package:go_router/go_router.dart';
|
||||
class CreateDietScreen extends StatelessWidget {
|
||||
static const name = 'createDietScreen';
|
||||
static const path = '/create-diet-screen';
|
||||
|
||||
const CreateDietScreen({super.key, this.diet});
|
||||
|
||||
final Diet? diet;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
@@ -40,6 +43,7 @@ class CreateDietScreen extends StatelessWidget {
|
||||
|
||||
class CreateDietScreenContent extends StatefulWidget {
|
||||
const CreateDietScreenContent({super.key, this.diet});
|
||||
|
||||
final Diet? diet;
|
||||
|
||||
@override
|
||||
@@ -95,7 +99,7 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
widget.diet != null ? 'Редактирование диеты' : s.create_diet,
|
||||
s.create_diet,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: true,
|
||||
@@ -151,7 +155,7 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
const SizedBox(height: 12),
|
||||
const DietDurationDropDownWidget(),
|
||||
const SizedBox(height: 12),
|
||||
const StatusDropDownWidget(),
|
||||
StatusDropDownWidget(dietState: widget.diet?.state),
|
||||
const SizedBox(height: 16),
|
||||
const DietTypeChoiceWidget(),
|
||||
const SizedBox(height: 16),
|
||||
@@ -247,23 +251,13 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
else
|
||||
CustomOutlinedButton(
|
||||
onPressed: () async {
|
||||
if (widget.diet != null) {
|
||||
final result = await context.read<CreateDietCubit>().updateDiet(
|
||||
widget.diet!.id,
|
||||
);
|
||||
if (result == 'error') {
|
||||
if (!context.mounted) return;
|
||||
showErrorDialog(context, title: '${s.could_not_update_diet} ${state.dietData.name}');
|
||||
}
|
||||
} else {
|
||||
final result = await context.read<CreateDietCubit>().createDiet();
|
||||
if (result == 'error') {
|
||||
if (!context.mounted) return;
|
||||
showErrorDialog(context, title: '${s.could_not_publish_diet} ${state.dietData.name}');
|
||||
}
|
||||
final result = await context.read<CreateDietCubit>().createDiet();
|
||||
if (result == 'error') {
|
||||
if (!context.mounted) return;
|
||||
showErrorDialog(context, title: '${s.could_not_publish_diet} ${state.dietData.name}');
|
||||
}
|
||||
},
|
||||
text: widget.diet != null ? s.save : s.publish,
|
||||
text: s.publish,
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||
buttonStyle: ButtonStyle(
|
||||
|
||||
@@ -12,6 +12,8 @@ import 'package:eatvio_app/features/glossary/repositories/glossary_repository.da
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class CreateDietCubit extends Cubit<CreateDietState> {
|
||||
final CreateDietRepository createDietRepository;
|
||||
@@ -319,18 +321,38 @@ class CreateDietCubit extends Cubit<CreateDietState> {
|
||||
return diet;
|
||||
}
|
||||
|
||||
Future<File> downloadImageAsFile(String imageUrl) async {
|
||||
final response = await http.get(Uri.parse(imageUrl));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final filePath = '${tempDir.path}/${imageUrl.split('/').last}';
|
||||
final file = File(filePath);
|
||||
return await file.writeAsBytes(response.bodyBytes);
|
||||
} else {
|
||||
throw Exception('Не удалось загрузить изображение');
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> createDiet() async {
|
||||
emit(state.copyWith(isDietPublishing: true));
|
||||
if (!_isFromValid()) return 'validation';
|
||||
try {
|
||||
final image = await ImageCompressUtility.compressFile(File(state.dietData.image!.path));
|
||||
File? file;
|
||||
if (state.dietData.imageUrl != null) {
|
||||
file = await downloadImageAsFile(state.dietData.imageUrl!);
|
||||
}
|
||||
File? image;
|
||||
if (state.dietData.image?.path != null) {
|
||||
image = await ImageCompressUtility.compressFile(File(state.dietData.image!.path));
|
||||
}
|
||||
final dietState = state.dietData.state!;
|
||||
final dailySchedule = state.dietData.dailySchedule;
|
||||
await createDietRepository.createDiet(
|
||||
name: state.dietData.name ?? '',
|
||||
duration: state.dietData.duration ?? 7,
|
||||
state: dietState,
|
||||
image: image,
|
||||
image: image ?? file!,
|
||||
meatType: state.dietData.type['meat'] == true ? '1' : '0',
|
||||
carbType: state.dietData.type['carb'] == true ? '1' : '0',
|
||||
vegType: state.dietData.type['veg'] == true ? '1' : '0',
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'create_diet_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreateDietState with _$CreateDietState {
|
||||
abstract class CreateDietState with _$CreateDietState {
|
||||
const factory CreateDietState({
|
||||
required bool isLoading,
|
||||
required bool isDietPublishing,
|
||||
|
||||
@@ -127,11 +127,12 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
|
||||
: Stack(
|
||||
children: [
|
||||
DottedBorder(
|
||||
stackFit: StackFit.expand,
|
||||
dashPattern: const [14, 14],
|
||||
color: state.dietImageError != null ? appTheme.red : appTheme.dottedBorder,
|
||||
borderType: BorderType.RRect,
|
||||
radius: const Radius.circular(12),
|
||||
options: RoundedRectDottedBorderOptions(
|
||||
stackFit: StackFit.expand,
|
||||
dashPattern: const [14, 14],
|
||||
color: state.dietImageError != null ? appTheme.red : appTheme.dottedBorder,
|
||||
radius: const Radius.circular(12),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
Center(
|
||||
|
||||
@@ -11,7 +11,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class StatusDropDownWidget extends StatefulWidget {
|
||||
const StatusDropDownWidget({super.key});
|
||||
final DietState? dietState;
|
||||
|
||||
const StatusDropDownWidget({super.key, this.dietState});
|
||||
|
||||
@override
|
||||
State<StatusDropDownWidget> createState() => _StatusDropDownWidgetState();
|
||||
@@ -19,6 +21,7 @@ class StatusDropDownWidget extends StatefulWidget {
|
||||
|
||||
class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
final List<String> dietStateTitles = [];
|
||||
String? currentState;
|
||||
// late final List<DietState> dietStates = DietState.values;
|
||||
|
||||
@override
|
||||
@@ -39,6 +42,13 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (widget.dietState != null) {
|
||||
if (widget.dietState == DietState.active) {
|
||||
currentState = dietStateTitles[0];
|
||||
} else if (widget.dietState == DietState.personal) {
|
||||
currentState = dietStateTitles[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -77,7 +87,7 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
value: state.dietState == DietState.active ? dietStateTitles[0] : state.dietState == DietState.personal ? dietStateTitles[1] : null,
|
||||
value: currentState,
|
||||
),
|
||||
if (state.dietStateError != null) ...[
|
||||
const SizedBox(
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'create_plan_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreatePlanModel with _$CreatePlanModel {
|
||||
abstract class CreatePlanModel with _$CreatePlanModel {
|
||||
const CreatePlanModel._();
|
||||
|
||||
const factory CreatePlanModel({
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'plan_slug_model.freezed.dart';
|
||||
part 'plan_slug_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PlanSlugModel with _$PlanSlugModel {
|
||||
abstract class PlanSlugModel with _$PlanSlugModel {
|
||||
factory PlanSlugModel({@JsonKey(name: 'slug') required String slug}) = _PlanSlugModel;
|
||||
|
||||
factory PlanSlugModel.fromJson(Map<String, dynamic> json) => _$PlanSlugModelFromJson(json);
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'create_plan_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreatePlanState with _$CreatePlanState {
|
||||
abstract class CreatePlanState with _$CreatePlanState {
|
||||
const factory CreatePlanState({
|
||||
required bool isLoading,
|
||||
required String? errorMessage,
|
||||
@@ -29,7 +29,7 @@ class CreatePlanState with _$CreatePlanState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlanValidationState with _$PlanValidationState {
|
||||
abstract class PlanValidationState with _$PlanValidationState {
|
||||
factory PlanValidationState({
|
||||
required bool titleHasError,
|
||||
required bool durationHasError,
|
||||
@@ -54,7 +54,7 @@ class PlanValidationState with _$PlanValidationState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class OptionValidationState with _$OptionValidationState {
|
||||
abstract class OptionValidationState with _$OptionValidationState {
|
||||
factory OptionValidationState({
|
||||
required bool titleHasError,
|
||||
required bool priceHasError,
|
||||
|
||||
@@ -116,11 +116,12 @@ class _PlanImagePickerWidgetState extends State<PlanImagePickerWidget> {
|
||||
: Stack(
|
||||
children: [
|
||||
DottedBorder(
|
||||
stackFit: StackFit.expand,
|
||||
dashPattern: const [14, 14],
|
||||
color: state.validationState.imageHasError ? appTheme.red : appTheme.dottedBorder,
|
||||
borderType: BorderType.RRect,
|
||||
radius: const Radius.circular(12),
|
||||
options: RoundedRectDottedBorderOptions(
|
||||
stackFit: StackFit.expand,
|
||||
dashPattern: const [14, 14],
|
||||
color: state.validationState.imageHasError ? appTheme.red : appTheme.dottedBorder,
|
||||
radius: const Radius.circular(12),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
Center(
|
||||
|
||||
@@ -99,7 +99,7 @@ enum TypeOfRecipe {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class RecipeCreateEntity with _$RecipeCreateEntity {
|
||||
abstract class RecipeCreateEntity with _$RecipeCreateEntity {
|
||||
const RecipeCreateEntity._();
|
||||
|
||||
const factory RecipeCreateEntity({
|
||||
@@ -138,7 +138,7 @@ class RecipeCreateEntity with _$RecipeCreateEntity {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class StepEntity with _$StepEntity {
|
||||
abstract class StepEntity with _$StepEntity {
|
||||
const StepEntity._();
|
||||
|
||||
const factory StepEntity({
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'ingredient.freezed.dart';
|
||||
part 'ingredient.g.dart';
|
||||
|
||||
@freezed
|
||||
class Ingredient with _$Ingredient {
|
||||
abstract class Ingredient with _$Ingredient {
|
||||
const factory Ingredient({
|
||||
required String name,
|
||||
required String unit,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'product.freezed.dart';
|
||||
part 'product.g.dart';
|
||||
|
||||
@freezed
|
||||
class Product with _$Product {
|
||||
abstract class Product with _$Product {
|
||||
const factory Product({
|
||||
required int id,
|
||||
required String name,
|
||||
|
||||
@@ -17,7 +17,7 @@ enum RecipeType {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class RecipeCreateModel with _$RecipeCreateModel {
|
||||
abstract class RecipeCreateModel with _$RecipeCreateModel {
|
||||
const factory RecipeCreateModel({
|
||||
required String title,
|
||||
required String state,
|
||||
|
||||
@@ -7,7 +7,7 @@ part 'recipe_model.freezed.dart';
|
||||
part 'recipe_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class RecipeModel with _$RecipeModel {
|
||||
abstract class RecipeModel with _$RecipeModel {
|
||||
const factory RecipeModel({
|
||||
List<Ingredient?>? ingredients,
|
||||
List<Step?>? steps,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'recipe_tag_model.freezed.dart';
|
||||
part 'recipe_tag_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class RecipeTagModel with _$RecipeTagModel {
|
||||
abstract class RecipeTagModel with _$RecipeTagModel {
|
||||
const factory RecipeTagModel({
|
||||
@JsonKey(name: "data") required List<RecipeTag> data,
|
||||
@JsonKey(name: "links") required Links links,
|
||||
@@ -17,7 +17,7 @@ class RecipeTagModel with _$RecipeTagModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class RecipeTag with _$RecipeTag {
|
||||
abstract class RecipeTag with _$RecipeTag {
|
||||
const factory RecipeTag({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "name") required String name,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'step.freezed.dart';
|
||||
part 'step.g.dart';
|
||||
|
||||
@freezed
|
||||
class Step with _$Step {
|
||||
abstract class Step with _$Step {
|
||||
const factory Step({
|
||||
String? image,
|
||||
String? description,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'create_recipe_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreateRecipeState with _$CreateRecipeState {
|
||||
abstract class CreateRecipeState with _$CreateRecipeState {
|
||||
const factory CreateRecipeState({
|
||||
required RecipeCreateEntity entity,
|
||||
required bool loading,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart';
|
||||
import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
@@ -14,79 +15,73 @@ class TagsWidget extends StatefulWidget {
|
||||
class _TagsWidgetState extends State<TagsWidget> {
|
||||
late final CreateRecipeCubit createRecipeCubit;
|
||||
final tagController = TextEditingController();
|
||||
late final List<String> tags;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
createRecipeCubit = context.read<CreateRecipeCubit>();
|
||||
tags = createRecipeCubit.state.entity.tags;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Теги'),
|
||||
const SizedBox(height: 4),
|
||||
CustomTextFormField(
|
||||
hintText: 'Например: без майонеза',
|
||||
controller: tagController,
|
||||
suffix: IconButton(
|
||||
onPressed: () {
|
||||
if (tagController.text.isNotEmpty) {
|
||||
setState(() {
|
||||
tags.add(tagController.text);
|
||||
tagController.clear();
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.done,
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
return BlocBuilder<CreateRecipeCubit, CreateRecipeState>(
|
||||
builder: (BuildContext context, CreateRecipeState state) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (int i = 0; i < tags.length; i++) ...[
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
tags.remove(tags[i]);
|
||||
});
|
||||
const Text('Теги'),
|
||||
const SizedBox(height: 4),
|
||||
CustomTextFormField(
|
||||
hintText: 'Например: без майонеза',
|
||||
controller: tagController,
|
||||
suffix: IconButton(
|
||||
onPressed: () {
|
||||
if (tagController.text.isNotEmpty) {
|
||||
context.read<CreateRecipeCubit>().addTag(tagController.text);
|
||||
setState(() {
|
||||
tagController.clear();
|
||||
});
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
color: Colors.grey.shade200,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
tags[i],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
color: Colors.grey.shade600,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
icon: Icon(
|
||||
Icons.done,
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
for (int i = 0; i < state.entity.tags.length; i++) ...[
|
||||
InkWell(
|
||||
onTap: () {
|
||||
context.read<CreateRecipeCubit>().removeTag(state.entity.tags[i]);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
color: Colors.grey.shade200,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
state.entity.tags[i],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
color: Colors.grey.shade600,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'consultant_comment_model.freezed.dart';
|
||||
part 'consultant_comment_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultantCommentModel with _$ConsultantCommentModel {
|
||||
abstract class ConsultantCommentModel with _$ConsultantCommentModel {
|
||||
factory ConsultantCommentModel({
|
||||
String? comment,
|
||||
@Default({}) @JsonKey(name: 'meals') Map<String, MealCommentModel> mealsComments,
|
||||
@@ -15,7 +15,7 @@ class ConsultantCommentModel with _$ConsultantCommentModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PortionCommentModel with _$PortionCommentModel {
|
||||
abstract class PortionCommentModel with _$PortionCommentModel {
|
||||
factory PortionCommentModel({
|
||||
required String comment,
|
||||
required int id,
|
||||
@@ -25,7 +25,7 @@ class PortionCommentModel with _$PortionCommentModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MealCommentModel with _$MealCommentModel {
|
||||
abstract class MealCommentModel with _$MealCommentModel {
|
||||
|
||||
factory MealCommentModel({
|
||||
required String comment,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'consultant_review_model.freezed.dart';
|
||||
part 'consultant_review_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultantReviewModel with _$ConsultantReviewModel {
|
||||
abstract class ConsultantReviewModel with _$ConsultantReviewModel {
|
||||
|
||||
factory ConsultantReviewModel({
|
||||
required String planName,
|
||||
@@ -18,7 +18,7 @@ class ConsultantReviewModel with _$ConsultantReviewModel {
|
||||
|
||||
|
||||
@freezed
|
||||
class ConsultantComments with _$ConsultantComments {
|
||||
abstract class ConsultantComments with _$ConsultantComments {
|
||||
|
||||
factory ConsultantComments({
|
||||
required String? dayComment,
|
||||
@@ -32,7 +32,7 @@ class ConsultantComments with _$ConsultantComments {
|
||||
|
||||
|
||||
@freezed
|
||||
class MealComment with _$MealComment {
|
||||
abstract class MealComment with _$MealComment {
|
||||
|
||||
factory MealComment({
|
||||
required String comment,
|
||||
@@ -43,7 +43,7 @@ class MealComment with _$MealComment {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PortionComment with _$PortionComment {
|
||||
abstract class PortionComment with _$PortionComment {
|
||||
|
||||
factory PortionComment({
|
||||
@JsonKey(name: 'id') required int portionId,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,9 @@ part of 'consultant_review_model.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ConsultantReviewModelImpl _$$ConsultantReviewModelImplFromJson(
|
||||
_ConsultantReviewModel _$ConsultantReviewModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ConsultantReviewModelImpl(
|
||||
_ConsultantReviewModel(
|
||||
planName: json['planName'] as String,
|
||||
planDuration: (json['planDuration'] as num).toInt(),
|
||||
currentPlanDay: (json['currentPlanDay'] as num).toInt(),
|
||||
@@ -16,8 +16,8 @@ _$ConsultantReviewModelImpl _$$ConsultantReviewModelImplFromJson(
|
||||
json['consultantComments'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ConsultantReviewModelImplToJson(
|
||||
_$ConsultantReviewModelImpl instance) =>
|
||||
Map<String, dynamic> _$ConsultantReviewModelToJson(
|
||||
_ConsultantReviewModel instance) =>
|
||||
<String, dynamic>{
|
||||
'planName': instance.planName,
|
||||
'planDuration': instance.planDuration,
|
||||
@@ -25,9 +25,8 @@ Map<String, dynamic> _$$ConsultantReviewModelImplToJson(
|
||||
'consultantComments': instance.consultantComments,
|
||||
};
|
||||
|
||||
_$ConsultantCommentsImpl _$$ConsultantCommentsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ConsultantCommentsImpl(
|
||||
_ConsultantComments _$ConsultantCommentsFromJson(Map<String, dynamic> json) =>
|
||||
_ConsultantComments(
|
||||
dayComment: json['dayComment'] as String?,
|
||||
mealsComments: (json['mealsComments'] as List<dynamic>)
|
||||
.map((e) => MealComment.fromJson(e as Map<String, dynamic>))
|
||||
@@ -37,34 +36,31 @@ _$ConsultantCommentsImpl _$$ConsultantCommentsImplFromJson(
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ConsultantCommentsImplToJson(
|
||||
_$ConsultantCommentsImpl instance) =>
|
||||
Map<String, dynamic> _$ConsultantCommentsToJson(_ConsultantComments instance) =>
|
||||
<String, dynamic>{
|
||||
'dayComment': instance.dayComment,
|
||||
'mealsComments': instance.mealsComments,
|
||||
'portionsComments': instance.portionsComments,
|
||||
};
|
||||
|
||||
_$MealCommentImpl _$$MealCommentImplFromJson(Map<String, dynamic> json) =>
|
||||
_$MealCommentImpl(
|
||||
_MealComment _$MealCommentFromJson(Map<String, dynamic> json) => _MealComment(
|
||||
comment: json['comment'] as String,
|
||||
typeNo: (json['typeNo'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$MealCommentImplToJson(_$MealCommentImpl instance) =>
|
||||
Map<String, dynamic> _$MealCommentToJson(_MealComment instance) =>
|
||||
<String, dynamic>{
|
||||
'comment': instance.comment,
|
||||
'typeNo': instance.typeNo,
|
||||
};
|
||||
|
||||
_$PortionCommentImpl _$$PortionCommentImplFromJson(Map<String, dynamic> json) =>
|
||||
_$PortionCommentImpl(
|
||||
_PortionComment _$PortionCommentFromJson(Map<String, dynamic> json) =>
|
||||
_PortionComment(
|
||||
portionId: (json['id'] as num).toInt(),
|
||||
comment: json['comment'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PortionCommentImplToJson(
|
||||
_$PortionCommentImpl instance) =>
|
||||
Map<String, dynamic> _$PortionCommentToJson(_PortionComment instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.portionId,
|
||||
'comment': instance.comment,
|
||||
|
||||
@@ -21,7 +21,7 @@ enum PortionState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
|
||||
abstract class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
|
||||
const factory DiaryDayWrapperModel({
|
||||
@JsonKey(
|
||||
name: "diary",
|
||||
@@ -33,7 +33,7 @@ class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiaryDayModel with _$DiaryDayModel {
|
||||
abstract class DiaryDayModel with _$DiaryDayModel {
|
||||
const factory DiaryDayModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "date") required String date,
|
||||
@@ -50,7 +50,7 @@ class DiaryDayModel with _$DiaryDayModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MealModel with _$MealModel {
|
||||
abstract class MealModel with _$MealModel {
|
||||
const factory MealModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "time") required String time,
|
||||
@@ -65,7 +65,7 @@ class MealModel with _$MealModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiaryPhotoModel with _$DiaryPhotoModel {
|
||||
abstract class DiaryPhotoModel with _$DiaryPhotoModel {
|
||||
const factory DiaryPhotoModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "original_name") required String originalName,
|
||||
@@ -77,7 +77,7 @@ class DiaryPhotoModel with _$DiaryPhotoModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PortionModel with _$PortionModel {
|
||||
abstract class PortionModel with _$PortionModel {
|
||||
const factory PortionModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "product_nutritional_value_id") int? productNutritionalValueId,
|
||||
@@ -92,7 +92,7 @@ class PortionModel with _$PortionModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class TypeOfDiaryModel with _$TypeOfDiaryModel {
|
||||
abstract class TypeOfDiaryModel with _$TypeOfDiaryModel {
|
||||
const factory TypeOfDiaryModel({
|
||||
@JsonKey(name: "has_chosen_diet") required bool hasChosenDiet,
|
||||
@JsonKey(name: "has_chosen_plan") required bool hasChosenPlan,
|
||||
@@ -103,7 +103,7 @@ class TypeOfDiaryModel with _$TypeOfDiaryModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProductInMeal with _$ProductInMeal {
|
||||
abstract class ProductInMeal with _$ProductInMeal {
|
||||
const factory ProductInMeal({
|
||||
@JsonKey(name: 'product_name') required String productName,
|
||||
@JsonKey(name: 'portion') required String portion,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'diary_index_model.freezed.dart';
|
||||
part 'diary_index_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class DiaryIndexModel with _$DiaryIndexModel {
|
||||
abstract class DiaryIndexModel with _$DiaryIndexModel {
|
||||
const factory DiaryIndexModel({
|
||||
required int id,
|
||||
}) = _DiaryIndexModel;
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'finish_diary_day_model.freezed.dart';
|
||||
part 'finish_diary_day_model.g.dart';
|
||||
|
||||
@Freezed()
|
||||
class FinishDiaryDayModel with _$FinishDiaryDayModel {
|
||||
abstract class FinishDiaryDayModel with _$FinishDiaryDayModel {
|
||||
const factory FinishDiaryDayModel({required String wakeUp, required String retire, @JsonKey(includeIfNull: false) String? comment}) = _FinishDiaryDayModel;
|
||||
|
||||
factory FinishDiaryDayModel.fromJson(Map<String, dynamic> json) => _$FinishDiaryDayModelFromJson(json);
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'nutrition_model.freezed.dart';
|
||||
part 'nutrition_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class NutritionDataModel with _$NutritionDataModel {
|
||||
abstract class NutritionDataModel with _$NutritionDataModel {
|
||||
const factory NutritionDataModel({
|
||||
required NutritionModel dailyNutritionIntake,
|
||||
required NutritionModel dailyNutritionRecommendation,
|
||||
@@ -15,7 +15,7 @@ class NutritionDataModel with _$NutritionDataModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class NutritionModel with _$NutritionModel {
|
||||
abstract class NutritionModel with _$NutritionModel {
|
||||
const factory NutritionModel({
|
||||
required double energy,
|
||||
required double proteins,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'product_moderation_model.freezed.dart';
|
||||
part 'product_moderation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ProductModerationModel with _$ProductModerationModel {
|
||||
abstract class ProductModerationModel with _$ProductModerationModel {
|
||||
const factory ProductModerationModel({
|
||||
required String name,
|
||||
@JsonKey(name: 'energy_on_100gr')
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'consultant_comments_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ConsultantCommentsState with _$ConsultantCommentsState {
|
||||
abstract class ConsultantCommentsState with _$ConsultantCommentsState {
|
||||
|
||||
factory ConsultantCommentsState({
|
||||
required ConsultantCommentModel commentsModel,
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'diary_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class DiaryState with _$DiaryState {
|
||||
abstract class DiaryState with _$DiaryState {
|
||||
const factory DiaryState() = _DiaryState;
|
||||
|
||||
const factory DiaryState.loading() = DiaryStateLoading;
|
||||
|
||||
@@ -79,12 +79,13 @@ class _ProductWidgetState extends State<ProductWidget> {
|
||||
}
|
||||
if (widget.portion.portionState == PortionState.eatenDeleted) {
|
||||
return DottedBorder(
|
||||
dashPattern: const [6, 6],
|
||||
padding: EdgeInsets.zero,
|
||||
borderPadding: EdgeInsets.zero,
|
||||
borderType: BorderType.RRect,
|
||||
radius: const Radius.circular(20),
|
||||
color: const Color(0xFF6D6F71),
|
||||
options: const RoundedRectDottedBorderOptions(
|
||||
dashPattern: [6, 6],
|
||||
padding: EdgeInsets.zero,
|
||||
borderPadding: EdgeInsets.zero,
|
||||
radius: Radius.circular(20),
|
||||
color: Color(0xFF6D6F71),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () => diaryCubit.restore(
|
||||
diaryId: state.diary.id,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'diet_likes_model.freezed.dart';
|
||||
part 'diet_likes_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class DietLikesModel with _$DietLikesModel {
|
||||
abstract class DietLikesModel with _$DietLikesModel {
|
||||
const factory DietLikesModel({
|
||||
@JsonKey(name: 'total_likers') required int totalLikes,
|
||||
@JsonKey(name: 'is_liked') required bool isLiked,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'about_diet_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AboutDietState with _$AboutDietState {
|
||||
abstract class AboutDietState with _$AboutDietState {
|
||||
const factory AboutDietState() = _AboutDietState;
|
||||
|
||||
const factory AboutDietState.initial() = DietStateInitial;
|
||||
|
||||
@@ -321,6 +321,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
|
||||
path: 'diet/${widget.diet.id}',
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
id: widget.diet.id,
|
||||
diet: widget.diet,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
@@ -501,6 +502,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
|
||||
path: 'diet/${widget.diet.id}',
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
id: widget.diet.id,
|
||||
diet: widget.diet,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
@@ -527,6 +529,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
|
||||
path: 'diet/${widget.diet.id}',
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
id: widget.diet.id,
|
||||
diet: widget.diet,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
|
||||
@@ -60,11 +60,11 @@ class MoreOptions extends StatelessWidget {
|
||||
? null
|
||||
: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/$path',
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/$path',),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'comment_model.freezed.dart';
|
||||
part 'comment_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CommentModel with _$CommentModel {
|
||||
abstract class CommentModel with _$CommentModel {
|
||||
const factory CommentModel({
|
||||
@JsonKey(name: "data") required List<Comment> data,
|
||||
@JsonKey(name: "links") required Links links,
|
||||
@@ -16,7 +16,7 @@ class CommentModel with _$CommentModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Comment with _$Comment {
|
||||
abstract class Comment with _$Comment {
|
||||
const factory Comment({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "author_name") required String authorName,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'diets_pagination_model.freezed.dart';
|
||||
part 'diets_pagination_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class DietsPagination with _$DietsPagination {
|
||||
abstract class DietsPagination with _$DietsPagination {
|
||||
const factory DietsPagination({
|
||||
@JsonKey(name: "data") required List<Diet> data,
|
||||
@JsonKey(name: "links") required Links links,
|
||||
@@ -17,7 +17,7 @@ class DietsPagination with _$DietsPagination {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Diet with _$Diet {
|
||||
abstract class Diet with _$Diet {
|
||||
const factory Diet({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "name") required String name,
|
||||
@@ -42,7 +42,7 @@ class Diet with _$Diet {
|
||||
enum DietState {
|
||||
@JsonKey(name: 'active')
|
||||
active,
|
||||
@JsonKey(name: 'draft')
|
||||
@JsonKey(name: 'drafted')
|
||||
draft,
|
||||
@JsonKey(name: 'personal')
|
||||
personal;
|
||||
@@ -53,7 +53,7 @@ enum DietState {
|
||||
case DietState.active:
|
||||
return 'active';
|
||||
case DietState.draft:
|
||||
return 'draft';
|
||||
return 'drafted';
|
||||
case DietState.personal:
|
||||
return 'personal';
|
||||
}
|
||||
@@ -61,7 +61,7 @@ enum DietState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CreatedDiet with _$CreatedDiet {
|
||||
abstract class CreatedDiet with _$CreatedDiet {
|
||||
const factory CreatedDiet({
|
||||
@JsonKey(name: "id") required int id,
|
||||
}) = _CreatedDiet;
|
||||
@@ -78,7 +78,7 @@ int parseDuration(dynamic duration) {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Author with _$Author {
|
||||
abstract class Author with _$Author {
|
||||
const factory Author({
|
||||
@JsonKey(name: "author_slug") required String authorSlug,
|
||||
@JsonKey(name: "author_name") required String authorName,
|
||||
@@ -92,7 +92,7 @@ class Author with _$Author {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DailySchedule with _$DailySchedule {
|
||||
abstract class DailySchedule with _$DailySchedule {
|
||||
const factory DailySchedule({
|
||||
@JsonKey(name: "name") required String name,
|
||||
@JsonKey(name: "portion") required Portion portion,
|
||||
@@ -141,7 +141,7 @@ enum Portion {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DietType with _$DietType {
|
||||
abstract class DietType with _$DietType {
|
||||
const DietType._();
|
||||
const factory DietType({
|
||||
@JsonKey(name: "light") bool? light,
|
||||
@@ -170,7 +170,7 @@ class EnumValues<T> {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DailyNutrition with _$DailyNutrition {
|
||||
abstract class DailyNutrition with _$DailyNutrition {
|
||||
const factory DailyNutrition({
|
||||
@JsonKey(name: 'energy') required double energy,
|
||||
@JsonKey(name: 'proteins') required double proteins,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'feed_blog_post_model.freezed.dart';
|
||||
part 'feed_blog_post_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class FeedBlogPostModel with _$FeedBlogPostModel {
|
||||
abstract class FeedBlogPostModel with _$FeedBlogPostModel {
|
||||
const factory FeedBlogPostModel({
|
||||
required int id,
|
||||
required String state,
|
||||
|
||||
@@ -7,7 +7,7 @@ part 'feed_blog_post_settings_model.freezed.dart';
|
||||
part 'feed_blog_post_settings_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class FeedBlogPostSettingsModel with _$FeedBlogPostSettingsModel {
|
||||
abstract class FeedBlogPostSettingsModel with _$FeedBlogPostSettingsModel {
|
||||
const factory FeedBlogPostSettingsModel({
|
||||
@JsonKey(name: 'data') required List<FeedBlogPostModel> feedBlogPostList,
|
||||
required Meta meta,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'feed_consultant_model.freezed.dart';
|
||||
part 'feed_consultant_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class FeedConsultantPaginationModel with _$FeedConsultantPaginationModel {
|
||||
abstract class FeedConsultantPaginationModel with _$FeedConsultantPaginationModel {
|
||||
const factory FeedConsultantPaginationModel({
|
||||
required List<FeedConsultantModel> data,
|
||||
required Links links,
|
||||
@@ -17,7 +17,7 @@ class FeedConsultantPaginationModel with _$FeedConsultantPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class FeedConsultantModel with _$FeedConsultantModel {
|
||||
abstract class FeedConsultantModel with _$FeedConsultantModel {
|
||||
const factory FeedConsultantModel({
|
||||
required String slug,
|
||||
required String name,
|
||||
|
||||
@@ -8,7 +8,7 @@ part 'plan_pagination_model.freezed.dart';
|
||||
part 'plan_pagination_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PlanPaginationModel with _$PlanPaginationModel {
|
||||
abstract class PlanPaginationModel with _$PlanPaginationModel {
|
||||
const factory PlanPaginationModel({
|
||||
@JsonKey(name: "data") required List<PlanModel> data,
|
||||
@JsonKey(name: "links") required Links links,
|
||||
@@ -19,7 +19,7 @@ class PlanPaginationModel with _$PlanPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlanModel with _$PlanModel {
|
||||
abstract class PlanModel with _$PlanModel {
|
||||
const factory PlanModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "slug") required String slug,
|
||||
@@ -61,7 +61,7 @@ PlanType planTypeFromJson(dynamic json) {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PacketOptions with _$PacketOptions {
|
||||
abstract class PacketOptions with _$PacketOptions {
|
||||
const factory PacketOptions({
|
||||
@JsonKey(name: "items", fromJson: _parseItems) required List<String> items,
|
||||
@JsonKey(name: "price") required dynamic price,
|
||||
@@ -82,7 +82,7 @@ List<String> _parseItems(json) {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlanType with _$PlanType {
|
||||
abstract class PlanType with _$PlanType {
|
||||
const PlanType._();
|
||||
const factory PlanType({
|
||||
@JsonKey(name: "fit", fromJson: parseBool) required bool? fit,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'recipes_model.freezed.dart';
|
||||
part 'recipes_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class Recipe with _$Recipe {
|
||||
abstract class Recipe with _$Recipe {
|
||||
const factory Recipe({
|
||||
required int id,
|
||||
required String image,
|
||||
@@ -36,14 +36,14 @@ class Recipe with _$Recipe {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Tag with _$Tag {
|
||||
abstract class Tag with _$Tag {
|
||||
const factory Tag({required String name}) = _Tag;
|
||||
|
||||
factory Tag.fromJson(Map<String, Object?> json) => _$TagFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Ingredient with _$Ingredient {
|
||||
abstract class Ingredient with _$Ingredient {
|
||||
const factory Ingredient({
|
||||
required String name,
|
||||
String? unit,
|
||||
@@ -60,7 +60,7 @@ int _parseProductId(json) {
|
||||
return json as int;
|
||||
}
|
||||
@freezed
|
||||
class Step with _$Step {
|
||||
abstract class Step with _$Step {
|
||||
const factory Step({required String image, @JsonKey(name: 'description_md') required String description}) = _Step;
|
||||
|
||||
factory Step.fromJson(Map<String, Object?> json) => _$StepFromJson(json);
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'recipes_pagination_model.freezed.dart';
|
||||
part 'recipes_pagination_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class RecipesPagination with _$RecipesPagination {
|
||||
abstract class RecipesPagination with _$RecipesPagination {
|
||||
const factory RecipesPagination({
|
||||
@JsonKey(name: 'data') required List<Recipe> recipesList,
|
||||
// @JsonKey(name: "current_page") required int currentPage,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'diets_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class DietsState with _$DietsState {
|
||||
abstract class DietsState with _$DietsState {
|
||||
const factory DietsState({
|
||||
required DietsFilterState filterState,
|
||||
required List<Diet> dietsList,
|
||||
@@ -25,7 +25,7 @@ class DietsState with _$DietsState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DietsFilterState with _$DietsFilterState {
|
||||
abstract class DietsFilterState with _$DietsFilterState {
|
||||
const factory DietsFilterState({
|
||||
required int sortingIndex,
|
||||
required int durationIndex,
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class PlansState with _$PlansState {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlansFilterState with _$PlansFilterState {
|
||||
abstract class PlansFilterState with _$PlansFilterState {
|
||||
const factory PlansFilterState({
|
||||
required (int?, int?) priceFilter,
|
||||
required int durationIndex,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'profile_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class ProfileState with _$ProfileState {
|
||||
abstract class ProfileState with _$ProfileState {
|
||||
|
||||
factory ProfileState({
|
||||
ProfileModel? profile,
|
||||
|
||||
@@ -243,11 +243,11 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
||||
),
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/blog_post/${state.feedBlogPostList[widget.index].id}',
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/blog_post/${state.feedBlogPostList[widget.index].id}',),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -93,6 +93,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
path: 'diet/${widget.diet.id}',
|
||||
id: widget.diet.id,
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
diet: widget.diet,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -185,11 +186,11 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
svgIcon: SvgPicture.asset('assets/icons/repost.svg'),
|
||||
onTap: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
final result = await Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/diet/${widget.diet.id}',
|
||||
final result = await SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/diet/${widget.diet.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
switch (result.status) {
|
||||
case ShareResultStatus.success:
|
||||
|
||||
@@ -257,11 +257,11 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
svgIcon: SvgPicture.asset('assets/icons/repost.svg'),
|
||||
onTap: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
final result = await Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/diet/${widget.plan.id}',
|
||||
final result = await SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/diet/${widget.plan.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
switch (result.status) {
|
||||
case ShareResultStatus.success:
|
||||
|
||||
@@ -226,11 +226,11 @@ class _RecipesWidgetState extends State<RecipesWidget> {
|
||||
),
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/blog_post/${widget.recipe.id}',
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/blog_post/${widget.recipe.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'glossary_model.freezed.dart';
|
||||
part 'glossary_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class GlossaryPaginationModel with _$GlossaryPaginationModel {
|
||||
abstract class GlossaryPaginationModel with _$GlossaryPaginationModel {
|
||||
const factory GlossaryPaginationModel({
|
||||
@JsonKey(name: 'data') required List<GlossaryModel> glossariesList,
|
||||
}) = _GlossaryPaginationModel;
|
||||
@@ -13,7 +13,7 @@ class GlossaryPaginationModel with _$GlossaryPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class GlossaryModerationModel with _$GlossaryModerationModel {
|
||||
abstract class GlossaryModerationModel with _$GlossaryModerationModel {
|
||||
const factory GlossaryModerationModel({
|
||||
@JsonKey(name: 'product_nutritional_value') required GlossaryModel glossary,
|
||||
}) = _GlossaryModerationModel;
|
||||
@@ -22,7 +22,7 @@ class GlossaryModerationModel with _$GlossaryModerationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class GlossaryModel with _$GlossaryModel {
|
||||
abstract class GlossaryModel with _$GlossaryModel {
|
||||
const factory GlossaryModel({
|
||||
required int id,
|
||||
required String name,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'my_diets_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class MyDietsState with _$MyDietsState {
|
||||
abstract class MyDietsState with _$MyDietsState {
|
||||
factory MyDietsState({
|
||||
@Default([]) List<Diet> activeDiets,
|
||||
@Default([]) List<Diet> draftDiets,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
@@ -7,6 +8,7 @@ import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/core/widgets/info_row.dart';
|
||||
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
||||
import 'package:eatvio_app/core/widgets/success_published_diet_bottom_sheet.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
@@ -148,11 +150,11 @@ class _MyDietWidgetState extends State<MyDietWidget> {
|
||||
CustomOutlinedButton(
|
||||
onPressed: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
await Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/diet/${widget.diet.id}',
|
||||
await SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/diet/${widget.diet.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
height: 52,
|
||||
@@ -194,7 +196,8 @@ class _MyDietWidgetState extends State<MyDietWidget> {
|
||||
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
|
||||
}
|
||||
} else {
|
||||
GoRouter.of(context).pushNamed(CreateDietScreen.name, extra: widget.diet);
|
||||
await showErrorDialog(context, title: 'Предупреждение', description: 'Вы можете создать новую диету на основе существующей.');
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed(CreateDietScreen.name, extra: widget.diet);
|
||||
}
|
||||
},
|
||||
text: switch (state.selectedStateIndex) {
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'card_model.freezed.dart';
|
||||
part 'card_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CardModel with _$CardModel {
|
||||
abstract class CardModel with _$CardModel {
|
||||
factory CardModel({
|
||||
required int id,
|
||||
@JsonKey(name: 'bank_pan') required String cardNumber,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'payment_url_model.freezed.dart';
|
||||
part 'payment_url_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentUrlModel with _$PaymentUrlModel {
|
||||
abstract class PaymentUrlModel with _$PaymentUrlModel {
|
||||
|
||||
factory PaymentUrlModel({
|
||||
required String paymentUrl,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'user_cards_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class UserCardsState with _$UserCardsState {
|
||||
abstract class UserCardsState with _$UserCardsState {
|
||||
|
||||
factory UserCardsState({
|
||||
@Default([]) List<CardModel> cards,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'my_plans_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class MyPlansState with _$MyPlansState {
|
||||
abstract class MyPlansState with _$MyPlansState {
|
||||
factory MyPlansState({
|
||||
@Default([]) List<PlanModel> activePlans,
|
||||
@Default([]) List<PlanModel> draftPlans,
|
||||
|
||||
@@ -138,11 +138,11 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
||||
CustomOutlinedButton(
|
||||
onPressed: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
await Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/plan/${widget.plan.id}',
|
||||
await SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/plan/${widget.plan.id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
height: 52,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'notification_model.freezed.dart';
|
||||
part 'notification_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class NotificationModel with _$NotificationModel {
|
||||
abstract class NotificationModel with _$NotificationModel {
|
||||
|
||||
factory NotificationModel({
|
||||
required NotificationType type
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'order_info_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class OrderInfoState with _$OrderInfoState {
|
||||
abstract class OrderInfoState with _$OrderInfoState {
|
||||
|
||||
factory OrderInfoState({
|
||||
@Default(true) bool isLoading,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'chosen_plan_model.freezed.dart';
|
||||
part 'chosen_plan_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChosenPlanModel with _$ChosenPlanModel {
|
||||
abstract class ChosenPlanModel with _$ChosenPlanModel {
|
||||
|
||||
factory ChosenPlanModel({
|
||||
@JsonKey() required int id,
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'about_plan_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AboutPlanState with _$AboutPlanState {
|
||||
abstract class AboutPlanState with _$AboutPlanState {
|
||||
|
||||
const factory AboutPlanState({
|
||||
required bool isLoading,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'badge_model.freezed.dart';
|
||||
part 'badge_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class BadgeModel with _$BadgeModel {
|
||||
abstract class BadgeModel with _$BadgeModel {
|
||||
const factory BadgeModel({
|
||||
required int id,
|
||||
required String title,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'chosen_diets_pagination_model.freezed.dart';
|
||||
part 'chosen_diets_pagination_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChosenDietsPaginationModel with _$ChosenDietsPaginationModel {
|
||||
abstract class ChosenDietsPaginationModel with _$ChosenDietsPaginationModel {
|
||||
factory ChosenDietsPaginationModel({
|
||||
@JsonKey(name: 'data') required List<ChosenDietModel> diets,
|
||||
}) = _ChosenDietsPaginationModel;
|
||||
@@ -14,7 +14,7 @@ class ChosenDietsPaginationModel with _$ChosenDietsPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ChosenDietModel with _$ChosenDietModel {
|
||||
abstract class ChosenDietModel with _$ChosenDietModel {
|
||||
factory ChosenDietModel({
|
||||
@JsonKey(name: 'id') required int chosenDietID,
|
||||
@JsonKey(name: 'chosen_plan_id') required int chosenPlanId,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'circumference_model.freezed.dart';
|
||||
part 'circumference_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CircumferenceModel with _$CircumferenceModel {
|
||||
abstract class CircumferenceModel with _$CircumferenceModel {
|
||||
const factory CircumferenceModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "user_id") required int userId,
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'profile_model.freezed.dart';
|
||||
part 'profile_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ProfileModel with _$ProfileModel {
|
||||
abstract class ProfileModel with _$ProfileModel {
|
||||
const factory ProfileModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "name") required String name,
|
||||
@@ -31,7 +31,7 @@ class ProfileModel with _$ProfileModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiplomasAndCertificatesModel with _$DiplomasAndCertificatesModel {
|
||||
abstract class DiplomasAndCertificatesModel with _$DiplomasAndCertificatesModel {
|
||||
const factory DiplomasAndCertificatesModel({
|
||||
required int id,
|
||||
required String path,
|
||||
@@ -41,10 +41,10 @@ class DiplomasAndCertificatesModel with _$DiplomasAndCertificatesModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class EducationModel with _$EducationModel {
|
||||
abstract class EducationModel with _$EducationModel {
|
||||
const factory EducationModel({
|
||||
@JsonKey(name: "has_medical_education") int? hasMedicalEducation,
|
||||
@JsonKey(name: "completed_cources") List<Map<String, CompletedCoursesModel>>? completedCourses,
|
||||
@JsonKey(name: "completed_courses") List<Map<String, CompletedCoursesModel>>? completedCourses,
|
||||
@JsonKey(name: "vk_link") String? vkLink,
|
||||
@JsonKey(name: "insta_link") String? instaLink,
|
||||
@JsonKey(name: "fb_link") String? fbLink,
|
||||
@@ -57,7 +57,7 @@ class EducationModel with _$EducationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CompletedCoursesModel with _$CompletedCoursesModel {
|
||||
abstract class CompletedCoursesModel with _$CompletedCoursesModel {
|
||||
const factory CompletedCoursesModel({
|
||||
required String date,
|
||||
required String title,
|
||||
@@ -67,7 +67,7 @@ class CompletedCoursesModel with _$CompletedCoursesModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProfileDetailsModel with _$ProfileDetailsModel {
|
||||
abstract class ProfileDetailsModel with _$ProfileDetailsModel {
|
||||
const factory ProfileDetailsModel({
|
||||
@JsonKey(name: "first_name") required String firstName,
|
||||
@JsonKey(name: "last_name") required String lastName,
|
||||
@@ -102,7 +102,7 @@ class ProfileDetailsModel with _$ProfileDetailsModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ProfilePreviewModel with _$ProfilePreviewModel {
|
||||
abstract class ProfilePreviewModel with _$ProfilePreviewModel {
|
||||
const factory ProfilePreviewModel({
|
||||
@JsonKey(name: "profile_photo_url") required String profilePhotoUrl,
|
||||
}) = _ProfilePreviewModel;
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'sub_model.freezed.dart';
|
||||
part 'sub_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class SubPaginationModel with _$SubPaginationModel {
|
||||
abstract class SubPaginationModel with _$SubPaginationModel {
|
||||
const factory SubPaginationModel({
|
||||
required List<SubModel> data,
|
||||
required Links links,
|
||||
@@ -17,7 +17,7 @@ class SubPaginationModel with _$SubPaginationModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SubModel with _$SubModel {
|
||||
abstract class SubModel with _$SubModel {
|
||||
const factory SubModel({
|
||||
required String slug,
|
||||
required String name,
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'weight_model.freezed.dart';
|
||||
part 'weight_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class WeightModel with _$WeightModel {
|
||||
abstract class WeightModel with _$WeightModel {
|
||||
const factory WeightModel({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "user_id") required int userId,
|
||||
|
||||
@@ -54,6 +54,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final List<String> chipsLabelList = ['Вес', 'Замеры', 'ИМТ'];
|
||||
final List<String> chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ'];
|
||||
final List<String> chipsIntervalList = ['1', '3', '6', '12', 'all'];
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
List<WeightModel> weightPoints = [];
|
||||
List<CircumferenceModel> circumferencePoints = [];
|
||||
@@ -756,6 +757,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
)
|
||||
: Tooltip(
|
||||
message: state.profile.badges[i].description,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 32),
|
||||
triggerMode: TooltipTriggerMode.tap,
|
||||
textStyle: const TextStyle(
|
||||
color: Colors.black,
|
||||
@@ -1124,11 +1126,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
onSelected: (value) {
|
||||
if (value == 'share') {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/profile/${state.profile.slug}',
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/profile/${state.profile.slug}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
} else {
|
||||
showModalBottomSheet(
|
||||
|
||||
@@ -214,11 +214,11 @@ class _ProfileBlogPostWidgetState extends State<ProfileBlogPostWidget> {
|
||||
),
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
'$baseUrl/ru/blog_post/${state.blogPosts[widget.index].id}',
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
uri: Uri.parse('$baseUrl/ru/blog_post/${state.blogPosts[widget.index].id}'),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||
@@ -180,4 +181,20 @@ class ProfileRepository {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getPassKey(String phone) async {
|
||||
return (jsonDecode((await profileService.getPassKey(json: '{"route_name": "user_detailz.change-phone-verify", "route_params": {"phone": "$phone"}}'))))['key_is']!;
|
||||
}
|
||||
|
||||
Future<String> getMyPhone() async {
|
||||
return (jsonDecode(await profileService.getMyPhone())['phone']);
|
||||
}
|
||||
|
||||
Future<void> sendEmailCode() async {
|
||||
return await profileService.sendEmailCode();
|
||||
}
|
||||
|
||||
Future<void> tryVerifyEmailByCode(String code) async {
|
||||
return await profileService.tryVerifyEmailByCode(code: "{\"code\": \"$code\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,4 +103,20 @@ abstract class ProfileService {
|
||||
|
||||
@GET('/api/profile/chosen_diets')
|
||||
Future<ChosenDietsPaginationModel> getChosenDiets();
|
||||
|
||||
@POST('/api/profile/make_pass_key')
|
||||
Future<String> getPassKey({
|
||||
@Body() required String json,
|
||||
});
|
||||
|
||||
@GET('/api/profile/my_phone')
|
||||
Future<String> getMyPhone();
|
||||
|
||||
@POST('/api/profile/send_email_code')
|
||||
Future<void> sendEmailCode();
|
||||
|
||||
@POST('/api/profile/verificate_email_code')
|
||||
Future<void> tryVerifyEmailByCode({
|
||||
@Body() required String code,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'about_recipe_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AboutRecipeState with _$AboutRecipeState {
|
||||
abstract class AboutRecipeState with _$AboutRecipeState {
|
||||
const factory AboutRecipeState() = _AboutRecipeState;
|
||||
|
||||
const factory AboutRecipeState.initial() = AboutRecipeStateInitial;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user