Files
PiliPlus/lib/plugin/pl_player/widgets/backward_seek.dart
bggRGjQaUbCoE 6f4321ae14 Revert "chore: clean up"
This reverts commit 538494b7ec.
2025-04-20 18:04:06 +08:00

94 lines
2.2 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
class BackwardSeekIndicator extends StatefulWidget {
// final void Function(Duration) onChanged;
final ValueChanged<Duration> onSubmitted;
final int duration;
const BackwardSeekIndicator({
super.key,
// required this.onChanged,
required this.onSubmitted,
required this.duration,
});
@override
State<BackwardSeekIndicator> createState() => BackwardSeekIndicatorState();
}
class BackwardSeekIndicatorState extends State<BackwardSeekIndicator> {
late Duration duration;
Timer? timer;
@override
void initState() {
super.initState();
duration = Duration(seconds: widget.duration);
timer = Timer(const Duration(milliseconds: 400), () {
widget.onSubmitted.call(duration);
});
}
@override
void dispose() {
timer?.cancel();
super.dispose();
}
void increment() {
timer?.cancel();
timer = Timer(const Duration(milliseconds: 400), () {
widget.onSubmitted.call(duration);
});
// widget.onChanged.call(value);
// 重复点击 快退秒数累加10
setState(() {
duration += Duration(seconds: widget.duration);
});
}
@override
Widget build(BuildContext context) {
return InkWell(
splashColor: const Color(0x44767676),
onTap: increment,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x88767676),
Color(0x00767676),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
alignment: Alignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.fast_rewind,
size: 24.0,
color: Colors.white,
),
const SizedBox(height: 8.0),
Text(
'快退${duration.inSeconds}',
style: const TextStyle(
fontSize: 12.0,
color: Colors.white,
),
),
],
),
),
);
}
}