2025-07-09 19:48:24 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2025-07-10 13:43:54 +00:00
|
|
|
import 'package:lightmeter/generated/l10n.dart';
|
2025-07-09 19:48:24 +00:00
|
|
|
import 'package:lightmeter/navigation/routes.dart';
|
|
|
|
import 'package:lightmeter/platform_config.dart';
|
|
|
|
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
|
|
|
import 'package:lightmeter/res/dimens.dart';
|
|
|
|
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
|
|
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|
|
|
|
|
|
|
class LogbookScreen extends StatefulWidget {
|
|
|
|
const LogbookScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<LogbookScreen> createState() => _LogbookScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _LogbookScreenState extends State<LogbookScreen> with SingleTickerProviderStateMixin {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SliverScreen(
|
2025-07-10 13:43:54 +00:00
|
|
|
title: Text(S.of(context).logbook),
|
2025-07-09 19:48:24 +00:00
|
|
|
slivers: [
|
|
|
|
_PicturesGridBuilder(
|
|
|
|
values: LogbookPhotos.of(context),
|
|
|
|
onEdit: _editProfile,
|
|
|
|
),
|
|
|
|
SliverToBoxAdapter(
|
|
|
|
child: SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-07-09 22:08:57 +00:00
|
|
|
void _editProfile(LogbookPhoto photo) {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
NavigationRoutes.logbookPhotoEditScreen.name,
|
|
|
|
arguments: photo,
|
|
|
|
);
|
|
|
|
}
|
2025-07-09 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _PicturesGridBuilder extends StatelessWidget {
|
|
|
|
final List<LogbookPhoto> values;
|
|
|
|
final void Function(LogbookPhoto photo) onEdit;
|
|
|
|
|
|
|
|
static const int _crossAxisCount = 3;
|
|
|
|
|
|
|
|
const _PicturesGridBuilder({
|
|
|
|
required this.values,
|
|
|
|
required this.onEdit,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SliverGrid(
|
|
|
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
|
|
|
maxCrossAxisExtent:
|
|
|
|
(MediaQuery.sizeOf(context).width - Dimens.paddingS * (_crossAxisCount - 1)) / _crossAxisCount,
|
|
|
|
mainAxisSpacing: Dimens.paddingS,
|
|
|
|
crossAxisSpacing: Dimens.paddingS,
|
|
|
|
childAspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
|
|
|
),
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int index) {
|
2025-07-09 22:08:57 +00:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () => onEdit(values[index]),
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
color: Colors.teal[100 * (index % 9)],
|
|
|
|
child: Image.file(File(values[index].name)),
|
|
|
|
),
|
2025-07-09 19:48:24 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
childCount: values.length,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|