Files
eatvio_app/lib/features/diary/presentation/widgets/photo_gallery_widget.dart
2024-11-27 16:23:48 +03:00

168 lines
6.2 KiB
Dart

// import 'package:flutter/material.dart';
//
// class PhotoGalleryWidget extends StatefulWidget {
// const PhotoGalleryWidget({super.key});
//
// @override
// State<PhotoGalleryWidget> createState() => _PhotoGalleryWidgetState();
// }
//
// class _PhotoGalleryWidgetState extends State<PhotoGalleryWidget> {
// showImagePicker(DiaryDayModel diaryDay) {
// showCupertinoModalPopup<void>(
// context: context,
// builder: (context) => CupertinoActionSheet(
// actions: [
// CupertinoActionSheetAction(
// onPressed: () async {
// Navigator.of(context).pop();
// final picker = ImagePicker();
// XFile? image = await picker.pickImage(source: ImageSource.camera);
// if (image != null)
// diaryCubit.uploadPhotos(
// files: [File(image.path)],
// diaryId: diaryDay.id,
// mealId: diaryDay.meals[currentSelectedMealNumber - 1].id,
// date: _selectedDay.toString(),
// );
// },
// child: const Row(
// children: const [
// Icon(Icons.photo_camera),
// SizedBox(width: 8),
// Text('Фото'),
// ],
// ),
// ),
// CupertinoActionSheetAction(
// onPressed: () async {
// Navigator.of(context).pop();
// final picker = ImagePicker();
// List<XFile>? images = await picker.pickMultiImage();
// if (images.isNotEmpty)
// diaryCubit.uploadPhotos(
// files: images.map((f) => File(f.path)).toList(),
// diaryId: diaryDay.id,
// mealId: diaryDay.meals[currentSelectedMealNumber - 1].id,
// date: _selectedDay.toString(),
// );
// },
// child: const Row(
// children: const [
// Icon(Icons.photo),
// SizedBox(width: 8),
// Text('Галерея'),
// ],
// ),
// ),
// ],
// cancelButton: CupertinoActionSheetAction(
// onPressed: () => Navigator.of(context).pop(),
// isDestructiveAction: true,
// child: const Text('Отмена'),
// ),
// ),
// );
// }
//
// @override
// Widget build(BuildContext context) {
// return Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Stack(
// alignment: Alignment.topRight,
// children: [
// ClipRRect(
// borderRadius: BorderRadius.circular(12),
// child: CachedNetworkImage(
// imageUrl: baseUrl + '/storage/' + photos[currentSelectedPhotoIndex].path,
// ),
// ),
// Padding(
// padding: const EdgeInsets.all(12),
// child: IconButton.filled(
// style: IconButton.styleFrom(
// backgroundColor: Colors.white,
// elevation: 0,
// ),
// onPressed: () async {
// await diaryCubit.deletePhoto(
// photo: photos[currentSelectedPhotoIndex],
// diaryId: diaryDay.id,
// mealId: diaryDay.meals[currentSelectedMealNumber - 1].id,
// date: _selectedDay.toString(),
// );
// setState(() {
// if (currentSelectedPhotoIndex == photos.length - 1 && currentSelectedPhotoIndex != 0) {
// currentSelectedPhotoIndex = photos.length - 2;
// }
// });
// },
// icon: Icon(
// Icons.close_rounded,
// color: Colors.grey,
// ),
// ),
// ),
// ],
// ),
// const SizedBox(height: 8),
// SingleChildScrollView(
// physics: const BouncingScrollPhysics(),
// scrollDirection: Axis.horizontal,
// child: Row(
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// for (int i = 0; i < photos.length + 1; i++) ...[
// if (i == photos.length)
// Padding(
// padding: const EdgeInsets.only(left: 8),
// child: InkWell(
// onTap: () => _showImagePicker(diaryDay),
// borderRadius: BorderRadius.circular(8),
// child: Ink(
// height: 52,
// width: 52,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8),
// color: Color(0xFFF1F2F6),
// ),
// child: Icon(
// Icons.add_rounded,
// color: appTheme.blueA400,
// ),
// ),
// ),
// ),
// if (i < photos.length)
// GestureDetector(
// onTap: () {
// setState(() {
// currentSelectedPhotoIndex = i;
// });
// },
// child: ClipRRect(
// borderRadius: BorderRadius.circular(8),
// child: SizedBox(
// height: 52,
// width: 52,
// child: CachedNetworkImage(
// imageUrl: baseUrl + '/storage/' + photos[i].path,
// fit: BoxFit.fitWidth,
// ),
// ),
// ),
// ),
// if (i < photos.length - 1) const SizedBox(width: 8),
// ],
// ],
// ),
// ),
// ],
// );
// }
// }