mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 07:50:42 +00:00
5adcee00dd
* Added `ServiceProviders` widget * Added `EnumProviders` widget for enum values * Moved `ThemeProvider` functionality to `EnumProviders` * Style * `EnumProviders` -> `UserPreferencesProvider` * `ServiceProviders` -> `ServiceProvider` * Moved `MeteringScreenLayoutProvider` functionality to `UserPreferencesProvider` * typo * Removed `InheritedModelAspectListener` * TODO * Removed Inherited Generics * Removed redundant `LightmeterProviders` * Removed redundant methods from `ServicesProvider` * `_inheritFrom` -> `_inheritFromEnumsModel` * Fixed `MeteringScreenLayoutConfig` updates * Separated `_ThemeModel` * typo * `_EnumsModel` -> `_UserPreferencesModel`
61 lines
2.1 KiB
Dart
61 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:lightmeter/interactors/metering_interactor.dart';
|
|
import 'package:lightmeter/providers/services_provider.dart';
|
|
import 'package:lightmeter/screens/metering/bloc_metering.dart';
|
|
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
|
import 'package:lightmeter/screens/metering/components/shared/volume_keys_notifier/notifier_volume_keys.dart';
|
|
import 'package:lightmeter/screens/metering/screen_metering.dart';
|
|
|
|
class MeteringFlow extends StatefulWidget {
|
|
const MeteringFlow({super.key});
|
|
|
|
@override
|
|
State<MeteringFlow> createState() => _MeteringFlowState();
|
|
}
|
|
|
|
class _MeteringFlowState extends State<MeteringFlow> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MeteringInteractorProvider(
|
|
data: MeteringInteractor(
|
|
ServicesProvider.of(context).userPreferencesService,
|
|
ServicesProvider.of(context).caffeineService,
|
|
ServicesProvider.of(context).hapticsService,
|
|
ServicesProvider.of(context).permissionsService,
|
|
ServicesProvider.of(context).lightSensorService,
|
|
ServicesProvider.of(context).volumeEventsService,
|
|
)..initialize(),
|
|
child: MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(create: (_) => MeteringCommunicationBloc()),
|
|
BlocProvider(
|
|
create: (context) => MeteringBloc(
|
|
MeteringInteractorProvider.of(context),
|
|
VolumeKeysNotifier(ServicesProvider.of(context).volumeEventsService),
|
|
context.read<MeteringCommunicationBloc>(),
|
|
),
|
|
),
|
|
],
|
|
child: const MeteringScreen(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MeteringInteractorProvider extends InheritedWidget {
|
|
final MeteringInteractor data;
|
|
|
|
const MeteringInteractorProvider({
|
|
required this.data,
|
|
required super.child,
|
|
super.key,
|
|
});
|
|
|
|
static MeteringInteractor of(BuildContext context) {
|
|
return context.findAncestorWidgetOfExactType<MeteringInteractorProvider>()!.data;
|
|
}
|
|
|
|
@override
|
|
bool updateShouldNotify(MeteringInteractorProvider oldWidget) => false;
|
|
}
|