// Author: fruit.com.cn import 'package:flutter/material.dart'; import '../../../core/theme/app_colors.dart'; const double _toggleSize = 68; const double _iconSize = 36; /// 播放/暂停压在画面上,垫一层半透明玻璃圆面保证亮画面下也能看见。 const RadialGradient _toggleGradient = RadialGradient( center: Alignment(-0.35, -0.4), radius: 0.9, colors: [Color(0x80FFFFFF), Color(0x52000000), Color(0x70000000)], ); const List _iconShadows = [ Shadow(color: AppColors.shadow, blurRadius: 12), ]; /// 首页沉浸流与全屏播放器共用的播放/暂停按钮。 class PlayerCenterToggle extends StatelessWidget { const PlayerCenterToggle({ super.key, required this.playing, required this.onTap, }); final bool playing; final VoidCallback onTap; @override Widget build(BuildContext context) { return Semantics( button: true, label: playing ? 'Pause' : 'Play', child: GestureDetector( onTap: onTap, child: SizedBox( width: _toggleSize, height: _toggleSize, child: DecoratedBox( key: const Key('player-center-toggle-surface'), decoration: const BoxDecoration( shape: BoxShape.circle, gradient: _toggleGradient, ), child: Center( child: Icon( playing ? Icons.pause_rounded : Icons.play_arrow_rounded, color: AppColors.onPrimary, size: _iconSize, shadows: _iconShadows, ), ), ), ), ), ); } }