forked from eatvio/eatvio_app
feat(tests): changed base url handling logic, added build type checking for push permission
This commit is contained in:
@@ -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<void> initialize({AppBuildType buildType = AppBuildType.prod}) async {
|
||||
static Future<void> 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<void> _initializeFirebase() async {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
await FirebaseMessaging.instance.requestPermission();
|
||||
if (sl<AppConfig>().buildType == AppBuildType.prod) {
|
||||
await FirebaseMessaging.instance.requestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
/// Инициализация системы внедрения зависимостей
|
||||
static Future<void> _initializeDependencyInjection() async {
|
||||
await di.init();
|
||||
static Future<void> _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 }
|
||||
|
||||
Reference in New Issue
Block a user