chore: add shadow to video play/pause icon shadow (#26836)

This commit is contained in:
Alex
2026-03-11 14:15:31 -05:00
committed by GitHub
parent 471c27cd33
commit 6c531e0a5a
2 changed files with 37 additions and 17 deletions

View File

@@ -1,12 +1,15 @@
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// A widget that animates implicitly between a play and a pause icon. /// A widget that animates implicitly between a play and a pause icon.
class AnimatedPlayPause extends StatefulWidget { class AnimatedPlayPause extends StatefulWidget {
const AnimatedPlayPause({super.key, required this.playing, this.size, this.color}); const AnimatedPlayPause({super.key, required this.playing, this.size, this.color, this.shadows});
final double? size; final double? size;
final bool playing; final bool playing;
final Color? color; final Color? color;
final List<Shadow>? shadows;
@override @override
State<StatefulWidget> createState() => AnimatedPlayPauseState(); State<StatefulWidget> createState() => AnimatedPlayPauseState();
@@ -39,12 +42,32 @@ class AnimatedPlayPauseState extends State<AnimatedPlayPause> with SingleTickerP
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final icon = AnimatedIcon(
color: widget.color,
size: widget.size,
icon: AnimatedIcons.play_pause,
progress: animationController,
);
return Center( return Center(
child: AnimatedIcon( child: Stack(
color: widget.color, alignment: Alignment.center,
size: widget.size, children: [
icon: AnimatedIcons.play_pause, for (final shadow in widget.shadows ?? const <Shadow>[])
progress: animationController, Transform.translate(
offset: shadow.offset,
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: shadow.blurRadius / 2, sigmaY: shadow.blurRadius / 2),
child: AnimatedIcon(
color: shadow.color,
size: widget.size,
icon: AnimatedIcons.play_pause,
progress: animationController,
),
),
),
icon,
],
), ),
); );
} }

View File

@@ -72,17 +72,14 @@ class VideoControls extends HookConsumerWidget {
children: [ children: [
Row( Row(
children: [ children: [
IconTheme( IconButton(
data: const IconThemeData(shadows: _controlShadows), iconSize: 32,
child: IconButton( padding: const EdgeInsets.all(12),
iconSize: 32, constraints: const BoxConstraints(),
padding: const EdgeInsets.all(12), icon: isFinished
constraints: const BoxConstraints(), ? const Icon(Icons.replay, color: Colors.white, size: 32, shadows: _controlShadows)
icon: isFinished : AnimatedPlayPause(color: Colors.white, size: 32, playing: isPlaying, shadows: _controlShadows),
? const Icon(Icons.replay, color: Colors.white, size: 32) onPressed: () => _toggle(ref, isCasting),
: AnimatedPlayPause(color: Colors.white, size: 32, playing: isPlaying),
onPressed: () => _toggle(ref, isCasting),
),
), ),
const Spacer(), const Spacer(),
Text( Text(