2022-12-14 17:33:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-01-26 09:10:23 +00:00
|
|
|
import 'package:lightmeter/interactors/metering_interactor.dart';
|
2023-08-13 18:58:11 +00:00
|
|
|
import 'package:lightmeter/providers/service_provider.dart';
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/screens/metering/bloc_metering.dart';
|
|
|
|
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
2023-07-09 11:39:33 +00:00
|
|
|
import 'package:lightmeter/screens/metering/components/shared/volume_keys_notifier/notifier_volume_keys.dart';
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/screens/metering/screen_metering.dart';
|
2023-06-04 11:04:04 +00:00
|
|
|
import 'package:lightmeter/utils/inherited_generics.dart';
|
2022-12-18 09:03:41 +00:00
|
|
|
|
2023-01-29 16:57:47 +00:00
|
|
|
class MeteringFlow extends StatefulWidget {
|
2022-12-14 17:33:38 +00:00
|
|
|
const MeteringFlow({super.key});
|
|
|
|
|
2023-01-29 16:57:47 +00:00
|
|
|
@override
|
|
|
|
State<MeteringFlow> createState() => _MeteringFlowState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MeteringFlowState extends State<MeteringFlow> {
|
2022-12-14 17:33:38 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-06-04 11:04:04 +00:00
|
|
|
return InheritedWidgetBase<MeteringInteractor>(
|
|
|
|
data: MeteringInteractor(
|
2023-08-13 18:58:11 +00:00
|
|
|
ServiceProvider.userPreferencesServiceOf(context),
|
|
|
|
ServiceProvider.caffeineServiceOf(context),
|
|
|
|
ServiceProvider.hapticsServiceOf(context),
|
|
|
|
ServiceProvider.permissionsServiceOf(context),
|
|
|
|
ServiceProvider.lightSensorServiceOf(context),
|
|
|
|
ServiceProvider.volumeEventsServiceOf(context),
|
2023-07-10 15:49:34 +00:00
|
|
|
)..initialize(),
|
2023-07-09 11:39:33 +00:00
|
|
|
child: InheritedWidgetBase<VolumeKeysNotifier>(
|
2023-08-13 18:58:11 +00:00
|
|
|
data: VolumeKeysNotifier(ServiceProvider.volumeEventsServiceOf(context)),
|
2023-07-09 11:39:33 +00:00
|
|
|
child: MultiBlocProvider(
|
|
|
|
providers: [
|
|
|
|
BlocProvider(create: (_) => MeteringCommunicationBloc()),
|
|
|
|
BlocProvider(
|
|
|
|
create: (context) => MeteringBloc(
|
|
|
|
context.get<MeteringInteractor>(),
|
|
|
|
context.get<VolumeKeysNotifier>(),
|
|
|
|
context.read<MeteringCommunicationBloc>(),
|
|
|
|
),
|
2023-01-21 10:37:49 +00:00
|
|
|
),
|
2023-07-09 11:39:33 +00:00
|
|
|
],
|
|
|
|
child: const MeteringScreen(),
|
|
|
|
),
|
2023-01-21 10:37:49 +00:00
|
|
|
),
|
2022-12-14 17:33:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|