From c4abd333e7cd893ecf807ffc257ce25435d35442 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 22 Jan 2025 15:27:10 +0300 Subject: [PATCH] feat: consultants rating --- .../.kotlin/errors/errors-1737375866289.log | 82 +++ android/app/build.gradle | 4 +- android/app/src/debug/AndroidManifest.xml | 2 +- android/app/src/main/AndroidManifest.xml | 3 +- .../kotlin/com/eatvioapp/app/MainActivity.kt | 2 +- android/app/src/profile/AndroidManifest.xml | 2 +- assets/icons/go_to_arrow.svg | 3 + lib/core/locator_service.dart | 2 + .../presentation/pages/blog_post_screen.dart | 14 +- .../services/blog_post_service.g.dart | 101 ++- .../calendar/services/calendar_service.g.dart | 41 +- .../chat/services/chat_service.g.dart | 184 ++--- .../services/consultant_service.g.dart | 74 +- .../services/create_diet_service.g.dart | 123 ++-- .../services/create_plan_service.g.dart | 95 +-- .../diary/services/diary_service.g.dart | 460 +++++------- .../presentation/widgets/more_options.dart | 10 +- .../diets/services/diet_service.g.dart | 115 ++- .../feed/models/feed_consultant_model.dart | 30 + .../models/feed_consultant_model.freezed.dart | 499 +++++++++++++ .../feed/models/feed_consultant_model.g.dart | 48 ++ lib/features/feed/models/recipes_model.dart | 2 + .../feed/models/recipes_model.freezed.dart | 91 ++- lib/features/feed/models/recipes_model.g.dart | 4 + .../consultants_cubit/consultants_cubit.dart | 25 + .../consultants_cubit/consultants_state.dart | 20 + .../consultants_state.freezed.dart | 686 ++++++++++++++++++ .../feed/presentation/pages/feed_screen.dart | 71 ++ .../widgets/blog_post_widget.dart | 14 +- .../widgets/consultant_widget.dart | 138 ++++ .../presentation/widgets/diets_widget.dart | 2 + .../presentation/widgets/plan_widget.dart | 2 + .../presentation/widgets/recipes_widget.dart | 22 +- .../feed/repositories/feed_repository.dart | 9 + lib/features/feed/services/feed_service.dart | 4 + .../feed/services/feed_service.g.dart | 442 +++++------ .../glossary/services/glossary_service.g.dart | 42 +- .../presentation/widgets/my_diet_widget.dart | 2 + .../my_diets/services/my_diets_service.g.dart | 63 +- .../presentation/widgets/my_plan_widget.dart | 2 + .../my_plans/services/my_plans_service.g.dart | 63 +- .../plans/services/plan_service.g.dart | 115 ++- .../plans/services/plans_service.g.dart | 37 +- .../presentation/pages/profile_screen.dart | 2 + .../widgets/profile_blog_post_widget.dart | 14 +- .../profile/services/profile_service.g.dart | 544 ++++++-------- .../recipes/services/recipe_service.g.dart | 197 ++--- .../services/registration_service.g.dart | 94 +-- .../settings/services/settings_service.g.dart | 99 +-- lib/main.dart | 1 + pubspec.yaml | 2 +- .../services/profile_service_test.mocks.dart | 511 ++++++------- 52 files changed, 3104 insertions(+), 2110 deletions(-) create mode 100644 android/.kotlin/errors/errors-1737375866289.log create mode 100644 assets/icons/go_to_arrow.svg create mode 100644 lib/features/feed/models/feed_consultant_model.dart create mode 100644 lib/features/feed/models/feed_consultant_model.freezed.dart create mode 100644 lib/features/feed/models/feed_consultant_model.g.dart create mode 100644 lib/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart create mode 100644 lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart create mode 100644 lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.freezed.dart create mode 100644 lib/features/feed/presentation/widgets/consultant_widget.dart diff --git a/android/.kotlin/errors/errors-1737375866289.log b/android/.kotlin/errors/errors-1737375866289.log new file mode 100644 index 00000000..0a315fa2 --- /dev/null +++ b/android/.kotlin/errors/errors-1737375866289.log @@ -0,0 +1,82 @@ +kotlin version: 2.0.21 +error message: Daemon compilation failed: null +java.lang.Exception + at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69) + at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111) + at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76) + at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62) + at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62) + at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) + at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) + at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209) + at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) + at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) + at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) + at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166) + at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) + at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) + at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59) + at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174) + at java.base/java.util.concurrent.FutureTask.run(Unknown Source) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:194) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:127) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:169) + at org.gradle.internal.Factories$1.create(Factories.java:31) + at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:263) + at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:127) + at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:132) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:133) + at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) + at java.base/java.util.concurrent.FutureTask.run(Unknown Source) + at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) + at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48) + at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.base/java.lang.Thread.run(Unknown Source) +Caused by: java.nio.file.DirectoryNotEmptyException: C:\Users\Alex\AppData\Local\Temp\kotlin-backups16986209765282043117 + at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source) + at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source) + at java.base/java.nio.file.Files.delete(Unknown Source) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash$lambda$11$lambda$10$lambda$9(CompilationTransaction.kt:244) + at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) + at java.base/java.util.ArrayList.forEach(Unknown Source) + at java.base/java.util.stream.SortedOps$RefSortingSink.end(Unknown Source) + at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source) + at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) + at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) + at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) + at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash(CompilationTransaction.kt:244) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.close(CompilationTransaction.kt:254) + at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:747) + at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:120) + at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:675) + at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92) + at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1660) + at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source) + at java.base/java.lang.reflect.Method.invoke(Unknown Source) + at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) + at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source) + at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source) + at java.base/java.security.AccessController.doPrivileged(Unknown Source) + at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source) + at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source) + at java.base/java.security.AccessController.doPrivileged(Unknown Source) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) + ... 3 more + + diff --git a/android/app/build.gradle b/android/app/build.gradle index d900ac79..53c4a200 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -13,7 +13,7 @@ if (keystorePropertiesFile.exists()) { } android { - namespace = "com.eatvioapp.app" + namespace = "ru.eatvioapp.app" compileSdk = flutter.compileSdkVersion ndkVersion = "25.1.8937393" @@ -27,7 +27,7 @@ android { } defaultConfig { - applicationId = "com.eatvioapp.app" + applicationId = "ru.eatvioapp.app" minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index fdeb7774..e98b9b52 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="ru.eatvioapp.app"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 902c137b..c7878e41 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/android/app/src/main/kotlin/com/eatvioapp/app/MainActivity.kt b/android/app/src/main/kotlin/com/eatvioapp/app/MainActivity.kt index ebb55c94..32dd569a 100644 --- a/android/app/src/main/kotlin/com/eatvioapp/app/MainActivity.kt +++ b/android/app/src/main/kotlin/com/eatvioapp/app/MainActivity.kt @@ -1,4 +1,4 @@ -package com.eatvioapp.app +package ru.eatvioapp.app import io.flutter.embedding.android.FlutterActivity diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index fdeb7774..e98b9b52 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="ru.eatvioapp.app"> diff --git a/assets/icons/go_to_arrow.svg b/assets/icons/go_to_arrow.svg new file mode 100644 index 00000000..111ec2c5 --- /dev/null +++ b/assets/icons/go_to_arrow.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/core/locator_service.dart b/lib/core/locator_service.dart index 3dda7501..4787fbff 100644 --- a/lib/core/locator_service.dart +++ b/lib/core/locator_service.dart @@ -28,6 +28,7 @@ import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart'; +import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/profile_cubit/profile_cubit.dart'; @@ -100,6 +101,7 @@ Future init() async { sl.registerFactory(() => MyDietsCubit(myDietsRepository: sl())); sl.registerFactory(() => MyPlansCubit(myPlansRepository: sl())); sl.registerFactory(() => UserDetailsCubit(profileRepository: sl())); + sl.registerFactory(() => ConsultantsCubit(feedRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); diff --git a/lib/features/blog_post/presentation/pages/blog_post_screen.dart b/lib/features/blog_post/presentation/pages/blog_post_screen.dart index ddb4ddc5..1696928a 100644 --- a/lib/features/blog_post/presentation/pages/blog_post_screen.dart +++ b/lib/features/blog_post/presentation/pages/blog_post_screen.dart @@ -310,11 +310,15 @@ class _BlogPostScreenState extends State { SizedBox(width: 8), _iconButton( icon: Icons.reply_rounded, - onTap: () => Share.shareUri( - Uri.parse( - baseUrl + '/ru/blog_post/' + widget.blogPost.id.toString(), - ), - ), + onTap: () { + final box = context.findRenderObject() as RenderBox?; + Share.shareUri( + Uri.parse( + baseUrl + '/ru/blog_post/' + widget.blogPost.id.toString(), + ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + }, ), Spacer(), Icon( diff --git a/lib/features/blog_post_create/services/blog_post_service.g.dart b/lib/features/blog_post_create/services/blog_post_service.g.dart index 33f4251a..1f338526 100644 --- a/lib/features/blog_post_create/services/blog_post_service.g.dart +++ b/lib/features/blog_post_create/services/blog_post_service.g.dart @@ -9,11 +9,7 @@ part of 'blog_post_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _BlogPostService implements BlogPostService { - _BlogPostService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _BlogPostService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,23 +23,21 @@ class _BlogPostService implements BlogPostService { final queryParameters = {}; final _headers = {}; final _data = formData; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/blogPosts/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/blogPosts/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -56,23 +50,21 @@ class _BlogPostService implements BlogPostService { final queryParameters = {}; final _headers = {}; final _data = formData; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/blogPosts/update/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/blogPosts/update/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -82,22 +74,16 @@ class _BlogPostService implements BlogPostService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/delete/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/delete/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -114,10 +100,7 @@ class _BlogPostService implements BlogPostService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/calendar/services/calendar_service.g.dart b/lib/features/calendar/services/calendar_service.g.dart index 787983c8..5055d002 100644 --- a/lib/features/calendar/services/calendar_service.g.dart +++ b/lib/features/calendar/services/calendar_service.g.dart @@ -9,11 +9,7 @@ part of 'calendar_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _CalendarService implements CalendarService { - _CalendarService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _CalendarService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,27 +23,23 @@ class _CalendarService implements CalendarService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/calendar/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/calendar/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => CalendarModel.fromJson(i as Map)) + .map( + (dynamic i) => CalendarModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -69,10 +61,7 @@ class _CalendarService implements CalendarService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/chat/services/chat_service.g.dart b/lib/features/chat/services/chat_service.g.dart index 978a0e43..37ae5e65 100644 --- a/lib/features/chat/services/chat_service.g.dart +++ b/lib/features/chat/services/chat_service.g.dart @@ -9,11 +9,7 @@ part of 'chat_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ChatService implements ChatService { - _ChatService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _ChatService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -28,22 +24,16 @@ class _ChatService implements ChatService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/chat/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/chat/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ChatRoomPreviewModel _value; try { @@ -61,27 +51,23 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/chat/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/chat/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Map _value; try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, ChatRoomModel.fromJson(v as Map))); + _value = _result.data!.map( + (k, dynamic v) => + MapEntry(k, ChatRoomModel.fromJson(v as Map)), + ); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -101,31 +87,26 @@ class _ChatService implements ChatService { final _headers = {}; final _data = FormData(); if (data != null) { - _data.fields.add(MapEntry( - 'data', - data, - )); + _data.fields.add(MapEntry('data', data)); } if (media_data != null) { _data.files.addAll(media_data.map((i) => MapEntry('media_data[]', i))); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/chat/${id}/message/send', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/chat/${id}/message/send', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -138,22 +119,16 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/chat/show/${id}/messages?page=${page}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/chat/show/${id}/messages?page=${page}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ChatMessagesModel _value; try { @@ -171,22 +146,16 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/ws/params', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/ws/params', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late WebsocketInfoModel _value; try { @@ -204,22 +173,16 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/chat/get_by_user/${user}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/chat/get_by_user/${user}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ChatRoomModel _value; try { @@ -244,10 +207,7 @@ class _ChatService implements ChatService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/consultant/become_consultant/services/consultant_service.g.dart b/lib/features/consultant/become_consultant/services/consultant_service.g.dart index d895b861..79dd924e 100644 --- a/lib/features/consultant/become_consultant/services/consultant_service.g.dart +++ b/lib/features/consultant/become_consultant/services/consultant_service.g.dart @@ -9,11 +9,7 @@ part of 'consultant_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ConsultantService implements ConsultantService { - _ConsultantService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _ConsultantService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -22,28 +18,23 @@ class _ConsultantService implements ConsultantService { final ParseErrorLogger? errorLogger; @override - Future consultantRegistration( - {required ConsultantProfileModel consultantModel}) async { + Future consultantRegistration({ + required ConsultantProfileModel consultantModel, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = consultantModel; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/consultant_request/registration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/consultant_request/registration', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -57,23 +48,21 @@ class _ConsultantService implements ConsultantService { if (photos != null) { _data.files.addAll(photos.map((i) => MapEntry('photos[]', i))); } - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/consultant_request/photos/upload', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/consultant_request/photos/upload', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { @@ -98,10 +87,7 @@ class _ConsultantService implements ConsultantService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/create_diet/services/create_diet_service.g.dart b/lib/features/create_diet/services/create_diet_service.g.dart index 0c5a4606..84a8c9a1 100644 --- a/lib/features/create_diet/services/create_diet_service.g.dart +++ b/lib/features/create_diet/services/create_diet_service.g.dart @@ -9,11 +9,7 @@ part of 'create_diet_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _CreateDietService implements CreateDietService { - _CreateDietService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _CreateDietService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -39,81 +35,57 @@ class _CreateDietService implements CreateDietService { final _headers = {}; final _data = FormData(); if (name != null) { - _data.fields.add(MapEntry( - 'name', - name, - )); + _data.fields.add(MapEntry('name', name)); } if (duration != null) { - _data.fields.add(MapEntry( - 'duration', - duration.toString(), - )); + _data.fields.add(MapEntry('duration', duration.toString())); } if (state != null) { - _data.fields.add(MapEntry( - 'state', - state, - )); + _data.fields.add(MapEntry('state', state)); } if (meatType != null) { - _data.fields.add(MapEntry( - 'type[meat]', - meatType, - )); + _data.fields.add(MapEntry('type[meat]', meatType)); } if (carbType != null) { - _data.fields.add(MapEntry( - 'type[carb]', - carbType, - )); + _data.fields.add(MapEntry('type[carb]', carbType)); } if (vegType != null) { - _data.fields.add(MapEntry( - 'type[veg]', - vegType, - )); + _data.fields.add(MapEntry('type[veg]', vegType)); } if (lightType != null) { - _data.fields.add(MapEntry( - 'type[light]', - lightType, - )); + _data.fields.add(MapEntry('type[light]', lightType)); } if (details != null) { - _data.fields.add(MapEntry( - 'details', - details, - )); + _data.fields.add(MapEntry('details', details)); } if (image != null) { if (image != null) { - _data.files.add(MapEntry( - 'image', - MultipartFile.fromFileSync( - image.path, - filename: image.path.split(Platform.pathSeparator).last, + _data.files.add( + MapEntry( + 'image', + MultipartFile.fromFileSync( + image.path, + filename: image.path.split(Platform.pathSeparator).last, + ), ), - )); + ); } } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/diets/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/diets/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late CreatedDiet _value; try { @@ -135,22 +107,16 @@ class _CreateDietService implements CreateDietService { final _headers = {}; final _data = {}; _data.addAll(model); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/create/${id}/daily_schedule', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/create/${id}/daily_schedule', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -167,10 +133,7 @@ class _CreateDietService implements CreateDietService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/create_plan/services/create_plan_service.g.dart b/lib/features/create_plan/services/create_plan_service.g.dart index af44f549..c93251e7 100644 --- a/lib/features/create_plan/services/create_plan_service.g.dart +++ b/lib/features/create_plan/services/create_plan_service.g.dart @@ -9,11 +9,7 @@ part of 'create_plan_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _CreatePlanService implements CreatePlanService { - _CreatePlanService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _CreatePlanService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -28,23 +24,21 @@ class _CreatePlanService implements CreatePlanService { final _headers = {}; final _data = {}; _data.addAll(model); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/plans/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/plans/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -58,22 +52,16 @@ class _CreatePlanService implements CreatePlanService { final _headers = {}; final _data = {}; _data.addAll(model); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/create/${slug}/packet_option', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/create/${slug}/packet_option', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -87,22 +75,16 @@ class _CreatePlanService implements CreatePlanService { final _headers = {}; final _data = {}; _data.addAll(model); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/create/${slug}/packet_options', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/create/${slug}/packet_options', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -119,10 +101,7 @@ class _CreatePlanService implements CreatePlanService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index 4544f6bf..c7b3820f 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -9,11 +9,7 @@ part of 'diary_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _DiaryService implements DiaryService { - _DiaryService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _DiaryService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -22,33 +18,30 @@ class _DiaryService implements DiaryService { final ParseErrorLogger? errorLogger; @override - Future> getDiaryIndexByDate( - {required String date}) async { + Future> getDiaryIndexByDate({ + required String date, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/index/${date}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/index/${date}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => DiaryDayModel.fromJson(i as Map)) + .map( + (dynamic i) => DiaryDayModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -63,22 +56,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/show', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/show', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late DiaryDayWrapperModel _value; try { @@ -96,22 +83,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/dailyNutritionData', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/dailyNutritionData', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late NutritionDataModel _value; try { @@ -133,30 +114,30 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; final _data = FormData(); - _data.files.add(MapEntry( - 'photo', - MultipartFile.fromFileSync( - photo.path, - filename: photo.path.split(Platform.pathSeparator).last, + _data.files.add( + MapEntry( + 'photo', + MultipartFile.fromFileSync( + photo.path, + filename: photo.path.split(Platform.pathSeparator).last, + ), ), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/photo/upload', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + ); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/photo/upload', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -170,22 +151,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diaryId}/meals/${typeNo}/photo/${userAttachment}/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'DELETE', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diaryId}/meals/${typeNo}/photo/${userAttachment}/delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -203,40 +178,27 @@ class _DiaryService implements DiaryService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'product_name', - productName, - )); - _data.fields.add(MapEntry( - 'portion', - portion, - )); - _data.fields.add(MapEntry( - 'quantity', - quantity.toString(), - )); + _data.fields.add(MapEntry('product_name', productName)); + _data.fields.add(MapEntry('portion', portion)); + _data.fields.add(MapEntry('quantity', quantity.toString())); if (productNutritionalValueId != null) { - _data.fields.add(MapEntry( - 'product_nutritional_value_id', - productNutritionalValueId.toString(), - )); + _data.fields.add( + MapEntry( + 'product_nutritional_value_id', + productNutritionalValueId.toString(), + ), + ); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/portion/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/portion/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -252,22 +214,16 @@ class _DiaryService implements DiaryService { final _headers = {}; final _data = {}; _data.addAll(productInMeal); - final _options = _setStreamType(Options( - method: 'PUT', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/update', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'PUT', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/update', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -281,22 +237,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/${portionModel}/mark_eaten', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/${portionModel}/mark_eaten', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -310,22 +260,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/${portionModel}/unmark_eaten', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/${portionModel}/unmark_eaten', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -339,22 +283,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/restore', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/restore', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -368,22 +306,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'DELETE', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/portions/${portionModel}/delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -396,22 +328,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; final _data = finishDiaryDayModel; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/finishDay', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/finishDay', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -425,22 +351,16 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; final _data = {'satiety': satiety}; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/satiety/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/satiety/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -454,49 +374,38 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; final _data = {'time': time}; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary}/meals/${typeNo}/time/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/${diary}/meals/${typeNo}/time/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @override - Future sendProductToModeration( - {required Map data}) async { + Future sendProductToModeration({ + required Map data, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = {}; _data.addAll(data); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/sendToModeration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/product_nutritional_values/sendToModeration', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late GlossaryModerationModel _value; try { @@ -521,10 +430,7 @@ class _DiaryService implements DiaryService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/diets/presentation/widgets/more_options.dart b/lib/features/diets/presentation/widgets/more_options.dart index 8a948a7c..01da9a87 100644 --- a/lib/features/diets/presentation/widgets/more_options.dart +++ b/lib/features/diets/presentation/widgets/more_options.dart @@ -13,8 +13,10 @@ import 'package:share_plus/share_plus.dart'; class MoreOptions extends StatelessWidget { const MoreOptions({super.key, this.disableActions, required this.path}); + final String path; final bool? disableActions; + @override Widget build(BuildContext context) { final s = S.of(context); @@ -52,11 +54,15 @@ class MoreOptions extends StatelessWidget { GestureDetector( onTap: disableActions == true ? null - : () => Share.shareUri( + : () { + final box = context.findRenderObject() as RenderBox?; + Share.shareUri( Uri.parse( '$baseUrl/ru/$path', ), - ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + }, child: Row( children: [ Text( diff --git a/lib/features/diets/services/diet_service.g.dart b/lib/features/diets/services/diet_service.g.dart index 63e35fb5..c23dded7 100644 --- a/lib/features/diets/services/diet_service.g.dart +++ b/lib/features/diets/services/diet_service.g.dart @@ -9,11 +9,7 @@ part of 'diet_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _DietService implements DietService { - _DietService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _DietService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _DietService implements DietService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/${id}/like', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/${id}/like', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late DietLikesModel _value; try { @@ -60,22 +50,16 @@ class _DietService implements DietService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/${id}/add_to_favorite', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/${id}/add_to_favorite', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Diet _value; try { @@ -93,22 +77,16 @@ class _DietService implements DietService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/${id}/remove_from_favorite', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/${id}/remove_from_favorite', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Diet _value; try { @@ -126,22 +104,16 @@ class _DietService implements DietService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Diet _value; try { @@ -166,10 +138,7 @@ class _DietService implements DietService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/feed/models/feed_consultant_model.dart b/lib/features/feed/models/feed_consultant_model.dart new file mode 100644 index 00000000..ac236454 --- /dev/null +++ b/lib/features/feed/models/feed_consultant_model.dart @@ -0,0 +1,30 @@ +import 'package:eatvio_app/core/models/pagination_model.dart'; +import 'package:eatvio_app/features/profile/models/badge_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'feed_consultant_model.freezed.dart'; +part 'feed_consultant_model.g.dart'; + +@freezed +class FeedConsultantPaginationModel with _$FeedConsultantPaginationModel { + const factory FeedConsultantPaginationModel({ + required List data, + required Links links, + required Meta meta, + }) = _FeedConsultantPaginationModel; + + factory FeedConsultantPaginationModel.fromJson(Map json) => _$FeedConsultantPaginationModelFromJson(json); +} + +@freezed +class FeedConsultantModel with _$FeedConsultantModel { + const factory FeedConsultantModel({ + required String slug, + required String name, + @JsonKey(name: 'rating_place') required int ratingPlace, + @JsonKey(name: 'profile_photo_url') required String photo, + required List badges, + }) = _FeedConsultantModel; + + factory FeedConsultantModel.fromJson(Map json) => _$FeedConsultantModelFromJson(json); +} diff --git a/lib/features/feed/models/feed_consultant_model.freezed.dart b/lib/features/feed/models/feed_consultant_model.freezed.dart new file mode 100644 index 00000000..75b07ec9 --- /dev/null +++ b/lib/features/feed/models/feed_consultant_model.freezed.dart @@ -0,0 +1,499 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'feed_consultant_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +FeedConsultantPaginationModel _$FeedConsultantPaginationModelFromJson( + Map json) { + return _FeedConsultantPaginationModel.fromJson(json); +} + +/// @nodoc +mixin _$FeedConsultantPaginationModel { + List get data => throw _privateConstructorUsedError; + Links get links => throw _privateConstructorUsedError; + Meta get meta => throw _privateConstructorUsedError; + + /// Serializes this FeedConsultantPaginationModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $FeedConsultantPaginationModelCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FeedConsultantPaginationModelCopyWith<$Res> { + factory $FeedConsultantPaginationModelCopyWith( + FeedConsultantPaginationModel value, + $Res Function(FeedConsultantPaginationModel) then) = + _$FeedConsultantPaginationModelCopyWithImpl<$Res, + FeedConsultantPaginationModel>; + @useResult + $Res call({List data, Links links, Meta meta}); + + $LinksCopyWith<$Res> get links; + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class _$FeedConsultantPaginationModelCopyWithImpl<$Res, + $Val extends FeedConsultantPaginationModel> + implements $FeedConsultantPaginationModelCopyWith<$Res> { + _$FeedConsultantPaginationModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_value.copyWith( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + ) as $Val); + } + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $LinksCopyWith<$Res> get links { + return $LinksCopyWith<$Res>(_value.links, (value) { + return _then(_value.copyWith(links: value) as $Val); + }); + } + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MetaCopyWith<$Res> get meta { + return $MetaCopyWith<$Res>(_value.meta, (value) { + return _then(_value.copyWith(meta: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$FeedConsultantPaginationModelImplCopyWith<$Res> + implements $FeedConsultantPaginationModelCopyWith<$Res> { + factory _$$FeedConsultantPaginationModelImplCopyWith( + _$FeedConsultantPaginationModelImpl value, + $Res Function(_$FeedConsultantPaginationModelImpl) then) = + __$$FeedConsultantPaginationModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List data, Links links, Meta meta}); + + @override + $LinksCopyWith<$Res> get links; + @override + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class __$$FeedConsultantPaginationModelImplCopyWithImpl<$Res> + extends _$FeedConsultantPaginationModelCopyWithImpl<$Res, + _$FeedConsultantPaginationModelImpl> + implements _$$FeedConsultantPaginationModelImplCopyWith<$Res> { + __$$FeedConsultantPaginationModelImplCopyWithImpl( + _$FeedConsultantPaginationModelImpl _value, + $Res Function(_$FeedConsultantPaginationModelImpl) _then) + : super(_value, _then); + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_$FeedConsultantPaginationModelImpl( + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$FeedConsultantPaginationModelImpl + implements _FeedConsultantPaginationModel { + const _$FeedConsultantPaginationModelImpl( + {required final List data, + required this.links, + required this.meta}) + : _data = data; + + factory _$FeedConsultantPaginationModelImpl.fromJson( + Map json) => + _$$FeedConsultantPaginationModelImplFromJson(json); + + final List _data; + @override + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + final Links links; + @override + final Meta meta; + + @override + String toString() { + return 'FeedConsultantPaginationModel(data: $data, links: $links, meta: $meta)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FeedConsultantPaginationModelImpl && + const DeepCollectionEquality().equals(other._data, _data) && + (identical(other.links, links) || other.links == links) && + (identical(other.meta, meta) || other.meta == meta)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_data), links, meta); + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$FeedConsultantPaginationModelImplCopyWith< + _$FeedConsultantPaginationModelImpl> + get copyWith => __$$FeedConsultantPaginationModelImplCopyWithImpl< + _$FeedConsultantPaginationModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$FeedConsultantPaginationModelImplToJson( + this, + ); + } +} + +abstract class _FeedConsultantPaginationModel + implements FeedConsultantPaginationModel { + const factory _FeedConsultantPaginationModel( + {required final List data, + required final Links links, + required final Meta meta}) = _$FeedConsultantPaginationModelImpl; + + factory _FeedConsultantPaginationModel.fromJson(Map json) = + _$FeedConsultantPaginationModelImpl.fromJson; + + @override + List get data; + @override + Links get links; + @override + Meta get meta; + + /// Create a copy of FeedConsultantPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FeedConsultantPaginationModelImplCopyWith< + _$FeedConsultantPaginationModelImpl> + get copyWith => throw _privateConstructorUsedError; +} + +FeedConsultantModel _$FeedConsultantModelFromJson(Map json) { + return _FeedConsultantModel.fromJson(json); +} + +/// @nodoc +mixin _$FeedConsultantModel { + String get slug => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + @JsonKey(name: 'rating_place') + int get ratingPlace => throw _privateConstructorUsedError; + @JsonKey(name: 'profile_photo_url') + String get photo => throw _privateConstructorUsedError; + List get badges => throw _privateConstructorUsedError; + + /// Serializes this FeedConsultantModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of FeedConsultantModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $FeedConsultantModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FeedConsultantModelCopyWith<$Res> { + factory $FeedConsultantModelCopyWith( + FeedConsultantModel value, $Res Function(FeedConsultantModel) then) = + _$FeedConsultantModelCopyWithImpl<$Res, FeedConsultantModel>; + @useResult + $Res call( + {String slug, + String name, + @JsonKey(name: 'rating_place') int ratingPlace, + @JsonKey(name: 'profile_photo_url') String photo, + List badges}); +} + +/// @nodoc +class _$FeedConsultantModelCopyWithImpl<$Res, $Val extends FeedConsultantModel> + implements $FeedConsultantModelCopyWith<$Res> { + _$FeedConsultantModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of FeedConsultantModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? slug = null, + Object? name = null, + Object? ratingPlace = null, + Object? photo = null, + Object? badges = null, + }) { + return _then(_value.copyWith( + slug: null == slug + ? _value.slug + : slug // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + ratingPlace: null == ratingPlace + ? _value.ratingPlace + : ratingPlace // ignore: cast_nullable_to_non_nullable + as int, + photo: null == photo + ? _value.photo + : photo // ignore: cast_nullable_to_non_nullable + as String, + badges: null == badges + ? _value.badges + : badges // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$FeedConsultantModelImplCopyWith<$Res> + implements $FeedConsultantModelCopyWith<$Res> { + factory _$$FeedConsultantModelImplCopyWith(_$FeedConsultantModelImpl value, + $Res Function(_$FeedConsultantModelImpl) then) = + __$$FeedConsultantModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String slug, + String name, + @JsonKey(name: 'rating_place') int ratingPlace, + @JsonKey(name: 'profile_photo_url') String photo, + List badges}); +} + +/// @nodoc +class __$$FeedConsultantModelImplCopyWithImpl<$Res> + extends _$FeedConsultantModelCopyWithImpl<$Res, _$FeedConsultantModelImpl> + implements _$$FeedConsultantModelImplCopyWith<$Res> { + __$$FeedConsultantModelImplCopyWithImpl(_$FeedConsultantModelImpl _value, + $Res Function(_$FeedConsultantModelImpl) _then) + : super(_value, _then); + + /// Create a copy of FeedConsultantModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? slug = null, + Object? name = null, + Object? ratingPlace = null, + Object? photo = null, + Object? badges = null, + }) { + return _then(_$FeedConsultantModelImpl( + slug: null == slug + ? _value.slug + : slug // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + ratingPlace: null == ratingPlace + ? _value.ratingPlace + : ratingPlace // ignore: cast_nullable_to_non_nullable + as int, + photo: null == photo + ? _value.photo + : photo // ignore: cast_nullable_to_non_nullable + as String, + badges: null == badges + ? _value._badges + : badges // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$FeedConsultantModelImpl implements _FeedConsultantModel { + const _$FeedConsultantModelImpl( + {required this.slug, + required this.name, + @JsonKey(name: 'rating_place') required this.ratingPlace, + @JsonKey(name: 'profile_photo_url') required this.photo, + required final List badges}) + : _badges = badges; + + factory _$FeedConsultantModelImpl.fromJson(Map json) => + _$$FeedConsultantModelImplFromJson(json); + + @override + final String slug; + @override + final String name; + @override + @JsonKey(name: 'rating_place') + final int ratingPlace; + @override + @JsonKey(name: 'profile_photo_url') + final String photo; + final List _badges; + @override + List get badges { + if (_badges is EqualUnmodifiableListView) return _badges; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_badges); + } + + @override + String toString() { + return 'FeedConsultantModel(slug: $slug, name: $name, ratingPlace: $ratingPlace, photo: $photo, badges: $badges)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FeedConsultantModelImpl && + (identical(other.slug, slug) || other.slug == slug) && + (identical(other.name, name) || other.name == name) && + (identical(other.ratingPlace, ratingPlace) || + other.ratingPlace == ratingPlace) && + (identical(other.photo, photo) || other.photo == photo) && + const DeepCollectionEquality().equals(other._badges, _badges)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, slug, name, ratingPlace, photo, + const DeepCollectionEquality().hash(_badges)); + + /// Create a copy of FeedConsultantModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$FeedConsultantModelImplCopyWith<_$FeedConsultantModelImpl> get copyWith => + __$$FeedConsultantModelImplCopyWithImpl<_$FeedConsultantModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$FeedConsultantModelImplToJson( + this, + ); + } +} + +abstract class _FeedConsultantModel implements FeedConsultantModel { + const factory _FeedConsultantModel( + {required final String slug, + required final String name, + @JsonKey(name: 'rating_place') required final int ratingPlace, + @JsonKey(name: 'profile_photo_url') required final String photo, + required final List badges}) = _$FeedConsultantModelImpl; + + factory _FeedConsultantModel.fromJson(Map json) = + _$FeedConsultantModelImpl.fromJson; + + @override + String get slug; + @override + String get name; + @override + @JsonKey(name: 'rating_place') + int get ratingPlace; + @override + @JsonKey(name: 'profile_photo_url') + String get photo; + @override + List get badges; + + /// Create a copy of FeedConsultantModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FeedConsultantModelImplCopyWith<_$FeedConsultantModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/feed/models/feed_consultant_model.g.dart b/lib/features/feed/models/feed_consultant_model.g.dart new file mode 100644 index 00000000..67bd27da --- /dev/null +++ b/lib/features/feed/models/feed_consultant_model.g.dart @@ -0,0 +1,48 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'feed_consultant_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$FeedConsultantPaginationModelImpl + _$$FeedConsultantPaginationModelImplFromJson(Map json) => + _$FeedConsultantPaginationModelImpl( + data: (json['data'] as List) + .map((e) => + FeedConsultantModel.fromJson(e as Map)) + .toList(), + links: Links.fromJson(json['links'] as Map), + meta: Meta.fromJson(json['meta'] as Map), + ); + +Map _$$FeedConsultantPaginationModelImplToJson( + _$FeedConsultantPaginationModelImpl instance) => + { + 'data': instance.data, + 'links': instance.links, + 'meta': instance.meta, + }; + +_$FeedConsultantModelImpl _$$FeedConsultantModelImplFromJson( + Map json) => + _$FeedConsultantModelImpl( + slug: json['slug'] as String, + name: json['name'] as String, + ratingPlace: (json['rating_place'] as num).toInt(), + photo: json['profile_photo_url'] as String, + badges: (json['badges'] as List) + .map((e) => BadgeModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$FeedConsultantModelImplToJson( + _$FeedConsultantModelImpl instance) => + { + 'slug': instance.slug, + 'name': instance.name, + 'rating_place': instance.ratingPlace, + 'profile_photo_url': instance.photo, + 'badges': instance.badges, + }; diff --git a/lib/features/feed/models/recipes_model.dart b/lib/features/feed/models/recipes_model.dart index ad61afd1..8f0db8ad 100644 --- a/lib/features/feed/models/recipes_model.dart +++ b/lib/features/feed/models/recipes_model.dart @@ -21,6 +21,8 @@ class Recipes with _$Recipes { required String type, required String slug, @JsonKey(name: 'total_comments') required int commentsCount, + @JsonKey(name: 'was_liked_by_me') required bool wasLikedByMe, + @JsonKey(name: 'energy_per_serving') required double calories, @JsonKey(name: 'total_likes') required int likesCount, @JsonKey(name: 'total_views') required int viewsCount, required Author author, diff --git a/lib/features/feed/models/recipes_model.freezed.dart b/lib/features/feed/models/recipes_model.freezed.dart index 9dd4f54e..34d1c39a 100644 --- a/lib/features/feed/models/recipes_model.freezed.dart +++ b/lib/features/feed/models/recipes_model.freezed.dart @@ -39,6 +39,10 @@ mixin _$Recipes { String get slug => throw _privateConstructorUsedError; @JsonKey(name: 'total_comments') int get commentsCount => throw _privateConstructorUsedError; + @JsonKey(name: 'was_liked_by_me') + bool get wasLikedByMe => throw _privateConstructorUsedError; + @JsonKey(name: 'energy_per_serving') + double get calories => throw _privateConstructorUsedError; @JsonKey(name: 'total_likes') int get likesCount => throw _privateConstructorUsedError; @JsonKey(name: 'total_views') @@ -74,6 +78,8 @@ abstract class $RecipesCopyWith<$Res> { String type, String slug, @JsonKey(name: 'total_comments') int commentsCount, + @JsonKey(name: 'was_liked_by_me') bool wasLikedByMe, + @JsonKey(name: 'energy_per_serving') double calories, @JsonKey(name: 'total_likes') int likesCount, @JsonKey(name: 'total_views') int viewsCount, Author author}); @@ -110,6 +116,8 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes> Object? type = null, Object? slug = null, Object? commentsCount = null, + Object? wasLikedByMe = null, + Object? calories = null, Object? likesCount = null, Object? viewsCount = null, Object? author = null, @@ -171,6 +179,14 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes> ? _value.commentsCount : commentsCount // ignore: cast_nullable_to_non_nullable as int, + wasLikedByMe: null == wasLikedByMe + ? _value.wasLikedByMe + : wasLikedByMe // ignore: cast_nullable_to_non_nullable + as bool, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as double, likesCount: null == likesCount ? _value.likesCount : likesCount // ignore: cast_nullable_to_non_nullable @@ -219,6 +235,8 @@ abstract class _$$RecipesImplCopyWith<$Res> implements $RecipesCopyWith<$Res> { String type, String slug, @JsonKey(name: 'total_comments') int commentsCount, + @JsonKey(name: 'was_liked_by_me') bool wasLikedByMe, + @JsonKey(name: 'energy_per_serving') double calories, @JsonKey(name: 'total_likes') int likesCount, @JsonKey(name: 'total_views') int viewsCount, Author author}); @@ -254,6 +272,8 @@ class __$$RecipesImplCopyWithImpl<$Res> Object? type = null, Object? slug = null, Object? commentsCount = null, + Object? wasLikedByMe = null, + Object? calories = null, Object? likesCount = null, Object? viewsCount = null, Object? author = null, @@ -315,6 +335,14 @@ class __$$RecipesImplCopyWithImpl<$Res> ? _value.commentsCount : commentsCount // ignore: cast_nullable_to_non_nullable as int, + wasLikedByMe: null == wasLikedByMe + ? _value.wasLikedByMe + : wasLikedByMe // ignore: cast_nullable_to_non_nullable + as bool, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as double, likesCount: null == likesCount ? _value.likesCount : likesCount // ignore: cast_nullable_to_non_nullable @@ -349,6 +377,8 @@ class _$RecipesImpl implements _Recipes { required this.type, required this.slug, @JsonKey(name: 'total_comments') required this.commentsCount, + @JsonKey(name: 'was_liked_by_me') required this.wasLikedByMe, + @JsonKey(name: 'energy_per_serving') required this.calories, @JsonKey(name: 'total_likes') required this.likesCount, @JsonKey(name: 'total_views') required this.viewsCount, required this.author}) @@ -404,6 +434,12 @@ class _$RecipesImpl implements _Recipes { @JsonKey(name: 'total_comments') final int commentsCount; @override + @JsonKey(name: 'was_liked_by_me') + final bool wasLikedByMe; + @override + @JsonKey(name: 'energy_per_serving') + final double calories; + @override @JsonKey(name: 'total_likes') final int likesCount; @override @@ -414,7 +450,7 @@ class _$RecipesImpl implements _Recipes { @override String toString() { - return 'Recipes(id: $id, image: $image, state: $state, cookingTime: $cookingTime, ingredients: $ingredients, description: $description, steps: $steps, videoUrl: $videoUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title, type: $type, slug: $slug, commentsCount: $commentsCount, likesCount: $likesCount, viewsCount: $viewsCount, author: $author)'; + return 'Recipes(id: $id, image: $image, state: $state, cookingTime: $cookingTime, ingredients: $ingredients, description: $description, steps: $steps, videoUrl: $videoUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title, type: $type, slug: $slug, commentsCount: $commentsCount, wasLikedByMe: $wasLikedByMe, calories: $calories, likesCount: $likesCount, viewsCount: $viewsCount, author: $author)'; } @override @@ -443,6 +479,10 @@ class _$RecipesImpl implements _Recipes { (identical(other.slug, slug) || other.slug == slug) && (identical(other.commentsCount, commentsCount) || other.commentsCount == commentsCount) && + (identical(other.wasLikedByMe, wasLikedByMe) || + other.wasLikedByMe == wasLikedByMe) && + (identical(other.calories, calories) || + other.calories == calories) && (identical(other.likesCount, likesCount) || other.likesCount == likesCount) && (identical(other.viewsCount, viewsCount) || @@ -452,25 +492,28 @@ class _$RecipesImpl implements _Recipes { @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, - id, - image, - state, - cookingTime, - const DeepCollectionEquality().hash(_ingredients), - description, - const DeepCollectionEquality().hash(_steps), - videoUrl, - createdAt, - updatedAt, - title, - type, - slug, - commentsCount, - likesCount, - viewsCount, - author); + int get hashCode => Object.hashAll([ + runtimeType, + id, + image, + state, + cookingTime, + const DeepCollectionEquality().hash(_ingredients), + description, + const DeepCollectionEquality().hash(_steps), + videoUrl, + createdAt, + updatedAt, + title, + type, + slug, + commentsCount, + wasLikedByMe, + calories, + likesCount, + viewsCount, + author + ]); /// Create a copy of Recipes /// with the given fields replaced by the non-null parameter values. @@ -504,6 +547,8 @@ abstract class _Recipes implements Recipes { required final String type, required final String slug, @JsonKey(name: 'total_comments') required final int commentsCount, + @JsonKey(name: 'was_liked_by_me') required final bool wasLikedByMe, + @JsonKey(name: 'energy_per_serving') required final double calories, @JsonKey(name: 'total_likes') required final int likesCount, @JsonKey(name: 'total_views') required final int viewsCount, required final Author author}) = _$RecipesImpl; @@ -544,6 +589,12 @@ abstract class _Recipes implements Recipes { @JsonKey(name: 'total_comments') int get commentsCount; @override + @JsonKey(name: 'was_liked_by_me') + bool get wasLikedByMe; + @override + @JsonKey(name: 'energy_per_serving') + double get calories; + @override @JsonKey(name: 'total_likes') int get likesCount; @override diff --git a/lib/features/feed/models/recipes_model.g.dart b/lib/features/feed/models/recipes_model.g.dart index 7f8c0142..cc96df42 100644 --- a/lib/features/feed/models/recipes_model.g.dart +++ b/lib/features/feed/models/recipes_model.g.dart @@ -26,6 +26,8 @@ _$RecipesImpl _$$RecipesImplFromJson(Map json) => type: json['type'] as String, slug: json['slug'] as String, commentsCount: (json['total_comments'] as num).toInt(), + wasLikedByMe: json['was_liked_by_me'] as bool, + calories: (json['energy_per_serving'] as num).toDouble(), likesCount: (json['total_likes'] as num).toInt(), viewsCount: (json['total_views'] as num).toInt(), author: Author.fromJson(json['author'] as Map), @@ -47,6 +49,8 @@ Map _$$RecipesImplToJson(_$RecipesImpl instance) => 'type': instance.type, 'slug': instance.slug, 'total_comments': instance.commentsCount, + 'was_liked_by_me': instance.wasLikedByMe, + 'energy_per_serving': instance.calories, 'total_likes': instance.likesCount, 'total_views': instance.viewsCount, 'author': instance.author, diff --git a/lib/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart new file mode 100644 index 00000000..9b30f4cc --- /dev/null +++ b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart @@ -0,0 +1,25 @@ +import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart'; +import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class ConsultantsCubit extends Cubit { + final FeedRepository feedRepository; + + ConsultantsCubit({ + required this.feedRepository, + }) : super(ConsultantsState()); + + getConsultants() async { + emit(ConsultantsState.loading()); + try { + emit( + ConsultantsState.loaded( + consultantsList: await feedRepository.getConsultants(), + isLoading: false, + ), + ); + } catch (e) { + emit(ConsultantsState.error(errorMessage: e.toString())); + } + } +} diff --git a/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart new file mode 100644 index 00000000..a0b71763 --- /dev/null +++ b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart @@ -0,0 +1,20 @@ +import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'consultants_state.freezed.dart'; + +@freezed +abstract class ConsultantsState with _$ConsultantsState { + const factory ConsultantsState() = _ConsultantsState; + + const factory ConsultantsState.loading() = ConsultantsStateLoading; + + const factory ConsultantsState.loaded({ + required List consultantsList, + required bool isLoading, + }) = ConsultantsStateLoaded; + + const factory ConsultantsState.error({ + required String errorMessage, + }) = ConsultantsStateError; +} diff --git a/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.freezed.dart b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.freezed.dart new file mode 100644 index 00000000..5dd8aa15 --- /dev/null +++ b/lib/features/feed/presentation/bloc/consultants_cubit/consultants_state.freezed.dart @@ -0,0 +1,686 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'consultants_state.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$ConsultantsState { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function( + List consultantsList, bool isLoading) + loaded, + required TResult Function(String errorMessage) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function( + List consultantsList, bool isLoading)? + loaded, + TResult? Function(String errorMessage)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(List consultantsList, bool isLoading)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_ConsultantsState value) $default, { + required TResult Function(ConsultantsStateLoading value) loading, + required TResult Function(ConsultantsStateLoaded value) loaded, + required TResult Function(ConsultantsStateError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ConsultantsState value)? $default, { + TResult? Function(ConsultantsStateLoading value)? loading, + TResult? Function(ConsultantsStateLoaded value)? loaded, + TResult? Function(ConsultantsStateError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ConsultantsState value)? $default, { + TResult Function(ConsultantsStateLoading value)? loading, + TResult Function(ConsultantsStateLoaded value)? loaded, + TResult Function(ConsultantsStateError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConsultantsStateCopyWith<$Res> { + factory $ConsultantsStateCopyWith( + ConsultantsState value, $Res Function(ConsultantsState) then) = + _$ConsultantsStateCopyWithImpl<$Res, ConsultantsState>; +} + +/// @nodoc +class _$ConsultantsStateCopyWithImpl<$Res, $Val extends ConsultantsState> + implements $ConsultantsStateCopyWith<$Res> { + _$ConsultantsStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$ConsultantsStateImplCopyWith<$Res> { + factory _$$ConsultantsStateImplCopyWith(_$ConsultantsStateImpl value, + $Res Function(_$ConsultantsStateImpl) then) = + __$$ConsultantsStateImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ConsultantsStateImplCopyWithImpl<$Res> + extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateImpl> + implements _$$ConsultantsStateImplCopyWith<$Res> { + __$$ConsultantsStateImplCopyWithImpl(_$ConsultantsStateImpl _value, + $Res Function(_$ConsultantsStateImpl) _then) + : super(_value, _then); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$ConsultantsStateImpl implements _ConsultantsState { + const _$ConsultantsStateImpl(); + + @override + String toString() { + return 'ConsultantsState()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ConsultantsStateImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function( + List consultantsList, bool isLoading) + loaded, + required TResult Function(String errorMessage) error, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function( + List consultantsList, bool isLoading)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(List consultantsList, bool isLoading)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ConsultantsState value) $default, { + required TResult Function(ConsultantsStateLoading value) loading, + required TResult Function(ConsultantsStateLoaded value) loaded, + required TResult Function(ConsultantsStateError value) error, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ConsultantsState value)? $default, { + TResult? Function(ConsultantsStateLoading value)? loading, + TResult? Function(ConsultantsStateLoaded value)? loaded, + TResult? Function(ConsultantsStateError value)? error, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ConsultantsState value)? $default, { + TResult Function(ConsultantsStateLoading value)? loading, + TResult Function(ConsultantsStateLoaded value)? loaded, + TResult Function(ConsultantsStateError value)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class _ConsultantsState implements ConsultantsState { + const factory _ConsultantsState() = _$ConsultantsStateImpl; +} + +/// @nodoc +abstract class _$$ConsultantsStateLoadingImplCopyWith<$Res> { + factory _$$ConsultantsStateLoadingImplCopyWith( + _$ConsultantsStateLoadingImpl value, + $Res Function(_$ConsultantsStateLoadingImpl) then) = + __$$ConsultantsStateLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ConsultantsStateLoadingImplCopyWithImpl<$Res> + extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateLoadingImpl> + implements _$$ConsultantsStateLoadingImplCopyWith<$Res> { + __$$ConsultantsStateLoadingImplCopyWithImpl( + _$ConsultantsStateLoadingImpl _value, + $Res Function(_$ConsultantsStateLoadingImpl) _then) + : super(_value, _then); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$ConsultantsStateLoadingImpl implements ConsultantsStateLoading { + const _$ConsultantsStateLoadingImpl(); + + @override + String toString() { + return 'ConsultantsState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConsultantsStateLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function( + List consultantsList, bool isLoading) + loaded, + required TResult Function(String errorMessage) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function( + List consultantsList, bool isLoading)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(List consultantsList, bool isLoading)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ConsultantsState value) $default, { + required TResult Function(ConsultantsStateLoading value) loading, + required TResult Function(ConsultantsStateLoaded value) loaded, + required TResult Function(ConsultantsStateError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ConsultantsState value)? $default, { + TResult? Function(ConsultantsStateLoading value)? loading, + TResult? Function(ConsultantsStateLoaded value)? loaded, + TResult? Function(ConsultantsStateError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ConsultantsState value)? $default, { + TResult Function(ConsultantsStateLoading value)? loading, + TResult Function(ConsultantsStateLoaded value)? loaded, + TResult Function(ConsultantsStateError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class ConsultantsStateLoading implements ConsultantsState { + const factory ConsultantsStateLoading() = _$ConsultantsStateLoadingImpl; +} + +/// @nodoc +abstract class _$$ConsultantsStateLoadedImplCopyWith<$Res> { + factory _$$ConsultantsStateLoadedImplCopyWith( + _$ConsultantsStateLoadedImpl value, + $Res Function(_$ConsultantsStateLoadedImpl) then) = + __$$ConsultantsStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({List consultantsList, bool isLoading}); +} + +/// @nodoc +class __$$ConsultantsStateLoadedImplCopyWithImpl<$Res> + extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateLoadedImpl> + implements _$$ConsultantsStateLoadedImplCopyWith<$Res> { + __$$ConsultantsStateLoadedImplCopyWithImpl( + _$ConsultantsStateLoadedImpl _value, + $Res Function(_$ConsultantsStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? consultantsList = null, + Object? isLoading = null, + }) { + return _then(_$ConsultantsStateLoadedImpl( + consultantsList: null == consultantsList + ? _value._consultantsList + : consultantsList // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc + +class _$ConsultantsStateLoadedImpl implements ConsultantsStateLoaded { + const _$ConsultantsStateLoadedImpl( + {required final List consultantsList, + required this.isLoading}) + : _consultantsList = consultantsList; + + final List _consultantsList; + @override + List get consultantsList { + if (_consultantsList is EqualUnmodifiableListView) return _consultantsList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_consultantsList); + } + + @override + final bool isLoading; + + @override + String toString() { + return 'ConsultantsState.loaded(consultantsList: $consultantsList, isLoading: $isLoading)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConsultantsStateLoadedImpl && + const DeepCollectionEquality() + .equals(other._consultantsList, _consultantsList) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading)); + } + + @override + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_consultantsList), isLoading); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ConsultantsStateLoadedImplCopyWith<_$ConsultantsStateLoadedImpl> + get copyWith => __$$ConsultantsStateLoadedImplCopyWithImpl< + _$ConsultantsStateLoadedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function( + List consultantsList, bool isLoading) + loaded, + required TResult Function(String errorMessage) error, + }) { + return loaded(consultantsList, isLoading); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function( + List consultantsList, bool isLoading)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return loaded?.call(consultantsList, isLoading); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(List consultantsList, bool isLoading)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(consultantsList, isLoading); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ConsultantsState value) $default, { + required TResult Function(ConsultantsStateLoading value) loading, + required TResult Function(ConsultantsStateLoaded value) loaded, + required TResult Function(ConsultantsStateError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ConsultantsState value)? $default, { + TResult? Function(ConsultantsStateLoading value)? loading, + TResult? Function(ConsultantsStateLoaded value)? loaded, + TResult? Function(ConsultantsStateError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ConsultantsState value)? $default, { + TResult Function(ConsultantsStateLoading value)? loading, + TResult Function(ConsultantsStateLoaded value)? loaded, + TResult Function(ConsultantsStateError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class ConsultantsStateLoaded implements ConsultantsState { + const factory ConsultantsStateLoaded( + {required final List consultantsList, + required final bool isLoading}) = _$ConsultantsStateLoadedImpl; + + List get consultantsList; + bool get isLoading; + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ConsultantsStateLoadedImplCopyWith<_$ConsultantsStateLoadedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ConsultantsStateErrorImplCopyWith<$Res> { + factory _$$ConsultantsStateErrorImplCopyWith( + _$ConsultantsStateErrorImpl value, + $Res Function(_$ConsultantsStateErrorImpl) then) = + __$$ConsultantsStateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String errorMessage}); +} + +/// @nodoc +class __$$ConsultantsStateErrorImplCopyWithImpl<$Res> + extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateErrorImpl> + implements _$$ConsultantsStateErrorImplCopyWith<$Res> { + __$$ConsultantsStateErrorImplCopyWithImpl(_$ConsultantsStateErrorImpl _value, + $Res Function(_$ConsultantsStateErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? errorMessage = null, + }) { + return _then(_$ConsultantsStateErrorImpl( + errorMessage: null == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ConsultantsStateErrorImpl implements ConsultantsStateError { + const _$ConsultantsStateErrorImpl({required this.errorMessage}); + + @override + final String errorMessage; + + @override + String toString() { + return 'ConsultantsState.error(errorMessage: $errorMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConsultantsStateErrorImpl && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, errorMessage); + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ConsultantsStateErrorImplCopyWith<_$ConsultantsStateErrorImpl> + get copyWith => __$$ConsultantsStateErrorImplCopyWithImpl< + _$ConsultantsStateErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function( + List consultantsList, bool isLoading) + loaded, + required TResult Function(String errorMessage) error, + }) { + return error(errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function( + List consultantsList, bool isLoading)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return error?.call(errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(List consultantsList, bool isLoading)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ConsultantsState value) $default, { + required TResult Function(ConsultantsStateLoading value) loading, + required TResult Function(ConsultantsStateLoaded value) loaded, + required TResult Function(ConsultantsStateError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ConsultantsState value)? $default, { + TResult? Function(ConsultantsStateLoading value)? loading, + TResult? Function(ConsultantsStateLoaded value)? loaded, + TResult? Function(ConsultantsStateError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ConsultantsState value)? $default, { + TResult Function(ConsultantsStateLoading value)? loading, + TResult Function(ConsultantsStateLoaded value)? loaded, + TResult Function(ConsultantsStateError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class ConsultantsStateError implements ConsultantsState { + const factory ConsultantsStateError({required final String errorMessage}) = + _$ConsultantsStateErrorImpl; + + String get errorMessage; + + /// Create a copy of ConsultantsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ConsultantsStateErrorImplCopyWith<_$ConsultantsStateErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index 20573fc4..d921fb9f 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -4,6 +4,8 @@ import 'package:eatvio_app/core/widgets/custom_search_bar.dart'; import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; import 'package:eatvio_app/features/create_plan/presentation/create_plan_screen.dart'; +import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart'; +import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; @@ -14,6 +16,7 @@ import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/consultant_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/diet_filter_bottom_sheet.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/diets_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/filter_badge.dart'; @@ -43,6 +46,7 @@ class _FeedScreenState extends State { final RecipesCubit recipesCubit = sl()..loadRecipesList(); final DietsCubit dietsCubit = sl()..loadDiets(); final PlansCubit plansCubit = sl()..loadPlans(); + final ConsultantsCubit consultantsCubit = sl()..getConsultants(); final searchController = TextEditingController(); final List chipsLabelList = ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты']; @@ -51,6 +55,7 @@ class _FeedScreenState extends State { final recipesScrollController = ScrollController(); final dietsScrollController = ScrollController(); final plansScrollController = ScrollController(); + final consultantsScrollController = ScrollController(); @override void initState() { @@ -59,6 +64,7 @@ class _FeedScreenState extends State { recipesScrollController.addListener(_onScrollRecipes); dietsScrollController.addListener(_onScrollDiets); plansScrollController.addListener(_onScrollPlans); + consultantsScrollController.addListener(_onScrollConsultants); super.initState(); } @@ -86,6 +92,10 @@ class _FeedScreenState extends State { } } + _onScrollConsultants() { + if (consultantsScrollController.offset >= consultantsScrollController.position.maxScrollExtent && !consultantsScrollController.position.outOfRange) {} + } + @override void dispose() { blogPostsScrollController.dispose(); @@ -111,6 +121,9 @@ class _FeedScreenState extends State { BlocProvider( create: (context) => sl()..loadPlans(), ), + BlocProvider( + create: (context) => sl()..getConsultants(), + ), ], child: Scaffold( floatingActionButton: _selectedChipIndex == 1 @@ -145,6 +158,7 @@ class _FeedScreenState extends State { 1 => recipesScrollController, 2 => dietsScrollController, 3 => plansScrollController, + 4 => consultantsScrollController, _ => blogPostsScrollController }, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -186,6 +200,9 @@ class _FeedScreenState extends State { case 3: plansCubit.loadPlans(query: query); break; + case 4: + consultantsCubit.getConsultants(); + break; } }, ); @@ -207,6 +224,9 @@ class _FeedScreenState extends State { case 3: plansCubit.loadPlans(); break; + case 4: + consultantsCubit.getConsultants(); + break; } }, ); @@ -238,6 +258,7 @@ class _FeedScreenState extends State { 1 => _buildAllRecipes(), 2 => _buildDiets(), 3 => _buildPlans(), + 4 => _buildConsultants(), _ => Center(child: Text(chipsLabelList[_selectedChipIndex])), }, ), @@ -287,6 +308,56 @@ class _FeedScreenState extends State { ); } + _buildConsultants() { + return RefreshIndicator( + onRefresh: () => consultantsCubit.getConsultants(), + child: BlocBuilder( + bloc: consultantsCubit, + builder: (BuildContext context, ConsultantsState state) { + if (state is ConsultantsStateLoaded) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: ListView.separated( + padding: EdgeInsets.symmetric(vertical: 16), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return ConsultantWidget(consultant: state.consultantsList[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 12); + }, + itemCount: state.consultantsList.length, + ), + ), + ), + ); + } else if (state is ConsultantsStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), + ), + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: const Loader(), + ); + } + }, + ), + ); + } + _buildAllRecipes() { return RefreshIndicator( onRefresh: () => recipesCubit.loadRecipesList(), diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index 4cb5c767..3e066448 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -207,11 +207,15 @@ class _BlogPostWidgetState extends State { 'assets/icons/share.svg', colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn), ), - onTap: () => Share.shareUri( - Uri.parse( - baseUrl + '/ru/blog_post/' + state.feedBlogPostList[widget.index].id.toString(), - ), - ), + onTap: () { + final box = context.findRenderObject() as RenderBox?; + Share.shareUri( + Uri.parse( + baseUrl + '/ru/blog_post/' + state.feedBlogPostList[widget.index].id.toString(), + ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + }, ), Spacer(), Icon( diff --git a/lib/features/feed/presentation/widgets/consultant_widget.dart b/lib/features/feed/presentation/widgets/consultant_widget.dart new file mode 100644 index 00000000..033633c6 --- /dev/null +++ b/lib/features/feed/presentation/widgets/consultant_widget.dart @@ -0,0 +1,138 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart'; +import 'package:eatvio_app/features/profile/models/badge_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; + +class ConsultantWidget extends StatelessWidget { + final FeedConsultantModel consultant; + + const ConsultantWidget({ + super.key, + required this.consultant, + }); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + GoRouter.of(context).pushNamed( + 'profileScreen', + extra: Author( + authorSlug: consultant.slug, + authorName: consultant.name, + authorProfileIcon: consultant.photo, + authorIsMe: false, + ), + ); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFFF6F6F6), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Ink( + padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + '${consultant.ratingPlace}', + style: TextStyle( + fontSize: 20, + color: appTheme.blueA400, + fontWeight: FontWeight.w600, + ), + ), + ), + const SizedBox(width: 8), + CircleAvatar( + foregroundImage: NetworkImage(consultant.photo), + ), + const SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + consultant.name, + style: TextStyle( + height: 1, + fontWeight: FontWeight.w500, + fontSize: 15, + color: Color(0xFF323F4B), + ), + ), + const SizedBox(height: 4), + Text( + 'Рейтинг: RATING', + style: TextStyle( + color: appTheme.blueA400, + height: 1, + fontWeight: FontWeight.w500, + fontSize: 12, + ), + ), + ], + ), + ], + ), + Ink( + padding: EdgeInsets.all(6), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: Colors.white, + ), + child: SvgPicture.asset( + 'assets/icons/go_to_arrow.svg', + ), + ), + ], + ), + const SizedBox(height: 8), + Text('description'), + if (consultant.badges.isNotEmpty) const SizedBox(height: 8), + _badges(consultant.badges, context), + ], + ), + ), + ); + } + + _badges(List badges, BuildContext context) { + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + for (int i = 0; i < badges.length; i++) ...[ + badges[i].image.contains('svg') + ? SvgPicture.network( + baseUrl + '/storage/' + badges[i].image, + width: 28, + height: 28, + ) + : CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + badges[i].image, + ), + i < badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(), + ], + ], + ), + ); + } +} diff --git a/lib/features/feed/presentation/widgets/diets_widget.dart b/lib/features/feed/presentation/widgets/diets_widget.dart index 6597f72e..d42d7da3 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -144,10 +144,12 @@ class _DietsWidgetState extends State { FeedIconButton( 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.toString(), ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ); switch (result.status) { case ShareResultStatus.success: diff --git a/lib/features/feed/presentation/widgets/plan_widget.dart b/lib/features/feed/presentation/widgets/plan_widget.dart index f51dac71..bc3baf86 100644 --- a/lib/features/feed/presentation/widgets/plan_widget.dart +++ b/lib/features/feed/presentation/widgets/plan_widget.dart @@ -201,10 +201,12 @@ class _PlanWidgetState extends State { FeedIconButton( 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.toString(), ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ); switch (result.status) { case ShareResultStatus.success: diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index eb4b065f..61936531 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -21,6 +21,14 @@ class RecipesWidget extends StatefulWidget { } class _RecipesWidgetState extends State { + late bool isLiked; + + @override + void initState() { + super.initState(); + isLiked = false; + } + @override Widget build(BuildContext context) { return InkWell( @@ -143,11 +151,15 @@ class _RecipesWidgetState extends State { 'assets/icons/share.svg', colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn), ), - onTap: () => Share.shareUri( - Uri.parse( - baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(), - ), - ), + onTap: () { + final box = context.findRenderObject() as RenderBox?; + Share.shareUri( + Uri.parse( + baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(), + ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + }, ), Spacer(), Icon( diff --git a/lib/features/feed/repositories/feed_repository.dart b/lib/features/feed/repositories/feed_repository.dart index 9c3360fc..a90b4d5b 100644 --- a/lib/features/feed/repositories/feed_repository.dart +++ b/lib/features/feed/repositories/feed_repository.dart @@ -1,6 +1,7 @@ import 'package:eatvio_app/features/feed/models/comment_model.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart'; import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; @@ -208,4 +209,12 @@ class FeedRepository { rethrow; } } + + Future> getConsultants() async { + try { + return (await feedService.getConsultants()).data; + } catch (e) { + rethrow; + } + } } diff --git a/lib/features/feed/services/feed_service.dart b/lib/features/feed/services/feed_service.dart index 585d8217..9551f16b 100644 --- a/lib/features/feed/services/feed_service.dart +++ b/lib/features/feed/services/feed_service.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/features/feed/models/comment_model.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart'; import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_pagination_model.dart'; import 'package:retrofit/retrofit.dart'; @@ -101,4 +102,7 @@ abstract class FeedService { Future unlikedBlogPost({ @Path() required int id, }); + + @GET('/api/consultants/index') + Future getConsultants(); } diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 89279ebb..17825316 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -9,11 +9,7 @@ part of 'feed_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _FeedService implements FeedService { - _FeedService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _FeedService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -34,22 +30,16 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late FeedBlogPostSettingsModel _value; try { @@ -76,22 +66,16 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late RecipesPagination _value; try { @@ -122,22 +106,16 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late DietsPagination _value; try { @@ -170,22 +148,16 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late PlanPaginationModel _value; try { @@ -203,22 +175,16 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/${id}/comments/show', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/${id}/comments/show', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late CommentModel _value; try { @@ -241,32 +207,20 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'body', - body, - )); + _data.fields.add(MapEntry('body', body)); if (parentCommentId != null) { - _data.fields.add(MapEntry( - 'parentCommentId', - parentCommentId.toString(), - )); + _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString())); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/${id}/comment/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/${id}/comment/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -276,22 +230,16 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/${id}/comments/show', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/${id}/comments/show', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late CommentModel _value; try { @@ -314,32 +262,20 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'body', - body, - )); + _data.fields.add(MapEntry('body', body)); if (parentCommentId != null) { - _data.fields.add(MapEntry( - 'parentCommentId', - parentCommentId.toString(), - )); + _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString())); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/${id}/comment/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/${id}/comment/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -349,22 +285,16 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/${slug}/comments/show', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/${slug}/comments/show', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late CommentModel _value; try { @@ -387,32 +317,20 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'body', - body, - )); + _data.fields.add(MapEntry('body', body)); if (parentCommentId != null) { - _data.fields.add(MapEntry( - 'parentCommentId', - parentCommentId.toString(), - )); + _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString())); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/${slug}/comment/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/${slug}/comment/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -422,22 +340,16 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/${id}/comments/show', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/${id}/comments/show', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late CommentModel _value; try { @@ -460,32 +372,20 @@ class _FeedService implements FeedService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'body', - body, - )); + _data.fields.add(MapEntry('body', body)); if (parentCommentId != null) { - _data.fields.add(MapEntry( - 'parentCommentId', - parentCommentId.toString(), - )); + _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString())); } - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/${id}/comment/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/${id}/comment/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -495,22 +395,16 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/${id}/like', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/${id}/like', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -520,25 +414,46 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/${id}/unliked', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/${id}/unliked', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } + @override + Future getConsultants() async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/consultants/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); + final _result = await _dio.fetch>(_options); + late FeedConsultantPaginationModel _value; + try { + _value = FeedConsultantPaginationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || @@ -552,10 +467,7 @@ class _FeedService implements FeedService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/glossary/services/glossary_service.g.dart b/lib/features/glossary/services/glossary_service.g.dart index bd3a1137..cd6584f6 100644 --- a/lib/features/glossary/services/glossary_service.g.dart +++ b/lib/features/glossary/services/glossary_service.g.dart @@ -9,11 +9,7 @@ part of 'glossary_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _GlossaryService implements GlossaryService { - _GlossaryService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _GlossaryService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -22,28 +18,23 @@ class _GlossaryService implements GlossaryService { final ParseErrorLogger? errorLogger; @override - Future getGlossaryByQuery( - {required String query}) async { + Future getGlossaryByQuery({ + required String query, + }) async { final _extra = {}; final queryParameters = {r'search': query}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/glossaries/search', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/glossaries/search', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late GlossaryPaginationModel _value; try { @@ -68,10 +59,7 @@ class _GlossaryService implements GlossaryService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/my_diets/presentation/widgets/my_diet_widget.dart b/lib/features/my_diets/presentation/widgets/my_diet_widget.dart index 41655991..d173117e 100644 --- a/lib/features/my_diets/presentation/widgets/my_diet_widget.dart +++ b/lib/features/my_diets/presentation/widgets/my_diet_widget.dart @@ -128,10 +128,12 @@ class _MyDietWidgetState extends State { SizedBox(width: 6), CustomOutlinedButton( onPressed: () async { + final box = context.findRenderObject() as RenderBox?; await Share.shareUri( Uri.parse( baseUrl + '/ru/diet/' + widget.diet.id.toString(), ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ); }, height: 52, diff --git a/lib/features/my_diets/services/my_diets_service.g.dart b/lib/features/my_diets/services/my_diets_service.g.dart index fec66099..3588c0ac 100644 --- a/lib/features/my_diets/services/my_diets_service.g.dart +++ b/lib/features/my_diets/services/my_diets_service.g.dart @@ -9,11 +9,7 @@ part of 'my_diets_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _MyDietsService implements MyDietsService { - _MyDietsService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _MyDietsService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -40,22 +36,16 @@ class _MyDietsService implements MyDietsService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late DietsPagination _value; try { @@ -73,22 +63,16 @@ class _MyDietsService implements MyDietsService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diets/delete/${dietId}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diets/delete/${dietId}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -105,10 +89,7 @@ class _MyDietsService implements MyDietsService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/my_plans/presentation/widgets/my_plan_widget.dart b/lib/features/my_plans/presentation/widgets/my_plan_widget.dart index 1040a207..9132624d 100644 --- a/lib/features/my_plans/presentation/widgets/my_plan_widget.dart +++ b/lib/features/my_plans/presentation/widgets/my_plan_widget.dart @@ -135,10 +135,12 @@ class _MyPlanWidgetState extends State { SizedBox(width: 6), CustomOutlinedButton( onPressed: () async { + final box = context.findRenderObject() as RenderBox?; await Share.shareUri( Uri.parse( baseUrl + '/ru/plan/' + widget.plan.id.toString(), ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ); }, height: 52, diff --git a/lib/features/my_plans/services/my_plans_service.g.dart b/lib/features/my_plans/services/my_plans_service.g.dart index dd70281f..4e4804e0 100644 --- a/lib/features/my_plans/services/my_plans_service.g.dart +++ b/lib/features/my_plans/services/my_plans_service.g.dart @@ -9,11 +9,7 @@ part of 'my_plans_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _MyPlansService implements MyPlansService { - _MyPlansService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _MyPlansService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -42,22 +38,16 @@ class _MyPlansService implements MyPlansService { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late PlanPaginationModel _value; try { @@ -75,22 +65,16 @@ class _MyPlansService implements MyPlansService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/delete/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/delete/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -107,10 +91,7 @@ class _MyPlansService implements MyPlansService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/plans/services/plan_service.g.dart b/lib/features/plans/services/plan_service.g.dart index 71abb5af..09f90b41 100644 --- a/lib/features/plans/services/plan_service.g.dart +++ b/lib/features/plans/services/plan_service.g.dart @@ -9,11 +9,7 @@ part of 'plan_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _PlanService implements PlanService { - _PlanService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _PlanService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _PlanService implements PlanService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/show/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/show/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late PlanModel _value; try { @@ -60,22 +50,16 @@ class _PlanService implements PlanService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/${slug}/like', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/${slug}/like', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -85,22 +69,16 @@ class _PlanService implements PlanService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/${slug}/add_to_favorite', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/${slug}/add_to_favorite', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -110,22 +88,16 @@ class _PlanService implements PlanService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/${slug}/remove_from_favorite', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/${slug}/remove_from_favorite', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -142,10 +114,7 @@ class _PlanService implements PlanService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/plans/services/plans_service.g.dart b/lib/features/plans/services/plans_service.g.dart index 7fe37d3d..3e4ebdf1 100644 --- a/lib/features/plans/services/plans_service.g.dart +++ b/lib/features/plans/services/plans_service.g.dart @@ -9,11 +9,7 @@ part of 'plans_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _PlansService implements PlansService { - _PlansService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _PlansService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _PlansService implements PlansService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/plans/get_by_author/${author}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/plans/get_by_author/${author}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late PlanPaginationModel _value; try { @@ -67,10 +57,7 @@ class _PlansService implements PlansService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 1baf2cae..98b18d58 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -1006,10 +1006,12 @@ class _ProfileScreenState extends State { const Spacer(), PopupMenuButton( onSelected: (value) { + final box = context.findRenderObject() as RenderBox?; Share.shareUri( Uri.parse( baseUrl + '/ru/profile/' + state.profile.slug, ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ); }, itemBuilder: (context) => [ diff --git a/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart b/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart index a448ed10..dd1389bc 100644 --- a/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart +++ b/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart @@ -208,11 +208,15 @@ class _ProfileBlogPostWidgetState extends State { 'assets/icons/share.svg', colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn), ), - onTap: () => Share.shareUri( - Uri.parse( - baseUrl + '/ru/blog_post/' + state.blogPosts[widget.index].id.toString(), - ), - ), + onTap: () { + final box = context.findRenderObject() as RenderBox?; + Share.shareUri( + Uri.parse( + baseUrl + '/ru/blog_post/' + state.blogPosts[widget.index].id.toString(), + ), + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + }, ), Spacer(), Icon( diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index e8214593..532747e6 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -9,11 +9,7 @@ part of 'profile_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ProfileService implements ProfileService { - _ProfileService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _ProfileService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/show/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/show/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileModel _value; try { @@ -60,22 +50,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileModel _value; try { @@ -93,22 +77,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/detailz', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/detailz', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileDetailsModel _value; try { @@ -121,28 +99,23 @@ class _ProfileService implements ProfileService { } @override - Future getProfileDetailsBySlug( - {required String slug}) async { + Future getProfileDetailsBySlug({ + required String slug, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/detailz/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/detailz/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileDetailsModel _value; try { @@ -164,34 +137,25 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'chest_circumference', - chestCircumference.toString(), - )); - _data.fields.add(MapEntry( - 'waist_circumference', - waistCircumference.toString(), - )); - _data.fields.add(MapEntry( - 'hip_circumference', - hipCircumference.toString(), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/addCircumference', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + _data.fields.add( + MapEntry('chest_circumference', chestCircumference.toString()), + ); + _data.fields.add( + MapEntry('waist_circumference', waistCircumference.toString()), + ); + _data.fields.add( + MapEntry('hip_circumference', hipCircumference.toString()), + ); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/addCircumference', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -201,58 +165,46 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; final _data = FormData(); - _data.fields.add(MapEntry( - 'weight', - weight.toString(), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/addWeight', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + _data.fields.add(MapEntry('weight', weight.toString())); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/addWeight', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @override - Future> getBlogPostByAuthorSlug( - {required String slug}) async { + Future> getBlogPostByAuthorSlug({ + required String slug, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/blogPosts/search_by_author/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/blogPosts/search_by_author/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => - FeedBlogPostModel.fromJson(i as Map)) + .map( + (dynamic i) => + FeedBlogPostModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -267,27 +219,23 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/measure/weight/${period}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/measure/weight/${period}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => WeightModel.fromJson(i as Map)) + .map( + (dynamic i) => WeightModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -305,27 +253,23 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/measure/weight/${period}/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/measure/weight/${period}/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => WeightModel.fromJson(i as Map)) + .map( + (dynamic i) => WeightModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -335,34 +279,31 @@ class _ProfileService implements ProfileService { } @override - Future> getCircumferences( - {required String period}) async { + Future> getCircumferences({ + required String period, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/measure/circumferences/${period}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/measure/circumferences/${period}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => - CircumferenceModel.fromJson(i as Map)) + .map( + (dynamic i) => + CircumferenceModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -380,28 +321,24 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/measure/circumferences/${period}/{user}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/measure/circumferences/${period}/{user}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late List _value; try { _value = _result.data! - .map((dynamic i) => - CircumferenceModel.fromJson(i as Map)) + .map( + (dynamic i) => + CircumferenceModel.fromJson(i as Map), + ) .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); @@ -417,27 +354,21 @@ class _ProfileService implements ProfileService { }) async { final _extra = {}; final queryParameters = { - r'filters[name][$startsWith]': query + r'filters[name][$startsWith]': query, }; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/${slug}/subscribers', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/${slug}/subscribers', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late SubPaginationModel _value; try { @@ -456,27 +387,21 @@ class _ProfileService implements ProfileService { }) async { final _extra = {}; final queryParameters = { - r'filters[name][$startsWith]': query + r'filters[name][$startsWith]': query, }; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/${slug}/subscriptions', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/${slug}/subscriptions', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late SubPaginationModel _value; try { @@ -494,22 +419,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/subscribe/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/subscribe/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -519,22 +438,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/unsubscribe/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/unsubscribe/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -544,30 +457,30 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; final _data = FormData(); - _data.files.add(MapEntry( - 'photo', - MultipartFile.fromFileSync( - photo.path, - filename: photo.path.split(Platform.pathSeparator).last, + _data.files.add( + MapEntry( + 'photo', + MultipartFile.fromFileSync( + photo.path, + filename: photo.path.split(Platform.pathSeparator).last, + ), ), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - contentType: 'multipart/form-data', - ) - .compose( - _dio.options, - '/api/profile/photo/upload', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + ); + final _options = _setStreamType( + Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/profile/photo/upload', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -577,22 +490,16 @@ class _ProfileService implements ProfileService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/photo/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'DELETE', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/photo/delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); await _dio.fetch(_options); } @@ -609,10 +516,7 @@ class _ProfileService implements ProfileService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index 20e02b55..63de7d2c 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -9,11 +9,7 @@ part of 'recipe_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _RecipeService implements RecipeService { - _RecipeService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _RecipeService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _RecipeService implements RecipeService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late RecipeModel _value; try { @@ -60,30 +50,27 @@ class _RecipeService implements RecipeService { final queryParameters = {r'name': name}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Map> _value; try { - _value = _result.data!.map((k, dynamic v) => MapEntry( + _value = _result.data!.map( + (k, dynamic v) => MapEntry( k, (v as List) .map((i) => Product.fromJson(i as Map)) - .toList())); + .toList(), + ), + ); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -109,34 +96,19 @@ class _RecipeService implements RecipeService { final _headers = {}; final _data = FormData(); if (type != null) { - _data.fields.add(MapEntry( - 'type', - type, - )); + _data.fields.add(MapEntry('type', type)); } if (state != null) { - _data.fields.add(MapEntry( - 'state', - state, - )); + _data.fields.add(MapEntry('state', state)); } if (title != null) { - _data.fields.add(MapEntry( - 'title', - title, - )); + _data.fields.add(MapEntry('title', title)); } if (description != null) { - _data.fields.add(MapEntry( - 'description', - description, - )); + _data.fields.add(MapEntry('description', description)); } if (video_url != null) { - _data.fields.add(MapEntry( - 'video_url', - video_url, - )); + _data.fields.add(MapEntry('video_url', video_url)); } ingredients.forEach((i) { _data.fields.add(MapEntry('ingredients', jsonEncode(i))); @@ -145,34 +117,27 @@ class _RecipeService implements RecipeService { _data.fields.add(MapEntry('steps', jsonEncode(i))); }); if (cooking_time != null) { - _data.fields.add(MapEntry( - 'cooking_time', - cooking_time.toString(), - )); + _data.fields.add(MapEntry('cooking_time', cooking_time.toString())); } - _data.files.add(MapEntry( - 'image', - MultipartFile.fromFileSync( - image.path, - filename: image.path.split(Platform.pathSeparator).last, + _data.files.add( + MapEntry( + 'image', + MultipartFile.fromFileSync( + image.path, + filename: image.path.split(Platform.pathSeparator).last, + ), ), - )); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + ); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late RecipeModel _value; try { @@ -185,30 +150,21 @@ class _RecipeService implements RecipeService { } @override - Future editRecipe( - Map recipe, - String id, - ) async { + Future editRecipe(Map recipe, String id) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = FormData.fromMap(recipe); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/update/{id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/update/{id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late RecipeModel _value; try { @@ -226,22 +182,16 @@ class _RecipeService implements RecipeService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/recipes/tags', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/recipes/tags', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late RecipeTagModel _value; try { @@ -266,10 +216,7 @@ class _RecipeService implements RecipeService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/registration/services/registration_service.g.dart b/lib/features/registration/services/registration_service.g.dart index c7b90410..f9560e28 100644 --- a/lib/features/registration/services/registration_service.g.dart +++ b/lib/features/registration/services/registration_service.g.dart @@ -9,11 +9,7 @@ part of 'registration_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _RegistrationService implements RegistrationService { - _RegistrationService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _RegistrationService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -22,29 +18,24 @@ class _RegistrationService implements RegistrationService { final ParseErrorLogger? errorLogger; @override - Future> register( - {required Map sheet}) async { + Future> register({ + required Map sheet, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = {}; _data.addAll(sheet); - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/register', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType>( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/register', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late Map _value; try { @@ -62,22 +53,16 @@ class _RegistrationService implements RegistrationService { final queryParameters = {r'user_address': query}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/location_by_address', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/location_by_address', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late LocationModel _value; try { @@ -101,22 +86,16 @@ class _RegistrationService implements RegistrationService { }; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/location_by_coordinate', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/location_by_coordinate', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late LocationModel _value; try { @@ -141,10 +120,7 @@ class _RegistrationService implements RegistrationService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/features/settings/services/settings_service.g.dart b/lib/features/settings/services/settings_service.g.dart index 53d31175..05385077 100644 --- a/lib/features/settings/services/settings_service.g.dart +++ b/lib/features/settings/services/settings_service.g.dart @@ -9,11 +9,7 @@ part of 'settings_service.dart'; // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _SettingsService implements SettingsService { - _SettingsService( - this._dio, { - this.baseUrl, - this.errorLogger, - }); + _SettingsService(this._dio, {this.baseUrl, this.errorLogger}); final Dio _dio; @@ -27,22 +23,16 @@ class _SettingsService implements SettingsService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/settings', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/settings', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileSettingsModel _value; try { @@ -55,29 +45,24 @@ class _SettingsService implements SettingsService { } @override - Future updateProfileSettings( - {required Map data}) async { + Future updateProfileSettings({ + required Map data, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = {}; _data.addAll(data); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/settings/update', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/settings/update', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileSettingsModel _value; try { @@ -90,29 +75,24 @@ class _SettingsService implements SettingsService { } @override - Future updateProfileDetails( - {required Map data}) async { + Future updateProfileDetails({ + required Map data, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = {}; _data.addAll(data); - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/profile/update', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); + final _options = _setStreamType( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/api/profile/update', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); final _result = await _dio.fetch>(_options); late ProfileDetailsModel _value; try { @@ -137,10 +117,7 @@ class _SettingsService implements SettingsService { return requestOptions; } - String _combineBaseUrls( - String dioBaseUrl, - String? baseUrl, - ) { + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } diff --git a/lib/main.dart b/lib/main.dart index e910f18e..4973e7e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,6 +20,7 @@ Future main() async { FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); await di.init(); runApp(MyApp()); + FlutterNativeSplash.remove(); } class MyApp extends StatelessWidget { diff --git a/pubspec.yaml b/pubspec.yaml index a49cf98b..b8740b3c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,7 @@ dependencies: syncfusion_flutter_gauges: ^28.1.38 table_calendar: ^3.1.3 flutter_keyboard_visibility: ^6.0.0 - share_plus: ^10.1.3 + share_plus: ^10.1.4 flutter_html: ^3.0.0-beta.2 file_picker: ^8.1.7 audioplayers: ^6.1.0 diff --git a/test/features/profile/services/profile_service_test.mocks.dart b/test/features/profile/services/profile_service_test.mocks.dart index c853a94e..3d08d4ea 100644 --- a/test/features/profile/services/profile_service_test.mocks.dart +++ b/test/features/profile/services/profile_service_test.mocks.dart @@ -32,35 +32,20 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: subtype_of_sealed_class class _FakeProfileModel_0 extends _i1.SmartFake implements _i2.ProfileModel { - _FakeProfileModel_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeProfileModel_0(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeProfileDetailsModel_1 extends _i1.SmartFake implements _i2.ProfileDetailsModel { - _FakeProfileDetailsModel_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeProfileDetailsModel_1(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeSubPaginationModel_2 extends _i1.SmartFake implements _i3.SubPaginationModel { - _FakeSubPaginationModel_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeSubPaginationModel_2(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [ProfileService]. @@ -70,106 +55,78 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { @override _i5.Future<_i2.ProfileModel> getProfileBySlug({required String? slug}) => (super.noSuchMethod( - Invocation.method( - #getProfileBySlug, - [], - {#slug: slug}, - ), - returnValue: _i5.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( - this, - Invocation.method( - #getProfileBySlug, - [], - {#slug: slug}, - ), - )), - returnValueForMissingStub: - _i5.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( - this, - Invocation.method( - #getProfileBySlug, - [], - {#slug: slug}, - ), - )), - ) as _i5.Future<_i2.ProfileModel>); + Invocation.method(#getProfileBySlug, [], {#slug: slug}), + returnValue: _i5.Future<_i2.ProfileModel>.value( + _FakeProfileModel_0( + this, + Invocation.method(#getProfileBySlug, [], {#slug: slug}), + ), + ), + returnValueForMissingStub: _i5.Future<_i2.ProfileModel>.value( + _FakeProfileModel_0( + this, + Invocation.method(#getProfileBySlug, [], {#slug: slug}), + ), + ), + ) + as _i5.Future<_i2.ProfileModel>); @override - _i5.Future<_i2.ProfileModel> getMyProfile() => (super.noSuchMethod( - Invocation.method( - #getMyProfile, - [], - ), - returnValue: _i5.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( - this, - Invocation.method( - #getMyProfile, - [], - ), - )), - returnValueForMissingStub: - _i5.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( - this, - Invocation.method( - #getMyProfile, - [], - ), - )), - ) as _i5.Future<_i2.ProfileModel>); + _i5.Future<_i2.ProfileModel> getMyProfile() => + (super.noSuchMethod( + Invocation.method(#getMyProfile, []), + returnValue: _i5.Future<_i2.ProfileModel>.value( + _FakeProfileModel_0(this, Invocation.method(#getMyProfile, [])), + ), + returnValueForMissingStub: _i5.Future<_i2.ProfileModel>.value( + _FakeProfileModel_0(this, Invocation.method(#getMyProfile, [])), + ), + ) + as _i5.Future<_i2.ProfileModel>); @override _i5.Future<_i2.ProfileDetailsModel> getMyProfileDetails() => (super.noSuchMethod( - Invocation.method( - #getMyProfileDetails, - [], - ), - returnValue: _i5.Future<_i2.ProfileDetailsModel>.value( - _FakeProfileDetailsModel_1( - this, - Invocation.method( - #getMyProfileDetails, - [], - ), - )), - returnValueForMissingStub: _i5.Future<_i2.ProfileDetailsModel>.value( - _FakeProfileDetailsModel_1( - this, - Invocation.method( - #getMyProfileDetails, - [], - ), - )), - ) as _i5.Future<_i2.ProfileDetailsModel>); + Invocation.method(#getMyProfileDetails, []), + returnValue: _i5.Future<_i2.ProfileDetailsModel>.value( + _FakeProfileDetailsModel_1( + this, + Invocation.method(#getMyProfileDetails, []), + ), + ), + returnValueForMissingStub: + _i5.Future<_i2.ProfileDetailsModel>.value( + _FakeProfileDetailsModel_1( + this, + Invocation.method(#getMyProfileDetails, []), + ), + ), + ) + as _i5.Future<_i2.ProfileDetailsModel>); @override - _i5.Future<_i2.ProfileDetailsModel> getProfileDetailsBySlug( - {required String? slug}) => + _i5.Future<_i2.ProfileDetailsModel> getProfileDetailsBySlug({ + required String? slug, + }) => (super.noSuchMethod( - Invocation.method( - #getProfileDetailsBySlug, - [], - {#slug: slug}, - ), - returnValue: _i5.Future<_i2.ProfileDetailsModel>.value( - _FakeProfileDetailsModel_1( - this, - Invocation.method( - #getProfileDetailsBySlug, - [], - {#slug: slug}, - ), - )), - returnValueForMissingStub: _i5.Future<_i2.ProfileDetailsModel>.value( - _FakeProfileDetailsModel_1( - this, - Invocation.method( - #getProfileDetailsBySlug, - [], - {#slug: slug}, - ), - )), - ) as _i5.Future<_i2.ProfileDetailsModel>); + Invocation.method(#getProfileDetailsBySlug, [], {#slug: slug}), + returnValue: _i5.Future<_i2.ProfileDetailsModel>.value( + _FakeProfileDetailsModel_1( + this, + Invocation.method(#getProfileDetailsBySlug, [], {#slug: slug}), + ), + ), + returnValueForMissingStub: + _i5.Future<_i2.ProfileDetailsModel>.value( + _FakeProfileDetailsModel_1( + this, + Invocation.method(#getProfileDetailsBySlug, [], { + #slug: slug, + }), + ), + ), + ) + as _i5.Future<_i2.ProfileDetailsModel>); @override _i5.Future addCircumference({ @@ -178,59 +135,53 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { required int? hipCircumference, }) => (super.noSuchMethod( - Invocation.method( - #addCircumference, - [], - { - #chestCircumference: chestCircumference, - #waistCircumference: waistCircumference, - #hipCircumference: hipCircumference, - }, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + Invocation.method(#addCircumference, [], { + #chestCircumference: chestCircumference, + #waistCircumference: waistCircumference, + #hipCircumference: hipCircumference, + }), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future addWeight({required double? weight}) => (super.noSuchMethod( - Invocation.method( - #addWeight, - [], - {#weight: weight}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); - - @override - _i5.Future> getBlogPostByAuthorSlug( - {required String? slug}) => + _i5.Future addWeight({required double? weight}) => (super.noSuchMethod( - Invocation.method( - #getBlogPostByAuthorSlug, - [], - {#slug: slug}, - ), - returnValue: _i5.Future>.value( - <_i6.FeedBlogPostModel>[]), - returnValueForMissingStub: - _i5.Future>.value( - <_i6.FeedBlogPostModel>[]), - ) as _i5.Future>); + Invocation.method(#addWeight, [], {#weight: weight}), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); + + @override + _i5.Future> getBlogPostByAuthorSlug({ + required String? slug, + }) => + (super.noSuchMethod( + Invocation.method(#getBlogPostByAuthorSlug, [], {#slug: slug}), + returnValue: _i5.Future>.value( + <_i6.FeedBlogPostModel>[], + ), + returnValueForMissingStub: + _i5.Future>.value( + <_i6.FeedBlogPostModel>[], + ), + ) + as _i5.Future>); @override _i5.Future> getWeight({required String? period}) => (super.noSuchMethod( - Invocation.method( - #getWeight, - [], - {#period: period}, - ), - returnValue: - _i5.Future>.value(<_i7.WeightModel>[]), - returnValueForMissingStub: - _i5.Future>.value(<_i7.WeightModel>[]), - ) as _i5.Future>); + Invocation.method(#getWeight, [], {#period: period}), + returnValue: _i5.Future>.value( + <_i7.WeightModel>[], + ), + returnValueForMissingStub: _i5.Future>.value( + <_i7.WeightModel>[], + ), + ) + as _i5.Future>); @override _i5.Future> getWeightBySlug({ @@ -238,35 +189,34 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { required String? slug, }) => (super.noSuchMethod( - Invocation.method( - #getWeightBySlug, - [], - { - #period: period, - #slug: slug, - }, - ), - returnValue: - _i5.Future>.value(<_i7.WeightModel>[]), - returnValueForMissingStub: - _i5.Future>.value(<_i7.WeightModel>[]), - ) as _i5.Future>); + Invocation.method(#getWeightBySlug, [], { + #period: period, + #slug: slug, + }), + returnValue: _i5.Future>.value( + <_i7.WeightModel>[], + ), + returnValueForMissingStub: _i5.Future>.value( + <_i7.WeightModel>[], + ), + ) + as _i5.Future>); @override - _i5.Future> getCircumferences( - {required String? period}) => + _i5.Future> getCircumferences({ + required String? period, + }) => (super.noSuchMethod( - Invocation.method( - #getCircumferences, - [], - {#period: period}, - ), - returnValue: _i5.Future>.value( - <_i8.CircumferenceModel>[]), - returnValueForMissingStub: - _i5.Future>.value( - <_i8.CircumferenceModel>[]), - ) as _i5.Future>); + Invocation.method(#getCircumferences, [], {#period: period}), + returnValue: _i5.Future>.value( + <_i8.CircumferenceModel>[], + ), + returnValueForMissingStub: + _i5.Future>.value( + <_i8.CircumferenceModel>[], + ), + ) + as _i5.Future>); @override _i5.Future> getCircumferencesBySlug({ @@ -274,20 +224,19 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { required String? slug, }) => (super.noSuchMethod( - Invocation.method( - #getCircumferencesBySlug, - [], - { - #period: period, - #slug: slug, - }, - ), - returnValue: _i5.Future>.value( - <_i8.CircumferenceModel>[]), - returnValueForMissingStub: - _i5.Future>.value( - <_i8.CircumferenceModel>[]), - ) as _i5.Future>); + Invocation.method(#getCircumferencesBySlug, [], { + #period: period, + #slug: slug, + }), + returnValue: _i5.Future>.value( + <_i8.CircumferenceModel>[], + ), + returnValueForMissingStub: + _i5.Future>.value( + <_i8.CircumferenceModel>[], + ), + ) + as _i5.Future>); @override _i5.Future<_i3.SubPaginationModel> getSubscribers({ @@ -295,39 +244,30 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { String? query, }) => (super.noSuchMethod( - Invocation.method( - #getSubscribers, - [], - { - #slug: slug, - #query: query, - }, - ), - returnValue: - _i5.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( - this, - Invocation.method( - #getSubscribers, - [], - { + Invocation.method(#getSubscribers, [], { #slug: slug, #query: query, - }, - ), - )), - returnValueForMissingStub: - _i5.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( - this, - Invocation.method( - #getSubscribers, - [], - { - #slug: slug, - #query: query, - }, - ), - )), - ) as _i5.Future<_i3.SubPaginationModel>); + }), + returnValue: _i5.Future<_i3.SubPaginationModel>.value( + _FakeSubPaginationModel_2( + this, + Invocation.method(#getSubscribers, [], { + #slug: slug, + #query: query, + }), + ), + ), + returnValueForMissingStub: _i5.Future<_i3.SubPaginationModel>.value( + _FakeSubPaginationModel_2( + this, + Invocation.method(#getSubscribers, [], { + #slug: slug, + #query: query, + }), + ), + ), + ) + as _i5.Future<_i3.SubPaginationModel>); @override _i5.Future<_i3.SubPaginationModel> getSubscriptions({ @@ -335,81 +275,64 @@ class MockProfileService extends _i1.Mock implements _i4.ProfileService { String? query, }) => (super.noSuchMethod( - Invocation.method( - #getSubscriptions, - [], - { - #slug: slug, - #query: query, - }, - ), - returnValue: - _i5.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( - this, - Invocation.method( - #getSubscriptions, - [], - { + Invocation.method(#getSubscriptions, [], { #slug: slug, #query: query, - }, - ), - )), - returnValueForMissingStub: - _i5.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( - this, - Invocation.method( - #getSubscriptions, - [], - { - #slug: slug, - #query: query, - }, - ), - )), - ) as _i5.Future<_i3.SubPaginationModel>); + }), + returnValue: _i5.Future<_i3.SubPaginationModel>.value( + _FakeSubPaginationModel_2( + this, + Invocation.method(#getSubscriptions, [], { + #slug: slug, + #query: query, + }), + ), + ), + returnValueForMissingStub: _i5.Future<_i3.SubPaginationModel>.value( + _FakeSubPaginationModel_2( + this, + Invocation.method(#getSubscriptions, [], { + #slug: slug, + #query: query, + }), + ), + ), + ) + as _i5.Future<_i3.SubPaginationModel>); @override - _i5.Future subscribe({required String? slug}) => (super.noSuchMethod( - Invocation.method( - #subscribe, - [], - {#slug: slug}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future subscribe({required String? slug}) => + (super.noSuchMethod( + Invocation.method(#subscribe, [], {#slug: slug}), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future unsubscribe({required String? slug}) => (super.noSuchMethod( - Invocation.method( - #unsubscribe, - [], - {#slug: slug}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future unsubscribe({required String? slug}) => + (super.noSuchMethod( + Invocation.method(#unsubscribe, [], {#slug: slug}), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override _i5.Future uploadPhoto({required _i9.File? photo}) => (super.noSuchMethod( - Invocation.method( - #uploadPhoto, - [], - {#photo: photo}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + Invocation.method(#uploadPhoto, [], {#photo: photo}), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future deletePhoto() => (super.noSuchMethod( - Invocation.method( - #deletePhoto, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future deletePhoto() => + (super.noSuchMethod( + Invocation.method(#deletePhoto, []), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); }