Added ServiceProviders widget

This commit is contained in:
Vadim 2023-08-13 15:27:43 +02:00
parent 4917ee8aef
commit 0c58597a8e
15 changed files with 128 additions and 86 deletions

View file

@ -9,10 +9,10 @@ import 'package:lightmeter/environment.dart';
import 'package:lightmeter/providers/equipment_profile_provider.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart';
import 'package:lightmeter/providers/ev_source_type_provider.dart'; import 'package:lightmeter/providers/ev_source_type_provider.dart';
import 'package:lightmeter/providers/metering_screen_layout_provider.dart'; import 'package:lightmeter/providers/metering_screen_layout_provider.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/providers/stop_type_provider.dart'; import 'package:lightmeter/providers/stop_type_provider.dart';
import 'package:lightmeter/providers/supported_locale_provider.dart'; import 'package:lightmeter/providers/supported_locale_provider.dart';
import 'package:lightmeter/providers/theme_provider.dart'; import 'package:lightmeter/providers/theme_provider.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -31,20 +31,14 @@ class LightmeterProviders extends StatelessWidget {
]), ]),
builder: (_, snapshot) { builder: (_, snapshot) {
if (snapshot.data != null) { if (snapshot.data != null) {
return InheritedWidgetBase<Environment>( return ServiceProviders(
data: env.copyWith(hasLightSensor: snapshot.data![1] as bool), caffeineService: const CaffeineService(),
child: InheritedWidgetBase<UserPreferencesService>( environment: env.copyWith(hasLightSensor: snapshot.data![1] as bool),
data: UserPreferencesService(snapshot.data![0] as SharedPreferences), hapticsService: const HapticsService(),
child: InheritedWidgetBase<LightSensorService>( lightSensorService: const LightSensorService(LocalPlatform()),
data: const LightSensorService(LocalPlatform()), permissionsService: const PermissionsService(),
child: InheritedWidgetBase<CaffeineService>( userPreferencesService: UserPreferencesService(snapshot.data![0] as SharedPreferences),
data: const CaffeineService(), volumeEventsService: const VolumeEventsService(LocalPlatform()),
child: InheritedWidgetBase<HapticsService>(
data: const HapticsService(),
child: InheritedWidgetBase<VolumeEventsService>(
data: const VolumeEventsService(LocalPlatform()),
child: InheritedWidgetBase<PermissionsService>(
data: const PermissionsService(),
child: MeteringScreenLayoutProvider( child: MeteringScreenLayoutProvider(
child: StopTypeProvider( child: StopTypeProvider(
child: EquipmentProfileProvider( child: EquipmentProfileProvider(
@ -60,12 +54,6 @@ class LightmeterProviders extends StatelessWidget {
), ),
), ),
), ),
),
),
),
),
),
),
); );
} else if (snapshot.error != null) { } else if (snapshot.error != null) {
return Center(child: Text(snapshot.error!.toString())); return Center(child: Text(snapshot.error!.toString()));

View file

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
@ -35,7 +35,8 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
EquipmentProfile get _selectedProfile => _customProfiles.firstWhere( EquipmentProfile get _selectedProfile => _customProfiles.firstWhere(
(e) => e.id == _selectedId, (e) => e.id == _selectedId,
orElse: () { orElse: () {
context.get<UserPreferencesService>().selectedEquipmentProfileId = _defaultProfile.id; ServiceProviders.userPreferencesServiceOf(context).selectedEquipmentProfileId =
_defaultProfile.id;
return _defaultProfile; return _defaultProfile;
}, },
); );
@ -43,8 +44,8 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_selectedId = context.get<UserPreferencesService>().selectedEquipmentProfileId; _selectedId = ServiceProviders.userPreferencesServiceOf(context).selectedEquipmentProfileId;
_customProfiles = context.get<UserPreferencesService>().equipmentProfiles; _customProfiles = ServiceProviders.userPreferencesServiceOf(context).equipmentProfiles;
} }
@override @override
@ -62,7 +63,8 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
setState(() { setState(() {
_selectedId = data.id; _selectedId = data.id;
}); });
context.get<UserPreferencesService>().selectedEquipmentProfileId = _selectedProfile.id; ServiceProviders.userPreferencesServiceOf(context).selectedEquipmentProfileId =
_selectedProfile.id;
} }
/// Creates a default equipment profile /// Creates a default equipment profile
@ -94,7 +96,7 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
} }
void _refreshSavedProfiles() { void _refreshSavedProfiles() {
context.get<UserPreferencesService>().equipmentProfiles = _customProfiles; ServiceProviders.userPreferencesServiceOf(context).equipmentProfiles = _customProfiles;
setState(() {}); setState(() {});
} }
} }

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/ev_source_type.dart'; import 'package:lightmeter/data/models/ev_source_type.dart';
import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
class EvSourceTypeProvider extends StatefulWidget { class EvSourceTypeProvider extends StatefulWidget {
@ -23,9 +22,9 @@ class EvSourceTypeProviderState extends State<EvSourceTypeProvider> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
final evSourceType = context.get<UserPreferencesService>().evSourceType; final evSourceType = ServiceProviders.userPreferencesServiceOf(context).evSourceType;
valueListenable = ValueNotifier( valueListenable = ValueNotifier(
evSourceType == EvSourceType.sensor && !context.get<Environment>().hasLightSensor evSourceType == EvSourceType.sensor && !ServiceProviders.environmentOf(context).hasLightSensor
? EvSourceType.camera ? EvSourceType.camera
: evSourceType, : evSourceType,
); );
@ -52,12 +51,12 @@ class EvSourceTypeProviderState extends State<EvSourceTypeProvider> {
void toggleType() { void toggleType() {
switch (valueListenable.value) { switch (valueListenable.value) {
case EvSourceType.camera: case EvSourceType.camera:
if (context.get<Environment>().hasLightSensor) { if (ServiceProviders.environmentOf(context).hasLightSensor) {
valueListenable.value = EvSourceType.sensor; valueListenable.value = EvSourceType.sensor;
} }
case EvSourceType.sensor: case EvSourceType.sensor:
valueListenable.value = EvSourceType.camera; valueListenable.value = EvSourceType.camera;
} }
context.get<UserPreferencesService>().evSourceType = valueListenable.value; ServiceProviders.userPreferencesServiceOf(context).evSourceType = valueListenable.value;
} }
} }

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
class MeteringScreenLayoutProvider extends StatefulWidget { class MeteringScreenLayoutProvider extends StatefulWidget {
@ -18,7 +18,7 @@ class MeteringScreenLayoutProvider extends StatefulWidget {
class MeteringScreenLayoutProviderState extends State<MeteringScreenLayoutProvider> { class MeteringScreenLayoutProviderState extends State<MeteringScreenLayoutProvider> {
late final MeteringScreenLayoutConfig _config = late final MeteringScreenLayoutConfig _config =
context.get<UserPreferencesService>().meteringScreenLayout; ServiceProviders.userPreferencesServiceOf(context).meteringScreenLayout;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -38,7 +38,7 @@ class MeteringScreenLayoutProviderState extends State<MeteringScreenLayoutProvid
); );
}); });
}); });
context.get<UserPreferencesService>().meteringScreenLayout = _config; ServiceProviders.userPreferencesServiceOf(context).meteringScreenLayout = _config;
} }
} }

