Skip to content

Commit

Permalink
Add tagging note functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
nusjose committed May 17, 2024
1 parent 9f11198 commit 8b69c60
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
40 changes: 38 additions & 2 deletions lib/src/cupertino/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class CupertinoControls extends StatefulWidget {
required this.iconColor,
this.showPlayButton = true,
this.airPlayButton = null,
this.onTabTaggingNote = null,
super.key,
});

final Color backgroundColor;
final Color iconColor;
final bool showPlayButton;
final dynamic airPlayButton;
final Function()? onTabTaggingNote;

@override
State<StatefulWidget> createState() {
Expand Down Expand Up @@ -85,6 +87,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
final iconColor = widget.iconColor;
final orientation = MediaQuery.of(context).orientation;
final airPlayButton = Platform.isAndroid ? null : widget.airPlayButton;
final onTaggingNote = widget.onTabTaggingNote;
final barHeight = orientation == Orientation.portrait ? 30.0 : 47.0;
final buttonPadding = orientation == Orientation.portrait ? 16.0 : 24.0;

Expand All @@ -106,7 +109,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_buildTopBar(backgroundColor, iconColor, barHeight,
buttonPadding, airPlayButton),
buttonPadding, airPlayButton, onTaggingNote),
const Spacer(),
if (_subtitleOn)
Transform.translate(
Expand Down Expand Up @@ -369,6 +372,36 @@ class _CupertinoControlsState extends State<CupertinoControls>
);
}

GestureDetector _buildTaggingNote(Color backgroundColor, Color iconColor,
double barHeight, double buttonPadding, Function()? onTabTaggingNote) {
return GestureDetector(
onTap: onTabTaggingNote,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 1.0,
duration: const Duration(milliseconds: 300),
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 10.0),
child: Container(
height: barHeight,
padding: EdgeInsets.only(
left: buttonPadding,
right: buttonPadding,
),
color: backgroundColor,
child: Center(child: Icon(
CupertinoIcons.tags_solid,
color: iconColor,
size: 16,
)),
),
),
),
),
);
}

Widget _buildHitArea() {
final bool isFinished = _latestValue.position >= _latestValue.duration;
final bool showPlayButton =
Expand Down Expand Up @@ -617,7 +650,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
}

Widget _buildTopBar(Color backgroundColor, Color iconColor, double barHeight,
double buttonPadding, dynamic airPlayButton) {
double buttonPadding, dynamic airPlayButton, Function()? onTaggingNote) {
return Container(
height: barHeight,
margin: EdgeInsets.only(
Expand All @@ -642,6 +675,9 @@ class _CupertinoControlsState extends State<CupertinoControls>
_buildAirplayButton(backgroundColor, iconColor, barHeight,
buttonPadding, airPlayButton),
const Spacer(),
if(onTaggingNote == null) _buildTaggingNote(backgroundColor, iconColor, barHeight,
buttonPadding, onTaggingNote),
const SizedBox(width: 8,),
if (chewieController.allowMuting)
_buildMuteButton(
controller,
Expand Down
24 changes: 24 additions & 0 deletions lib/src/material/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import 'package:video_player/video_player.dart';
class MaterialControls extends StatefulWidget {
const MaterialControls({
this.showPlayButton = true,
this.onTabTaggingNote = null,
super.key,
});

final bool showPlayButton;
final Function()? onTabTaggingNote;

@override
State<StatefulWidget> createState() {
Expand Down Expand Up @@ -150,6 +152,7 @@ class _MaterialControlsState extends State<MaterialControls>
duration: const Duration(milliseconds: 250),
child: Row(
children: [
_buildTaggingNote(),
_buildSubtitleToggle(),
if (chewieController.showOptions) _buildOptionsButton(),
],
Expand Down Expand Up @@ -469,6 +472,27 @@ class _MaterialControlsState extends State<MaterialControls>
);
}

Widget _buildTaggingNote() {
if (widget.onTabTaggingNote == null) {
return const SizedBox();
}
return GestureDetector(
onTap: widget.onTabTaggingNote,
child: Container(
height: barHeight,
color: Colors.transparent,
padding: const EdgeInsets.only(
left: 12.0,
right: 12.0,
),
child: Icon(
Icons.note_alt_sharp,
color: _subtitleOn ? Colors.white : Colors.grey[700],
),
),
);
}

void _onSubtitleTap() {
setState(() {
_subtitleOn = !_subtitleOn;
Expand Down

0 comments on commit 8b69c60

Please sign in to comment.