diff --git a/integration_test/auth_screen/auth_login_test.dart b/integration_test/auth_screen/auth_login_test.dart index 711e0aa3..ce538770 100644 --- a/integration_test/auth_screen/auth_login_test.dart +++ b/integration_test/auth_screen/auth_login_test.dart @@ -1,9 +1,8 @@ import 'package:eatvio_app/app_keys.dart'; import 'package:eatvio_app/core/app_initializer.dart'; +import 'package:eatvio_app/main.dart' as app; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import 'package:eatvio_app/main.dart' as app; - import '../common_cases/skip_welcome_screen.dart'; void main() { @@ -13,7 +12,7 @@ void main() { await AppInitializer.initialize(buildType: AppBuildType.tests); }); - testWidgets('Signs in successfully with valid credentials', (WidgetTester tester) async { + testWidgets('Signs in successfully with valid credentials', (WidgetTester tester) async { await tester.pumpWidget(const app.MyApp()); await tester.pumpAndSettle(const Duration(seconds: 3)); await skipWelcomeScreen(tester); @@ -25,7 +24,7 @@ void main() { expect(passwordFieldFinder, findsOneWidget, reason: 'Password text field should be found.'); expect(signInButtonFinder, findsOneWidget, reason: 'Sign In button should be found.'); - await tester.enterText(emailFieldFinder, 'reshetnik.n+user3@gmail.com'); + await tester.enterText(emailFieldFinder, 'reshetnick.mike+user4@gmail.com'); await tester.enterText(passwordFieldFinder, '1234567890'); await tester.pumpAndSettle(); diff --git a/integration_test/auth_screen/auth_logo_button_test.dart b/integration_test/auth_screen/auth_logo_button_test.dart index c427f327..c7ac598d 100644 --- a/integration_test/auth_screen/auth_logo_button_test.dart +++ b/integration_test/auth_screen/auth_logo_button_test.dart @@ -4,7 +4,6 @@ import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:eatvio_app/main.dart' as app; - import '../common_cases/skip_welcome_screen.dart'; void main() { @@ -15,7 +14,7 @@ void main() { }); testWidgets('tapping logo 7 times opens dev tools', (WidgetTester tester) async { - await tester.pumpWidget(const app.MyApp()); + await tester.pumpWidget(const app.MyApp()); await tester.pumpAndSettle(const Duration(seconds: 3)); await skipWelcomeScreen(tester); final logoButtonFinder = find.byKey(AppKeys.hiddenLogoButtonAuthScreen); diff --git a/lib/core/app_config.dart b/lib/core/app_config.dart index 3fb06b39..03513645 100644 --- a/lib/core/app_config.dart +++ b/lib/core/app_config.dart @@ -1,3 +1,5 @@ +import 'package:eatvio_app/core/app_initializer.dart'; +import 'package:eatvio_app/core/env_config.dart'; import 'package:eatvio_app/core/internet_connection_cubit/internet_connection_cubit.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/views/cubit/views_cubit.dart'; @@ -13,8 +15,24 @@ import 'package:flutter_localizations/flutter_localizations.dart'; /// Конфигурация приложения class AppConfig { + AppConfig({required this.buildType}){ + _baseUrl = switch (buildType) { + AppBuildType.prod => EnvConfig.baseUrl, + AppBuildType.tests => EnvConfig.devBaseUrl, + AppBuildType.dev => EnvConfig.devBaseUrl, + }; + } + + final AppBuildType buildType; + late final String _baseUrl; + String get baseUrl => _baseUrl; + + void setBaseUrl(String baseUrls) { + _baseUrl = baseUrls; + } + /// Список глобальных BlocProvider'ов - static List get globalBlocProviders => [ + List get globalBlocProviders => [ BlocProvider(create: (context) => sl()), BlocProvider(create: (context) => sl()..getNotifications()), BlocProvider(create: (context) => sl()..loadFeedBlogPostList()), @@ -25,7 +43,7 @@ class AppConfig { ]; /// Делегаты локализации - static const List localizationDelegates = [ + List get localizationDelegates => [ S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, @@ -33,5 +51,5 @@ class AppConfig { ]; /// Поддерживаемые локали - static const List supportedLocales = [Locale.fromSubtags(languageCode: 'ru')]; + List get supportedLocales => [const Locale.fromSubtags(languageCode: 'ru')]; } diff --git a/lib/core/app_initializer.dart b/lib/core/app_initializer.dart index 45e89fcf..57ccbfb0 100644 --- a/lib/core/app_initializer.dart +++ b/lib/core/app_initializer.dart @@ -1,10 +1,12 @@ import 'dart:io' as io; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/env_config.dart'; import 'package:eatvio_app/core/locator_service.dart' as di; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/firebase_options.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -13,21 +15,12 @@ import 'package:sentry_flutter/sentry_flutter.dart'; /// Класс для инициализации приложения class AppInitializer { - /// Инициализация всех сервисов приложения - static Future initialize({AppBuildType buildType = AppBuildType.prod}) async { + static Future initialize({required AppBuildType buildType}) async { await _initializeEnvironment(); - switch (buildType) { - case AppBuildType.tests: - baseUrl = EnvConfig.devBaseUrl; - buildType = AppBuildType.tests; - break; - case AppBuildType.prod: - break; - } - await _initializeSentry(); + await _initializeDependencyInjection(buildType: buildType); + await _initializeSentry(); await _initializeFirebase(); - await _initializeDependencyInjection(); await _initializeDebugMode(); await _initializeAnalytics(); } @@ -46,12 +39,14 @@ class AppInitializer { /// Инициализация Firebase static Future _initializeFirebase() async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - await FirebaseMessaging.instance.requestPermission(); + if (sl().buildType == AppBuildType.prod) { + await FirebaseMessaging.instance.requestPermission(); + } } /// Инициализация системы внедрения зависимостей - static Future _initializeDependencyInjection() async { - await di.init(); + static Future _initializeDependencyInjection({required AppBuildType buildType}) async { + await di.init(buildType: buildType); } /// Настройка режима отладки @@ -77,4 +72,4 @@ class AppInitializer { } } -enum AppBuildType { prod, tests } +enum AppBuildType { prod, tests, dev } diff --git a/lib/core/const.dart b/lib/core/const.dart index a5f06149..5aab4fd4 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,6 +1,3 @@ -import 'package:eatvio_app/core/env_config.dart'; - -String baseUrl = EnvConfig.devBaseUrl; bool hidePlans = const bool.fromEnvironment('HIDE_PLANS', defaultValue: false); const buildDate = String.fromEnvironment('BUILD_DATE', defaultValue: ''); diff --git a/lib/core/di/app_config_registration.dart b/lib/core/di/app_config_registration.dart new file mode 100644 index 00000000..de003d20 --- /dev/null +++ b/lib/core/di/app_config_registration.dart @@ -0,0 +1,12 @@ +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/app_initializer.dart'; +import 'package:get_it/get_it.dart'; + +class AppConfigRegistration { + static final sl = GetIt.instance; + + /// Регистрация AppConfig + static void registerAppConfig({required AppBuildType buildType}) { + sl.registerLazySingleton(() => AppConfig(buildType: buildType)); + } +} diff --git a/lib/core/di/external_registrations.dart b/lib/core/di/external_registrations.dart index 38b3caa0..231eeef3 100644 --- a/lib/core/di/external_registrations.dart +++ b/lib/core/di/external_registrations.dart @@ -1,6 +1,6 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/core/dio/phone_verify_error_interceptor.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/interceptors/phone_verify_error_interceptor.dart'; import 'package:eatvio_app/core/interceptors/token_interceptor.dart'; import 'package:get_it/get_it.dart'; @@ -18,7 +18,7 @@ class ExternalRegistrations { sl.registerLazySingleton( () => Dio( BaseOptions( - baseUrl: baseUrl, + baseUrl: sl().baseUrl, headers: { 'accept': 'application/json', 'content-type': 'application/json', diff --git a/lib/core/firebase_api.dart b/lib/core/firebase_api.dart index 2d89bd43..7f4baad7 100644 --- a/lib/core/firebase_api.dart +++ b/lib/core/firebase_api.dart @@ -1,5 +1,7 @@ import 'dart:developer'; import 'dart:io'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/app_initializer.dart'; import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:flutter/services.dart'; @@ -19,7 +21,9 @@ class FirebaseApi { if (await _isHuaweiDevice()) { token = await _getHuaweiPushTokenNative(); } else { - await _firebaseMessaging.requestPermission(); + if ((sl().buildType == AppBuildType.prod)) { + await _firebaseMessaging.requestPermission(); + } token = await _firebaseMessaging.getToken(); } return token; diff --git a/lib/core/dio/phone_verify_error_interceptor.dart b/lib/core/interceptors/phone_verify_error_interceptor.dart similarity index 100% rename from lib/core/dio/phone_verify_error_interceptor.dart rename to lib/core/interceptors/phone_verify_error_interceptor.dart diff --git a/lib/core/locator_service.dart b/lib/core/locator_service.dart index 8299fea2..d3ed9b95 100644 --- a/lib/core/locator_service.dart +++ b/lib/core/locator_service.dart @@ -1,3 +1,5 @@ +import 'package:eatvio_app/core/app_initializer.dart'; +import 'package:eatvio_app/core/di/app_config_registration.dart'; import 'package:eatvio_app/core/di/cubit_registrations.dart'; import 'package:eatvio_app/core/di/external_registrations.dart'; import 'package:eatvio_app/core/di/repository_registrations.dart'; @@ -9,19 +11,22 @@ import 'package:get_it/get_it.dart'; final sl = GetIt.instance; /// Инициализация системы внедрения зависимостей -Future init() async { +Future init({required AppBuildType buildType}) async { + // Регистрация AppConfig + AppConfigRegistration.registerAppConfig(buildType: buildType); + // Регистрация внешних зависимостей (Dio, etc.) ExternalRegistrations.registerAll(); - + // Регистрация сервисов ServiceRegistrations.registerAll(); - + // Регистрация репозиториев RepositoryRegistrations.registerAll(); - + // Регистрация Cubit'ов CubitRegistrations.registerAll(); - + // Регистрация WebSocket менеджера sl.registerLazySingleton(() => WsManager(wsService: sl())); -} \ No newline at end of file +} diff --git a/lib/core/routing/other_routes.dart b/lib/core/routing/other_routes.dart index 43cf885f..7ae20a0f 100644 --- a/lib/core/routing/other_routes.dart +++ b/lib/core/routing/other_routes.dart @@ -1,5 +1,5 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/firebase_api.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/routing/route_constants.dart'; @@ -76,7 +76,7 @@ class OtherRoutes { builder: (context, state) => const UpdateScreen(), redirect: (context, state) async { try { - final versions = (await sl().get('$baseUrl/api/app_versions')).data; + final versions = (await sl().get('${sl().baseUrl}/api/app_versions')).data; PackageInfo packageInfo = await PackageInfo.fromPlatform(); String version = packageInfo.version; Version currentVersion = Version.parse(version); diff --git a/lib/core/websockets/ws_manager.dart b/lib/core/websockets/ws_manager.dart index 528f2ae9..24430f6c 100644 --- a/lib/core/websockets/ws_manager.dart +++ b/lib/core/websockets/ws_manager.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:dart_pusher_channels/dart_pusher_channels.dart'; import 'package:easy_debounce/easy_debounce.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/websockets/ws_service.dart'; @@ -111,7 +112,7 @@ class WsManager { _privateNotificationChannel = client?.privateChannel( '$newNotificationsChannelName.$userId', authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('$baseUrl/broadcasting/auth'), + authorizationEndpoint: Uri.parse('${sl().baseUrl}/broadcasting/auth'), headers: { 'Authorization': 'Bearer $token', }, @@ -124,7 +125,7 @@ class WsManager { _privateMessagesChannel = client?.privateChannel( '$newMessagesChannelName.$userId', authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('$baseUrl/broadcasting/auth'), + authorizationEndpoint: Uri.parse('${sl().baseUrl}/broadcasting/auth'), headers: { 'Authorization': 'Bearer $token', }, @@ -137,7 +138,7 @@ class WsManager { _privateDirectChatChannel = client?.privateChannel( '$directChatChannelName.$chatId', authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel( - authorizationEndpoint: Uri.parse('$baseUrl/broadcasting/auth'), + authorizationEndpoint: Uri.parse('${sl().baseUrl}/broadcasting/auth'), headers: { 'Authorization': 'Bearer $token', }, diff --git a/lib/core/widgets/custom_popup.dart b/lib/core/widgets/custom_popup.dart index b5934f4d..dbe0090b 100644 --- a/lib/core/widgets/custom_popup.dart +++ b/lib/core/widgets/custom_popup.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; @@ -86,7 +86,7 @@ class CustomPopup extends StatelessWidget { if (isAuthor) { addItem('assets/icons/copy2.svg', 'Скопировать ссылку', () { - Clipboard.setData(ClipboardData(text: '$baseUrl/ru/$path')); + Clipboard.setData(ClipboardData(text: '${sl().baseUrl}/ru/$path')); showInfoToast(s.link_was_copied); }); addItem('assets/icons/share2.svg', 'Поделиться', () { @@ -94,7 +94,7 @@ class CustomPopup extends StatelessWidget { SharePlus.instance.share( ShareParams( uri: Uri.parse( - '$baseUrl/ru/$path', + '${sl().baseUrl}/ru/$path', ), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), @@ -140,7 +140,7 @@ class CustomPopup extends StatelessWidget { }); } else { addItem('assets/icons/copy2.svg', 'Скопировать ссылку', () { - Clipboard.setData(ClipboardData(text: '$baseUrl/ru/$path')); + Clipboard.setData(ClipboardData(text: '${sl().baseUrl}/ru/$path')); showInfoToast(s.link_was_copied); }); addItem('assets/icons/share2.svg', 'Поделиться', () { @@ -148,7 +148,7 @@ class CustomPopup extends StatelessWidget { SharePlus.instance.share( ShareParams( uri: Uri.parse( - '$baseUrl/ru/$path', + '${sl().baseUrl}/ru/$path', ), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), diff --git a/lib/features/auth/presentation/pages/auth_screen.dart b/lib/features/auth/presentation/pages/auth_screen.dart index ce6fee32..102f31cb 100644 --- a/lib/features/auth/presentation/pages/auth_screen.dart +++ b/lib/features/auth/presentation/pages/auth_screen.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:developer'; import 'package:eatvio_app/app_keys.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/firebase_api.dart'; @@ -229,7 +230,7 @@ class _AuthScreenState extends State { decorationColor: appTheme.blueA400, decoration: TextDecoration.underline, ), - recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')), + recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl().baseUrl}/oferta_bs.pdf')), ), const TextSpan(text: ' и '), ], @@ -241,7 +242,7 @@ class _AuthScreenState extends State { decorationColor: appTheme.blueA400, decoration: TextDecoration.underline, ), - recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/docs/privacy.pdf')), + recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl().baseUrl}/docs/privacy.pdf')), ), ], ), @@ -308,7 +309,7 @@ class _AuthScreenState extends State { children: [ const Text('Где взять QR-код?\n', style: TextStyle(fontSize: 18)), Text( - '1. Войдите на сайте $baseUrl в свой аккаунт\n\n2. Перейдите в настройки профиля\n\n3. В разделе "Доп информация" перейдите на "QR Login"', + '1. Войдите на сайте ${sl().baseUrl} в свой аккаунт\n\n2. Перейдите в настройки профиля\n\n3. В разделе "Доп информация" перейдите на "QR Login"', ), const SizedBox(height: 12), Row( diff --git a/lib/features/auth/presentation/pages/scan_qr_code_screen.dart b/lib/features/auth/presentation/pages/scan_qr_code_screen.dart index 83296f0e..723f95e9 100644 --- a/lib/features/auth/presentation/pages/scan_qr_code_screen.dart +++ b/lib/features/auth/presentation/pages/scan_qr_code_screen.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/firebase_api.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/token_storage.dart'; @@ -40,17 +40,11 @@ class _ScanQRCodeScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text('Сканирование QR-кода'), - centerTitle: true, - ), + appBar: AppBar(title: const Text('Сканирование QR-кода'), centerTitle: true), body: Column( children: [ Expanded( - child: QRView( - key: qrKey, - onQRViewCreated: _onQRViewCreated, - ), + child: QRView(key: qrKey, onQRViewCreated: _onQRViewCreated), ), ], ), @@ -68,17 +62,9 @@ class _ScanQRCodeScreenState extends State { final scannedUrl = scanData.code; final uri = Uri.parse(scannedUrl ?? ''); final scannedBaseUrl = (uri.hasAuthority) ? '${uri.scheme}://${uri.host}' : ''; - baseUrl = scannedBaseUrl; - sl().options.baseUrl = baseUrl; - final response = await Dio().getUri( - uri, - options: Options( - headers: { - 'accept': 'application/json', - 'content-type': 'application/json', - }, - ), - ); + sl().setBaseUrl(scannedBaseUrl); + sl().options.baseUrl = scannedBaseUrl; + final response = await Dio().getUri(uri, options: Options(headers: {'accept': 'application/json', 'content-type': 'application/json'})); final token = response.data['token']; await TokenStorage.saveTokenInStorage(token); try { @@ -97,10 +83,7 @@ class _ScanQRCodeScreenState extends State { } catch (e) { rethrow; } - AppRouter.navigatorKey.currentContext?.go( - '/feed-screen', - extra: {'needToInitializeWebSocket': false}, - ); + AppRouter.navigatorKey.currentContext?.go('/feed-screen', extra: {'needToInitializeWebSocket': false}); showSuccessToast('Добро пожаловать!'); } catch (e) { await controller.resumeCamera(); 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 61b64f9e..76562bcd 100644 --- a/lib/features/blog_post/presentation/pages/blog_post_screen.dart +++ b/lib/features/blog_post/presentation/pages/blog_post_screen.dart @@ -1,6 +1,6 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/core/widgets/custom_popup.dart'; @@ -207,7 +207,7 @@ class _BlogPostScreenState extends State { children: [ CircleAvatar( radius: 16, - foregroundImage: NetworkImage(baseUrl + (blogPostState.blogPostModel?.author.authorProfileIcon ?? '')), + foregroundImage: NetworkImage(sl().baseUrl + (blogPostState.blogPostModel?.author.authorProfileIcon ?? '')), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), const SizedBox(width: 8), @@ -239,7 +239,7 @@ class _BlogPostScreenState extends State { ), const SizedBox(height: 8), if (blogPostState.blogPostModel?.image.isNotEmpty ?? false) - CachedNetworkImage(imageUrl: '$baseUrl/storage/${blogPostState.blogPostModel?.image ?? ''}'), + CachedNetworkImage(imageUrl: '${sl().baseUrl}/storage/${blogPostState.blogPostModel?.image ?? ''}'), Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Row( @@ -267,7 +267,7 @@ class _BlogPostScreenState extends State { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/blog_post/${widget.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/blog_post/${widget.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart index 6be43b3a..40ad3dfa 100644 --- a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart +++ b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/permission_handler/permission_handler.dart'; import 'package:eatvio_app/core/theme/app_decoration.dart'; import 'package:eatvio_app/core/widgets/show_error_dialog.dart'; @@ -304,7 +304,7 @@ class _BlogPostCreateScreenState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(16), child: Image( - image: NetworkImage('$baseUrl/storage/${widget.feedBlogPostModel!.image}'), + image: NetworkImage('${sl().baseUrl}/storage/${widget.feedBlogPostModel!.image}'), ), ), ), diff --git a/lib/features/blog_post_create/repositories/blog_post_repository.dart b/lib/features/blog_post_create/repositories/blog_post_repository.dart index aeea8474..48f4f0c1 100644 --- a/lib/features/blog_post_create/repositories/blog_post_repository.dart +++ b/lib/features/blog_post_create/repositories/blog_post_repository.dart @@ -1,7 +1,8 @@ import 'dart:developer'; import 'dart:io'; import 'package:dio/dio.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:http/http.dart' as http; import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart'; import 'package:eatvio_app/features/blog_post_create/services/blog_post_service.dart'; @@ -36,7 +37,7 @@ class BlogPostRepository { Future downloadImage(String imageUrl) async { try { // Загрузка изображения - final response = await http.get(Uri.parse('$baseUrl/storage/$imageUrl')); + final response = await http.get(Uri.parse('${sl().baseUrl}/storage/$imageUrl')); if (response.statusCode == 200) { // Получение временной директории diff --git a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart index a67fbbaf..b1e846ca 100644 --- a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart +++ b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart @@ -1,5 +1,6 @@ import 'package:badges/badges.dart' as badges; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/image_constant.dart'; import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart'; import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart'; @@ -102,7 +103,7 @@ class _BottomNavigationBarWidgetState extends State { label: '', icon: CircleAvatar( foregroundImage: NetworkImage( - widget.profileModel.profilePhotoUrl.contains('https') ? widget.profileModel.profilePhotoUrl : baseUrl + widget.profileModel.profilePhotoUrl, + widget.profileModel.profilePhotoUrl.contains('https') ? widget.profileModel.profilePhotoUrl : sl().baseUrl + widget.profileModel.profilePhotoUrl, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: 16, diff --git a/lib/features/chat/presentation/pages/photo_view_screen.dart b/lib/features/chat/presentation/pages/photo_view_screen.dart index 1c17d40e..3cbdc744 100644 --- a/lib/features/chat/presentation/pages/photo_view_screen.dart +++ b/lib/features/chat/presentation/pages/photo_view_screen.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -88,7 +89,7 @@ class _PhotoViewScreenState extends State { color: Colors.white, ), title: Text( - widget.imageUrls[index].replaceAll('$baseUrl/storage/chat_files/', ''), + widget.imageUrls[index].replaceAll('${sl().baseUrl}/storage/chat_files/', ''), style: const TextStyle( color: Colors.white, fontSize: 12, diff --git a/lib/features/chat/presentation/widgets/order_card.dart b/lib/features/chat/presentation/widgets/order_card.dart index 31d99aad..2b7b50b2 100644 --- a/lib/features/chat/presentation/widgets/order_card.dart +++ b/lib/features/chat/presentation/widgets/order_card.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; @@ -47,7 +48,7 @@ class _OrderCardState extends State { ClipRRect( borderRadius: BorderRadius.circular(12), child: Image.network( - '$baseUrl/storage/${widget.plan.image}', + '${sl().baseUrl}/storage/${widget.plan.image}', width: double.infinity, fit: BoxFit.cover, ), diff --git a/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart index d44920cb..734387f1 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart @@ -1,4 +1,6 @@ +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:flutter/material.dart'; @@ -49,7 +51,7 @@ class _LastStepScreenState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 4), child: TextButton( - onPressed: () async => await launchUrl(Uri.parse(hidePlans ? '$baseUrl/docs/privacy.pdf' : '$baseUrl/oferta_bs.pdf')), + onPressed: () async => await launchUrl(Uri.parse(hidePlans ? '${sl().baseUrl}/docs/privacy.pdf' : '${sl().baseUrl}/oferta_bs.pdf')), child: Text( hidePlans ? 'Политика конфиденциальности и пользовательское соглашение' : 'Договор офёрты', style: const TextStyle(height: 1, fontSize: 16, color: Color(0xFF323F4B), decoration: TextDecoration.underline), diff --git a/lib/features/create_diet/presentation/cubit/create_diet_cubit.dart b/lib/features/create_diet/presentation/cubit/create_diet_cubit.dart index 6eb41358..757101ae 100644 --- a/lib/features/create_diet/presentation/cubit/create_diet_cubit.dart +++ b/lib/features/create_diet/presentation/cubit/create_diet_cubit.dart @@ -2,8 +2,10 @@ import 'dart:convert'; import 'dart:io'; import 'dart:developer'; import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/create_diet/presentation/cubit/create_diet_state.dart'; import 'package:eatvio_app/features/create_diet/repositories/create_diet_repository.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; @@ -53,7 +55,7 @@ class CreateDietCubit extends Cubit { name: diet.name, duration: diet.duration, type: type, - imageUrl: '$baseUrl/storage/${diet.image}', + imageUrl: '${sl().baseUrl}/storage/${diet.image}', ), ); emit(state.copyWith(dietState: diet.state, durationIndex: durationValues.indexOf(diet.duration))); diff --git a/lib/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart b/lib/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart index 4ca081d4..4541782b 100644 --- a/lib/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart +++ b/lib/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart @@ -1,7 +1,8 @@ import 'dart:developer'; import 'dart:io'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/create_recipe/entities/recipe_create_entity.dart'; import 'package:eatvio_app/features/create_recipe/models/ingredient.dart' as i; import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_state.dart'; @@ -187,13 +188,13 @@ class CreateRecipeCubit extends Cubit { } Future recipeToEntity(Recipe recipe) async { - final file = await downloadImageAsFile('$baseUrl/storage/${recipe.image}'); + final file = await downloadImageAsFile('${sl().baseUrl}/storage/${recipe.image}'); final List steps = await Future.wait( recipe.steps!.map( (e) async => StepEntity( description: e.description, - image: e.image.isEmpty ? null : await downloadImageAsFile('$baseUrl/storage/${e.image}'), + image: e.image.isEmpty ? null : await downloadImageAsFile('${sl().baseUrl}/storage/${e.image}'), ), ), ); diff --git a/lib/features/dev_tools/presentation/dev_tools_screen.dart b/lib/features/dev_tools/presentation/dev_tools_screen.dart index 4922a87d..0be58bee 100644 --- a/lib/features/dev_tools/presentation/dev_tools_screen.dart +++ b/lib/features/dev_tools/presentation/dev_tools_screen.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/firebase_api.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/toasts.dart'; @@ -84,7 +84,7 @@ class _DevToolsScreenContentState extends State { void initState() { super.initState(); setState(() { - baseUrlForTest = baseUrl; + baseUrlForTest = sl().baseUrl; }); testsStates = List.generate(testCases.length, (index) => TestState.notRun); } @@ -111,8 +111,8 @@ class _DevToolsScreenContentState extends State { onPressed: () { setState(() { baseUrlForTest = controller.text; - baseUrl = baseUrlForTest.toLowerCase(); - sl().options.baseUrl = baseUrl; + sl().setBaseUrl(baseUrlForTest.toLowerCase()); + sl().options.baseUrl = baseUrlForTest.toLowerCase(); controller.clear(); }); }, @@ -122,23 +122,23 @@ class _DevToolsScreenContentState extends State { ), const SizedBox(height: 10), CustomOutlinedButton( - text: baseUrl == EnvConfig.devBaseUrl ? 'Set production base url' : 'Set dev2 base url', + text: sl().baseUrl == EnvConfig.devBaseUrl ? 'Set production base url' : 'Set dev2 base url', onPressed: () { setState(() { - if (baseUrl == EnvConfig.baseUrl) { + if (sl().baseUrl == EnvConfig.baseUrl) { baseUrlForTest = EnvConfig.devBaseUrl; } else { baseUrlForTest = EnvConfig.baseUrl; } - baseUrl = baseUrlForTest.toLowerCase(); - sl().options.baseUrl = baseUrl; + sl().setBaseUrl(baseUrlForTest.toLowerCase()); + sl().options.baseUrl = baseUrlForTest.toLowerCase(); controller.clear(); }); }, buttonStyle: const ButtonStyle(), ), - SizedBox(height: baseUrlForTest != baseUrl ? 40 : 10), - if (baseUrl.toLowerCase() != EnvConfig.baseUrl.toLowerCase()) + SizedBox(height: baseUrlForTest != sl().baseUrl ? 40 : 10), + if (sl().baseUrl.toLowerCase() != EnvConfig.baseUrl.toLowerCase()) ListView.builder( shrinkWrap: true, itemCount: testCases.length, diff --git a/lib/features/diary/presentation/widgets/photo_gallery_widget.dart b/lib/features/diary/presentation/widgets/photo_gallery_widget.dart index 352b6519..87643817 100644 --- a/lib/features/diary/presentation/widgets/photo_gallery_widget.dart +++ b/lib/features/diary/presentation/widgets/photo_gallery_widget.dart @@ -1,8 +1,9 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/permission_handler/permission_handler.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; @@ -139,7 +140,7 @@ class _PhotoGalleryWidgetState extends State { ClipRRect( borderRadius: BorderRadius.circular(12), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${state.diary.meals[mealIndex].photos[currentSelectedPhotoIndex].path}', + imageUrl: '${sl().baseUrl}/storage/${state.diary.meals[mealIndex].photos[currentSelectedPhotoIndex].path}', ), ), if (!state.isConsultantView && !state.isDiaryFinished && !state.isDiaryCommented) @@ -211,7 +212,7 @@ class _PhotoGalleryWidgetState extends State { height: 52, width: 52, child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${state.diary.meals[mealIndex].photos[i].path}', + imageUrl: '${sl().baseUrl}/storage/${state.diary.meals[mealIndex].photos[i].path}', fit: BoxFit.fitWidth, ), ), diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index e4dd4a75..e06989f1 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; @@ -353,7 +353,7 @@ class _AboutDietScreenState extends State { Stack( children: [ CachedNetworkImage( - imageUrl: '$baseUrl/storage/${dietState.diet.image}', + imageUrl: '${sl().baseUrl}/storage/${dietState.diet.image}', height: 300, width: MediaQuery.sizeOf(context).width, fit: BoxFit.fill, diff --git a/lib/features/diets/presentation/widgets/author_card.dart b/lib/features/diets/presentation/widgets/author_card.dart index 6fff0b93..548b9263 100644 --- a/lib/features/diets/presentation/widgets/author_card.dart +++ b/lib/features/diets/presentation/widgets/author_card.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; @@ -37,7 +38,7 @@ class AuthorCard extends StatelessWidget { decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( - image: NetworkImage(baseUrl + author.authorProfileIcon), + image: NetworkImage(sl().baseUrl + author.authorProfileIcon), fit: BoxFit.cover, ), ), diff --git a/lib/features/diets/presentation/widgets/more_options.dart b/lib/features/diets/presentation/widgets/more_options.dart index 4c28e5c9..480b9915 100644 --- a/lib/features/diets/presentation/widgets/more_options.dart +++ b/lib/features/diets/presentation/widgets/more_options.dart @@ -1,5 +1,6 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:eatvio_app/features/complaining/presentation/complaining_bottom_sheet.dart'; import 'package:eatvio_app/core/widgets/custom_divider.dart'; @@ -35,7 +36,7 @@ class MoreOptions extends StatelessWidget { onTap: disableActions == true ? null : () { - Clipboard.setData(ClipboardData(text: '$baseUrl/ru/$path')); + Clipboard.setData(ClipboardData(text: '${sl().baseUrl}/ru/$path')); showInfoToast(s.link_was_copied); }, child: Row( @@ -62,7 +63,7 @@ class MoreOptions extends StatelessWidget { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/$path',), + uri: Uri.parse('${sl().baseUrl}/ru/$path',), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index e001a038..261e421a 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -1,7 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/core/widgets/custom_popup.dart'; @@ -64,7 +65,7 @@ class _BlogPostWidgetState extends State { authorName: state.feedBlogPostList[widget.index].author.authorName, authorProfileIcon: state.feedBlogPostList[widget.index].author.authorProfileIcon.contains('https') ? state.feedBlogPostList[widget.index].author.authorProfileIcon - : baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, + : sl().baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, authorIsMe: state.feedBlogPostList[widget.index].author.authorIsMe, ), ); @@ -75,7 +76,7 @@ class _BlogPostWidgetState extends State { foregroundImage: NetworkImage( state.feedBlogPostList[widget.index].author.authorProfileIcon.contains('https') ? state.feedBlogPostList[widget.index].author.authorProfileIcon - : baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, + : sl().baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), @@ -157,15 +158,15 @@ class _BlogPostWidgetState extends State { onTap: () { context.pushTransparentRoute( rootNavigator: true, - PhotoViewScreen(imageUrls: ['$baseUrl/storage/${state.feedBlogPostList[widget.index].image}'], index: 0), + PhotoViewScreen(imageUrls: ['${sl().baseUrl}/storage/${state.feedBlogPostList[widget.index].image}'], index: 0), ); }, child: Hero( - tag: '$baseUrl/storage/${state.feedBlogPostList[widget.index].image}', + tag: '${sl().baseUrl}/storage/${state.feedBlogPostList[widget.index].image}', child: CachedNetworkImage( fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, - imageUrl: '$baseUrl/storage/${state.feedBlogPostList[widget.index].image}', + imageUrl: '${sl().baseUrl}/storage/${state.feedBlogPostList[widget.index].image}', errorWidget: (context, str, object) => const SizedBox.shrink(), ), ), @@ -219,7 +220,7 @@ class _BlogPostWidgetState extends State { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/blog_post/${state.feedBlogPostList[widget.index].id}'), + uri: Uri.parse('${sl().baseUrl}/ru/blog_post/${state.feedBlogPostList[widget.index].id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/feed/presentation/widgets/comments_widget.dart b/lib/features/feed/presentation/widgets/comments_widget.dart index 3617fe33..b313ecaa 100644 --- a/lib/features/feed/presentation/widgets/comments_widget.dart +++ b/lib/features/feed/presentation/widgets/comments_widget.dart @@ -1,5 +1,5 @@ +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/comments/presentation/comments_actions_bottom_sheet.dart'; -import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; @@ -99,13 +99,13 @@ class _CommentsWidgetState extends State { extra: Author( authorSlug: comment.authorSlug, authorName: comment.authorName, - authorProfileIcon: comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : baseUrl + comment.authorProfileIcon, + authorProfileIcon: comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : sl().baseUrl + comment.authorProfileIcon, authorIsMe: isMe, ), ); }, child: CircleAvatar( - foregroundImage: NetworkImage(comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : baseUrl + comment.authorProfileIcon), + foregroundImage: NetworkImage(comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : sl().baseUrl + comment.authorProfileIcon), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: radius, ), diff --git a/lib/features/feed/presentation/widgets/consultant_widget.dart b/lib/features/feed/presentation/widgets/consultant_widget.dart index 3b4a4b80..57d34b07 100644 --- a/lib/features/feed/presentation/widgets/consultant_widget.dart +++ b/lib/features/feed/presentation/widgets/consultant_widget.dart @@ -1,5 +1,5 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; @@ -14,10 +14,7 @@ import 'package:go_router/go_router.dart'; class ConsultantWidget extends StatelessWidget { final FeedConsultantModel consultant; - const ConsultantWidget({ - super.key, - required this.consultant, - }); + const ConsultantWidget({super.key, required this.consultant}); @override Widget build(BuildContext context) { @@ -36,10 +33,7 @@ class ConsultantWidget extends StatelessWidget { borderRadius: BorderRadius.circular(20), child: Ink( padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: const Color(0xFFF6F6F6), - ), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: const Color(0xFFF6F6F6)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -51,46 +45,32 @@ class ConsultantWidget extends StatelessWidget { children: [ Ink( padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), child: Text( '${consultant.ratingPlace}', - style: TextStyle( - fontSize: 20, - color: appTheme.blueA400, - fontWeight: FontWeight.w600, - ), + style: TextStyle(fontSize: 20, color: appTheme.blueA400, fontWeight: FontWeight.w600), ), ), const SizedBox(width: 8), - CircleAvatar( - foregroundImage: NetworkImage(baseUrl + consultant.photo), - backgroundImage: const AssetImage('assets/images/no_avatar.png'), - ), + if (consultant.photo.contains('https')) + CircleAvatar(foregroundImage: NetworkImage(consultant.photo), backgroundImage: const AssetImage('assets/images/no_avatar.png')) + else + CircleAvatar( + foregroundImage: NetworkImage(sl().baseUrl + consultant.photo), + backgroundImage: const AssetImage('assets/images/no_avatar.png'), + ), const SizedBox(width: 8), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( consultant.name, - style: const TextStyle( - height: 1, - fontWeight: FontWeight.w500, - fontSize: 15, - color: Color(0xFF323F4B), - ), + style: const TextStyle(height: 1, fontWeight: FontWeight.w500, fontSize: 15, color: Color(0xFF323F4B)), ), const SizedBox(height: 4), Text( 'Рейтинг: ${consultant.totalScores}', - style: TextStyle( - color: appTheme.blueA400, - height: 1, - fontWeight: FontWeight.w500, - fontSize: 12, - ), + style: TextStyle(color: appTheme.blueA400, height: 1, fontWeight: FontWeight.w500, fontSize: 12), ), ], ), @@ -98,21 +78,13 @@ class ConsultantWidget extends StatelessWidget { ), Ink( padding: const EdgeInsets.all(6), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.white, - ), - child: SvgPicture.asset( - 'assets/icons/go_to_arrow.svg', - ), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), color: Colors.white), + child: SvgPicture.asset('assets/icons/go_to_arrow.svg'), ), ], ), const SizedBox(height: 8), - Text( - consultant.description, - maxLines: 2, - ), + Text(consultant.description, maxLines: 2), if (consultant.badges.isNotEmpty) const SizedBox(height: 8), _badges(consultant.badges, context), ], @@ -128,16 +100,8 @@ class ConsultantWidget extends StatelessWidget { 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}', - width: 28, - height: 28, - ), + ? SvgPicture.network('${sl().baseUrl}/storage/${badges[i].image}', width: 28, height: 28) + : CachedNetworkImage(imageUrl: '${sl().baseUrl}/storage/${badges[i].image}', width: 28, height: 28), 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 d91cdd74..1f39ff72 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -1,7 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; @@ -56,7 +57,7 @@ class _DietsWidgetState extends State { ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${widget.diet.image}', + imageUrl: '${sl().baseUrl}/storage/${widget.diet.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, ), @@ -189,7 +190,7 @@ class _DietsWidgetState extends State { final box = context.findRenderObject() as RenderBox?; final result = await SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/diet/${widget.diet.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/diet/${widget.diet.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/feed/presentation/widgets/plan_widget.dart b/lib/features/feed/presentation/widgets/plan_widget.dart index 588d61d0..ae43d830 100644 --- a/lib/features/feed/presentation/widgets/plan_widget.dart +++ b/lib/features/feed/presentation/widgets/plan_widget.dart @@ -1,7 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; @@ -61,7 +62,7 @@ class _PlanWidgetState extends State { ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${widget.plan.image}', + imageUrl: '${sl().baseUrl}/storage/${widget.plan.image}', fit: BoxFit.cover, width: MediaQuery.of(context).size.width, height: 426, @@ -187,7 +188,7 @@ class _PlanWidgetState extends State { decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( - image: NetworkImage(baseUrl + widget.plan.author.authorProfileIcon), + image: NetworkImage(sl().baseUrl + widget.plan.author.authorProfileIcon), fit: BoxFit.cover, ), ), @@ -263,7 +264,7 @@ class _PlanWidgetState extends State { final box = context.findRenderObject() as RenderBox?; final result = await SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/diet/${widget.plan.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/diet/${widget.plan.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index c0dbeb39..5fb415b1 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -1,8 +1,9 @@ // ignore_for_file: dead_code import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; @@ -75,7 +76,7 @@ class _RecipesWidgetState extends State { ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${widget.recipe.image}', + imageUrl: '${sl().baseUrl}/storage/${widget.recipe.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, ), @@ -231,7 +232,7 @@ class _RecipesWidgetState extends State { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/recipe/${widget.recipe.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/recipe/${widget.recipe.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/glossary/presentation/pages/glossary_screen.dart b/lib/features/glossary/presentation/pages/glossary_screen.dart index 7205b3d3..22050f00 100644 --- a/lib/features/glossary/presentation/pages/glossary_screen.dart +++ b/lib/features/glossary/presentation/pages/glossary_screen.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -18,7 +19,7 @@ class _GlossaryScreenState extends State { _controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) - ..loadRequest(Uri.parse('$baseUrl/product_nutritional_value')); + ..loadRequest(Uri.parse('${sl().baseUrl}/product_nutritional_value')); } @override diff --git a/lib/features/menu/presentation/pages/menu_screen.dart b/lib/features/menu/presentation/pages/menu_screen.dart index 123e5faf..7d237245 100644 --- a/lib/features/menu/presentation/pages/menu_screen.dart +++ b/lib/features/menu/presentation/pages/menu_screen.dart @@ -1,4 +1,5 @@ import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/token_storage.dart'; @@ -117,7 +118,7 @@ class MenuScreen extends StatelessWidget { CupertinoDialogAction( onPressed: () async { try { - await sl().post('$baseUrl/api/profile/logout'); + await sl().post('${sl().baseUrl}/api/profile/logout'); } finally { await TokenStorage.removeTokenInStorage(); if (context.mounted) { diff --git a/lib/features/menu/presentation/widgets/blocked_user_widget.dart b/lib/features/menu/presentation/widgets/blocked_user_widget.dart index 494df21c..a107a4df 100644 --- a/lib/features/menu/presentation/widgets/blocked_user_widget.dart +++ b/lib/features/menu/presentation/widgets/blocked_user_widget.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; @@ -33,7 +34,7 @@ class _BlockedUserWidgetState extends State { child: Row( children: [ CircleAvatar( - foregroundImage: NetworkImage(baseUrl + widget.profile.profilePhotoUrl), + foregroundImage: NetworkImage(sl().baseUrl + widget.profile.profilePhotoUrl), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: 28, ), 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 965bd088..d6f41d7f 100644 --- a/lib/features/my_diets/presentation/widgets/my_diet_widget.dart +++ b/lib/features/my_diets/presentation/widgets/my_diet_widget.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; @@ -56,7 +57,7 @@ class _MyDietWidgetState extends State { child: ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${widget.diet.image}', + imageUrl: '${sl().baseUrl}/storage/${widget.diet.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, ), @@ -153,7 +154,7 @@ class _MyDietWidgetState extends State { final box = context.findRenderObject() as RenderBox?; await SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/diet/${widget.diet.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/diet/${widget.diet.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); 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 7ecdc653..5d057be5 100644 --- a/lib/features/my_plans/presentation/widgets/my_plan_widget.dart +++ b/lib/features/my_plans/presentation/widgets/my_plan_widget.dart @@ -1,5 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; @@ -42,7 +43,7 @@ class _MyPlanWidgetState extends State { onTap: () => GoRouter.of(context).pushNamed('aboutPlanScreen', extra: {'slug': widget.plan.slug, 'navigateToComments': false}), child: ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), - child: CachedNetworkImage(imageUrl: '$baseUrl/storage/${widget.plan.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width), + child: CachedNetworkImage(imageUrl: '${sl().baseUrl}/storage/${widget.plan.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width), ), ), Positioned( @@ -157,7 +158,7 @@ class _MyPlanWidgetState extends State { final box = context.findRenderObject() as RenderBox?; await SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/plan/${widget.plan.id}'), + uri: Uri.parse('${sl().baseUrl}/ru/plan/${widget.plan.id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/order_info/presentation/widgets/plan_info.dart b/lib/features/order_info/presentation/widgets/plan_info.dart index 6c5e387d..d8f91880 100644 --- a/lib/features/order_info/presentation/widgets/plan_info.dart +++ b/lib/features/order_info/presentation/widgets/plan_info.dart @@ -1,5 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/widgets/main_background_bouble.dart'; @@ -31,7 +32,7 @@ class PlanInfo extends StatelessWidget { ClipRRect( borderRadius: BorderRadius.circular(8), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/$imagePath', + imageUrl: '${sl().baseUrl}/storage/$imagePath', height: 220, width: MediaQuery.sizeOf(context).width, fit: BoxFit.fill, diff --git a/lib/features/plans/presentation/pages/about_plan_screen.dart b/lib/features/plans/presentation/pages/about_plan_screen.dart index b5905664..64a437c1 100644 --- a/lib/features/plans/presentation/pages/about_plan_screen.dart +++ b/lib/features/plans/presentation/pages/about_plan_screen.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; @@ -401,7 +401,7 @@ class _AboutPlanScreenState extends State { Stack( children: [ CachedNetworkImage( - imageUrl: '$baseUrl/storage/${state.planModel?.image}', + imageUrl: '${sl().baseUrl}/storage/${state.planModel?.image}', height: 300, width: MediaQuery.sizeOf(context).width, fit: BoxFit.fill, diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 11ae9b7a..5c25dfe5 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_router.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; @@ -655,7 +656,7 @@ class _ProfileScreenState extends State { borderRadius: BorderRadius.circular(4), boxShadow: [BoxShadow(color: Colors.black.withAlpha((255 * 0.2).toInt()), blurRadius: 32)], ), - child: SvgPicture.network('$baseUrl/storage/${state.profile.badges[i].image}', width: 40, height: 40), + child: SvgPicture.network('${sl().baseUrl}/storage/${state.profile.badges[i].image}', width: 40, height: 40), ) : Tooltip( message: state.profile.badges[i].description, @@ -667,7 +668,7 @@ class _ProfileScreenState extends State { borderRadius: BorderRadius.circular(4), boxShadow: [BoxShadow(color: Colors.black.withAlpha((255 * 0.2).toInt()), blurRadius: 32)], ), - child: CachedNetworkImage(imageUrl: '$baseUrl/storage/${state.profile.badges[i].image}', width: 40, height: 40), + child: CachedNetworkImage(imageUrl: '${sl().baseUrl}/storage/${state.profile.badges[i].image}', width: 40, height: 40), ), i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(), ], @@ -803,7 +804,7 @@ class _ProfileScreenState extends State { icon: 'assets/icons/eye.svg', text: 'Посмотреть', onTap: () async { - context.pushTransparentRoute(rootNavigator: true, PhotoViewScreen(imageUrls: [baseUrl + state.profile.profilePhotoUrl], index: 0)); + context.pushTransparentRoute(rootNavigator: true, PhotoViewScreen(imageUrls: [sl().baseUrl + state.profile.profilePhotoUrl], index: 0)); }, ), if (widget.author == null || widget.author!.authorIsMe) ...[ @@ -885,7 +886,7 @@ class _ProfileScreenState extends State { child: CircleAvatar( radius: 32, foregroundImage: NetworkImage( - state.profile.profilePhotoUrl.contains('https') ? state.profile.profilePhotoUrl : baseUrl + state.profile.profilePhotoUrl, + state.profile.profilePhotoUrl.contains('https') ? state.profile.profilePhotoUrl : sl().baseUrl + state.profile.profilePhotoUrl, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), @@ -960,7 +961,7 @@ class _ProfileScreenState extends State { onTap: () { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( - ShareParams(uri: Uri.parse('$baseUrl/ru/profile/${state.profile.slug}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size), + ShareParams(uri: Uri.parse('${sl().baseUrl}/ru/profile/${state.profile.slug}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size), ); }, ), 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 0f0408d8..7c55c420 100644 --- a/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart +++ b/lib/features/profile/presentation/widgets/profile_blog_post_widget.dart @@ -1,7 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/feed_icon_button.dart'; @@ -69,7 +70,7 @@ class _ProfileBlogPostWidgetState extends State { foregroundImage: NetworkImage( state.blogPosts[widget.index].author.authorProfileIcon.contains('https') ? state.blogPosts[widget.index].author.authorProfileIcon - : baseUrl + state.blogPosts[widget.index].author.authorProfileIcon, + : sl().baseUrl + state.blogPosts[widget.index].author.authorProfileIcon, ), backgroundImage: const AssetImage('assets/images/no_avatar.png'), ), @@ -157,17 +158,17 @@ class _ProfileBlogPostWidgetState extends State { context.pushTransparentRoute( rootNavigator: true, PhotoViewScreen( - imageUrls: ['$baseUrl/storage/${state.blogPosts[widget.index].image}'], + imageUrls: ['${sl().baseUrl}/storage/${state.blogPosts[widget.index].image}'], index: 0, ), ); }, child: Hero( - tag: '$baseUrl/storage/${state.blogPosts[widget.index].image}', + tag: '${sl().baseUrl}/storage/${state.blogPosts[widget.index].image}', child: CachedNetworkImage( fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, - imageUrl: '$baseUrl/storage/${state.blogPosts[widget.index].image}', + imageUrl: '${sl().baseUrl}/storage/${state.blogPosts[widget.index].image}', errorWidget: (context, str, object) => const SizedBox.shrink(), ), ), @@ -226,7 +227,7 @@ class _ProfileBlogPostWidgetState extends State { final box = context.findRenderObject() as RenderBox?; SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/blog_post/${state.blogPosts[widget.index].id}'), + uri: Uri.parse('${sl().baseUrl}/ru/blog_post/${state.blogPosts[widget.index].id}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/profile/presentation/widgets/sub_widget.dart b/lib/features/profile/presentation/widgets/sub_widget.dart index 27365fd2..d5d3a61a 100644 --- a/lib/features/profile/presentation/widgets/sub_widget.dart +++ b/lib/features/profile/presentation/widgets/sub_widget.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/profile/models/sub_model.dart'; import 'package:eatvio_app/features/profile/presentation/widgets/sub_action_button_widget.dart'; @@ -36,7 +37,7 @@ class _SubWidgetState extends State { child: Row( children: [ CircleAvatar( - foregroundImage: NetworkImage(baseUrl + widget.subModel.profilePhotoUrl), + foregroundImage: NetworkImage(sl().baseUrl + widget.subModel.profilePhotoUrl), backgroundImage: const AssetImage('assets/images/no_avatar.png'), radius: 28, ), diff --git a/lib/features/recipe/presentation/pages/about_recipe_screen.dart b/lib/features/recipe/presentation/pages/about_recipe_screen.dart index f23ac880..efc19a12 100644 --- a/lib/features/recipe/presentation/pages/about_recipe_screen.dart +++ b/lib/features/recipe/presentation/pages/about_recipe_screen.dart @@ -2,7 +2,7 @@ import 'dart:developer'; import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; @@ -247,7 +247,7 @@ class _AboutRecipeScreenState extends State { Stack( children: [ CachedNetworkImage( - imageUrl: '$baseUrl/storage/${recipeState.recipe.image}', + imageUrl: '${sl().baseUrl}/storage/${recipeState.recipe.image}', height: 300, width: MediaQuery.sizeOf(context).width, fit: BoxFit.fill, diff --git a/lib/features/recipe/presentation/widgets/my_recipe_widget.dart b/lib/features/recipe/presentation/widgets/my_recipe_widget.dart index 2610ca13..d791135a 100644 --- a/lib/features/recipe/presentation/widgets/my_recipe_widget.dart +++ b/lib/features/recipe/presentation/widgets/my_recipe_widget.dart @@ -1,5 +1,5 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; @@ -71,7 +71,7 @@ class _MyRecipeWidgetState extends State { child: ClipRRect( borderRadius: const BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: '$baseUrl/storage/${widget.recipe.image}', + imageUrl: '${sl().baseUrl}/storage/${widget.recipe.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width, ), @@ -162,7 +162,7 @@ class _MyRecipeWidgetState extends State { final box = context.findRenderObject() as RenderBox?; await SharePlus.instance.share( ShareParams( - uri: Uri.parse('$baseUrl/ru/recipe/${widget.recipe.slug}'), + uri: Uri.parse('${sl().baseUrl}/ru/recipe/${widget.recipe.slug}'), sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ), ); diff --git a/lib/features/recipe/presentation/widgets/steps_widget.dart b/lib/features/recipe/presentation/widgets/steps_widget.dart index f4281c81..dbd45602 100644 --- a/lib/features/recipe/presentation/widgets/steps_widget.dart +++ b/lib/features/recipe/presentation/widgets/steps_widget.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/widgets/main_background_bouble.dart'; @@ -44,7 +45,7 @@ class StepsWidget extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.circular(16), child: Image.network( - '$baseUrl/storage/${recipe.steps![index].image}', + '${sl().baseUrl}/storage/${recipe.steps![index].image}', fit: BoxFit.cover, ), ), diff --git a/lib/features/registration/presentation/pages/verify_screen.dart b/lib/features/registration/presentation/pages/verify_screen.dart index 8d5df9df..867af06f 100644 --- a/lib/features/registration/presentation/pages/verify_screen.dart +++ b/lib/features/registration/presentation/pages/verify_screen.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; import 'package:eatvio_app/features/registration/services/registration_analytics_service.dart'; @@ -89,7 +90,7 @@ class _VerifyScreenState extends State { }, ), ) - ..loadRequest(Uri.parse('$baseUrl/login_with_pass_key?id=${widget.passKey}')); + ..loadRequest(Uri.parse('${sl().baseUrl}/login_with_pass_key?id=${widget.passKey}')); } @override diff --git a/lib/features/registration/presentation/pages/webview_registration_screen.dart b/lib/features/registration/presentation/pages/webview_registration_screen.dart index 05c0ffc1..6cc777d2 100644 --- a/lib/features/registration/presentation/pages/webview_registration_screen.dart +++ b/lib/features/registration/presentation/pages/webview_registration_screen.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:developer'; -import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart'; import 'package:eatvio_app/features/registration/services/registration_analytics_service.dart'; @@ -54,7 +54,7 @@ class _WebViewRegistrationScreenState extends State { }, ), ) - ..loadRequest(Uri.parse('$baseUrl/registration/step1')); + ..loadRequest(Uri.parse('${sl().baseUrl}/registration/step1')); _injectJavaScript(); } diff --git a/lib/features/support/presentation/pages/support_screen.dart b/lib/features/support/presentation/pages/support_screen.dart index 6aa44a42..a01a88af 100644 --- a/lib/features/support/presentation/pages/support_screen.dart +++ b/lib/features/support/presentation/pages/support_screen.dart @@ -1,4 +1,6 @@ +import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:eatvio_app/core/widgets/custom_divider.dart'; import 'package:eatvio_app/generated/l10n.dart'; @@ -71,7 +73,7 @@ class SupportScreen extends StatelessWidget { const SizedBox(height: 12), if (!hidePlans) ...[ InkWell( - onTap: () async => await launchUrl(Uri.parse('$baseUrl/docs/public_offer.pdf')), + onTap: () async => await launchUrl(Uri.parse('${sl().baseUrl}/docs/public_offer.pdf')), borderRadius: BorderRadius.circular(16), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4), @@ -81,7 +83,7 @@ class SupportScreen extends StatelessWidget { const SizedBox(height: 8), ], InkWell( - onTap: () async => await launchUrl(Uri.parse('$baseUrl/docs/privacy.pdf')), + onTap: () async => await launchUrl(Uri.parse('${sl().baseUrl}/docs/privacy.pdf')), borderRadius: BorderRadius.circular(16), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4), @@ -90,7 +92,7 @@ class SupportScreen extends StatelessWidget { ), const SizedBox(height: 8), InkWell( - onTap: () async => await launchUrl(Uri.parse('$baseUrl/company-details')), + onTap: () async => await launchUrl(Uri.parse('${sl().baseUrl}/company-details')), borderRadius: BorderRadius.circular(16), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4), diff --git a/lib/main.dart b/lib/main.dart index fa5ff699..af6db638 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_initializer.dart'; import 'package:eatvio_app/core/app_router.dart'; +import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -8,7 +9,7 @@ import 'package:flutter_portal/flutter_portal.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; Future main() async { - await AppInitializer.initialize(); + await AppInitializer.initialize(buildType: AppBuildType.prod); await AppInitializer.runAppWithSentry(() => runApp(const MyApp())); } @@ -18,15 +19,15 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MultiBlocProvider( - providers: AppConfig.globalBlocProviders, + providers: sl().globalBlocProviders, child: Portal( child: KeyboardDismisser( child: MaterialApp.router( theme: ThemeHelper().themeData(), - routerConfig: AppRouter.appRouter, + routerConfig: AppRouter.appRouter, debugShowCheckedModeBanner: false, - localizationsDelegates: AppConfig.localizationDelegates, - supportedLocales: AppConfig.supportedLocales, + localizationsDelegates: sl().localizationDelegates, + supportedLocales: sl().supportedLocales, ), ), ),