View file

@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/data/caffeine_service.dart';
import 'package:lightmeter/data/haptics_service.dart';
import 'package:lightmeter/data/light_sensor_service.dart';
import 'package:lightmeter/data/permissions_service.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/data/volume_events_service.dart';
import 'package:lightmeter/environment.dart';
class ServiceProviders extends InheritedWidget {
final CaffeineService caffeineService;
final Environment environment;
final HapticsService hapticsService;
final LightSensorService lightSensorService;
final PermissionsService permissionsService;
final UserPreferencesService userPreferencesService;
final VolumeEventsService volumeEventsService;
const ServiceProviders({
required this.caffeineService,
required this.environment,
required this.hapticsService,
required this.lightSensorService,
required this.permissionsService,
required this.userPreferencesService,
required this.volumeEventsService,
required super.child,
});
static CaffeineService caffeineServiceOf(BuildContext context) {
return ServiceProviders._of(context).caffeineService;
}
static Environment environmentOf(BuildContext context) {
return ServiceProviders._of(context).environment;
}
static HapticsService hapticsServiceOf(BuildContext context) {
return ServiceProviders._of(context).hapticsService;
}
static LightSensorService lightSensorServiceOf(BuildContext context) {
return ServiceProviders._of(context).lightSensorService;
}
static PermissionsService permissionsServiceOf(BuildContext context) {
return ServiceProviders._of(context).permissionsService;
}
static UserPreferencesService userPreferencesServiceOf(BuildContext context) {
return ServiceProviders._of(context).userPreferencesService;
}
static VolumeEventsService volumeEventsServiceOf(BuildContext context) {
return ServiceProviders._of(context).volumeEventsService;
}
static ServiceProviders _of(BuildContext context) {
return context.findAncestorWidgetOfExactType<ServiceProviders>()!;
}
@override
bool updateShouldNotify(ServiceProviders oldWidget) => false;
}

