From 68ccc5f01eb9c5131f79ea7cbacf71af713eb615 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:04:24 +0200 Subject: [PATCH] Synced _iap_ stub with repo --- iap/lib/m3_lightmeter_iap.dart | 31 +-------- iap/lib/src/data/iap_storage_service.dart | 17 +++++ .../providers/equipment_profile_provider.dart | 61 ----------------- iap/lib/src/providers/films_provider.dart | 65 ------------------- .../src/providers/selectable_provider.dart | 29 --------- 5 files changed, 20 insertions(+), 183 deletions(-) create mode 100644 iap/lib/src/data/iap_storage_service.dart delete mode 100644 iap/lib/src/providers/equipment_profile_provider.dart delete mode 100644 iap/lib/src/providers/films_provider.dart delete mode 100644 iap/lib/src/providers/selectable_provider.dart diff --git a/iap/lib/m3_lightmeter_iap.dart b/iap/lib/m3_lightmeter_iap.dart index 171fe47..43e69aa 100644 --- a/iap/lib/m3_lightmeter_iap.dart +++ b/iap/lib/m3_lightmeter_iap.dart @@ -1,34 +1,9 @@ library m3_lightmeter_iap; -import 'package:flutter/material.dart'; -import 'package:m3_lightmeter_iap/src/providers/equipment_profile_provider.dart'; -import 'package:m3_lightmeter_iap/src/providers/films_provider.dart'; -import 'package:m3_lightmeter_iap/src/providers/iap_products_provider.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; export 'src/data/models/iap_product.dart'; - -export 'src/providers/equipment_profile_provider.dart'; -export 'src/providers/films_provider.dart'; export 'src/providers/iap_products_provider.dart'; +export 'src/data/iap_storage_service.dart'; -class IAPProviders extends StatelessWidget { - final Object sharedPreferences; - final Widget child; - - const IAPProviders({ - required this.sharedPreferences, - required this.child, - super.key, - }); - - @override - Widget build(BuildContext context) { - return IAPProductsProvider( - child: FilmsProvider( - child: EquipmentProfileProvider( - child: child, - ), - ), - ); - } -} +const List films = []; diff --git a/iap/lib/src/data/iap_storage_service.dart b/iap/lib/src/data/iap_storage_service.dart new file mode 100644 index 0000000..f62f622 --- /dev/null +++ b/iap/lib/src/data/iap_storage_service.dart @@ -0,0 +1,17 @@ +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; + +class IAPStorageService { + const IAPStorageService(Object _); + + String get selectedEquipmentProfileId => ''; + set selectedEquipmentProfileId(String id) {} + + List get equipmentProfiles => []; + set equipmentProfiles(List profiles) {} + + Film get selectedFilm => const Film.other(); + set selectedFilm(Film value) {} + + List get filmsInUse => []; + set filmsInUse(List profiles) {} +} diff --git a/iap/lib/src/providers/equipment_profile_provider.dart b/iap/lib/src/providers/equipment_profile_provider.dart deleted file mode 100644 index 0a037a9..0000000 --- a/iap/lib/src/providers/equipment_profile_provider.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:m3_lightmeter_iap/src/providers/selectable_provider.dart'; -import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; - -class EquipmentProfileProvider extends StatefulWidget { - final Widget child; - - const EquipmentProfileProvider({required this.child, super.key}); - - static EquipmentProfileProviderState of(BuildContext context) { - return context.findAncestorStateOfType()!; - } - - @override - State createState() => EquipmentProfileProviderState(); -} - -class EquipmentProfileProviderState extends State { - static const EquipmentProfile _defaultProfile = EquipmentProfile( - id: '', - name: '', - apertureValues: ApertureValue.values, - ndValues: NdValue.values, - shutterSpeedValues: ShutterSpeedValue.values, - isoValues: IsoValue.values, - ); - - @override - Widget build(BuildContext context) { - return EquipmentProfiles( - values: const [_defaultProfile], - selected: _defaultProfile, - child: widget.child, - ); - } - - void setProfile(EquipmentProfile data) {} - - void addProfile(String name, [EquipmentProfile? copyFrom]) {} - - void updateProdile(EquipmentProfile data) {} - - void deleteProfile(EquipmentProfile data) {} -} - -class EquipmentProfiles extends SelectableInheritedModel { - const EquipmentProfiles({ - super.key, - required super.values, - required super.selected, - required super.child, - }); - - static List of(BuildContext context) { - return InheritedModel.inheritFrom(context, aspect: SelectableAspect.list)!.values; - } - - static EquipmentProfile selectedOf(BuildContext context) { - return InheritedModel.inheritFrom(context, aspect: SelectableAspect.selected)!.selected; - } -} diff --git a/iap/lib/src/providers/films_provider.dart b/iap/lib/src/providers/films_provider.dart deleted file mode 100644 index e75ccd3..0000000 --- a/iap/lib/src/providers/films_provider.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:m3_lightmeter_iap/src/providers/selectable_provider.dart'; -import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; - -class FilmsProvider extends StatefulWidget { - final Widget child; - - const FilmsProvider({ - required this.child, - super.key, - }); - - static FilmsProviderState of(BuildContext context) { - return context.findAncestorStateOfType()!; - } - - @override - State createState() => FilmsProviderState(); -} - -class FilmsProviderState extends State { - @override - Widget build(BuildContext context) { - return Films( - values: const [Film.other()], - filmsInUse: const [Film.other()], - selected: const Film.other(), - child: widget.child, - ); - } - - void setFilm(Film film) {} - - void saveFilms(List films) {} -} - -class Films extends SelectableInheritedModel { - final List filmsInUse; - - const Films({ - super.key, - required super.values, - required this.filmsInUse, - required super.selected, - required super.child, - }); - - /// [Film.other()] + all the custom fields with actual reciprocity formulas - static List of(BuildContext context) { - return InheritedModel.inheritFrom(context)!.values; - } - - /// [Film.other()] + films in use selected by user - static List inUseOf(BuildContext context) { - return InheritedModel.inheritFrom( - context, - aspect: SelectableAspect.list, - )! - .filmsInUse; - } - - static Film selectedOf(BuildContext context) { - return InheritedModel.inheritFrom(context, aspect: SelectableAspect.selected)!.selected; - } -} diff --git a/iap/lib/src/providers/selectable_provider.dart b/iap/lib/src/providers/selectable_provider.dart deleted file mode 100644 index c18f998..0000000 --- a/iap/lib/src/providers/selectable_provider.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; - -enum SelectableAspect { list, selected } - -class SelectableInheritedModel extends InheritedModel { - const SelectableInheritedModel({ - super.key, - required this.values, - required this.selected, - required super.child, - }); - - final List values; - final T selected; - - @override - bool updateShouldNotify(SelectableInheritedModel oldWidget) => true; - - @override - bool updateShouldNotifyDependent(SelectableInheritedModel oldWidget, Set dependencies) { - if (dependencies.contains(SelectableAspect.list)) { - return true; - } else if (dependencies.contains(SelectableAspect.selected)) { - return selected != oldWidget.selected; - } else { - return false; - } - } -}