Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FlickPortraitControls to include showFullScreenButton prop #269

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions lib/src/controls/flick_portrait_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import 'package:flick_video_player/flick_video_player.dart';

/// Default portrait controls.
class FlickPortraitControls extends StatelessWidget {
const FlickPortraitControls(
{Key? key,
this.iconSize = 20,
this.fontSize = 12,
this.progressBarSettings})
: super(key: key);
const FlickPortraitControls({Key? key, this.iconSize = 20, this.fontSize = 12, this.progressBarSettings, this.showFullScreenButton = true}) : super(key: key);

/// Icon size.
///
Expand All @@ -20,6 +15,9 @@ class FlickPortraitControls extends StatelessWidget {
/// This size is used for all the text.
final double fontSize;

/// Props for show/hide full screen button
final bool showFullScreenButton;

/// [FlickProgressBarSettings] settings.
final FlickProgressBarSettings? progressBarSettings;

Expand Down Expand Up @@ -82,8 +80,7 @@ class FlickPortraitControls extends StatelessWidget {
FlickAutoHideChild(
child: Text(
' / ',
style: TextStyle(
color: Colors.white, fontSize: fontSize),
style: TextStyle(color: Colors.white, fontSize: fontSize),
),
),
FlickTotalDuration(
Expand All @@ -100,9 +97,11 @@ class FlickPortraitControls extends StatelessWidget {
SizedBox(
width: iconSize / 2,
),
FlickFullScreenToggle(
size: iconSize,
),
showFullScreenButton
? FlickFullScreenToggle(
size: iconSize,
)
: SizedBox.shrink()
],
),
],
Expand Down
17 changes: 3 additions & 14 deletions lib/src/widgets/flick_full_screen_toggle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ import 'package:provider/provider.dart';

/// Show a widget based on the full-screen state of the player and toggle the same.
class FlickFullScreenToggle extends StatelessWidget {
const FlickFullScreenToggle(
{Key? key,
this.enterFullScreenChild,
this.exitFullScreenChild,
this.toggleFullscreen,
this.size,
this.color,
this.padding,
this.decoration})
const FlickFullScreenToggle({Key? key, this.enterFullScreenChild, this.exitFullScreenChild, this.toggleFullscreen, this.size, this.color, this.padding, this.decoration})
: super(key: key);

/// Widget shown when player is not in full-screen.
Expand Down Expand Up @@ -47,8 +39,7 @@ class FlickFullScreenToggle extends StatelessWidget {

@override
Widget build(BuildContext context) {
FlickControlManager controlManager =
Provider.of<FlickControlManager>(context);
FlickControlManager controlManager = Provider.of<FlickControlManager>(context);
Widget enterFullScreenWidget = enterFullScreenChild ??
Icon(
Icons.fullscreen,
Expand All @@ -62,9 +53,7 @@ class FlickFullScreenToggle extends StatelessWidget {
color: color,
);

Widget child = controlManager.isFullscreen
? exitFullScreenWidget
: enterFullScreenWidget;
Widget child = controlManager.isFullscreen ? exitFullScreenWidget : enterFullScreenWidget;

return GestureDetector(
key: key,
Expand Down