Merge remote-tracking branch 'upstream_main' into HEAD

# Conflicts:
#	lib/generated/intl/messages_en.dart
#	lib/generated/intl/messages_ru.dart
This commit is contained in:
2026-11-23 22:48:19 +03:00
67 changed files with 3777 additions and 2899 deletions

View File

@@ -18,21 +18,22 @@ class AppInitializer {
static Future<void> initialize({required AppBuildType buildType}) async {
await _initializeEnvironment();
await _initializeDependencyInjection(buildType: buildType);
await _initializeSentry();
_preserveSplash();
await _initializeFirebase();
await _initializeDebugMode();
await _initializeAnalytics();
}
/// Инициализация Sentry
static Future<void> _initializeSentry() async {
static void _preserveSplash() {
final widgetsBinding = SentryWidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
}
/// Загрузка переменных окружения
static Future<void> _initializeEnvironment() async {
await dotenv.load(fileName: ".env");
if (!dotenv.isInitialized) {
await dotenv.load(fileName: '.env');
}
}
/// Инициализация Firebase
@@ -64,20 +65,25 @@ class AppInitializer {
/// Инициализация аналитики
static Future<void> _initializeAnalytics() async {
AppMetrica.activate(AppMetricaConfig(EnvConfig.appMetricaApiKey));
AppMetrica.activate(AppMetricaConfig(EnvConfig.appMetricaApiKey, flutterCrashReporting: false));
AppMetrica.reportEvent('Application started');
}
/// Запуск приложения с Sentry
static Future<void> runAppWithSentry(VoidCallback appRunner) async {
static Future<void> runAppWithSentry(
FutureOr<void> Function() appRunner,
) async {
SentryWidgetsFlutterBinding.ensureInitialized();
await _initializeEnvironment();
const sendInDebug = bool.fromEnvironment('SENTRY_IN_DEBUG');
await SentryFlutter.init((options) {
options.dsn = EnvConfig.sentryDsn;
options.tracesSampleRate = 1.0;
options.debug = false;
if (kDebugMode && sendInDebug) options.environment = 'debug';
options.beforeSend = (event, hint) {
if (kDebugMode) return null;
if (!ErrorReportPolicy.allowSentryEvent(event, hint)) return null;
return event;
if (kDebugMode && !sendInDebug) return null;
return ErrorReportPolicy.prepareSentryEvent(event, hint);
};
}, appRunner: appRunner);
}

View File

@@ -6,7 +6,11 @@ part 'comments_service.g.dart';
@RestApi()
abstract class CommentsService {
factory CommentsService(Dio dio, {String baseUrl}) = _CommentsService;
factory CommentsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CommentsService;
@DELETE('/api/comments/{id}')
Future<void> deleteComment(@Path('id') int id);

View File

@@ -1,6 +1,8 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/constants/app_constants.dart';
import 'package:eatvio_app/core/error_reporting/api_response_dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/core/error_reporting/error_reporter.dart';
import 'package:eatvio_app/core/error_reporting/sentry_error_reporter.dart';
import 'package:eatvio_app/core/interceptors/phone_verify_error_interceptor.dart';
@@ -18,14 +20,15 @@ class ExternalRegistrations {
/// Регистрация всех внешних зависимостей
static void registerAll() {
sl.registerLazySingleton<ErrorReporter>(SentryErrorReporter.new);
sl.registerLazySingleton(() => ApiResponseErrorReporter(sl()));
_registerDio();
_registerPrefs();
}
/// Регистрация Dio HTTP клиента
static void _registerDio() {
sl.registerLazySingleton(
() => Dio(
sl.registerLazySingleton<Dio>(
() => ApiResponseDio(
BaseOptions(
baseUrl: sl<AppConfig>().baseUrl,
headers: {'accept': 'application/json', 'content-type': 'application/json'},
@@ -33,6 +36,7 @@ class ExternalRegistrations {
receiveTimeout: AppConstants.pendingDelay,
sendTimeout: AppConstants.pendingDelay,
),
sl(),
)..interceptors.addAll([TokenInterceptor(), PhoneVerifyErrorInterceptor()])
..addSentry(
failedRequestStatusCodes: const [SentryStatusCode.defaultRange()],

View File

@@ -86,7 +86,9 @@ class RepositoryRegistrations {
sl.registerLazySingleton<CommentsRepository>(() => CommentsRepository(service: sl()));
sl.registerLazySingleton<NotificationSettingsRepository>(() => NotificationSettingsRepository(sl()));
sl.registerLazySingleton<SbpRepository>(() => SbpRepository(sbpService: sl()));
sl.registerLazySingleton<PaymentRepository>(() => PaymentRepository(chatService: sl()));
sl.registerLazySingleton<PaymentRepository>(
() => PaymentRepository(chatService: sl(), responseErrors: sl()),
);
sl.registerLazySingleton<PersonalDietSuggestionRepository>(() => PersonalDietSuggestionRepository(personalDietSuggestionService: sl()));
sl.registerLazySingleton<RegistrationRepositoryV2>(() => RegistrationRepositoryV2(registrationService: sl()));

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/core/comments/services/comments_service.dart';
import 'package:eatvio_app/core/firebase_api.dart';
import 'package:eatvio_app/core/views/service/views_service.dart';
@@ -56,37 +57,83 @@ class ServiceRegistrations {
/// Регистрация Service как синглтонов
static void _registerSingletonServices() {
// Core services
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
sl.registerLazySingleton<VideoCallService>(() => VideoCallService(sl()));
sl.registerLazySingleton<ChatService>(
() => ChatService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<VideoCallService>(
() => VideoCallService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<PublicDownloadsSaver>(
() => const PublicDownloadsSaver(),
);
sl.registerLazySingleton<VideoCallRecordingFileService>(
() => VideoCallRecordingFileService(dio: sl(), downloadsSaver: sl()),
);
sl.registerLazySingleton<FeedService>(() => FeedService(sl()));
sl.registerLazySingleton<ProfileService>(() => ProfileService(sl()));
sl.registerLazySingleton<InsightsService>(() => InsightsService(sl()));
sl.registerLazySingleton<CalendarService>(() => CalendarService(sl()));
sl.registerLazySingleton<SettingsService>(() => SettingsService(sl()));
sl.registerLazySingleton<ConsultantService>(() => ConsultantService(sl()));
sl.registerLazySingleton<DiaryService>(() => DiaryService(sl()));
sl.registerLazySingleton<GlossaryService>(() => GlossaryService(sl()));
sl.registerLazySingleton<BarcodeService>(() => BarcodeService(sl()));
sl.registerLazySingleton<DietService>(() => DietService(sl()));
sl.registerLazySingleton<PlansService>(() => PlansService(sl()));
sl.registerLazySingleton<PlanService>(() => PlanService(sl()));
sl.registerLazySingleton<MyDietsService>(() => MyDietsService(sl()));
sl.registerLazySingleton<MyPlansService>(() => MyPlansService(sl()));
sl.registerLazySingleton<WsService>(() => WsService(sl()));
sl.registerLazySingleton<AboutRecipeService>(() => AboutRecipeService(sl()));
sl.registerLazySingleton<ComplainingService>(() => ComplainingService(sl()));
sl.registerLazySingleton<AuthService>(() => AuthService(sl()));
sl.registerLazySingleton<CardsService>(() => CardsService(sl()));
sl.registerLazySingleton<FeedService>(
() => FeedService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ProfileService>(
() => ProfileService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<InsightsService>(
() => InsightsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<CalendarService>(
() => CalendarService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<SettingsService>(
() => SettingsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ConsultantService>(
() => ConsultantService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<DiaryService>(
() => DiaryService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<GlossaryService>(
() => GlossaryService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<BarcodeService>(
() => BarcodeService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<DietService>(
() => DietService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<PlansService>(
() => PlansService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<PlanService>(
() => PlanService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<MyDietsService>(
() => MyDietsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<MyPlansService>(
() => MyPlansService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<WsService>(() => WsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()));
sl.registerLazySingleton<AboutRecipeService>(
() => AboutRecipeService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ComplainingService>(
() => ComplainingService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<AuthService>(
() => AuthService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<CardsService>(
() => CardsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ConsultationService>(() => ConsultationService(sl()));
sl.registerLazySingleton<CancelPlanService>(() => CancelPlanService(sl()));
sl.registerLazySingleton<CreatePlanService>(() => CreatePlanService(sl()));
sl.registerLazySingleton<NotificationsService>(() => NotificationsService(sl()));
sl.registerLazySingleton<CancelPlanService>(
() => CancelPlanService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<CreatePlanService>(
() => CreatePlanService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<NotificationsService>(
() => NotificationsService(sl(), responseErrors: sl()),
);
sl.registerLazySingleton<FirebaseApi>(() => FirebaseApi(errorReporter: sl()));
sl.registerLazySingleton<VideoCallCallKitCoordinator>(
() => VideoCallCallKitCoordinator(firebaseApi: sl()),
@@ -94,23 +141,49 @@ class ServiceRegistrations {
sl.registerLazySingleton<VideoCallSystemPipCoordinator>(
() => VideoCallSystemPipCoordinator(),
);
sl.registerLazySingleton<ResetPasswordService>(() => ResetPasswordService(sl()));
sl.registerLazySingleton<BlockedUserService>(() => BlockedUserService(sl()));
sl.registerLazySingleton<CommentsService>(() => CommentsService(sl()));
sl.registerLazySingleton<MyRecipesService>(() => MyRecipesService(sl()));
sl.registerLazySingleton<ConsultantRatingService>(() => ConsultantRatingService(sl()));
sl.registerLazySingleton<NotificationSettingsService>(() => NotificationSettingsService(sl()));
sl.registerLazySingleton<ViewsService>(() => ViewsService(sl()));
sl.registerLazySingleton<ResetPasswordService>(
() => ResetPasswordService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<BlockedUserService>(
() => BlockedUserService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<CommentsService>(
() => CommentsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<MyRecipesService>(
() => MyRecipesService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ConsultantRatingService>(
() => ConsultantRatingService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<NotificationSettingsService>(
() => NotificationSettingsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<ViewsService>(
() => ViewsService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<SbpService>(() => const SbpServiceImpl());
sl.registerLazySingleton<PersonalDietSuggestionService>(() => PersonalDietSuggestionService(sl()));
sl.registerLazySingleton<RegistrationServiceV2>(() => RegistrationServiceV2(sl()));
sl.registerLazySingleton<PersonalDietSuggestionService>(
() => PersonalDietSuggestionService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<RegistrationServiceV2>(
() => RegistrationServiceV2(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
// Content services
sl.registerLazySingleton<CreateRecipeService>(() => CreateRecipeService(sl()));
sl.registerLazySingleton<BlogPostService>(() => BlogPostService(sl()));
sl.registerLazySingleton<CreateDietService>(() => CreateDietService(sl()));
sl.registerLazySingleton<CreateRecipeService>(
() => CreateRecipeService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<BlogPostService>(
() => BlogPostService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
sl.registerLazySingleton<CreateDietService>(
() => CreateDietService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
// Auth services
sl.registerLazySingleton<RegistrationService>(() => RegistrationService(sl()));
sl.registerLazySingleton<RegistrationService>(
() => RegistrationService(sl(), errorLogger: sl<ApiResponseErrorReporter>()),
);
}
}

View File

@@ -0,0 +1,71 @@
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
class ApiResponseDio extends DioForNative {
ApiResponseDio(BaseOptions super.options, this._responseErrors) {
transformer = _ApiResponseTransformer(
transformer,
_responseErrors,
_responseStatuses,
);
}
final ApiResponseErrorReporter _responseErrors;
final _responseStatuses = Expando<int>();
@override
Future<Response<T>> fetch<T>(RequestOptions requestOptions) async {
try {
return await super.fetch<T>(requestOptions);
} on DioException catch (error) {
final cause = error.error;
final status = _responseStatuses[error.requestOptions];
// Dio приводит тип корневого значения до вызова fromJson в Retrofit.
if (error.type == DioExceptionType.unknown &&
error.requestOptions.responseType == ResponseType.json &&
cause is TypeError &&
status != null) {
_responseErrors.report(
error,
cause.stackTrace ?? error.stackTrace,
method: error.requestOptions.method,
statusCode: status,
);
}
rethrow;
}
}
}
class _ApiResponseTransformer implements Transformer {
_ApiResponseTransformer(this._delegate, this._responseErrors, this._statuses);
final Transformer _delegate;
final ApiResponseErrorReporter _responseErrors;
final Expando<int> _statuses;
@override
Future<String> transformRequest(RequestOptions options) =>
_delegate.transformRequest(options);
@override
Future<dynamic> transformResponse(
RequestOptions options,
ResponseBody response,
) async {
try {
final data = await _delegate.transformResponse(options, response);
_statuses[options] = response.statusCode;
return data;
} on FormatException catch (error, stackTrace) {
_responseErrors.report(
error,
stackTrace,
method: options.method,
statusCode: response.statusCode,
);
rethrow;
}
}
}

View File

@@ -0,0 +1,111 @@
import 'dart:async';
import 'dart:developer';
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/error_reporter.dart';
import 'package:retrofit/retrofit.dart';
class ApiResponseErrorReporter implements ParseErrorLogger {
ApiResponseErrorReporter(this._reporter);
final ErrorReporter _reporter;
static final _capturedErrors = Expando<bool>();
static bool wasCaptured(Object error) =>
_isCaptured(error) || (error is DioException && _isCaptured(error.error));
static bool _isCaptured(Object? error) =>
error != null &&
(error is Error || error is Exception) &&
_capturedErrors[error] == true;
static T decode<T>(
ApiResponseErrorReporter? reporter,
Response<dynamic> response,
String endpoint,
T Function() parse,
) {
try {
return parse();
} catch (error, stackTrace) {
reporter?.report(
error,
stackTrace,
method: response.requestOptions.method,
statusCode: response.statusCode,
endpoint: endpoint,
);
rethrow;
}
}
@override
void logError(
Object error,
StackTrace stackTrace,
RequestOptions options, {
Response<dynamic>? response,
}) {
report(
error,
stackTrace,
method: options.method,
statusCode: response?.statusCode,
);
}
void report(
Object error,
StackTrace stackTrace, {
required String method,
int? statusCode,
String? endpoint,
}) {
if (error is Error || error is Exception) {
_capturedErrors[error] = true;
}
// Сообщение исходного исключения может содержать значения из ответа API.
final cause = error is DioException ? error.error ?? error : error;
unawaited(
_send(
ApiResponseDecodeException(cause.runtimeType.toString()),
stackTrace,
{
'http_method': method,
'http_status_code': ?statusCode,
'endpoint': ?endpoint,
},
),
);
}
Future<void> _send(
ApiResponseDecodeException error,
StackTrace stackTrace,
Map<String, Object?> context,
) async {
try {
await _reporter.report(
error,
stackTrace,
origin: 'api_response',
extras: context,
);
} catch (reportError, reportStackTrace) {
log(
'Не удалось записать ошибку разбора ответа API',
error: reportError.runtimeType,
stackTrace: reportStackTrace,
);
}
}
}
class ApiResponseDecodeException implements Exception {
ApiResponseDecodeException(this.causeType);
final String causeType;
@override
String toString() => 'Could not decode API response ($causeType)';
}

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/core/push/hms_client_error.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@@ -14,6 +15,7 @@ class ErrorReportPolicy {
/// When `false`, the error is not sent via [ErrorReporter].
static bool shouldReport(Object? error) {
if (error == null) return false;
if (ApiResponseErrorReporter.wasCaptured(error)) return false;
if (error is String) return false;
if (error is SocketException) return false;
if (isHmsClientUnavailable(error)) return false;
@@ -34,11 +36,23 @@ class ErrorReportPolicy {
final t = event.throwable;
if (t == null) return true;
if (t is DioException) {
return _allowSentrySdkDio(t);
return !ApiResponseErrorReporter.wasCaptured(t) && _allowSentrySdkDio(t);
}
return shouldReport(t);
}
static SentryEvent? prepareSentryEvent(SentryEvent event, Hint hint) {
if (!allowSentryEvent(event, hint)) return null;
if (event.throwable is ApiResponseDecodeException) {
// HTTP breadcrumbs могут содержать идентификаторы в пути и параметры запроса.
event.breadcrumbs = event.breadcrumbs
?.where((breadcrumb) => breadcrumb.category != 'http')
.toList();
event.request = null;
}
return event;
}
/// Cancel, timeouts, socket / connection errors — do not send (noisy, often user environment).
static bool _isTransientDioFailure(DioException e) {
switch (e.type) {

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/core/firebase_api.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/prefs.dart';
@@ -103,7 +104,7 @@ class OtherRoutes {
redirect: (context, state) async {
try {
// Проверка версии с таймаутом, чтобы не блокировать запуск приложения
final versions = await sl<Dio>()
final response = await sl<Dio>()
.get('${sl<AppConfig>().baseUrl}/api/app_versions')
.timeout(
const Duration(seconds: 5),
@@ -111,12 +112,8 @@ class OtherRoutes {
// При таймауте пропускаем проверку и идем дальше
throw TimeoutException('Version check timeout');
},
)
.then((response) => response.data)
.catchError((e) {
// При любой ошибке пропускаем проверку версии
return null;
});
);
final versions = response.data;
if (versions == null) {
// Если проверка не удалась, пропускаем экран обновления
@@ -126,7 +123,15 @@ class OtherRoutes {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version;
Version currentVersion = Version.parse(version);
Version latestVersion = Version.parse(versions['min_version']);
final responseErrors = sl.isRegistered<ApiResponseErrorReporter>()
? sl<ApiResponseErrorReporter>()
: null;
final latestVersion = ApiResponseErrorReporter.decode(
responseErrors,
response,
'/api/app_versions',
() => Version.parse(versions['min_version']),
);
if (latestVersion > currentVersion) {
return null;
} else {

View File

@@ -6,7 +6,11 @@ part 'views_service.g.dart';
@RestApi()
abstract class ViewsService {
factory ViewsService(Dio dio, {String baseUrl}) = _ViewsService;
factory ViewsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ViewsService;
@POST('/api/views')
Future<void> viewContent({

View File

@@ -8,7 +8,11 @@ part 'ws_service.g.dart';
@RestApi()
abstract class WsService {
factory WsService(Dio dio, {String baseUrl}) = _WsService;
factory WsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _WsService;
@GET('/api/profile/ws/params')
Future<WebsocketInfoModel> getWebsocket();

View File

@@ -12,7 +12,11 @@ part 'auth_service.g.dart';
@RestApi()
abstract class AuthService {
factory AuthService(Dio dio, {String? baseUrl}) = _AuthService;
factory AuthService(
Dio dio, {
String? baseUrl,
ParseErrorLogger? errorLogger,
}) = _AuthService;
@POST('/api/login')
Future<TokenModel> getTokenByCredentials({@Body() required CredentialsModel credentials});

View File

@@ -5,7 +5,11 @@ part 'reset_password_service.g.dart';
@RestApi()
abstract class ResetPasswordService {
factory ResetPasswordService(Dio dio, {String baseUrl}) = _ResetPasswordService;
factory ResetPasswordService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ResetPasswordService;
@POST('/api/send_password_reset_code')
Future<HttpResponse> sendEmailCodeForPasswordChange({

View File

@@ -1,24 +1,28 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
import 'package:retrofit/retrofit.dart';
part 'barcode_service.g.dart';
@RestApi()
abstract class BarcodeService {
factory BarcodeService(Dio dio, {String baseUrl}) = _BarcodeService;
@GET('/api/gsone/barcode/{barcode}')
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
@GET('/api/gsone/barcode/status/{task_id}')
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
}
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
import 'package:retrofit/retrofit.dart';
part 'barcode_service.g.dart';
@RestApi()
abstract class BarcodeService {
factory BarcodeService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _BarcodeService;
@GET('/api/gsone/barcode/{barcode}')
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
@GET('/api/gsone/barcode/status/{task_id}')
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
}

View File

@@ -5,7 +5,11 @@ part 'blog_post_service.g.dart';
@RestApi()
abstract class BlogPostService {
factory BlogPostService(Dio dio, {String baseUrl}) = _BlogPostService;
factory BlogPostService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _BlogPostService;
@POST('/api/v2/blogPosts/create/published')
@MultiPart()

View File

@@ -6,7 +6,11 @@ part 'calendar_service.g.dart';
@RestApi()
abstract class CalendarService {
factory CalendarService(Dio dio, {String baseUrl}) = _CalendarService;
factory CalendarService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CalendarService;
@GET('/api/calendar/index')
Future<List<CalendarModel>> getCalendar();

View File

@@ -6,7 +6,11 @@ part 'cancel_plan_service.g.dart';
@RestApi()
abstract class CancelPlanService {
factory CancelPlanService(Dio dio, {String baseUrl}) = _CancelPlanService;
factory CancelPlanService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CancelPlanService;
@POST('/api/chosen_plans/{id}/cancel')
Future<void> cancelChosenPlan({

View File

@@ -17,7 +17,11 @@ part 'chat_service.g.dart';
@RestApi()
abstract class ChatService {
factory ChatService(Dio dio, {String baseUrl}) = _ChatService;
factory ChatService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ChatService;
@GET('/api/v2/chat/index')
Future<ChatRoomPaginationModel> getChatRooms({

View File

@@ -6,7 +6,11 @@ part 'complaining_service.g.dart';
@RestApi()
abstract class ComplainingService {
factory ComplainingService(Dio dio, {String baseUrl}) = _ComplainingService;
factory ComplainingService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ComplainingService;
@POST('/api/plans/{slug}/complain/{category}')
Future<void> sendPlanComplain({

View File

@@ -9,7 +9,11 @@ part 'consultant_service.g.dart';
@RestApi()
abstract class ConsultantService {
factory ConsultantService(Dio dio, {String baseUrl}) = _ConsultantService;
factory ConsultantService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ConsultantService;
@POST('/api/v2/consultant_request/registration')
Future<void> consultantRegistration({

View File

@@ -8,7 +8,11 @@ part 'consultant_rating_service.g.dart';
@RestApi()
abstract class ConsultantRatingService {
factory ConsultantRatingService(Dio dio, {String baseUrl}) = _ConsultantRatingService;
factory ConsultantRatingService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ConsultantRatingService;
@GET('/api/consultants/rating/statistics')
Future<StatisticsModel> getConsultantStatistics({@Query('filters[duration][\$gte]') String? date});

View File

@@ -6,7 +6,11 @@ part 'create_diet_service.g.dart';
@RestApi()
abstract class CreateDietService {
factory CreateDietService(Dio dio, {String baseUrl}) = _CreateDietService;
factory CreateDietService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CreateDietService;
@POST('/api/diets/create/published')
@MultiPart()

View File

@@ -5,7 +5,11 @@ part 'create_plan_service.g.dart';
@RestApi()
abstract class CreatePlanService {
factory CreatePlanService(Dio dio, {String baseUrl}) = _CreatePlanService;
factory CreatePlanService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CreatePlanService;
@POST('/api/plans/create/published')
@MultiPart()

View File

@@ -8,7 +8,11 @@ part 'recipe_service.g.dart';
@RestApi()
abstract class CreateRecipeService {
factory CreateRecipeService(Dio dio, {String baseUrl}) = _CreateRecipeService;
factory CreateRecipeService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CreateRecipeService;
@POST('/api/recipes/{slug}/like')
Future<void> likeRecipe({

View File

@@ -13,7 +13,11 @@ part 'diary_service.g.dart';
@RestApi()
abstract class DiaryService {
factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService;
factory DiaryService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _DiaryService;
@GET('/api/diary/index/{date}')
Future<List<DiaryDayModel>> getDiaryIndexByDate({@Path('date') required String date});

View File

@@ -7,7 +7,11 @@ part 'diet_service.g.dart';
@RestApi()
abstract class DietService {
factory DietService(Dio dio, {String baseUrl}) = _DietService;
factory DietService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _DietService;
@POST('/api/diets/{id}/like')
Future<DietLikesModel> likeDiet({

View File

@@ -14,7 +14,11 @@ part 'feed_service.g.dart';
@RestApi()
abstract class FeedService {
factory FeedService(Dio dio, {String baseUrl}) = _FeedService;
factory FeedService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _FeedService;
@GET('/api/blogPosts/index')
Future<FeedBlogPostSettingsModel> getBlogPostList({@Query('page') required int page, @Query('query_search') String? query});

View File

@@ -6,7 +6,11 @@ part 'glossary_service.g.dart';
@RestApi()
abstract class GlossaryService {
factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService;
factory GlossaryService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _GlossaryService;
@GET('/api/glossaries/search')
Future<GlossaryPaginationModel> getGlossaryByQuery({

View File

@@ -9,7 +9,11 @@ part 'insights_service.g.dart';
/// недоступный профиль — 403.
@RestApi()
abstract class InsightsService {
factory InsightsService(Dio dio, {String baseUrl}) = _InsightsService;
factory InsightsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _InsightsService;
/// Свои графики целиком.
@GET('/api/profile/insights')

View File

@@ -6,7 +6,11 @@ part 'blocked_users_service.g.dart';
@RestApi()
abstract class BlockedUserService {
factory BlockedUserService(Dio dio, {String baseUrl}) = _BlockedUserService;
factory BlockedUserService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _BlockedUserService;
@GET('/api/blocked_users')
Future<BlockedUsersModel> getBlockedUsers();

View File

@@ -6,7 +6,11 @@ part 'notification_settings_service.g.dart';
@RestApi()
abstract class NotificationSettingsService {
factory NotificationSettingsService(Dio dio, {String baseUrl}) = _NotificationSettingsService;
factory NotificationSettingsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _NotificationSettingsService;
@GET('/api/profile/notification_settings')
Future<NotificationSettingsModel> getNotificationSettings();

View File

@@ -7,7 +7,11 @@ part 'my_diets_service.g.dart';
@RestApi()
abstract class MyDietsService {
factory MyDietsService(Dio dio, {String baseUrl}) = _MyDietsService;
factory MyDietsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _MyDietsService;
@GET('/api/profile/my_diets')
Future<DietsPagination> getDiets({

View File

@@ -7,7 +7,11 @@ part 'cards_service.g.dart';
@RestApi()
abstract class CardsService {
factory CardsService(Dio dio, {String baseUrl}) = _CardsService;
factory CardsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _CardsService;
@GET('/api/finances/cards')
Future<List<CardModel>> getCards();

View File

@@ -6,7 +6,11 @@ part 'my_plans_service.g.dart';
@RestApi()
abstract class MyPlansService {
factory MyPlansService(Dio dio, {String baseUrl}) = _MyPlansService;
factory MyPlansService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _MyPlansService;
@GET('/api/profile/my_plans')
Future<PlanPaginationModel> getPlans({

View File

@@ -1,13 +1,17 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/features/notifications/models/notification_model.dart';
class NotificationsService {
final Dio dio;
NotificationsService(this.dio);
final ApiResponseErrorReporter? responseErrors;
static const _endpoint = '/api/profile/notifications';
NotificationsService(this.dio, {this.responseErrors});
Future<Map<String, dynamic>?> getNotifications({required int page}) async {
final response = await dio.get('$_endpoint?page=$page');
try {
final response = await dio.get('/api/profile/notifications?page=$page');
if (response.statusCode == 200) {
final data = response.data['data'] as List<dynamic>;
@@ -493,7 +497,14 @@ class NotificationsService {
),
NotificationType.unknown => UnknownNotification(type: type, createdAt: parseDate(createdAt)),
};
} catch (e) {
} catch (error, stackTrace) {
responseErrors?.report(
error,
stackTrace,
method: response.requestOptions.method,
statusCode: response.statusCode,
endpoint: _endpoint,
);
return UnknownNotification(type: NotificationType.unknown, createdAt: DateTime.now());
}
}).toList();
@@ -510,7 +521,14 @@ class NotificationsService {
};
}
return null;
} catch (e) {
} catch (error, stackTrace) {
responseErrors?.report(
error,
stackTrace,
method: response.requestOptions.method,
statusCode: response.statusCode,
endpoint: _endpoint,
);
rethrow;
}
}

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/features/chat/models/payment_model.dart';
import 'package:eatvio_app/features/chat/services/chat_service.dart';
import 'package:eatvio_app/features/payment/models/promo_applied_list_response.dart';
@@ -10,8 +11,9 @@ import 'package:eatvio_app/features/payment/models/promo_validate_response.dart'
/// Репозиторий оплаты консультаций (chosen_plan) через Alfa Bank / СБП.
class PaymentRepository {
final ChatService chatService;
final ApiResponseErrorReporter? responseErrors;
PaymentRepository({required this.chatService});
PaymentRepository({required this.chatService, this.responseErrors});
/// Запускает процесс оплаты: POST `/api/chosen_plans/{id}/start_payment_process`
/// с `payment_provider: alfa-bank`.
@@ -64,9 +66,15 @@ class PaymentRepository {
body: {'promo_code': promoCode},
);
} on DioException catch (e) {
final data = e.response?.data;
if (data is Map<String, dynamic>) {
return PromoApplyResponse.fromJson(data);
final response = e.response;
final data = response?.data;
if (response != null && data is Map<String, dynamic>) {
return ApiResponseErrorReporter.decode(
responseErrors,
response,
'/api/chosen_plans/{id}/apply_promo',
() => PromoApplyResponse.fromJson(data),
);
}
rethrow;
}
@@ -77,9 +85,15 @@ class PaymentRepository {
try {
return await chatService.removePromoCode(id: planId);
} on DioException catch (e) {
final data = e.response?.data;
if (data is Map<String, dynamic>) {
return PromoRemoveResponse.fromJson(data);
final response = e.response;
final data = response?.data;
if (response != null && data is Map<String, dynamic>) {
return ApiResponseErrorReporter.decode(
responseErrors,
response,
'/api/chosen_plans/{id}/remove_promo_code',
() => PromoRemoveResponse.fromJson(data),
);
}
rethrow;
}

View File

@@ -6,8 +6,11 @@ part 'personal_diet_suggestion_service.g.dart';
@RestApi()
abstract class PersonalDietSuggestionService {
factory PersonalDietSuggestionService(Dio dio, {String? baseUrl}) =
_PersonalDietSuggestionService;
factory PersonalDietSuggestionService(
Dio dio, {
String? baseUrl,
ParseErrorLogger? errorLogger,
}) = _PersonalDietSuggestionService;
@GET('/api/consultations')
Future<ConsultationPaginationModel> getConsultationWithPersonalDiets({

View File

@@ -7,7 +7,11 @@ part 'plan_service.g.dart';
@RestApi()
abstract class PlanService {
factory PlanService(Dio dio, {String baseUrl}) = _PlanService;
factory PlanService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _PlanService;
@GET('/api/plans/show/{slug}')
Future<PlanModel> getPlan(@Path('slug') String slug);

View File

@@ -6,7 +6,11 @@ part 'plans_service.g.dart';
@RestApi()
abstract class PlansService {
factory PlansService(Dio dio, {String baseUrl}) = _PlansService;
factory PlansService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _PlansService;
@GET('/api/plans/get_by_author/{author}')
Future<PlanPaginationModel> getPlansBySlug({

View File

@@ -14,7 +14,11 @@ part 'profile_service.g.dart';
@RestApi()
abstract class ProfileService {
factory ProfileService(Dio dio, {String baseUrl}) = _ProfileService;
factory ProfileService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _ProfileService;
@GET('/api/profile/show/{slug}')
Future<ProfileModel> getProfileBySlug({@Path() required String slug});

View File

@@ -6,7 +6,11 @@ part 'about_recipe_service.g.dart';
@RestApi()
abstract class AboutRecipeService {
factory AboutRecipeService(Dio dio, {String baseUrl}) = _AboutRecipeService;
factory AboutRecipeService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _AboutRecipeService;
@POST('/api/recipes/{slug}/like')
Future<void> likeRecipe({

View File

@@ -6,7 +6,11 @@ part 'my_recipes_service.g.dart';
@RestApi()
abstract class MyRecipesService {
factory MyRecipesService(Dio dio, {String baseUrl}) = _MyRecipesService;
factory MyRecipesService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _MyRecipesService;
@GET('/api/recipes/my')
Future<MyRecipePaginationModel> getMyRecipes();

View File

@@ -6,7 +6,11 @@ part 'registration_service.g.dart';
@RestApi()
abstract class RegistrationService {
factory RegistrationService(Dio dio, {String baseUrl}) = _RegistrationService;
factory RegistrationService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _RegistrationService;
@POST('/api/register')
Future<Map<String, String>> register({

View File

@@ -5,7 +5,11 @@ part 'registration_service_v2.g.dart';
@RestApi()
abstract class RegistrationServiceV2 {
factory RegistrationServiceV2(Dio dio, {String baseUrl}) = _RegistrationServiceV2;
factory RegistrationServiceV2(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _RegistrationServiceV2;
@POST('/api/register')
Future<Map<String, String>> register({

View File

@@ -80,29 +80,33 @@ class SettingsCubit extends Cubit<SettingsState> {
}
}
Future<void> updateProfileDetails({
Future<bool> updateProfileDetails({
required ProfileDetailsModel profileDetailsModel,
}) async {
try {
await settingsRepository.updateProfileDetails(
profileDetailsModel: profileDetailsModel,
);
return true;
} catch (e, st) {
await reportFrom(e, st, this);
return false;
} finally {
await init();
}
}
Future<void> updateProfileSettings({
Future<bool> updateProfileSettings({
required ProfileSettingsModel profileSettingsModel,
}) async {
try {
await settingsRepository.updateProfileSettings(
profileSettingsModel: profileSettingsModel,
);
return true;
} catch (e, st) {
await reportFrom(e, st, this);
return false;
} finally {
await init();
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_drop_down.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
@@ -10,6 +11,7 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:cupertino_ui/cupertino_ui.dart';
import 'package:go_router/go_router.dart';
class GeneralInfoScreen extends StatefulWidget {
final SettingsEntity settingsEntity;
@@ -233,7 +235,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
setState(() {
isLoading = true;
});
await widget.settingsEntity.settingsCubit.updateProfileDetails(
final detailsSaved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
firstName: firstNameController.text,
lastName: lastNameController.text,
@@ -244,7 +246,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
lang: languageController.text,
),
);
await widget.settingsEntity.settingsCubit.updateProfileSettings(
final settingsSaved = await widget.settingsEntity.settingsCubit.updateProfileSettings(
profileSettingsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith(
isPublicProfile: isPublicProfile.value,
),
@@ -253,6 +255,10 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
setState(() {
isLoading = false;
});
if (detailsSaved && settingsSaved) {
showSuccessToast(S.of(context).data_saved_successfully);
context.pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:go_router/go_router.dart';
@@ -137,8 +138,8 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
aboutAlergy: aboutAllergyController.text,
aboutTakingPils: aboutTakingPillsController.text,
@@ -148,7 +149,11 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
additionalInfo: additionalInfoController.text,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,8 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -200,7 +202,7 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
onTap: () async {
late final double activityCoefficient;
switch (_physicalActivity) {
case PhysicalActivity.minimum:
@@ -221,12 +223,16 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
default:
break;
}
widget.settingsEntity.settingsCubit.updateProfileDetails(
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
activityCoefficient: activityCoefficient,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
@@ -108,8 +109,8 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
chestCircumference: int.parse(chestCircumferenceController.text),
waistCircumference: int.parse(waistCircumferenceController.text),
@@ -118,7 +119,11 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
weight: double.parse(weightController.text),
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
@@ -114,8 +115,8 @@ class _PressureScreenState extends State<PressureScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
bloodPressureUp: int.parse(bloodPressureUpController.text),
bloodPressureDown: int.parse(bloodPressureDownController.text),
@@ -123,7 +124,11 @@ class _PressureScreenState extends State<PressureScreen> {
hasHypo: hypo.value,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -9,7 +9,11 @@ part 'settings_service.g.dart';
@RestApi()
abstract class SettingsService {
factory SettingsService(Dio dio, {String baseUrl}) = _SettingsService;
factory SettingsService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _SettingsService;
@GET('/api/profile/settings')
Future<ProfileSettingsModel> getProfileSettings();

View File

@@ -7,7 +7,11 @@ part 'video_call_service.g.dart';
@RestApi()
abstract class VideoCallService {
factory VideoCallService(Dio dio, {String baseUrl}) = _VideoCallService;
factory VideoCallService(
Dio dio, {
String baseUrl,
ParseErrorLogger? errorLogger,
}) = _VideoCallService;
@GET('/api/v2/chat/{conversation}/video-call/token')
Future<VideoCallTokenResponse> getParticipantToken({

View File

@@ -11,6 +11,7 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';
@@ -20,8 +21,8 @@ import 'messages_ru.dart' as messages_ru;
typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new Future.value(null),
'ru': () => new Future.value(null),
'en': () => new SynchronousFuture(null),
'ru': () => new SynchronousFuture(null),
};
MessageLookupByLibrary? _findExact(String localeName) {
@@ -36,18 +37,20 @@ MessageLookupByLibrary? _findExact(String localeName) {
}
/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) async {
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
localeName,
(locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null,
);
if (availableLocale == null) {
return new Future.value(false);
return new SynchronousFuture(false);
}
var lib = _deferredLibraries[availableLocale];
await (lib == null ? new Future.value(false) : lib());
lib == null ? new SynchronousFuture(false) : lib();
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new Future.value(true);
return new SynchronousFuture(true);
}
bool _messagesExistFor(String locale) {
@@ -59,8 +62,11 @@ bool _messagesExistFor(String locale) {
}
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale =
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
var actualLocale = Intl.verifiedLocale(
locale,
_messagesExistFor,
onFailure: (_) => null,
);
if (actualLocale == null) return null;
return _findExact(actualLocale);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,7 @@
"last_name": "Фамилия",
"what_is_your_name": "Как вас зовут?",
"date_of_birth": "Дата рождения",
"data_saved_successfully": "Data saved successfully",
"country": "Страна",
"Russia": "Россия",
"city": "Город",

View File

@@ -9,6 +9,7 @@
"last_name": "Фамилия",
"what_is_your_name": "Как вас зовут?",
"date_of_birth": "Дата рождения",
"data_saved_successfully": "Данные успешно сохранены",
"country": "Страна",
"Russia": "Россия",
"city": "Город",

View File

@@ -16,13 +16,14 @@ import 'package:flutter_portal/flutter_portal.dart';
import 'package:keyboard_dismisser/keyboard_dismisser.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
FlutterForegroundTask.initCommunicationPort();
VideoCallForegroundBootstrap.ensureInitialized();
await AppInitializer.initialize(buildType: AppBuildType.prod);
await sl<VideoCallCallKitCoordinator>().initialize();
await PushNavigationHandler.initialize();
await AppInitializer.runAppWithSentry(() => runApp(const MyApp()));
await AppInitializer.runAppWithSentry(() async {
FlutterForegroundTask.initCommunicationPort();
VideoCallForegroundBootstrap.ensureInitialized();
await AppInitializer.initialize(buildType: AppBuildType.prod);
await sl<VideoCallCallKitCoordinator>().initialize();
await PushNavigationHandler.initialize();
runApp(const MyApp());
});
}
class MyApp extends StatefulWidget {