fix(ui): fix video player controls getting hidden.

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2023-08-16 16:42:48 +05:30
parent e5d593a9e6
commit 27074ddb55
2 changed files with 155 additions and 148 deletions
@@ -281,32 +281,30 @@ class _FullScreenMediaState extends State<StreamFullScreenMedia> {
final currentAttachmentPackage = final currentAttachmentPackage =
widget.mediaAttachmentPackages[index]; widget.mediaAttachmentPackages[index];
final attachment = currentAttachmentPackage.attachment; final attachment = currentAttachmentPackage.attachment;
if (attachment.type == 'image' || attachment.type == 'giphy') { return ValueListenableBuilder(
final imageUrl = attachment.imageUrl ??
attachment.assetUrl ??
attachment.thumbUrl;
return ValueListenableBuilder<bool>(
valueListenable: _isDisplayingDetail, valueListenable: _isDisplayingDetail,
builder: (context, isDisplayingDetail, _) => builder: (context, isDisplayingDetail, child) {
AnimatedContainer( return AnimatedContainer(
duration: kThemeChangeDuration,
color: isDisplayingDetail color: isDisplayingDetail
? StreamChannelHeaderTheme.of(context).color ? StreamChannelHeaderTheme.of(context).color
: Colors.black, : Colors.black,
duration: kThemeAnimationDuration, child: Builder(
child: ContextMenuArea( builder: (context) {
verticalPadding: 0, if (attachment.type == 'image' ||
builder: (_) => [ attachment.type == 'giphy') {
DownloadMenuItem( final imageUrl = attachment.imageUrl ??
attachment: attachment, attachment.assetUrl ??
), attachment.thumbUrl;
],
child: PhotoView( return PhotoView(
imageProvider: (imageUrl == null && imageProvider: (imageUrl == null &&
attachment.localUri != null && attachment.localUri != null &&
attachment.file?.bytes != null) attachment.file?.bytes != null)
? Image.memory(attachment.file!.bytes!).image ? Image.memory(attachment.file!.bytes!).image
: CachedNetworkImageProvider(imageUrl!), : CachedNetworkImageProvider(imageUrl!),
errorBuilder: (_, __, ___) => const AttachmentError(), errorBuilder: (_, __, ___) =>
const AttachmentError(),
loadingBuilder: (context, _) { loadingBuilder: (context, _) {
final image = Image.asset( final image = Image.asset(
'images/placeholder.png', 'images/placeholder.png',
@@ -329,9 +327,6 @@ class _FullScreenMediaState extends State<StreamFullScreenMedia> {
backgroundDecoration: const BoxDecoration( backgroundDecoration: const BoxDecoration(
color: Colors.transparent, color: Colors.transparent,
), ),
),
),
),
); );
} else if (attachment.type == 'video') { } else if (attachment.type == 'video') {
final controller = videoPackages[attachment.id]!; final controller = videoPackages[attachment.id]!;
@@ -340,27 +335,31 @@ class _FullScreenMediaState extends State<StreamFullScreenMedia> {
child: CircularProgressIndicator.adaptive(), child: CircularProgressIndicator.adaptive(),
); );
} }
return InkWell(
onTap: switchDisplayingDetail, final mediaQuery = MediaQuery.of(context);
child: Padding( final bottomPadding = mediaQuery.padding.bottom;
padding: const EdgeInsets.symmetric(vertical: 50),
child: ContextMenuArea( return AnimatedPadding(
verticalPadding: 0, duration: kThemeChangeDuration,
builder: (_) => [ padding: EdgeInsets.symmetric(
DownloadMenuItem( vertical: isDisplayingDetail
attachment: attachment, ? kToolbarHeight + bottomPadding
: 0,
), ),
],
child: Chewie( child: Chewie(
controller: controller.chewieController!, controller: controller.chewieController!,
), ),
),
),
); );
} }
return const SizedBox(); return const SizedBox();
}, },
), ),
);
},
);
},
),
), ),
), ),
), ),
@@ -475,6 +474,7 @@ class VideoPackage {
videoPlayerController: _videoPlayerController, videoPlayerController: _videoPlayerController,
autoInitialize: _autoInitialize, autoInitialize: _autoInitialize,
showControls: _showControls, showControls: _showControls,
showOptions: false,
aspectRatio: _videoPlayerController.value.aspectRatio, aspectRatio: _videoPlayerController.value.aspectRatio,
); );
}); });
@@ -307,32 +307,31 @@ class _FullScreenMediaDesktopState extends State<FullScreenMediaDesktop> {
final currentAttachmentPackage = final currentAttachmentPackage =
widget.mediaAttachmentPackages[index]; widget.mediaAttachmentPackages[index];
final attachment = currentAttachmentPackage.attachment; final attachment = currentAttachmentPackage.attachment;
if (attachment.type == 'image' || attachment.type == 'giphy') {
final imageUrl = attachment.imageUrl ?? return ValueListenableBuilder(
attachment.assetUrl ??
attachment.thumbUrl;
return ValueListenableBuilder<bool>(
valueListenable: _isDisplayingDetail, valueListenable: _isDisplayingDetail,
builder: (context, isDisplayingDetail, _) => builder: (context, isDisplayingDetail, child) {
AnimatedContainer( return AnimatedContainer(
duration: kThemeChangeDuration,
color: isDisplayingDetail color: isDisplayingDetail
? StreamChannelHeaderTheme.of(context).color ? StreamChannelHeaderTheme.of(context).color
: Colors.black, : Colors.black,
duration: kThemeAnimationDuration, child: Builder(
child: ContextMenuArea( builder: (context) {
verticalPadding: 0, if (attachment.type == 'image' ||
builder: (_) => [ attachment.type == 'giphy') {
DownloadMenuItem( final imageUrl = attachment.imageUrl ??
attachment: attachment, attachment.assetUrl ??
), attachment.thumbUrl;
],
child: PhotoView( return PhotoView(
imageProvider: (imageUrl == null && imageProvider: (imageUrl == null &&
attachment.localUri != null && attachment.localUri != null &&
attachment.file?.bytes != null) attachment.file?.bytes != null)
? Image.memory(attachment.file!.bytes!).image ? Image.memory(attachment.file!.bytes!).image
: CachedNetworkImageProvider(imageUrl!), : CachedNetworkImageProvider(imageUrl!),
errorBuilder: (_, __, ___) => const AttachmentError(), errorBuilder: (_, __, ___) =>
const AttachmentError(),
loadingBuilder: (context, _) { loadingBuilder: (context, _) {
final image = Image.asset( final image = Image.asset(
'images/placeholder.png', 'images/placeholder.png',
@@ -355,9 +354,6 @@ class _FullScreenMediaDesktopState extends State<FullScreenMediaDesktop> {
backgroundDecoration: const BoxDecoration( backgroundDecoration: const BoxDecoration(
color: Colors.transparent, color: Colors.transparent,
), ),
),
),
),
); );
} else if (attachment.type == 'video') { } else if (attachment.type == 'video') {
final package = videoPackages[attachment.id]!; final package = videoPackages[attachment.id]!;
@@ -370,10 +366,16 @@ class _FullScreenMediaDesktopState extends State<FullScreenMediaDesktop> {
autoStart: widget.autoplayVideos, autoStart: widget.autoplayVideos,
); );
return InkWell( final mediaQuery = MediaQuery.of(context);
onTap: switchDisplayingDetail, final bottomPadding = mediaQuery.padding.bottom;
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 50), return AnimatedPadding(
duration: kThemeChangeDuration,
padding: EdgeInsets.symmetric(
vertical: isDisplayingDetail
? kToolbarHeight + bottomPadding
: 0,
),
child: ContextMenuArea( child: ContextMenuArea(
verticalPadding: 0, verticalPadding: 0,
builder: (_) => [ builder: (_) => [
@@ -385,12 +387,17 @@ class _FullScreenMediaDesktopState extends State<FullScreenMediaDesktop> {
player: package.player, player: package.player,
), ),
), ),
),
); );
} }
return const SizedBox(); return const SizedBox();
}, },
), ),
);
},
);
},
),
), ),
), ),
); );