From 52cf89c805de58ed2bae6b355331c4c9953a6673 Mon Sep 17 00:00:00 2001 From: Dulaj Nadawa Date: Thu, 7 Jan 2021 09:44:07 +0530 Subject: [PATCH] Add Fullscreen Background Color, Theme Color and Icon Color attributes --- example/pubspec.lock | 103 +++++++++++---------------------- lib/src/fullscreen_player.dart | 24 ++++---- lib/vimeoplayer.dart | 32 ++++++---- pubspec.lock | 97 ++++++++++--------------------- 4 files changed, 99 insertions(+), 157 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index ce010d6..104f219 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,62 +1,48 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - charcode: + version: "2.1.0-nullsafety.1" + characters: dependency: transitive description: - name: charcode + name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.1.0-nullsafety.3" + charcode: dependency: transitive description: - name: collection + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: convert + name: clock url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0-nullsafety.1" + collection: dependency: transitive description: - name: crypto + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.15.0-nullsafety.3" cupertino_icons: dependency: "direct main" description: @@ -64,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -93,34 +86,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: @@ -128,20 +114,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" sky_engine: dependency: transitive description: flutter @@ -153,56 +125,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" video_player: dependency: transitive description: @@ -230,14 +202,7 @@ packages: name: vimeoplayer url: "https://pub.dartlang.org" source: hosted - version: "0.1.7" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" + version: "0.0.2" sdks: - dart: ">=2.8.0 <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/lib/src/fullscreen_player.dart b/lib/src/fullscreen_player.dart index b674f18..ae2c140 100644 --- a/lib/src/fullscreen_player.dart +++ b/lib/src/fullscreen_player.dart @@ -15,6 +15,9 @@ class FullscreenPlayer extends StatefulWidget { final position; final Future initFuture; final String qualityValue; + final Color fullScreenBackgroundColor; + final Color iconColor; + final Color themeColor; FullscreenPlayer({ @required this.id, @@ -24,7 +27,7 @@ class FullscreenPlayer extends StatefulWidget { this.position, this.initFuture, this.qualityValue, - Key key, + Key key, this.fullScreenBackgroundColor, this.iconColor, this.themeColor, }) : super(key: key); @override @@ -110,6 +113,7 @@ class _FullscreenPlayerState extends State { return WillPopScope( onWillPop: _onWillPop, child: Scaffold( + backgroundColor: widget.fullScreenBackgroundColor, body: Center( child: Stack( alignment: AlignmentDirectional.center, @@ -177,7 +181,7 @@ class _FullscreenPlayerState extends State { child: CircularProgressIndicator( strokeWidth: 4, valueColor: AlwaysStoppedAnimation( - Color(0xFF22A3D2)), + widget.themeColor), )); } }), @@ -331,8 +335,8 @@ class _FullscreenPlayerState extends State { bottom: videoHeight / 2 - 30, ), icon: _controller.value.isPlaying - ? Icon(Icons.pause, size: 60.0) - : Icon(Icons.play_arrow, size: 60.0), + ? Icon(Icons.pause, size: 60.0, color: widget.iconColor,) + : Icon(Icons.play_arrow, size: 60.0,color: widget.iconColor,), onPressed: () { setState(() { _controller.value.isPlaying @@ -346,7 +350,7 @@ class _FullscreenPlayerState extends State { top: videoHeight - 80, left: videoWidth + videoMargin - 50), child: IconButton( alignment: AlignmentDirectional.center, - icon: Icon(Icons.fullscreen, size: 30.0), + icon: Icon(Icons.fullscreen, size: 30.0,color: widget.iconColor,), onPressed: () { setState(() { _controller.pause(); @@ -364,7 +368,7 @@ class _FullscreenPlayerState extends State { Container( margin: EdgeInsets.only(left: videoWidth + videoMargin - 48), child: IconButton( - icon: Icon(Icons.settings, size: 26.0), + icon: Icon(Icons.settings, size: 26.0,color: widget.iconColor,), onPressed: () { position = _controller.value.position.inSeconds; _seek = true; @@ -397,7 +401,7 @@ class _FullscreenPlayerState extends State { child: Text(value.position.inMinutes.toString() + ':' + (value.position.inSeconds - value.position.inMinutes * 60) - .toString()), + .toString(),style: TextStyle(color: widget.iconColor),), ), Container( height: 20, @@ -406,9 +410,9 @@ class _FullscreenPlayerState extends State { _controller, allowScrubbing: true, colors: VideoProgressColors( - playedColor: Color(0xFF22A3D2), + playedColor: widget.themeColor, backgroundColor: Color(0x5515162B), - bufferedColor: Color(0x5583D8F7), + bufferedColor: widget.themeColor.withOpacity(0.4), ), padding: EdgeInsets.only(top: 8.0, bottom: 8.0), ), @@ -419,7 +423,7 @@ class _FullscreenPlayerState extends State { child: Text(value.duration.inMinutes.toString() + ':' + (value.duration.inSeconds - value.duration.inMinutes * 60) - .toString()), + .toString(),style: TextStyle(color: widget.iconColor)), ), ], ); diff --git a/lib/vimeoplayer.dart b/lib/vimeoplayer.dart index 6c6d506..f8baacd 100644 --- a/lib/vimeoplayer.dart +++ b/lib/vimeoplayer.dart @@ -13,13 +13,18 @@ class VimeoPlayer extends StatefulWidget { final bool autoPlay; final bool looping; final int position; + final Color fullScreenBackgroundColor; + final Color iconColor; + final Color themeColor; + + static const col = Color(0xFF22A3D2); VimeoPlayer({ @required this.id, this.autoPlay, this.looping, this.position, - Key key, + Key key, this.fullScreenBackgroundColor=Colors.black, this.iconColor=Colors.white, this.themeColor=col, }) : super(key: key); @override @@ -148,7 +153,7 @@ class _VimeoPlayerState extends State { child: CircularProgressIndicator( strokeWidth: 4, valueColor: - AlwaysStoppedAnimation(Color(0xFF22A3D2)), + AlwaysStoppedAnimation(widget.themeColor), )); } }), @@ -306,8 +311,8 @@ class _VimeoPlayerState extends State { top: videoHeight / 2 - 30, bottom: videoHeight / 2 - 30), icon: _controller.value.isPlaying - ? Icon(Icons.pause, size: 60.0) - : Icon(Icons.play_arrow, size: 60.0), + ? Icon(Icons.pause, size: 60.0,color: widget.iconColor,) + : Icon(Icons.play_arrow, size: 60.0,color: widget.iconColor,), onPressed: () { setState(() { _controller.value.isPlaying @@ -321,7 +326,7 @@ class _VimeoPlayerState extends State { top: videoHeight - 70, left: videoWidth + videoMargin - 50), child: IconButton( alignment: AlignmentDirectional.center, - icon: Icon(Icons.fullscreen, size: 30.0), + icon: Icon(Icons.fullscreen, size: 30.0,color: widget.iconColor,), onPressed: () async { setState(() { _controller.pause(); @@ -337,6 +342,9 @@ class _VimeoPlayerState extends State { pageBuilder: (BuildContext context, _, __) => FullscreenPlayer( id: _id, + fullScreenBackgroundColor: widget.fullScreenBackgroundColor, + iconColor: widget.iconColor, + themeColor: widget.themeColor, autoPlay: true, controller: _controller, position: @@ -362,7 +370,7 @@ class _VimeoPlayerState extends State { Container( margin: EdgeInsets.only(left: videoWidth + videoMargin - 48), child: IconButton( - icon: Icon(Icons.settings, size: 26.0), + icon: Icon(Icons.settings, size: 26.0,color: widget.iconColor,), onPressed: () { position = _controller.value.position.inSeconds; _seek = true; @@ -387,9 +395,9 @@ class _VimeoPlayerState extends State { _controller, allowScrubbing: true, colors: VideoProgressColors( - playedColor: Color(0xFF22A3D2), + playedColor: widget.themeColor, backgroundColor: Color(0x5515162B), - bufferedColor: Color(0x5583D8F7), + bufferedColor: widget.themeColor.withOpacity(0.4), ), padding: EdgeInsets.only(top: 2), ), @@ -411,7 +419,7 @@ class _VimeoPlayerState extends State { child: Text(value.position.inMinutes.toString() + ':' + (value.position.inSeconds - value.position.inMinutes * 60) - .toString()), + .toString(),style: TextStyle(color: widget.iconColor)), ), Container( height: 20, @@ -420,9 +428,9 @@ class _VimeoPlayerState extends State { _controller, allowScrubbing: true, colors: VideoProgressColors( - playedColor: Color(0xFF22A3D2), + playedColor: widget.themeColor, backgroundColor: Color(0x5515162B), - bufferedColor: Color(0x5583D8F7), + bufferedColor: widget.themeColor.withOpacity(0.4), ), padding: EdgeInsets.only(top: 8.0, bottom: 8.0), ), @@ -433,7 +441,7 @@ class _VimeoPlayerState extends State { child: Text(value.duration.inMinutes.toString() + ':' + (value.duration.inSeconds - value.duration.inMinutes * 60) - .toString()), + .toString(),style: TextStyle(color: widget.iconColor)), ), ], ); diff --git a/pubspec.lock b/pubspec.lock index 09a6a4d..0ec86d4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,62 +1,55 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: collection + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.1.0-nullsafety.1" + collection: dependency: transitive description: - name: convert + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.15.0-nullsafety.3" + fake_async: dependency: transitive description: - name: crypto + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -86,34 +79,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: @@ -121,20 +107,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" sky_engine: dependency: transitive description: flutter @@ -146,56 +118,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" video_player: dependency: "direct main" description: @@ -217,13 +189,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" sdks: - dart: ">=2.8.0 <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"