Files
ReelShort/lib/pages/player/widgets/player_speed_sheet.dart
T

80 lines
2.3 KiB
Dart

// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
const List<double> _speedOptions = [0.75, 1.0, 1.25, 1.5, 2.0, 3.0];
const double _sheetRadius = 20;
/// 播放倍速选择弹窗。
class PlayerSpeedSheet extends StatelessWidget {
/// 创建倍速选择弹窗。
const PlayerSpeedSheet({super.key, required this.selected});
/// 当前倍速。
final double selected;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
border: false,
child: Material(
key: const Key('player-speed-sheet'),
type: MaterialType.transparency,
clipBehavior: Clip.antiAlias,
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
l10n.playbackSpeed,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
),
),
for (final value in _speedOptions) _option(context, value),
const SizedBox(height: 8),
],
),
),
),
);
}
Widget _option(BuildContext context, double value) {
final active = value == selected;
return ListTile(
key: Key('player-speed-${value.toString()}'),
dense: true,
title: Text(
'${value.toString()}x',
style: TextStyle(
color: active ? AppColors.blue : AppColors.onSurface,
fontSize: 14,
fontWeight: active ? FontWeight.w800 : FontWeight.w500,
),
),
trailing: active
? const Icon(Icons.check_rounded, color: AppColors.blue, size: 20)
: null,
onTap: () => Navigator.pop(context, value),
);
}
}