2022-10-26 19:49:21 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-12-16 08:08:12 +00:00
|
|
|
import 'package:lightmeter/data/models/exposure_pair.dart';
|
2023-09-02 08:32:08 +00:00
|
|
|
import 'package:lightmeter/generated/l10n.dart';
|
2023-10-20 14:12:43 +00:00
|
|
|
import 'package:lightmeter/providers/films_provider.dart';
|
2022-10-26 19:49:21 +00:00
|
|
|
import 'package:lightmeter/res/dimens.dart';
|
2023-05-11 13:30:18 +00:00
|
|
|
import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart';
|
2023-09-02 08:32:08 +00:00
|
|
|
import 'package:lightmeter/screens/shared/icon_placeholder/widget_icon_placeholder.dart';
|
2024-05-07 17:24:51 +00:00
|
|
|
import 'package:lightmeter/utils/context_utils.dart';
|
2022-10-26 19:49:21 +00:00
|
|
|
|
|
|
|
class ExposurePairsList extends StatelessWidget {
|
2022-10-29 18:02:45 +00:00
|
|
|
final List<ExposurePair> exposurePairs;
|
2024-05-07 17:24:51 +00:00
|
|
|
final ValueChanged<ExposurePair> onExposurePairTap;
|
2022-10-26 19:49:21 +00:00
|
|
|
|
2024-05-07 17:24:51 +00:00
|
|
|
const ExposurePairsList(this.exposurePairs, {required this.onExposurePairTap, super.key});
|
2022-10-26 19:49:21 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-04 14:17:40 +00:00
|
|
|
return AnimatedSwitcher(
|
|
|
|
duration: Dimens.switchDuration,
|
|
|
|
child: exposurePairs.isEmpty
|
2023-09-02 08:32:08 +00:00
|
|
|
? IconPlaceholder(
|
|
|
|
icon: Icons.not_interested,
|
|
|
|
text: S.of(context).noExposurePairs,
|
|
|
|
)
|
2023-08-04 14:17:40 +00:00
|
|
|
: Stack(
|
2022-12-16 21:25:08 +00:00
|
|
|
alignment: Alignment.center,
|
2022-10-26 19:49:21 +00:00
|
|
|
children: [
|
2023-08-04 14:17:40 +00:00
|
|
|
Positioned.fill(
|
|
|
|
child: ListView.builder(
|
|
|
|
key: ValueKey(exposurePairs.hashCode),
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL),
|
|
|
|
itemCount: exposurePairs.length,
|
2024-05-07 17:24:51 +00:00
|
|
|
itemBuilder: (_, index) {
|
|
|
|
final exposurePair = ExposurePair(
|
|
|
|
exposurePairs[index].aperture,
|
|
|
|
Films.selectedOf(context).reciprocityFailure(exposurePairs[index].shutterSpeed),
|
|
|
|
);
|
|
|
|
return Stack(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: [
|
|
|
|
GestureDetector(
|
|
|
|
onTap: context.isPro ? () => onExposurePairTap(exposurePair) : null,
|
|
|
|
child: Row(
|
|
|
|
key: ValueKey(index),
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: ExposurePairsListItem(
|
|
|
|
exposurePair.aperture,
|
|
|
|
tickOnTheLeft: false,
|
|
|
|
),
|
|
|
|
),
|
2023-08-04 14:17:40 +00:00
|
|
|
),
|
2024-05-07 17:24:51 +00:00
|
|
|
Expanded(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: ExposurePairsListItem(
|
|
|
|
exposurePair.shutterSpeed,
|
|
|
|
tickOnTheLeft: true,
|
|
|
|
),
|
|
|
|
),
|
2023-08-04 14:17:40 +00:00
|
|
|
),
|
2024-05-07 17:24:51 +00:00
|
|
|
],
|
2023-08-04 14:17:40 +00:00
|
|
|
),
|
2024-05-07 17:24:51 +00:00
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) => Align(
|
|
|
|
alignment: index == 0
|
|
|
|
? Alignment.bottomCenter
|
|
|
|
: (index == exposurePairs.length - 1 ? Alignment.topCenter : Alignment.center),
|
|
|
|
child: SizedBox(
|
|
|
|
height: index == 0 || index == exposurePairs.length - 1
|
|
|
|
? constraints.maxHeight / 2
|
|
|
|
: constraints.maxHeight,
|
|
|
|
child: ColoredBox(
|
|
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
|
|
child: const SizedBox(width: 1),
|
|
|
|
),
|
2023-08-04 14:17:40 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-05-07 17:24:51 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2022-10-26 19:49:21 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|