2023-10-20 14:12:43 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
|
|
|
import 'package:lightmeter/providers/films_provider.dart';
|
|
|
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
|
|
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|
|
|
import 'package:mocktail/mocktail.dart';
|
|
|
|
|
|
|
|
class _MockIAPStorageService extends Mock implements IAPStorageService {}
|
|
|
|
|
|
|
|
class MockIAPProviders extends StatefulWidget {
|
2024-03-13 14:34:26 +00:00
|
|
|
final List<EquipmentProfile>? equipmentProfiles;
|
2023-10-20 14:12:43 +00:00
|
|
|
final String selectedEquipmentProfileId;
|
2024-04-30 10:44:01 +00:00
|
|
|
final List<Film> availableFilms;
|
|
|
|
final List<Film> filmsInUse;
|
2023-10-20 14:12:43 +00:00
|
|
|
final Film selectedFilm;
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
const MockIAPProviders({
|
2024-02-21 11:33:25 +00:00
|
|
|
this.equipmentProfiles = const [],
|
2023-10-20 14:12:43 +00:00
|
|
|
this.selectedEquipmentProfileId = '',
|
2024-04-30 10:44:01 +00:00
|
|
|
List<Film>? availableFilms,
|
|
|
|
List<Film>? filmsInUse,
|
2024-10-06 18:26:40 +00:00
|
|
|
this.selectedFilm = const FilmStub(),
|
2023-10-20 14:12:43 +00:00
|
|
|
required this.child,
|
|
|
|
super.key,
|
2024-04-30 10:44:01 +00:00
|
|
|
}) : availableFilms = availableFilms ?? mockFilms,
|
|
|
|
filmsInUse = filmsInUse ?? mockFilms;
|
2023-10-20 14:12:43 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<MockIAPProviders> createState() => _MockIAPProvidersState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MockIAPProvidersState extends State<MockIAPProviders> {
|
|
|
|
late final _MockIAPStorageService mockIAPStorageService;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
mockIAPStorageService = _MockIAPStorageService();
|
2024-03-13 14:34:26 +00:00
|
|
|
when(() => mockIAPStorageService.equipmentProfiles).thenReturn(widget.equipmentProfiles ?? mockEquipmentProfiles);
|
2023-10-20 14:12:43 +00:00
|
|
|
when(() => mockIAPStorageService.selectedEquipmentProfileId).thenReturn(widget.selectedEquipmentProfileId);
|
2024-04-30 10:44:01 +00:00
|
|
|
when(() => mockIAPStorageService.filmsInUse).thenReturn(widget.filmsInUse);
|
2023-10-20 14:12:43 +00:00
|
|
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(widget.selectedFilm);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return EquipmentProfileProvider(
|
|
|
|
storageService: mockIAPStorageService,
|
|
|
|
child: FilmsProvider(
|
|
|
|
storageService: mockIAPStorageService,
|
2024-04-30 10:44:01 +00:00
|
|
|
availableFilms: widget.availableFilms,
|
2023-10-20 14:12:43 +00:00
|
|
|
child: widget.child,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultEquipmentProfile = EquipmentProfile(
|
|
|
|
id: '',
|
|
|
|
name: '',
|
|
|
|
apertureValues: ApertureValue.values,
|
|
|
|
ndValues: NdValue.values,
|
|
|
|
shutterSpeedValues: ShutterSpeedValue.values,
|
|
|
|
isoValues: IsoValue.values,
|
|
|
|
);
|
|
|
|
|
|
|
|
final mockEquipmentProfiles = [
|
|
|
|
EquipmentProfile(
|
|
|
|
id: '1',
|
|
|
|
name: 'Praktica + Zenitar',
|
|
|
|
apertureValues: ApertureValue.values.sublist(
|
|
|
|
ApertureValue.values.indexOf(const ApertureValue(1.7, StopType.half)),
|
|
|
|
ApertureValue.values.indexOf(const ApertureValue(16, StopType.full)) + 1,
|
|
|
|
),
|
2024-02-21 11:33:25 +00:00
|
|
|
ndValues: const [
|
|
|
|
NdValue(0),
|
|
|
|
NdValue(2),
|
|
|
|
NdValue(4),
|
|
|
|
NdValue(8),
|
|
|
|
],
|
2023-10-20 14:12:43 +00:00
|
|
|
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
|
|
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
2024-04-30 10:44:01 +00:00
|
|
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1,
|
2023-10-20 14:12:43 +00:00
|
|
|
),
|
|
|
|
isoValues: const [
|
|
|
|
IsoValue(50, StopType.full),
|
|
|
|
IsoValue(100, StopType.full),
|
|
|
|
IsoValue(200, StopType.full),
|
|
|
|
IsoValue(250, StopType.third),
|
|
|
|
IsoValue(400, StopType.full),
|
|
|
|
IsoValue(500, StopType.third),
|
|
|
|
IsoValue(800, StopType.full),
|
|
|
|
IsoValue(1600, StopType.full),
|
|
|
|
IsoValue(3200, StopType.full),
|
|
|
|
],
|
2024-04-07 08:54:57 +00:00
|
|
|
lensZoom: 1.91,
|
2023-10-20 14:12:43 +00:00
|
|
|
),
|
2024-03-13 14:34:26 +00:00
|
|
|
EquipmentProfile(
|
2023-10-20 14:12:43 +00:00
|
|
|
id: '2',
|
|
|
|
name: 'Praktica + Jupiter',
|
2024-03-13 14:34:26 +00:00
|
|
|
apertureValues: ApertureValue.values.sublist(
|
|
|
|
ApertureValue.values.indexOf(const ApertureValue(3.5, StopType.third)),
|
|
|
|
ApertureValue.values.indexOf(const ApertureValue(22, StopType.full)) + 1,
|
|
|
|
),
|
|
|
|
ndValues: const [
|
|
|
|
NdValue(0),
|
|
|
|
NdValue(2),
|
|
|
|
NdValue(4),
|
|
|
|
NdValue(8),
|
|
|
|
],
|
|
|
|
shutterSpeedValues: ShutterSpeedValue.values.sublist(
|
|
|
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
|
2024-04-30 10:44:01 +00:00
|
|
|
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1,
|
2024-03-13 14:34:26 +00:00
|
|
|
),
|
|
|
|
isoValues: const [
|
|
|
|
IsoValue(50, StopType.full),
|
|
|
|
IsoValue(100, StopType.full),
|
|
|
|
IsoValue(200, StopType.full),
|
|
|
|
IsoValue(250, StopType.third),
|
|
|
|
IsoValue(400, StopType.full),
|
|
|
|
IsoValue(500, StopType.third),
|
|
|
|
IsoValue(800, StopType.full),
|
|
|
|
IsoValue(1600, StopType.full),
|
|
|
|
IsoValue(3200, StopType.full),
|
|
|
|
],
|
2024-04-07 08:54:57 +00:00
|
|
|
lensZoom: 5.02,
|
2023-10-20 14:12:43 +00:00
|
|
|
),
|
|
|
|
];
|
|
|
|
|
2024-10-06 18:26:40 +00:00
|
|
|
const mockFilms = [
|
|
|
|
FilmExponential(id: '1', name: 'Mock film 1', iso: 100, exponent: 1.34),
|
|
|
|
FilmExponential(id: '2', name: 'Mock film 2', iso: 400, exponent: 1.34),
|
|
|
|
FilmExponential(id: '3', name: 'Mock film 3', iso: 800, exponent: 1.34),
|
|
|
|
FilmExponential(id: '4', name: 'Mock film 4', iso: 1200, exponent: 1.34),
|
|
|
|
];
|