View file

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@ -22,7 +22,7 @@ class StopTypeProviderState extends State<StopTypeProvider> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_stopType = context.get<UserPreferencesService>().stopType; _stopType = ServiceProviders.userPreferencesServiceOf(context).stopType;
} }
@override @override
@ -37,6 +37,6 @@ class StopTypeProviderState extends State<StopTypeProvider> {
setState(() { setState(() {
_stopType = type; _stopType = type;
}); });
context.get<UserPreferencesService>().stopType = type; ServiceProviders.userPreferencesServiceOf(context).stopType = type;
} }
} }

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/supported_locale.dart'; import 'package:lightmeter/data/models/supported_locale.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
class SupportedLocaleProvider extends StatefulWidget { class SupportedLocaleProvider extends StatefulWidget {
@ -23,7 +23,7 @@ class SupportedLocaleProviderState extends State<SupportedLocaleProvider> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
valueListenable = ValueNotifier(context.get<UserPreferencesService>().locale); valueListenable = ValueNotifier(ServiceProviders.userPreferencesServiceOf(context).locale);
} }
@override @override
@ -47,7 +47,7 @@ class SupportedLocaleProviderState extends State<SupportedLocaleProvider> {
void setLocale(SupportedLocale locale) { void setLocale(SupportedLocale locale) {
S.load(Locale(locale.intlName)).then((value) { S.load(Locale(locale.intlName)).then((value) {
valueListenable.value = locale; valueListenable.value = locale;
context.get<UserPreferencesService>().locale = locale; ServiceProviders.userPreferencesServiceOf(context).locale = locale;
}); });
} }
} }

View file

