context.get<SettingsInteractor>()

This commit is contained in:
Vadim 2023-05-30 17:40:45 +02:00
parent 0d5ce84683
commit ed28d2d9fc
5 changed files with 11 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import 'package:lightmeter/interactors/settings_interactor.dart';
import 'package:lightmeter/screens/settings/components/general/components/caffeine/bloc_list_tile_caffeine.dart'; import 'package:lightmeter/screens/settings/components/general/components/caffeine/bloc_list_tile_caffeine.dart';
import 'package:lightmeter/screens/settings/components/general/components/caffeine/widget_list_tile_caffeine.dart'; import 'package:lightmeter/screens/settings/components/general/components/caffeine/widget_list_tile_caffeine.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
class CaffeineListTileProvider extends StatelessWidget { class CaffeineListTileProvider extends StatelessWidget {
const CaffeineListTileProvider({super.key}); const CaffeineListTileProvider({super.key});
@ -11,7 +12,7 @@ class CaffeineListTileProvider extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => CaffeineListTileBloc(context.read<SettingsInteractor>()), create: (context) => CaffeineListTileBloc(context.get<SettingsInteractor>()),
child: const CaffeineListTile(), child: const CaffeineListTile(),
); );
} }

View file

@ -4,6 +4,7 @@ import 'package:lightmeter/interactors/settings_interactor.dart';
import 'package:lightmeter/screens/settings/components/general/components/haptics/bloc_list_tile_haptics.dart'; import 'package:lightmeter/screens/settings/components/general/components/haptics/bloc_list_tile_haptics.dart';
import 'package:lightmeter/screens/settings/components/general/components/haptics/widget_list_tile_haptics.dart'; import 'package:lightmeter/screens/settings/components/general/components/haptics/widget_list_tile_haptics.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
class HapticsListTileProvider extends StatelessWidget { class HapticsListTileProvider extends StatelessWidget {
const HapticsListTileProvider({super.key}); const HapticsListTileProvider({super.key});
@ -11,7 +12,7 @@ class HapticsListTileProvider extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => HapticsListTileBloc(context.read<SettingsInteractor>()), create: (context) => HapticsListTileBloc(context.get<SettingsInteractor>()),
child: const HapticsListTile(), child: const HapticsListTile(),
); );
} }

View file

@ -4,6 +4,7 @@ import 'package:lightmeter/interactors/settings_interactor.dart';
import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart'; import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart';
import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart'; import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
class CalibrationDialogProvider extends StatelessWidget { class CalibrationDialogProvider extends StatelessWidget {
const CalibrationDialogProvider({super.key}); const CalibrationDialogProvider({super.key});
@ -11,7 +12,7 @@ class CalibrationDialogProvider extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => CalibrationDialogBloc(context.read<SettingsInteractor>()), create: (context) => CalibrationDialogBloc(context.get<SettingsInteractor>()),
child: const CalibrationDialog(), child: const CalibrationDialog(),
); );
} }

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/interactors/settings_interactor.dart'; import 'package:lightmeter/interactors/settings_interactor.dart';
import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/provider_dialog_calibration.dart'; import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/provider_dialog_calibration.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
class CalibrationListTile extends StatelessWidget { class CalibrationListTile extends StatelessWidget {
const CalibrationListTile({super.key}); const CalibrationListTile({super.key});
@ -14,8 +15,8 @@ class CalibrationListTile extends StatelessWidget {
onTap: () { onTap: () {
showDialog<double>( showDialog<double>(
context: context, context: context,
builder: (_) => Provider.value( builder: (_) => InheritedWidgetBase(
value: context.read<SettingsInteractor>(), data: context.get<SettingsInteractor>(),
child: const CalibrationDialogProvider(), child: const CalibrationDialogProvider(),
), ),
); );

View file

@ -11,8 +11,8 @@ class SettingsFlow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Provider( return InheritedWidgetBase<SettingsInteractor>(
create: (context) => SettingsInteractor( data: SettingsInteractor(
context.get<UserPreferencesService>(), context.get<UserPreferencesService>(),
context.get<CaffeineService>(), context.get<CaffeineService>(),
context.get<HapticsService>(), context.get<HapticsService>(),