mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 16:30:40 +00:00
sync with resources
This commit is contained in:
parent
98262fc4ee
commit
4498167ddc
10 changed files with 40 additions and 61 deletions
|
@ -9,7 +9,7 @@ class IAPStorageService {
|
||||||
List<EquipmentProfile> get equipmentProfiles => [];
|
List<EquipmentProfile> get equipmentProfiles => [];
|
||||||
set equipmentProfiles(List<EquipmentProfile> profiles) {}
|
set equipmentProfiles(List<EquipmentProfile> profiles) {}
|
||||||
|
|
||||||
Film get selectedFilm => const Film.other();
|
Film get selectedFilm => const FilmStub();
|
||||||
set selectedFilm(Film value) {}
|
set selectedFilm(Film value) {}
|
||||||
|
|
||||||
List<Film> get filmsInUse => [];
|
List<Film> get filmsInUse => [];
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MockIAPProviders extends StatefulWidget {
|
||||||
this.selectedEquipmentProfileId = '',
|
this.selectedEquipmentProfileId = '',
|
||||||
List<Film>? availableFilms,
|
List<Film>? availableFilms,
|
||||||
List<Film>? filmsInUse,
|
List<Film>? filmsInUse,
|
||||||
this.selectedFilm = const Film.other(),
|
this.selectedFilm = const FilmStub(),
|
||||||
required this.child,
|
required this.child,
|
||||||
super.key,
|
super.key,
|
||||||
}) : availableFilms = availableFilms ?? mockFilms,
|
}) : availableFilms = availableFilms ?? mockFilms,
|
||||||
|
@ -128,13 +128,9 @@ final mockEquipmentProfiles = [
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
const mockFilms = [_MockFilm(100, 2), _MockFilm(400, 2), _MockFilm(3, 800), _MockFilm(400, 1.5)];
|
const mockFilms = [
|
||||||
|
FilmExponential(id: '1', name: 'Mock film 1', iso: 100, exponent: 1.34),
|
||||||
class _MockFilm extends Film {
|
FilmExponential(id: '2', name: 'Mock film 2', iso: 400, exponent: 1.34),
|
||||||
final double reciprocityMultiplier;
|
FilmExponential(id: '3', name: 'Mock film 3', iso: 800, exponent: 1.34),
|
||||||
|
FilmExponential(id: '4', name: 'Mock film 4', iso: 1200, exponent: 1.34),
|
||||||
const _MockFilm(int iso, this.reciprocityMultiplier) : super('Mock film $iso x$reciprocityMultiplier', iso);
|
];
|
||||||
|
|
||||||
@override
|
|
||||||
double reciprocityFormula(double t) => t * reciprocityMultiplier;
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ extension WidgetTesterCommonActions on WidgetTester {
|
||||||
String selectedEquipmentProfileId = '',
|
String selectedEquipmentProfileId = '',
|
||||||
List<Film>? availableFilms,
|
List<Film>? availableFilms,
|
||||||
List<Film>? filmsInUse,
|
List<Film>? filmsInUse,
|
||||||
Film selectedFilm = const Film.other(),
|
Film selectedFilm = const FilmStub(),
|
||||||
}) async {
|
}) async {
|
||||||
await pumpWidget(
|
await pumpWidget(
|
||||||
MockIAPProductsProvider(
|
MockIAPProductsProvider(
|
||||||
|
|
|
@ -40,14 +40,14 @@ class FilmsProviderState extends State<FilmsProvider> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Films(
|
return Films(
|
||||||
values: [
|
values: [
|
||||||
const Film.other(),
|
const FilmStub(),
|
||||||
...widget.availableFilms ?? films,
|
...widget.availableFilms ?? films,
|
||||||
],
|
],
|
||||||
filmsInUse: [
|
filmsInUse: [
|
||||||
const Film.other(),
|
const FilmStub(),
|
||||||
if (context.isPro) ..._filmsInUse,
|
if (context.isPro) ..._filmsInUse,
|
||||||
],
|
],
|
||||||
selected: context.isPro ? _selected : const Film.other(),
|
selected: context.isPro ? _selected : const FilmStub(),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ class FilmsProviderState extends State<FilmsProvider> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _discardSelectedIfNotIncluded() {
|
void _discardSelectedIfNotIncluded() {
|
||||||
if (_selected != const Film.other() && !_filmsInUse.contains(_selected)) {
|
if (_selected != const FilmStub() && !_filmsInUse.contains(_selected)) {
|
||||||
_selected = const Film.other();
|
_selected = const FilmStub();
|
||||||
widget.storageService.selectedFilm = const Film.other();
|
widget.storageService.selectedFilm = const FilmStub();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,12 +86,12 @@ class Films extends SelectableInheritedModel<Film> {
|
||||||
required super.child,
|
required super.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// [Film.other()] + all the custom fields with actual reciprocity formulas
|
/// [FilmStub()] + all the custom fields with actual reciprocity formulas
|
||||||
static List<Film> of(BuildContext context) {
|
static List<Film> of(BuildContext context) {
|
||||||
return InheritedModel.inheritFrom<Films>(context)!.values;
|
return InheritedModel.inheritFrom<Films>(context)!.values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Film.other()] + films in use selected by user
|
/// [FilmStub()] + films in use selected by user
|
||||||
static List<Film> inUseOf<T>(BuildContext context) {
|
static List<Film> inUseOf<T>(BuildContext context) {
|
||||||
return InheritedModel.inheritFrom<Films>(
|
return InheritedModel.inheritFrom<Films>(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -30,7 +30,7 @@ class FilmPicker extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
String _label(BuildContext context) {
|
String _label(BuildContext context) {
|
||||||
if (Films.selectedOf(context) == const Film.other() || Films.selectedOf(context).iso == selectedIso.value) {
|
if (Films.selectedOf(context) == const FilmStub() || Films.selectedOf(context).iso == selectedIso.value) {
|
||||||
return S.of(context).film;
|
return S.of(context).film;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MeteringScreenLayoutListTile extends StatelessWidget {
|
||||||
EquipmentProfileProvider.of(context).setProfile(EquipmentProfiles.of(context).first);
|
EquipmentProfileProvider.of(context).setProfile(EquipmentProfiles.of(context).first);
|
||||||
}
|
}
|
||||||
if (!value[MeteringScreenLayoutFeature.filmPicker]!) {
|
if (!value[MeteringScreenLayoutFeature.filmPicker]!) {
|
||||||
FilmsProvider.of(context).setFilm(const Film.other());
|
FilmsProvider.of(context).setFilm(const FilmStub());
|
||||||
}
|
}
|
||||||
UserPreferencesProvider.of(context).setMeteringScreenLayout(value);
|
UserPreferencesProvider.of(context).setMeteringScreenLayout(value);
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,7 +32,7 @@ import 'models/screenshot_args.dart';
|
||||||
|
|
||||||
//https://stackoverflow.com/a/67186625/13167574
|
//https://stackoverflow.com/a/67186625/13167574
|
||||||
|
|
||||||
const _mockFilm = Film('Ilford HP5+', 400);
|
const _mockFilm = FilmExponential(id: '1', name: 'Ilford HP5+', iso: 400, exponent: 1.34);
|
||||||
final Color _lightThemeColor = primaryColorsList[5];
|
final Color _lightThemeColor = primaryColorsList[5];
|
||||||
final Color _darkThemeColor = primaryColorsList[3];
|
final Color _darkThemeColor = primaryColorsList[3];
|
||||||
final ThemeData _themeLight = themeFrom(_lightThemeColor, Brightness.light);
|
final ThemeData _themeLight = themeFrom(_lightThemeColor, Brightness.light);
|
||||||
|
|
|
@ -96,7 +96,7 @@ void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Select films in use',
|
'Select films in use',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
when(() => mockIAPStorageService.selectedFilm).thenReturn(const Film.other());
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub());
|
||||||
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
|
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
|
||||||
|
|
||||||
/// Init
|
/// Init
|
||||||
|
@ -113,14 +113,14 @@ void main() {
|
||||||
expectSelectedFilmName('');
|
expectSelectedFilmName('');
|
||||||
|
|
||||||
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(0).toList()).called(1);
|
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(0).toList()).called(1);
|
||||||
verifyNever(() => mockIAPStorageService.selectedFilm = const Film.other());
|
verifyNever(() => mockIAPStorageService.selectedFilm = const FilmStub());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Select film',
|
'Select film',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
when(() => mockIAPStorageService.selectedFilm).thenReturn(const Film.other());
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub());
|
||||||
when(() => mockIAPStorageService.filmsInUse).thenReturn(mockFilms);
|
when(() => mockIAPStorageService.filmsInUse).thenReturn(mockFilms);
|
||||||
|
|
||||||
/// Init
|
/// Init
|
||||||
|
@ -156,14 +156,14 @@ void main() {
|
||||||
expectSelectedFilmName('');
|
expectSelectedFilmName('');
|
||||||
|
|
||||||
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
|
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
|
||||||
verify(() => mockIAPStorageService.selectedFilm = const Film.other()).called(1);
|
verify(() => mockIAPStorageService.selectedFilm = const FilmStub()).called(1);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'None film selected',
|
'None film selected',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
when(() => mockIAPStorageService.selectedFilm).thenReturn(const Film.other());
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub());
|
||||||
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
|
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
|
||||||
|
|
||||||
/// Init
|
/// Init
|
||||||
|
@ -172,7 +172,7 @@ void main() {
|
||||||
expectSelectedFilmName('');
|
expectSelectedFilmName('');
|
||||||
|
|
||||||
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
|
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
|
||||||
verifyNever(() => mockIAPStorageService.selectedFilm = const Film.other());
|
verifyNever(() => mockIAPStorageService.selectedFilm = const FilmStub());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -198,7 +198,7 @@ void main() {
|
||||||
expectSelectedFilmName('');
|
expectSelectedFilmName('');
|
||||||
|
|
||||||
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(1).toList()).called(1);
|
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(1).toList()).called(1);
|
||||||
verify(() => mockIAPStorageService.selectedFilm = const Film.other()).called(1);
|
verify(() => mockIAPStorageService.selectedFilm = const FilmStub()).called(1);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -252,25 +252,8 @@ class _Application extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockFilms = [_MockFilm2x(), _MockFilm3x(), _MockFilm4x()];
|
const mockFilms = [
|
||||||
|
FilmExponential(id: '1', name: 'Mock film 2x', iso: 400, exponent: 1.34),
|
||||||
class _MockFilm2x extends Film {
|
FilmExponential(id: '2', name: 'Mock film 3x', iso: 800, exponent: 1.34),
|
||||||
const _MockFilm2x() : super('Mock film 2x', 400);
|
FilmExponential(id: '3', name: 'Mock film 4x', iso: 1200, exponent: 1.34),
|
||||||
|
];
|
||||||
@override
|
|
||||||
double reciprocityFormula(double t) => t * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MockFilm3x extends Film {
|
|
||||||
const _MockFilm3x() : super('Mock film 3x', 800);
|
|
||||||
|
|
||||||
@override
|
|
||||||
double reciprocityFormula(double t) => t * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MockFilm4x extends Film {
|
|
||||||
const _MockFilm4x() : super('Mock film 4x', 1600);
|
|
||||||
|
|
||||||
@override
|
|
||||||
double reciprocityFormula(double t) => t * 4;
|
|
||||||
}
|
|
||||||
|
|
|
@ -50,9 +50,9 @@ extension WidgetTesterActions on WidgetTester {
|
||||||
}) async {
|
}) async {
|
||||||
await pumpWidget(
|
await pumpWidget(
|
||||||
Films(
|
Films(
|
||||||
values: const [Film.other()],
|
values: const [FilmStub()],
|
||||||
filmsInUse: const [Film.other()],
|
filmsInUse: const [FilmStub()],
|
||||||
selected: const Film.other(),
|
selected: const FilmStub(),
|
||||||
child: WidgetTestApplicationMock(
|
child: WidgetTestApplicationMock(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -51,7 +51,7 @@ void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Film.other()',
|
'Film.other()',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
when(() => mockIAPStorageService.selectedFilm).thenReturn(const Film.other());
|
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub());
|
||||||
await pumpApplication(tester);
|
await pumpApplication(tester);
|
||||||
expectReadingValueContainerText(S.current.film);
|
expectReadingValueContainerText(S.current.film);
|
||||||
expectReadingValueContainerText(S.current.none);
|
expectReadingValueContainerText(S.current.none);
|
||||||
|
@ -104,8 +104,8 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _films = [
|
const _films = [
|
||||||
Film('ISO 100 Film', 100),
|
FilmExponential(id: '', name: 'ISO 100 Film', iso: 100, exponent: 1.34),
|
||||||
Film('ISO 400 Film', 400),
|
FilmExponential(id: '', name: 'ISO 400 Film', iso: 400, exponent: 1.34),
|
||||||
Film('ISO 800 Film', 800),
|
FilmExponential(id: '', name: 'ISO 800 Film', iso: 800, exponent: 1.34),
|
||||||
Film('ISO 1600 Film', 1600),
|
FilmExponential(id: '', name: 'ISO 1600 Film', iso: 1600, exponent: 1.34),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue