mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 17:00:39 +00:00
Synced _iap_ stub with repo
This commit is contained in:
parent
e06ee35265
commit
68ccc5f01e
5 changed files with 20 additions and 183 deletions
|
@ -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<Film> films = [];
|
||||
|
|
17
iap/lib/src/data/iap_storage_service.dart
Normal file
17
iap/lib/src/data/iap_storage_service.dart
Normal file
|
@ -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<EquipmentProfile> get equipmentProfiles => [];
|
||||
set equipmentProfiles(List<EquipmentProfile> profiles) {}
|
||||
|
||||
Film get selectedFilm => const Film.other();
|
||||
set selectedFilm(Film value) {}
|
||||
|
||||
List<Film> get filmsInUse => [];
|
||||
set filmsInUse(List<Film> profiles) {}
|
||||
}
|
|
@ -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<EquipmentProfileProviderState>()!;
|
||||
}
|
||||
|
||||
@override
|
||||
State<EquipmentProfileProvider> createState() => EquipmentProfileProviderState();
|
||||
}
|
||||
|
||||
class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
|
||||
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<EquipmentProfile> {
|
||||
const EquipmentProfiles({
|
||||
super.key,
|
||||
required super.values,
|
||||
required super.selected,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
static List<EquipmentProfile> of(BuildContext context) {
|
||||
return InheritedModel.inheritFrom<EquipmentProfiles>(context, aspect: SelectableAspect.list)!.values;
|
||||
}
|
||||
|
||||
static EquipmentProfile selectedOf(BuildContext context) {
|
||||
return InheritedModel.inheritFrom<EquipmentProfiles>(context, aspect: SelectableAspect.selected)!.selected;
|
||||
}
|
||||
}
|
|
@ -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<FilmsProviderState>()!;
|
||||
}
|
||||
|
||||
@override
|
||||
State<FilmsProvider> createState() => FilmsProviderState();
|
||||
}
|
||||
|
||||
class FilmsProviderState extends State<FilmsProvider> {
|
||||
@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<Film> films) {}
|
||||
}
|
||||
|
||||
class Films extends SelectableInheritedModel<Film> {
|
||||
final List<Film> 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<Film> of(BuildContext context) {
|
||||
return InheritedModel.inheritFrom<Films>(context)!.values;
|
||||
}
|
||||
|
||||
/// [Film.other()] + films in use selected by user
|
||||
static List<Film> inUseOf<T>(BuildContext context) {
|
||||
return InheritedModel.inheritFrom<Films>(
|
||||
context,
|
||||
aspect: SelectableAspect.list,
|
||||
)!
|
||||
.filmsInUse;
|
||||
}
|
||||
|
||||
static Film selectedOf(BuildContext context) {
|
||||
return InheritedModel.inheritFrom<Films>(context, aspect: SelectableAspect.selected)!.selected;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
enum SelectableAspect { list, selected }
|
||||
|
||||
class SelectableInheritedModel<T> extends InheritedModel<SelectableAspect> {
|
||||
const SelectableInheritedModel({
|
||||
super.key,
|
||||
required this.values,
|
||||
required this.selected,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
final List<T> values;
|
||||
final T selected;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(SelectableInheritedModel oldWidget) => true;
|
||||
|
||||
@override
|
||||
bool updateShouldNotifyDependent(SelectableInheritedModel oldWidget, Set<SelectableAspect> dependencies) {
|
||||
if (dependencies.contains(SelectableAspect.list)) {
|
||||
return true;
|
||||
} else if (dependencies.contains(SelectableAspect.selected)) {
|
||||
return selected != oldWidget.selected;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue