// Author: fruit.com.cn part of 'player_overlay.dart'; class _TopButton extends StatelessWidget { const _TopButton({ super.key, required this.tooltip, required this.icon, required this.onPressed, }); final String tooltip; final IconData icon; final VoidCallback onPressed; @override Widget build(BuildContext context) { return SizedBox.square( dimension: _topButtonSize, child: IconButton( tooltip: tooltip, padding: EdgeInsets.zero, style: IconButton.styleFrom( backgroundColor: AppColors.card, foregroundColor: AppColors.onSurface, ), onPressed: onPressed, icon: Icon(icon, size: 18), ), ); } } class _Rail extends StatelessWidget { const _Rail({ required this.l10n, required this.liked, required this.saved, required this.likeCount, required this.onLike, required this.onComments, required this.onSave, required this.onShare, required this.compact, }); final AppLocalizations l10n; final bool liked; final bool saved; final int? likeCount; final VoidCallback onLike; final VoidCallback onComments; final VoidCallback onSave; final VoidCallback onShare; final bool compact; @override Widget build(BuildContext context) { return Column( key: const Key('player-interaction-rail'), children: [ _RailButton( key: const Key('player-rail-like'), icon: liked ? Icons.favorite_rounded : Icons.favorite_border_rounded, color: liked ? AppColors.blueSoft : AppColors.onPrimary, label: likeCount?.toString() ?? l10n.like, onTap: onLike, compact: compact, ), _RailButton( key: const Key('player-rail-comments'), icon: Icons.chat_bubble_outline_rounded, label: l10n.comments, onTap: onComments, compact: compact, ), _RailButton( key: const Key('player-rail-save'), icon: saved ? Icons.star_rounded : Icons.star_border_rounded, label: l10n.favorite, onTap: onSave, compact: compact, ), _RailButton( key: const Key('player-rail-share'), icon: Icons.ios_share_rounded, label: l10n.share, onTap: onShare, compact: compact, ), ], ); } } class _RailButton extends StatelessWidget { const _RailButton({ super.key, required this.icon, required this.label, required this.onTap, required this.compact, this.color = AppColors.onPrimary, }); final IconData icon; final String label; final VoidCallback onTap; final bool compact; final Color color; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.only(bottom: compact ? 2 : _railGap), child: Column( children: [ SizedBox.square( dimension: _railButtonSize, child: IconButton( onPressed: onTap, padding: EdgeInsets.zero, style: IconButton.styleFrom( backgroundColor: AppColors.overlayDark, foregroundColor: color, ), icon: Icon(icon, size: 18), ), ), SizedBox(height: compact ? 1 : 3), Text( label, maxLines: 1, style: TextStyle( color: AppColors.onPrimary, fontSize: compact ? 8 : 9, fontWeight: FontWeight.w600, ), ), ], ), ); } } class _PageDots extends StatelessWidget { const _PageDots({super.key, required this.current, required this.total}); final int current; final int total; @override Widget build(BuildContext context) { if (total <= 1) return const SizedBox.shrink(); final start = (current - 2).clamp(0, total > 5 ? total - 5 : 0); final end = (start + 5).clamp(0, total); return Row( mainAxisSize: MainAxisSize.min, children: [ for (var index = start; index < end; index++) Container( width: index == current ? 14 : _dotSize, height: _dotSize, margin: const EdgeInsets.only(left: 4), decoration: BoxDecoration( color: index == current ? AppColors.blue : Colors.white54, borderRadius: BorderRadius.circular(_dotRadius), ), ), ], ); } } class _TimeLabel extends StatelessWidget { const _TimeLabel({super.key, required this.controller}); final VideoPlayerController? controller; @override Widget build(BuildContext context) { final source = controller; if (source == null) return _label(Duration.zero, Duration.zero); return ValueListenableBuilder( valueListenable: source, builder: (context, value, _) => _label(value.position, value.duration), ); } Widget _label(Duration position, Duration duration) => Text( '${_format(position)} / ${_format(duration)}', textAlign: TextAlign.center, style: const TextStyle( color: AppColors.onPrimary, fontSize: 10, fontWeight: FontWeight.w600, ), ); String _format(Duration value) { final minutes = value.inMinutes.remainder(60).toString().padLeft(2, '0'); final seconds = value.inSeconds.remainder(60).toString().padLeft(2, '0'); return '$minutes:$seconds'; } } class _ActionButton extends StatelessWidget { const _ActionButton({ super.key, required this.icon, required this.label, required this.onTap, }); final IconData icon; final String label; final VoidCallback? onTap; @override Widget build(BuildContext context) { return SizedBox( height: 38, child: FilledButton.icon( onPressed: onTap, style: FilledButton.styleFrom( padding: const EdgeInsets.symmetric(horizontal: 8), backgroundColor: AppColors.card, foregroundColor: AppColors.onSurface, disabledBackgroundColor: Colors.black38, disabledForegroundColor: Colors.white54, ), icon: Icon(icon, size: 16), label: Text( label, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 10, fontWeight: FontWeight.w700), ), ), ); } }