From 73cdda019097b4a93ce55dd65d8c591418a1e0ea Mon Sep 17 00:00:00 2001 From: Hitesh Kumar Saini Date: Thu, 5 May 2022 20:38:09 +0530 Subject: [PATCH] feat: initial fullscreen impl in Video widget --- lib/src/widgets/controls.dart | 25 ++++++++++++++ lib/src/widgets/video.dart | 61 ++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/controls.dart b/lib/src/widgets/controls.dart index 309dbc0c..dea60078 100644 --- a/lib/src/widgets/controls.dart +++ b/lib/src/widgets/controls.dart @@ -41,6 +41,10 @@ class Control extends StatefulWidget { required this.volumeInactiveColor, required this.volumeBackgroundColor, required this.volumeThumbColor, + this.enterFullscreen, + this.exitFullscreen, + this.isFullscreen: false, + this.showFullscreenButton: false, }) : super(key: key); final Widget child; @@ -57,6 +61,10 @@ class Control extends StatefulWidget { final Color? volumeInactiveColor; final Color? volumeBackgroundColor; final Color? volumeThumbColor; + final VoidCallback? enterFullscreen; + final VoidCallback? exitFullscreen; + final bool isFullscreen; + final bool showFullscreenButton; @override ControlState createState() => ControlState(); @@ -307,6 +315,23 @@ class ControlState extends State with SingleTickerProviderStateMixin { ], ), ), + if (widget.showFullscreenButton) + Positioned( + left: 15, + bottom: 12.5, + child: IconButton( + onPressed: !widget.isFullscreen + ? widget.enterFullscreen + : widget.exitFullscreen, + iconSize: 24, + icon: Icon( + !widget.isFullscreen + ? Icons.fullscreen + : Icons.fullscreen_exit, + color: Colors.white, + ), + ), + ), ], ), ), diff --git a/lib/src/widgets/video.dart b/lib/src/widgets/video.dart index 754a3df6..877efa64 100644 --- a/lib/src/widgets/video.dart +++ b/lib/src/widgets/video.dart @@ -23,6 +23,7 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:dart_vlc/dart_vlc.dart'; import 'package:dart_vlc/src/widgets/controls.dart'; +import 'package:window_manager/window_manager.dart'; /// Internally used map to keep [GlobalKey]s for [Video]'s [ControlState]s. Map> controls = {}; @@ -100,6 +101,8 @@ class Video extends StatefulWidget { this.showTimeLeft = false, this.progressBarTextStyle = const TextStyle(), this.filterQuality = FilterQuality.low, + this.showFullscreenButton = false, + this.fillColor: Colors.black, }) : player = player ?? players[playerId]! as Player, super(key: key); @@ -168,6 +171,12 @@ class Video extends StatefulWidget { /// instead of the total time, set this to true final bool showTimeLeft; + /// Whether to show the fullscreen button. + final bool showFullscreenButton; + + /// Fill color. + final Color fillColor; + _VideoStateBase createState() => _VideoStateTexture(); } @@ -183,17 +192,67 @@ abstract class _VideoStateBase extends State