mirror of
https://github.com/feeddeck/feeddeck.git
synced 2026-04-30 11:28:45 -05:00
This commit adds two improvements to the `ItemVideoPlayer` widget. These improvements are: 1. The padding for the widget is now defined within the widget, so that is must not be defined in the parent widget. With this change the widget follows the styling of our other widgets like `ItemMedia`. 2. On iOS the quality selection had a large bottom padding, this is now fixed, by using a `Wrap` widget instead of a `ListView` like we are using in the other modal bottom sheets which are showing some actions.
82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:feeddeck/models/item.dart';
|
|
import 'package:feeddeck/models/source.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_description.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_media.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_subtitle.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_title.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_videos.dart';
|
|
import 'package:feeddeck/widgets/item/details/utils/item_youtube/item_youtube_video.dart';
|
|
|
|
class ItemDetailsLemmy extends StatelessWidget {
|
|
const ItemDetailsLemmy({
|
|
super.key,
|
|
required this.item,
|
|
required this.source,
|
|
});
|
|
|
|
final FDItem item;
|
|
final FDSource source;
|
|
|
|
/// [_buildMedia] builds the media widget for the item. The media widget can
|
|
/// display an image, a video or y YouTube video.
|
|
///
|
|
/// See the `getMedia` function in the `lemmy.ts` file, for a list of
|
|
/// extension which are a image / video.
|
|
Widget _buildMedia() {
|
|
if (item.media != null && item.media! != '') {
|
|
final mediaUrl = Uri.parse(item.media!);
|
|
|
|
if (mediaUrl.path.endsWith('.jpg') ||
|
|
mediaUrl.path.endsWith('.jpeg') ||
|
|
mediaUrl.path.endsWith('.png') ||
|
|
mediaUrl.path.endsWith('.gif')) {
|
|
return ItemMedia(
|
|
itemMedia: item.media,
|
|
);
|
|
}
|
|
|
|
if (mediaUrl.path.endsWith('.mp4')) {
|
|
return ItemVideoPlayer(
|
|
video: item.media!,
|
|
);
|
|
}
|
|
|
|
if (item.media!.startsWith('https://youtu.be/') ||
|
|
item.media!.startsWith('https://www.youtube.com/watch?') ||
|
|
item.media!.startsWith('https://m.youtube.com/watch?')) {
|
|
return ItemYoutubeVideo(
|
|
null,
|
|
item.media!,
|
|
);
|
|
}
|
|
}
|
|
|
|
return Container();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
ItemTitle(
|
|
itemTitle: item.title,
|
|
),
|
|
ItemSubtitle(
|
|
item: item,
|
|
source: source,
|
|
),
|
|
_buildMedia(),
|
|
ItemDescription(
|
|
itemDescription: item.description,
|
|
sourceFormat: DescriptionFormat.html,
|
|
tagetFormat: DescriptionFormat.markdown,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|