2022-12-29 08:45:28 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '/models/gallery_album.dart';
|
|
|
|
import '../../../controller/gallery_controller.dart';
|
|
|
|
import 'date_category_view.dart';
|
|
|
|
import 'selected_medias_view.dart';
|
|
|
|
|
|
|
|
class AlbumMediasView extends StatelessWidget {
|
2022-12-30 05:18:18 +03:00
|
|
|
final PhoneGalleryController controller;
|
|
|
|
final bool singleMedia;
|
|
|
|
const AlbumMediasView(
|
2022-12-29 08:45:28 +03:00
|
|
|
{super.key,
|
|
|
|
required this.galleryAlbum,
|
|
|
|
required this.controller,
|
|
|
|
required this.singleMedia});
|
2022-12-30 05:18:18 +03:00
|
|
|
final GalleryAlbum galleryAlbum;
|
2022-12-29 08:45:28 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Stack(
|
|
|
|
children: [
|
|
|
|
ListView(
|
|
|
|
children: [
|
2022-12-31 16:43:05 +03:00
|
|
|
for (var category in checkCategories(galleryAlbum.dateCategories))
|
2022-12-29 08:45:28 +03:00
|
|
|
DateCategoryWiew(
|
|
|
|
category: category,
|
|
|
|
controller: controller,
|
|
|
|
singleMedia: singleMedia,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (controller.selectedFiles.isNotEmpty)
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
child: SelectedMediasView(
|
|
|
|
controller: controller,
|
|
|
|
))
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2022-12-31 16:43:05 +03:00
|
|
|
|
|
|
|
List<DateCategory> checkCategories(List<DateCategory> categories) {
|
|
|
|
if (controller.isRecent &&
|
|
|
|
controller.extraRecentMedia != null &&
|
|
|
|
controller.extraRecentMedia!.isNotEmpty) {
|
|
|
|
List<DateCategory> categoriesTmp = categories.map((e) => e).toList();
|
|
|
|
int index = categoriesTmp
|
|
|
|
.indexWhere((element) => element.name == controller.config.recent);
|
|
|
|
if (index != -1) {
|
|
|
|
DateCategory category = DateCategory(files: [
|
|
|
|
...controller.extraRecentMedia!,
|
|
|
|
...categoriesTmp[index].files
|
|
|
|
], name: categoriesTmp[index].name);
|
|
|
|
categoriesTmp[index] = category;
|
|
|
|
return categoriesTmp;
|
|
|
|
} else {
|
|
|
|
return [
|
|
|
|
DateCategory(
|
|
|
|
files: controller.extraRecentMedia!,
|
|
|
|
name: controller.config.recent),
|
|
|
|
...categoriesTmp
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return categories;
|
|
|
|
}
|
|
|
|
}
|
2022-12-29 08:45:28 +03:00
|
|
|
}
|