mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 01:20:46 +00:00
refactor(linter): Перейти на friflex_linter, обновить правила
This commit is contained in:
@@ -14,14 +14,12 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
/// Класс приложения
|
||||
class App extends StatefulWidget {
|
||||
const App({
|
||||
super.key,
|
||||
required this.router,
|
||||
required this.initDependencies,
|
||||
});
|
||||
const App({required this.router, required this.initDependencies, super.key});
|
||||
|
||||
/// Роутер приложения
|
||||
final GoRouter router;
|
||||
/// Функция для инициализации зависимостей
|
||||
|
||||
/// Функция для инициализации зависимостей
|
||||
final Future<DiContainer> Function() initDependencies;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:envied/envied.dart';
|
||||
import 'package:friflex_starter/app/app_config/i_app_config.dart';
|
||||
import 'package:friflex_starter/app/app_env.dart';
|
||||
|
||||
|
||||
part 'app_config.g.dart';
|
||||
|
||||
/// Класс для реализации конфигурации с моковыми данными
|
||||
|
||||
@@ -24,11 +24,13 @@ final class _Dev {
|
||||
502170444,
|
||||
];
|
||||
|
||||
static final String secretKey = String.fromCharCodes(List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]));
|
||||
static final String secretKey = String.fromCharCodes(
|
||||
List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]),
|
||||
);
|
||||
}
|
||||
|
||||
// coverage:ignore-file
|
||||
@@ -65,11 +67,13 @@ final class _Prod {
|
||||
2999310307,
|
||||
];
|
||||
|
||||
static final String baseUrl = String.fromCharCodes(List<int>.generate(
|
||||
_envieddatabaseUrl.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatabaseUrl[i] ^ _enviedkeybaseUrl[i]));
|
||||
static final String baseUrl = String.fromCharCodes(
|
||||
List<int>.generate(
|
||||
_envieddatabaseUrl.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatabaseUrl[i] ^ _enviedkeybaseUrl[i]),
|
||||
);
|
||||
|
||||
static const List<int> _enviedkeysecretKey = <int>[
|
||||
4268709792,
|
||||
@@ -85,11 +89,13 @@ final class _Prod {
|
||||
2677812202,
|
||||
];
|
||||
|
||||
static final String secretKey = String.fromCharCodes(List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]));
|
||||
static final String secretKey = String.fromCharCodes(
|
||||
List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]),
|
||||
);
|
||||
}
|
||||
|
||||
// coverage:ignore-file
|
||||
@@ -128,11 +134,13 @@ final class _Stage {
|
||||
206487528,
|
||||
];
|
||||
|
||||
static final String baseUrl = String.fromCharCodes(List<int>.generate(
|
||||
_envieddatabaseUrl.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatabaseUrl[i] ^ _enviedkeybaseUrl[i]));
|
||||
static final String baseUrl = String.fromCharCodes(
|
||||
List<int>.generate(
|
||||
_envieddatabaseUrl.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatabaseUrl[i] ^ _enviedkeybaseUrl[i]),
|
||||
);
|
||||
|
||||
static const List<int> _enviedkeysecretKey = <int>[
|
||||
1473916388,
|
||||
@@ -150,9 +158,11 @@ final class _Stage {
|
||||
317937294,
|
||||
];
|
||||
|
||||
static final String secretKey = String.fromCharCodes(List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]));
|
||||
static final String secretKey = String.fromCharCodes(
|
||||
List<int>.generate(
|
||||
_envieddatasecretKey.length,
|
||||
(int i) => i,
|
||||
growable: false,
|
||||
).map((int i) => _envieddatasecretKey[i] ^ _enviedkeysecretKey[i]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
/// Класс для добавления провайдеров темы и локализации
|
||||
final class AppProviders extends StatelessWidget {
|
||||
const AppProviders({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
const AppProviders({required this.child, super.key});
|
||||
|
||||
final Widget child;
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import 'package:provider/provider.dart';
|
||||
/// Класс для внедрения глобальных зависимостей
|
||||
final class DependsProviders extends StatelessWidget {
|
||||
const DependsProviders({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.diContainer,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@@ -25,9 +25,7 @@ final class AppHttpClient implements IHttpClient {
|
||||
..connectTimeout = const Duration(seconds: 5)
|
||||
..sendTimeout = const Duration(seconds: 7)
|
||||
..receiveTimeout = const Duration(seconds: 10)
|
||||
..headers = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
..headers = {'Content-Type': 'application/json'};
|
||||
debugService.log('HTTP client created');
|
||||
_httpClient.interceptors.add(debugService.dioLogger);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ typedef ThemeBuilder = Widget Function();
|
||||
|
||||
/// Виджет для подписки на изменение темы приложения
|
||||
class ThemeConsumer extends StatelessWidget {
|
||||
const ThemeConsumer({super.key, required this.builder});
|
||||
const ThemeConsumer({required this.builder, super.key});
|
||||
|
||||
final ThemeBuilder builder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ThemeNotifier>(
|
||||
builder: (_, __, ___) {
|
||||
builder: (_, _, _) {
|
||||
return builder();
|
||||
},
|
||||
);
|
||||
@@ -26,8 +26,9 @@ final class ThemeNotifier extends ChangeNotifier {
|
||||
ThemeMode get themeMode => _themeMode;
|
||||
|
||||
void changeTheme() {
|
||||
_themeMode =
|
||||
_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light;
|
||||
_themeMode = _themeMode == ThemeMode.light
|
||||
? ThemeMode.dark
|
||||
: ThemeMode.light;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:friflex_starter/features/debug/i_debug_service.dart';
|
||||
final class DiContainer {
|
||||
/// {@macro dependencies_container}
|
||||
DiContainer({required this.env, required IDebugService dService})
|
||||
: debugService = dService;
|
||||
: debugService = dService;
|
||||
final AppEnv env;
|
||||
|
||||
/// Сервис для отладки, получаем из конструктора
|
||||
@@ -44,30 +44,20 @@ final class DiContainer {
|
||||
appConfig = switch (env) {
|
||||
AppEnv.dev => AppConfigDev(),
|
||||
AppEnv.prod => AppConfigProd(),
|
||||
AppEnv.stage => AppConfigStage()
|
||||
AppEnv.stage => AppConfigStage(),
|
||||
};
|
||||
|
||||
// Инициализация HTTP клиента
|
||||
httpClientFactory = (debugService, appConfig) => AppHttpClient(
|
||||
debugService: debugService,
|
||||
appConfig: appConfig,
|
||||
);
|
||||
httpClientFactory = (debugService, appConfig) =>
|
||||
AppHttpClient(debugService: debugService, appConfig: appConfig);
|
||||
|
||||
// Инициализация сервисов
|
||||
services = DiServices()
|
||||
..init(
|
||||
onProgress: onProgress,
|
||||
onError: onError,
|
||||
diContainer: this,
|
||||
);
|
||||
..init(onProgress: onProgress, onError: onError, diContainer: this);
|
||||
// throw Exception('Тестовая - ошибка инициализации зависимостей');
|
||||
// Инициализация репозиториев
|
||||
repositories = DiRepositories()
|
||||
..init(
|
||||
onProgress: onProgress,
|
||||
onError: onError,
|
||||
diContainer: this,
|
||||
);
|
||||
..init(onProgress: onProgress, onError: onError, diContainer: this);
|
||||
|
||||
onComplete('Инициализация зависимостей завершена!');
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ final class DiRepositories {
|
||||
/// Интерфейс для работы с репозиторием профиля
|
||||
late final IProfileRepository profileRepository;
|
||||
|
||||
|
||||
/// Метод для инициализации репозиториев в приложении
|
||||
///
|
||||
/// Принимает:
|
||||
@@ -116,7 +115,7 @@ final class DiRepositories {
|
||||
stackTrace,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
onProgress(
|
||||
'Инициализация репозиториев завершена! Было подменено репозиториев - ${_mockReposToSwitch.length} (${_mockReposToSwitch.join(', ')})',
|
||||
);
|
||||
|
||||
@@ -26,11 +26,7 @@ final class DiServices {
|
||||
pathProvider = const AppPathProvider();
|
||||
onProgress(AppPathProvider.name);
|
||||
} on Object catch (error, stackTrace) {
|
||||
onError(
|
||||
'Ошибка инициализации ${IPathProvider.name}',
|
||||
error,
|
||||
stackTrace,
|
||||
);
|
||||
onError('Ошибка инициализации ${IPathProvider.name}', error, stackTrace);
|
||||
}
|
||||
try {
|
||||
secureStorage = AppSecureStorage(
|
||||
@@ -38,11 +34,7 @@ final class DiServices {
|
||||
);
|
||||
onProgress(AppSecureStorage.name);
|
||||
} on Object catch (error, stackTrace) {
|
||||
onError(
|
||||
'Ошибка инициализации ${ISecureStorage.name}',
|
||||
error,
|
||||
stackTrace,
|
||||
);
|
||||
onError('Ошибка инициализации ${ISecureStorage.name}', error, stackTrace);
|
||||
}
|
||||
|
||||
onProgress('Инициализация сервисов завершена!');
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/// Обратный вызов при ошибки инициализации
|
||||
typedef OnError = void Function(
|
||||
String message,
|
||||
Object error, [
|
||||
StackTrace? stackTrace,
|
||||
]);
|
||||
typedef OnError =
|
||||
void Function(String message, Object error, [StackTrace? stackTrace]);
|
||||
|
||||
/// Обратный вызов при прогрессе
|
||||
typedef OnProgress = void Function(String name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../domain/repository/i_auth_repository.dart';
|
||||
import 'package:friflex_starter/features/auth/domain/repository/i_auth_repository.dart';
|
||||
|
||||
/// {@template AuthMockRepository}
|
||||
/// Mock реализация репозитория авторизации
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:friflex_starter/app/http/i_http_client.dart';
|
||||
|
||||
import '../../domain/repository/i_auth_repository.dart';
|
||||
import 'package:friflex_starter/features/auth/domain/repository/i_auth_repository.dart';
|
||||
|
||||
/// {@template AuthRepository}
|
||||
/// Реализация репозитория авторизации
|
||||
/// {@endtemplate}
|
||||
final class AuthRepository implements IAuthRepository {
|
||||
final IHttpClient httpClient;
|
||||
|
||||
AuthRepository({required this.httpClient});
|
||||
final IHttpClient httpClient;
|
||||
|
||||
@override
|
||||
String get name => 'AuthRepository';
|
||||
|
||||
@@ -10,12 +10,8 @@ class AuthScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('AuthScreen'),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('AuthScreen'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('AuthScreen')),
|
||||
body: const Center(child: Text('AuthScreen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,36 +32,36 @@ abstract final class DebugRoutes {
|
||||
/// Принимает:
|
||||
/// - [routes] - вложенные роуты
|
||||
static GoRoute buildRoutes({List<RouteBase> routes = const []}) => GoRoute(
|
||||
path: debugScreenPath,
|
||||
name: debugScreenName,
|
||||
builder: (context, state) => const DebugScreen(),
|
||||
routes: [
|
||||
...routes,
|
||||
GoRoute(
|
||||
path: tokensScreenPath,
|
||||
name: tokensScreenName,
|
||||
builder: (context, state) => const TokensScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: uiKitScreenPath,
|
||||
name: uiKitScreenName,
|
||||
builder: (context, state) => const UiKitScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: iconsScreenPath,
|
||||
name: iconsScreenName,
|
||||
builder: (context, state) => const IconsScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: themeScreenPath,
|
||||
name: themeScreenName,
|
||||
builder: (context, state) => const ThemeScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: langScreenPath,
|
||||
name: langScreenName,
|
||||
builder: (context, state) => const LangScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
path: debugScreenPath,
|
||||
name: debugScreenName,
|
||||
builder: (context, state) => const DebugScreen(),
|
||||
routes: [
|
||||
...routes,
|
||||
GoRoute(
|
||||
path: tokensScreenPath,
|
||||
name: tokensScreenName,
|
||||
builder: (context, state) => const TokensScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: uiKitScreenPath,
|
||||
name: uiKitScreenName,
|
||||
builder: (context, state) => const UiKitScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: iconsScreenPath,
|
||||
name: iconsScreenName,
|
||||
builder: (context, state) => const IconsScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: themeScreenPath,
|
||||
name: themeScreenName,
|
||||
builder: (context, state) => const ThemeScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: langScreenPath,
|
||||
name: langScreenName,
|
||||
builder: (context, state) => const LangScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,15 +62,17 @@ class DebugService implements IDebugService {
|
||||
Map<String, dynamic>? args,
|
||||
StackTrace? stackTrace,
|
||||
}) {
|
||||
final logMessage =
|
||||
message is Function ? Function.apply(message, []) as Object : message;
|
||||
final logMessage = message is Function
|
||||
? Function.apply(message, []) as Object
|
||||
: message;
|
||||
_talker.error(logMessage, error, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
void log(Object message, {Object? logLevel, Map<String, dynamic>? args}) {
|
||||
final logMessage =
|
||||
message is Function ? Function.apply(message, []) as Object : message;
|
||||
final logMessage = message is Function
|
||||
? Function.apply(message, []) as Object
|
||||
: message;
|
||||
_talker.log(logMessage);
|
||||
}
|
||||
|
||||
@@ -80,14 +82,17 @@ class DebugService implements IDebugService {
|
||||
Object? logLevel,
|
||||
Map<String, dynamic>? args,
|
||||
}) {
|
||||
final logMessage =
|
||||
message is Function ? Function.apply(message, []) as Object : message;
|
||||
final logMessage = message is Function
|
||||
? Function.apply(message, []) as Object
|
||||
: message;
|
||||
_talker.warning(logMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> openDebugScreen(BuildContext context,
|
||||
{bool useRootNavigator = false,}) async {
|
||||
Future<void> openDebugScreen(
|
||||
BuildContext context, {
|
||||
bool useRootNavigator = false,
|
||||
}) async {
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (context) => TalkerScreen(talker: _talker)),
|
||||
);
|
||||
|
||||
@@ -14,11 +14,7 @@ abstract interface class IDebugService {
|
||||
dynamic get blocObserver;
|
||||
|
||||
/// Метод для логирования сообщений
|
||||
void log(
|
||||
Object message, {
|
||||
Object logLevel,
|
||||
Map<String, dynamic>? args,
|
||||
});
|
||||
void log(Object message, {Object logLevel, Map<String, dynamic>? args});
|
||||
|
||||
/// Метод для логирования предупреждений
|
||||
void logWarning(
|
||||
@@ -37,11 +33,7 @@ abstract interface class IDebugService {
|
||||
});
|
||||
|
||||
/// Метод для обработки ошибок
|
||||
void logDebug(
|
||||
Object message, {
|
||||
Object logLevel,
|
||||
Map<String, dynamic>? args,
|
||||
});
|
||||
void logDebug(Object message, {Object logLevel, Map<String, dynamic>? args});
|
||||
|
||||
/// Метод для открытия окна отладки
|
||||
///
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:friflex_starter/features/debug/debug_routes.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class DebugScreen extends StatelessWidget {
|
||||
const DebugScreen({Key? key}) : super(key: key);
|
||||
const DebugScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -15,9 +15,7 @@ class DebugScreen extends StatelessWidget {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(
|
||||
'Окружение: ${context.di.appConfig.env.name}',
|
||||
),
|
||||
Text('Окружение: ${context.di.appConfig.env.name}'),
|
||||
const HBox(22),
|
||||
Text(
|
||||
'Реализация AppServices: ${context.di.services.secureStorage.nameImpl}',
|
||||
|
||||
@@ -12,9 +12,7 @@ class IconsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconList = Assets.icons.values
|
||||
.map(
|
||||
(icon) => _ItemIcon(icon: icon.svg(), name: icon.path),
|
||||
)
|
||||
.map((icon) => _ItemIcon(icon: icon.svg(), name: icon.path))
|
||||
.toList();
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Иконки')),
|
||||
|
||||
@@ -22,18 +22,14 @@ class LangScreen extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.localization.changeLocal(
|
||||
const Locale('ru', 'RU'),
|
||||
);
|
||||
context.localization.changeLocal(const Locale('ru', 'RU'));
|
||||
},
|
||||
child: const Text('Сменить язык на Rусский'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
context.localization.changeLocal(
|
||||
const Locale('en', 'EN'),
|
||||
);
|
||||
context.localization.changeLocal(const Locale('en', 'EN'));
|
||||
},
|
||||
child: const Text('Сменить язык на Английский'),
|
||||
),
|
||||
@@ -54,9 +50,7 @@ class LangScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Текущий язык: ${context.l10n.localeName}',
|
||||
),
|
||||
Text('Текущий язык: ${context.l10n.localeName}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -29,9 +29,7 @@ class ThemeScreen extends StatelessWidget {
|
||||
child: const SizedBox(height: 100, width: 100),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Текущая тема: ${context.theme.themeMode}',
|
||||
),
|
||||
Text('Текущая тема: ${context.theme.themeMode}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -15,13 +15,9 @@ class TokensScreen extends StatelessWidget {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: const [
|
||||
Text(
|
||||
'Access Token: ',
|
||||
),
|
||||
Text('Access Token: '),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Refresh Token: ',
|
||||
),
|
||||
Text('Refresh Token: '),
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -11,16 +11,12 @@ class UiKitScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('UI Kit Screen'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('UI Kit Screen')),
|
||||
body: Center(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: const [
|
||||
Text(
|
||||
'UI Kit Screen',
|
||||
),
|
||||
Text('UI Kit Screen'),
|
||||
SizedBox(height: 16),
|
||||
// Здесь можно добавить другие компоненты UI Kit
|
||||
],
|
||||
|
||||
@@ -6,9 +6,9 @@ import 'package:flutter/material.dart';
|
||||
class ErrorScreen extends StatelessWidget {
|
||||
/// {@macro ErrorScreen}
|
||||
const ErrorScreen({
|
||||
super.key,
|
||||
required this.error,
|
||||
required this.stackTrace,
|
||||
super.key,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
@@ -31,14 +31,11 @@ class ErrorScreen extends StatelessWidget {
|
||||
child: const Text('Перезагрузить приложение'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'''
|
||||
Text('''
|
||||
Что-то пошло не так, попробуйте перезагрузить приложение
|
||||
error: $error
|
||||
stackTrace: $stackTrace
|
||||
''',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
''', textAlign: TextAlign.center),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../domain/repository/i_main_repository.dart';
|
||||
import 'package:friflex_starter/features/main/domain/repository/i_main_repository.dart';
|
||||
|
||||
/// {@template MainMockRepository}
|
||||
///
|
||||
@@ -6,4 +6,4 @@ import '../../domain/repository/i_main_repository.dart';
|
||||
final class MainMockRepository implements IMainRepository {
|
||||
@override
|
||||
String get name => 'MainMockRepository';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:friflex_starter/app/http/i_http_client.dart';
|
||||
|
||||
import '../../domain/repository/i_main_repository.dart';
|
||||
import 'package:friflex_starter/features/main/domain/repository/i_main_repository.dart';
|
||||
|
||||
/// {@template MainRepository}
|
||||
///
|
||||
/// {@endtemplate}
|
||||
final class MainRepository implements IMainRepository {
|
||||
final IHttpClient httpClient;
|
||||
|
||||
MainRepository({required this.httpClient});
|
||||
final IHttpClient httpClient;
|
||||
|
||||
@override
|
||||
String get name => 'MainRepository';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:friflex_starter/di/di_base_repo.dart';
|
||||
|
||||
/// {@template IMainRepository}
|
||||
///
|
||||
///
|
||||
/// {@endtemplate}
|
||||
abstract interface class IMainRepository with DiBaseRepo{}
|
||||
abstract interface class IMainRepository with DiBaseRepo {}
|
||||
|
||||
@@ -23,25 +23,24 @@ abstract final class MainRoutes {
|
||||
static StatefulShellBranch buildShellBranch({
|
||||
List<RouteBase> routes = const [],
|
||||
List<NavigatorObserver>? observers,
|
||||
}) =>
|
||||
StatefulShellBranch(
|
||||
initialLocation: _mainScreenPath,
|
||||
observers: observers,
|
||||
}) => StatefulShellBranch(
|
||||
initialLocation: _mainScreenPath,
|
||||
observers: observers,
|
||||
routes: [
|
||||
...routes,
|
||||
GoRoute(
|
||||
path: _mainScreenPath,
|
||||
name: mainScreenName,
|
||||
builder: (context, state) => const MainScreen(),
|
||||
routes: [
|
||||
...routes,
|
||||
// Пример вложенного роута для главного экрана
|
||||
GoRoute(
|
||||
path: _mainScreenPath,
|
||||
name: mainScreenName,
|
||||
builder: (context, state) => const MainScreen(),
|
||||
routes: [
|
||||
// Пример вложенного роута для главного экрана
|
||||
GoRoute(
|
||||
path: _mainDetailScreenPath,
|
||||
name: mainDetailScreenName,
|
||||
builder: (context, state) => const MainDetailScreen(),
|
||||
),
|
||||
],
|
||||
path: _mainDetailScreenPath,
|
||||
name: mainDetailScreenName,
|
||||
builder: (context, state) => const MainDetailScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,8 @@ class MainDetailScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Main Detail Screen'),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('Вложенный экран'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Main Detail Screen')),
|
||||
body: const Center(child: Text('Вложенный экран')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,7 @@ class MainScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Main Screen'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Main Screen')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../domain/repository/i_profile_repository.dart';
|
||||
import 'package:friflex_starter/features/profile/domain/repository/i_profile_repository.dart';
|
||||
|
||||
/// {@template ProfileMockRepository}
|
||||
///
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:friflex_starter/app/http/i_http_client.dart';
|
||||
|
||||
import '../../domain/repository/i_profile_repository.dart';
|
||||
import 'package:friflex_starter/features/profile/domain/repository/i_profile_repository.dart';
|
||||
|
||||
/// {@template ProfileRepository}
|
||||
///
|
||||
/// {@endtemplate}
|
||||
final class ProfileRepository implements IProfileRepository {
|
||||
final IHttpClient httpClient;
|
||||
|
||||
ProfileRepository({required this.httpClient});
|
||||
final IHttpClient httpClient;
|
||||
|
||||
@override
|
||||
String get name => 'ProfileRepository';
|
||||
|
||||
@@ -8,9 +8,9 @@ sealed class ProfileEvent extends Equatable {
|
||||
}
|
||||
|
||||
final class ProfileFetchProfileEvent extends ProfileEvent {
|
||||
final String id;
|
||||
|
||||
const ProfileFetchProfileEvent({required this.id});
|
||||
final String id;
|
||||
|
||||
@override
|
||||
List<Object> get props => [id];
|
||||
|
||||
@@ -12,24 +12,24 @@ final class ProfileInitialState extends ProfileState {}
|
||||
final class ProfileWaitingState extends ProfileState {}
|
||||
|
||||
final class ProfileErrorState extends ProfileState {
|
||||
final String message;
|
||||
final Object error;
|
||||
final StackTrace? stackTrace;
|
||||
|
||||
const ProfileErrorState({
|
||||
required this.message,
|
||||
required this.error,
|
||||
this.stackTrace,
|
||||
});
|
||||
final String message;
|
||||
final Object error;
|
||||
final StackTrace? stackTrace;
|
||||
|
||||
@override
|
||||
List<Object> get props => [message, error];
|
||||
}
|
||||
|
||||
final class ProfileSuccessState extends ProfileState {
|
||||
final Object data;
|
||||
|
||||
const ProfileSuccessState({required this.data});
|
||||
final Object data;
|
||||
|
||||
@override
|
||||
List<Object> get props => [data];
|
||||
|
||||
@@ -16,17 +16,16 @@ abstract final class ProfileRoutes {
|
||||
static StatefulShellBranch buildShellBranch({
|
||||
List<RouteBase> routes = const [],
|
||||
List<NavigatorObserver>? observers,
|
||||
}) =>
|
||||
StatefulShellBranch(
|
||||
initialLocation: _profileScreenPath,
|
||||
observers: observers,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _profileScreenPath,
|
||||
name: profileScreenName,
|
||||
builder: (context, state) => const ProfileScreen(),
|
||||
routes: routes,
|
||||
),
|
||||
],
|
||||
);
|
||||
}) => StatefulShellBranch(
|
||||
initialLocation: _profileScreenPath,
|
||||
observers: observers,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _profileScreenPath,
|
||||
name: profileScreenName,
|
||||
builder: (context, state) => const ProfileScreen(),
|
||||
routes: routes,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ class ProfileScreen extends StatelessWidget {
|
||||
// и вызываем событие ProfileFetchProfileEvent
|
||||
// Или любые другие события, которые вам нужны
|
||||
return BlocProvider(
|
||||
create: (context) => ProfileBloc(profileRepository)
|
||||
..add(const ProfileFetchProfileEvent(id: '1')),
|
||||
create: (context) =>
|
||||
ProfileBloc(profileRepository)
|
||||
..add(const ProfileFetchProfileEvent(id: '1')),
|
||||
child: const _ProfileScreenView(),
|
||||
);
|
||||
}
|
||||
@@ -29,9 +30,7 @@ class _ProfileScreenView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profile'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Profile')),
|
||||
body: Center(
|
||||
child: BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
|
||||
@@ -10,10 +10,7 @@ class RootScreen extends StatelessWidget {
|
||||
///
|
||||
/// Принимает:
|
||||
/// - [navigationShell] - текущая ветка навигации
|
||||
const RootScreen({
|
||||
super.key,
|
||||
required this.navigationShell,
|
||||
});
|
||||
const RootScreen({required this.navigationShell, super.key});
|
||||
|
||||
/// Текущая ветка навигации
|
||||
final StatefulNavigationShell navigationShell;
|
||||
|
||||
@@ -11,8 +11,6 @@ class SplashScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Assets.lottie.splash.lottie(),
|
||||
);
|
||||
return Center(child: Assets.lottie.splash.lottie());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ import 'app_localizations_ru.dart';
|
||||
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
|
||||
/// property.
|
||||
abstract class AppLocalizations {
|
||||
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
AppLocalizations(String locale)
|
||||
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
|
||||
final String localeName;
|
||||
|
||||
@@ -70,7 +71,8 @@ abstract class AppLocalizations {
|
||||
return Localizations.of<AppLocalizations>(context, AppLocalizations);
|
||||
}
|
||||
|
||||
static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
|
||||
static const LocalizationsDelegate<AppLocalizations> delegate =
|
||||
_AppLocalizationsDelegate();
|
||||
|
||||
/// A list of this localizations delegate along with the default localizations
|
||||
/// delegates.
|
||||
@@ -82,17 +84,18 @@ abstract class AppLocalizations {
|
||||
/// Additional delegates can be added by appending to this list in
|
||||
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||
/// of delegates is preferred or required.
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||||
<LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('ru')
|
||||
Locale('ru'),
|
||||
];
|
||||
|
||||
/// The conventional newborn programmer greeting
|
||||
@@ -102,7 +105,8 @@ abstract class AppLocalizations {
|
||||
String get helloWorld;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
class _AppLocalizationsDelegate
|
||||
extends LocalizationsDelegate<AppLocalizations> {
|
||||
const _AppLocalizationsDelegate();
|
||||
|
||||
@override
|
||||
@@ -111,25 +115,26 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
|
||||
}
|
||||
|
||||
@override
|
||||
bool isSupported(Locale locale) => <String>['en', 'ru'].contains(locale.languageCode);
|
||||
bool isSupported(Locale locale) =>
|
||||
<String>['en', 'ru'].contains(locale.languageCode);
|
||||
|
||||
@override
|
||||
bool shouldReload(_AppLocalizationsDelegate old) => false;
|
||||
}
|
||||
|
||||
AppLocalizations lookupAppLocalizations(Locale locale) {
|
||||
|
||||
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en': return AppLocalizationsEn();
|
||||
case 'ru': return AppLocalizationsRu();
|
||||
case 'en':
|
||||
return AppLocalizationsEn();
|
||||
case 'ru':
|
||||
return AppLocalizationsRu();
|
||||
}
|
||||
|
||||
throw FlutterError(
|
||||
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.'
|
||||
'that was used.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ typedef LocalizationBuilder = Widget Function();
|
||||
|
||||
/// Виджет для перестройки виджета в зависимости от локализации
|
||||
class LocalizationConsumer extends StatelessWidget {
|
||||
const LocalizationConsumer({super.key, required this.builder});
|
||||
const LocalizationConsumer({required this.builder, super.key});
|
||||
|
||||
final LocalizationBuilder builder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<LocalizationNotifier>(
|
||||
builder: (_, __, ___) {
|
||||
builder: (_, _, _) {
|
||||
return builder();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -26,9 +26,7 @@ class AppRouter {
|
||||
return GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
initialLocation: initialLocation,
|
||||
observers: [
|
||||
debugService.routeObserver,
|
||||
],
|
||||
observers: [debugService.routeObserver],
|
||||
routes: [
|
||||
StatefulShellRoute.indexedStack(
|
||||
parentNavigatorKey: rootNavigatorKey,
|
||||
|
||||
@@ -105,9 +105,7 @@ class AppRunner {
|
||||
/// выполняется до запуска приложения
|
||||
Future<void> _initApp() async {
|
||||
// Запрет на поворот экрана
|
||||
await SystemChrome.setPreferredOrientations(
|
||||
[DeviceOrientation.portraitUp],
|
||||
);
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
// Заморозка первого кадра (сплеш)
|
||||
WidgetsBinding.instance.deferFirstFrame();
|
||||
@@ -131,10 +129,7 @@ class AppRunner {
|
||||
// TODO(yura): Удалить после проверки
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
debugService.log(() => 'Тип сборки: ${env.name}');
|
||||
final diContainer = DiContainer(
|
||||
env: env,
|
||||
dService: debugService,
|
||||
);
|
||||
final diContainer = DiContainer(env: env, dService: debugService);
|
||||
await diContainer.init(
|
||||
onProgress: (name) => timerRunner.logOnProgress(name),
|
||||
onComplete: (name) {
|
||||
@@ -142,11 +137,8 @@ class AppRunner {
|
||||
..logOnComplete(name)
|
||||
..stop();
|
||||
},
|
||||
onError: (message, error, [stackTrace]) => debugService.logError(
|
||||
message,
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
),
|
||||
onError: (message, error, [stackTrace]) =>
|
||||
debugService.logError(message, error: error, stackTrace: stackTrace),
|
||||
);
|
||||
//throw Exception('Test error');
|
||||
return diContainer;
|
||||
|
||||
@@ -36,15 +36,10 @@ class TimerRunner {
|
||||
_debugService.log(
|
||||
'$message, прогресс: ${_stopwatch.elapsedMilliseconds} мс',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/// Метод для обработки прогресса инициализации зависимостей
|
||||
void logOnError(
|
||||
String message,
|
||||
Object error, [
|
||||
StackTrace? stackTrace,
|
||||
]) {
|
||||
void logOnError(String message, Object error, [StackTrace? stackTrace]) {
|
||||
_debugService.logError(() => message, error: error, stackTrace: stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:friflex_starter/app/app_env.dart';
|
||||
import 'package:friflex_starter/runner/app_runner.dart';
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:friflex_starter/app/app_env.dart';
|
||||
import 'package:friflex_starter/runner/app_runner.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user