From 88ec7335962391f62d093796cf371f3f1ff96920 Mon Sep 17 00:00:00 2001 From: Vadim Date: Wed, 19 Jul 2023 16:59:17 +0200 Subject: [PATCH] Fixed `EquipmentProfileListener` --- README.md | 2 ++ iap/pubspec.yaml | 1 - lib/screens/metering/screen_metering.dart | 3 +- .../utils/equipment_profile_listener.dart | 30 +++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 lib/screens/metering/utils/equipment_profile_listener.dart diff --git a/README.md b/README.md index 4738791..3a6be61 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ m3_lightmeter_iap: ``` After that run `flutter pub get` as usual. +For the first run it will be necessary to open _iap/_ folder and run `flutter pub get` from there. + # Contribution To report a bug or suggest a new feature open a new [issue](https://github.com/vodemn/m3_lightmeter/issues). diff --git a/iap/pubspec.yaml b/iap/pubspec.yaml index c72466f..6aed37e 100644 --- a/iap/pubspec.yaml +++ b/iap/pubspec.yaml @@ -23,4 +23,3 @@ dev_dependencies: flutter: uses-material-design: true - diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index d13d8a3..e7c7259 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -15,6 +15,7 @@ import 'package:lightmeter/screens/metering/components/camera_container/provider import 'package:lightmeter/screens/metering/components/light_sensor_container/provider_container_light_sensor.dart'; import 'package:lightmeter/screens/metering/event_metering.dart'; import 'package:lightmeter/screens/metering/state_metering.dart'; +import 'package:lightmeter/screens/metering/utils/equipment_profile_listener.dart'; import 'package:lightmeter/utils/inherited_generics.dart'; import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -73,7 +74,7 @@ class _InheritedListeners extends StatelessWidget { @override Widget build(BuildContext context) { - return InheritedWidgetListener( + return EquipmentProfileListener( onDidChangeDependencies: (value) { context.read().add(EquipmentProfileChangedEvent(value)); }, diff --git a/lib/screens/metering/utils/equipment_profile_listener.dart b/lib/screens/metering/utils/equipment_profile_listener.dart new file mode 100644 index 0000000..68d03dc --- /dev/null +++ b/lib/screens/metering/utils/equipment_profile_listener.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; + +class EquipmentProfileListener extends StatefulWidget { + final ValueChanged onDidChangeDependencies; + final Widget child; + + const EquipmentProfileListener({ + required this.onDidChangeDependencies, + required this.child, + super.key, + }); + + @override + State createState() => _EquipmentProfileListenerState(); +} + +class _EquipmentProfileListenerState extends State { + @override + void didChangeDependencies() { + super.didChangeDependencies(); + widget.onDidChangeDependencies(EquipmentProfiles.selectedOf(context)); + } + + @override + Widget build(BuildContext context) { + return widget.child; + } +}