media item and session images and location management, also refactoring and DRYing up code

This commit is contained in:
Joshua Burman
2024-12-31 22:41:17 -05:00
parent 5f628d6b48
commit 10332ec8be
17 changed files with 328 additions and 129 deletions

View File

@ -1,13 +1,16 @@
import 'package:flutter/material.dart';
import 'package:sendtrain/database/database.dart';
ImageProvider findMediaByType(List<MediaItem> media, String type) {
Iterable<MediaItem>? found = media.where((m) => m.type == MediaType.image);
ImageProvider findMediaByType(List<MediaItem> media, MediaType type) {
Iterable<MediaItem>? found = media.where((m) => m.type == type);
Image image;
if (found.isNotEmpty) {
return NetworkImage(found.first.reference);
} else {
// Element is not found
return const AssetImage('assets/images/placeholder.jpg');
}
}
if (found.isNotEmpty) {
image = Image.network(found.first.reference);
} else {
// Element is not found
image = Image.asset('assets/images/placeholder.jpg');
}
return image.image;
}

View File

@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
import 'package:sendtrain/database/database.dart';
import 'package:sendtrain/widgets/media/media_details.dart';
showMediaDetailWidget(BuildContext context, MediaItem media) {
showModalBottomSheet<void>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
context: context,
showDragHandle: true,
isScrollControlled: true,
useSafeArea: true,
builder: (BuildContext context) {
return MediaDetails(media: media);
});
}