@ -4,6 +4,7 @@ import 'package:flutter/scheduler.dart';
import 'package:lightmeter/data/models/dynamic_colors_state.dart'; import 'package:lightmeter/data/models/dynamic_colors_state.dart';
import 'package:lightmeter/data/models/theme_type.dart'; import 'package:lightmeter/data/models/theme_type.dart';
import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
import 'package:material_color_utilities/material_color_utilities.dart'; import 'package:material_color_utilities/material_color_utilities.dart';
@ -44,7 +45,7 @@ class ThemeProvider extends StatefulWidget {
} }
class ThemeProviderState extends State<ThemeProvider> with WidgetsBindingObserver { class ThemeProviderState extends State<ThemeProvider> with WidgetsBindingObserver {
UserPreferencesService get _prefs => context.get<UserPreferencesService>(); UserPreferencesService get _prefs => ServiceProviders.userPreferencesServiceOf(context);
late final _themeTypeNotifier = ValueNotifier<ThemeType>(_prefs.themeType); late final _themeTypeNotifier = ValueNotifier<ThemeType>(_prefs.themeType);
late final _dynamicColorNotifier = ValueNotifier<bool>(_prefs.dynamicColor); late final _dynamicColorNotifier = ValueNotifier<bool>(_prefs.dynamicColor);

View file

@ -1,12 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/data/caffeine_service.dart';
import 'package:lightmeter/data/haptics_service.dart';
import 'package:lightmeter/data/light_sensor_service.dart';
import 'package:lightmeter/data/permissions_service.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/data/volume_events_service.dart';
import 'package:lightmeter/interactors/metering_interactor.dart'; import 'package:lightmeter/interactors/metering_interactor.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/screens/metering/bloc_metering.dart'; import 'package:lightmeter/screens/metering/bloc_metering.dart';
import 'package:lightmeter/screens/metering/communication/bloc_communication_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/components/shared/volume_keys_notifier/notifier_volume_keys.dart';
@ -25,15 +20,15 @@ class _MeteringFlowState extends State<MeteringFlow> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InheritedWidgetBase<MeteringInteractor>( return InheritedWidgetBase<MeteringInteractor>(
data: MeteringInteractor( data: MeteringInteractor(
context.get<UserPreferencesService>(), ServiceProviders.userPreferencesServiceOf(context),
context.get<CaffeineService>(), ServiceProviders.caffeineServiceOf(context),
context.get<HapticsService>(), ServiceProviders.hapticsServiceOf(context),
context.get<PermissionsService>(), ServiceProviders.permissionsServiceOf(context),
context.get<LightSensorService>(), ServiceProviders.lightSensorServiceOf(context),
context.get<VolumeEventsService>(), ServiceProviders.volumeEventsServiceOf(context),
)..initialize(), )..initialize(),
child: InheritedWidgetBase<VolumeKeysNotifier>( child: InheritedWidgetBase<VolumeKeysNotifier>(
data: VolumeKeysNotifier(context.get<VolumeEventsService>()), data: VolumeKeysNotifier(ServiceProviders.volumeEventsServiceOf(context)),
child: MultiBlocProvider( child: MultiBlocProvider(
providers: [ providers: [
BlocProvider(create: (_) => MeteringCommunicationBloc()), BlocProvider(create: (_) => MeteringCommunicationBloc()),

View file

@ -6,8 +6,8 @@ import 'package:lightmeter/data/models/ev_source_type.dart';
import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/exposure_pair.dart';
import 'package:lightmeter/data/models/film.dart'; import 'package:lightmeter/data/models/film.dart';
import 'package:lightmeter/data/models/metering_screen_layout_config.dart'; import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/providers/ev_source_type_provider.dart'; import 'package:lightmeter/providers/ev_source_type_provider.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/screens/metering/bloc_metering.dart'; import 'package:lightmeter/screens/metering/bloc_metering.dart';
import 'package:lightmeter/screens/metering/components/bottom_controls/provider_bottom_controls.dart'; import 'package:lightmeter/screens/metering/components/bottom_controls/provider_bottom_controls.dart';
import 'package:lightmeter/screens/metering/components/camera_container/provider_container_camera.dart'; import 'package:lightmeter/screens/metering/components/camera_container/provider_container_camera.dart';
@ -45,7 +45,7 @@ class MeteringScreen extends StatelessWidget {
builder: (context, state) => MeteringBottomControlsProvider( builder: (context, state) => MeteringBottomControlsProvider(
ev: state is MeteringDataState ? state.ev : null, ev: state is MeteringDataState ? state.ev : null,
isMetering: state.isMetering, isMetering: state.isMetering,
onSwitchEvSourceType: context.get<Environment>().hasLightSensor onSwitchEvSourceType: ServiceProviders.environmentOf(context).hasLightSensor
? EvSourceTypeProvider.of(context).toggleType ? EvSourceTypeProvider.of(context).toggleType
: null, : null,
onMeasure: () => context.read<MeteringBloc>().add(const MeasureEvent()), onMeasure: () => context.read<MeteringBloc>().add(const MeasureEvent()),

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class ReportIssueListTile extends StatelessWidget { class ReportIssueListTile extends StatelessWidget {
@ -14,7 +13,7 @@ class ReportIssueListTile extends StatelessWidget {
title: Text(S.of(context).reportIssue), title: Text(S.of(context).reportIssue),
onTap: () { onTap: () {
launchUrl( launchUrl(
Uri.parse(context.get<Environment>().issuesReportUrl), Uri.parse(ServiceProviders.environmentOf(context).issuesReportUrl),
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
); );
}, },

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class SourceCodeListTile extends StatelessWidget { class SourceCodeListTile extends StatelessWidget {
@ -14,7 +13,7 @@ class SourceCodeListTile extends StatelessWidget {
title: Text(S.of(context).sourceCode), title: Text(S.of(context).sourceCode),
onTap: () { onTap: () {
launchUrl( launchUrl(
Uri.parse(context.get<Environment>().sourceCodeUrl), Uri.parse(ServiceProviders.environmentOf(context).sourceCodeUrl),
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
); );
}, },

View file

@ -1,8 +1,7 @@
import 'package:clipboard/clipboard.dart'; import 'package:clipboard/clipboard.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/providers/service_providers.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class WriteEmailListTile extends StatelessWidget { class WriteEmailListTile extends StatelessWidget {
@ -14,7 +13,7 @@ class WriteEmailListTile extends StatelessWidget {
leading: const Icon(Icons.email), leading: const Icon(Icons.email),
title: Text(S.of(context).writeEmail), title: Text(S.of(context).writeEmail),
onTap: () { onTap: () {
final email = context.get<Environment>().contactEmail; final email = ServiceProviders.environmentOf(context).contactEmail;
final mailToUrl = Uri.parse('mailto:$email?subject=M3 Lightmeter'); final mailToUrl = Uri.parse('mailto:$email?subject=M3 Lightmeter');
canLaunchUrl(mailToUrl).then((canLaunch) { canLaunchUrl(mailToUrl).then((canLaunch) {
if (canLaunch) { if (canLaunch) {

View file

@ -1,13 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.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/event_dialog_calibration.dart'; import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/event_dialog_calibration.dart';
import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/state_dialog_calibration.dart'; import 'package:lightmeter/screens/settings/components/metering/components/calibration/components/calibration_dialog/state_dialog_calibration.dart';
import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart'; import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart';
import 'package:lightmeter/utils/inherited_generics.dart';
import 'package:lightmeter/utils/to_string_signed.dart'; import 'package:lightmeter/utils/to_string_signed.dart';
class CalibrationDialog extends StatelessWidget { class CalibrationDialog extends StatelessWidget {
@ -15,7 +14,7 @@ class CalibrationDialog extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool hasLightSensor = context.get<Environment>().hasLightSensor; final bool hasLightSensor = ServiceProviders.environmentOf(context).hasLightSensor;
return AlertDialog( return AlertDialog(
icon: const Icon(Icons.settings_brightness), icon: const Icon(Icons.settings_brightness),
titlePadding: Dimens.dialogIconTitlePadding, titlePadding: Dimens.dialogIconTitlePadding,

View file

@ -1,9 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/caffeine_service.dart';
import 'package:lightmeter/data/haptics_service.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/data/volume_events_service.dart';
import 'package:lightmeter/interactors/settings_interactor.dart'; import 'package:lightmeter/interactors/settings_interactor.dart';
import 'package:lightmeter/providers/service_providers.dart';
import 'package:lightmeter/screens/settings/screen_settings.dart'; import 'package:lightmeter/screens/settings/screen_settings.dart';
import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:lightmeter/utils/inherited_generics.dart';
@ -14,10 +11,10 @@ class SettingsFlow extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InheritedWidgetBase<SettingsInteractor>( return InheritedWidgetBase<SettingsInteractor>(
data: SettingsInteractor( data: SettingsInteractor(
context.get<UserPreferencesService>(), ServiceProviders.userPreferencesServiceOf(context),
context.get<CaffeineService>(), ServiceProviders.caffeineServiceOf(context),
context.get<HapticsService>(), ServiceProviders.hapticsServiceOf(context),
context.get<VolumeEventsService>(), ServiceProviders.volumeEventsServiceOf(context),
), ),
child: const SettingsScreen(), child: const SettingsScreen(),
); );