Skip to content

Commit

Permalink
add: Buttons over timebar[FEATURE REQUEST] #12
Browse files Browse the repository at this point in the history
  • Loading branch information
TheHCJ committed Apr 11, 2024
1 parent 7921e8d commit 9202ccb
Showing 1 changed file with 59 additions and 51 deletions.
110 changes: 59 additions & 51 deletions lib/tweet/_video_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class _MaterialControlsState extends State<FritterMaterialControls> with SingleT

Widget _buildActionBar() {
return Positioned(
top: 0,
right: 0,
// NOTE: Removed SafeArea so the options button appears correctly at the top right
child: AnimatedOpacity(
Expand All @@ -153,62 +152,23 @@ class _MaterialControlsState extends State<FritterMaterialControls> with SingleT
child: Row(
children: [
_buildSubtitleToggle(),
if (chewieController.showOptions) _buildOptionsButton(),
const SizedBox(
width: 8.0,
),
if (chewieController.allowPlaybackSpeedChanging) _buildPlaybackSpeedButton(controller),
const SizedBox(
width: 8.0,
),
_buildDownloadButton(controller),
const SizedBox(
width: 16,
),
],
),
),
);
}

Widget _buildOptionsButton() {
final options = <OptionItem>[
OptionItem(
onTap: () async {
Navigator.pop(context);
_onSpeedButtonTap();
},
iconData: Icons.speed,
title: L10n.of(context).playback_speed,
)
];

if (chewieController.additionalOptions != null && chewieController.additionalOptions!(context).isNotEmpty) {
options.addAll(chewieController.additionalOptions!(context));
}

return AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 1.0,
duration: const Duration(milliseconds: 250),
child: IconButton(
onPressed: () async {
_hideTimer?.cancel();

if (chewieController.optionsBuilder != null) {
await chewieController.optionsBuilder!(context, options);
} else {
await showModalBottomSheet<OptionItem>(
context: context,
isScrollControlled: true,
useRootNavigator: chewieController.useRootNavigator,
builder: (context) => OptionsDialog(
options: options,
cancelButtonText: L10n.of(context).cancel,
),
);
}

if (_latestValue.isPlaying) {
_startHideTimer();
}
},
icon: const Icon(
Icons.more_vert,
color: Colors.white,
),
),
);
}

Widget _buildSubtitles(BuildContext context, Subtitles subtitles) {
if (!_subtitleOn) {
return Container();
Expand Down Expand Up @@ -330,6 +290,54 @@ class _MaterialControlsState extends State<FritterMaterialControls> with SingleT
);
}

GestureDetector _buildPlaybackSpeedButton(
VideoPlayerController controller,
) {
return GestureDetector(
onTap: _onSpeedButtonTap,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 1.0,
duration: const Duration(milliseconds: 300),
child: ClipRect(
child: Container(
height: barHeight,
padding: const EdgeInsets.only(
left: 6.0,
),
child: Icon(
Icons.speed,
color: Colors.white,
),
),
),
),
);
}

GestureDetector _buildDownloadButton(
VideoPlayerController controller,
) {
return GestureDetector(
onTap: chewieController.additionalOptions!(context)[0].onTap,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 1.0,
duration: const Duration(milliseconds: 300),
child: ClipRect(
child: Container(
height: barHeight,
padding: const EdgeInsets.only(
left: 6.0,
),
child: Icon(
chewieController.additionalOptions!(context)[0].iconData,
color: Colors.white,
),
),
),
),
);
}

GestureDetector _buildExpandButton() {
return GestureDetector(
onTap: _onExpandCollapse,
Expand Down

0 comments on commit 9202ccb

Please sign in to comment.