|
|
|
|
@ -111,6 +111,7 @@ class AnswerHandwritingMainBox extends HookWidget {
|
|
|
|
|
HandwritingInfo? _dataDetail = _useStateModel.handwritingDetail.value;
|
|
|
|
|
|
|
|
|
|
if (_data == null || _dataDetail == null) return Container();
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
@ -124,7 +125,7 @@ class AnswerHandwritingMainBox extends HookWidget {
|
|
|
|
|
_dataDetail,
|
|
|
|
|
key: _useStateModel.handwritingKey,
|
|
|
|
|
),
|
|
|
|
|
$PageNumberBox(_data.pageNum),
|
|
|
|
|
$PageNumberBox(_data.pageNum, _data.pageCount),
|
|
|
|
|
// 上一页按钮
|
|
|
|
|
$PreviousNutton(
|
|
|
|
|
_useStateModel.pageNum.value,
|
|
|
|
|
@ -209,7 +210,6 @@ class UseMainBoxState with CommonMixin {
|
|
|
|
|
|
|
|
|
|
HandwritingInfo? getHandwritingDetail(JobHandwriting? theData) {
|
|
|
|
|
if (theData == null) return null;
|
|
|
|
|
print('开始时间:${DateTime.now().millisecondsSinceEpoch}');
|
|
|
|
|
// 笔画分组
|
|
|
|
|
// var lattices = Map<int, List<Lattices>>.fromIterable(
|
|
|
|
|
// theData.lattices,
|
|
|
|
|
@ -374,6 +374,9 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
TestQuestionsImageInfo? imagInfoModel; // 试题图片数据
|
|
|
|
|
late ImageStreamListener theImageStreamListener;
|
|
|
|
|
|
|
|
|
|
late ValueNotifier<List<GestureHandwritingRecording>> _vnHandWritings;
|
|
|
|
|
|
|
|
|
|
late RemoveListener _jobHandwritingDrawingTrajectoryListener; // 批注关闭监听
|
|
|
|
|
List<List<GestureHandwritingRecording>> _packagedHandwritingDatas = [];
|
|
|
|
|
List<GestureHandwritingRecording> _packagedHandwritingDataAll = [];
|
|
|
|
|
List<GestureHandwritingRecording> pendingData = []; // 待执行数据
|
|
|
|
|
@ -384,7 +387,10 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
_vnHandWritings = ValueNotifier<List<GestureHandwritingRecording>>([]);
|
|
|
|
|
_jobHandwritingDrawingTrajectoryListener = ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).addListener((state) {
|
|
|
|
|
_vnHandWritings.value = state;
|
|
|
|
|
}, fireImmediately: false);
|
|
|
|
|
eventOn(callback: (e) {
|
|
|
|
|
switch (e.runtimeType) {
|
|
|
|
|
case JobHandwritingRunTimeBus:
|
|
|
|
|
@ -408,15 +414,14 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
toGoPlay();
|
|
|
|
|
} else {
|
|
|
|
|
// 暂停
|
|
|
|
|
toGoPause();
|
|
|
|
|
toGoPause(_val.recalculate);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PlaybackSpeedBus:
|
|
|
|
|
// 播放速度
|
|
|
|
|
var _model = (e as PlaybackSpeedBus);
|
|
|
|
|
speed = _model.speed;
|
|
|
|
|
toGoPause(); // 先暂停再重新播放
|
|
|
|
|
dragProgressBarInitData(handwritingTime, handwritingDuration);
|
|
|
|
|
dragProgressBarInitData(handwritingDuration - handwritingTime, handwritingDuration);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
@ -441,6 +446,8 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
timers.forEach((e) {
|
|
|
|
|
if (e.isActive) e.cancel();
|
|
|
|
|
});
|
|
|
|
|
_jobHandwritingDrawingTrajectoryListener();
|
|
|
|
|
_vnHandWritings.dispose();
|
|
|
|
|
try {
|
|
|
|
|
imageStream?.removeListener(theImageStreamListener);
|
|
|
|
|
eventCancel();
|
|
|
|
|
@ -449,12 +456,13 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 暂停播放
|
|
|
|
|
Future<void> toGoPause() async {
|
|
|
|
|
Future<void> toGoPause(bool recalculate) async {
|
|
|
|
|
timers.forEach((e) {
|
|
|
|
|
if (e.isActive) e.cancel();
|
|
|
|
|
});
|
|
|
|
|
timers = [];
|
|
|
|
|
if (pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
|
|
|
|
// 总时间-剩余时间=已经执行时间
|
|
|
|
|
if (recalculate && pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
|
|
|
|
// 待执行的数据不等于空 每个数据都需要减去当前暂停已经执行的时间
|
|
|
|
|
pendingData = pendingData.map((e) {
|
|
|
|
|
return GestureHandwritingRecording(
|
|
|
|
|
@ -470,7 +478,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
/// 拖动进度条后重新初始化数据
|
|
|
|
|
/// @param startTime 起始时间 单位秒
|
|
|
|
|
Future<void> dragProgressBarInitData(int startTime, int totalDuration) async {
|
|
|
|
|
eventFire(model: JobHandwritingPlaybarBus(false));
|
|
|
|
|
eventFire(model: JobHandwritingPlaybarBus(false, false));
|
|
|
|
|
timers.forEach((e) {
|
|
|
|
|
if (e.isActive) e.cancel();
|
|
|
|
|
});
|
|
|
|
|
@ -499,7 +507,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
stroke: item.stroke,
|
|
|
|
|
data: item.data,
|
|
|
|
|
usageTime: item.usageTime,
|
|
|
|
|
intervalTime: intervalTime < 0 ? 0 : intervalTime,
|
|
|
|
|
intervalTime: intervalTime,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -520,24 +528,23 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
|
|
|
|
|
/// 开始播放
|
|
|
|
|
Future<void> toGoPlay() async {
|
|
|
|
|
handwritingTime = 0;
|
|
|
|
|
var executableData = _packagedHandwritingDataAll;
|
|
|
|
|
if (pendingData.isNotEmpty) {
|
|
|
|
|
// 待执行的数据没有执行完成 就继续执行待执行数据
|
|
|
|
|
executableData = pendingData;
|
|
|
|
|
} else {
|
|
|
|
|
pendingData.addAll(_packagedHandwritingDataAll);
|
|
|
|
|
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
executableData.forEach((e) {
|
|
|
|
|
if (e.intervalTime == 0) {
|
|
|
|
|
zhixinCall(e);
|
|
|
|
|
try {
|
|
|
|
|
var executableData = _packagedHandwritingDataAll;
|
|
|
|
|
if (pendingData.isNotEmpty) {
|
|
|
|
|
// 待执行的数据没有执行完成 就继续执行待执行数据
|
|
|
|
|
executableData = pendingData;
|
|
|
|
|
} else {
|
|
|
|
|
pendingData.addAll(_packagedHandwritingDataAll);
|
|
|
|
|
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
executableData.forEach((e) {
|
|
|
|
|
var ter = Timer(Duration(milliseconds: e.intervalTime ~/ speed), () => zhixinCall(e));
|
|
|
|
|
timers.add(ter);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print('播放报错:$e');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算尺寸
|
|
|
|
|
@ -561,6 +568,8 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
newTrajectoryData.sort((a, b) => a.usageTime.compareTo(b.usageTime));
|
|
|
|
|
|
|
|
|
|
_packagedHandwritingDatas.add(newTrajectoryData); // 分组数据
|
|
|
|
|
_packagedHandwritingDataAll.addAll(newTrajectoryData); // 不分组数据
|
|
|
|
|
}
|
|
|
|
|
@ -570,26 +579,29 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
List<GestureHandwritingRecording> points = ref.watch(jobHandwritingDrawingTrajectoryProvider);
|
|
|
|
|
return Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: CustomPaint(
|
|
|
|
|
foregroundPainter: DrawingPainter(points: points),
|
|
|
|
|
// size: Size(ScreenUtil().screenWidth - 60.r, widget.boxHeight),
|
|
|
|
|
child: RepaintBoundary(
|
|
|
|
|
child: $TheCachedNetworkImage(
|
|
|
|
|
imageUrl: widget.image,
|
|
|
|
|
(context, imageProvider) {
|
|
|
|
|
Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain);
|
|
|
|
|
if (imagInfoModel == null) {
|
|
|
|
|
imageStream?.removeListener(theImageStreamListener);
|
|
|
|
|
// 视图中展示图片的尺寸计算获取
|
|
|
|
|
imageStream = imageWidget.image.resolve(ImageConfiguration());
|
|
|
|
|
imageStream?.addListener(theImageStreamListener);
|
|
|
|
|
}
|
|
|
|
|
child: RepaintBoundary(
|
|
|
|
|
child: CustomPaint(
|
|
|
|
|
willChange: true,
|
|
|
|
|
isComplex: true,
|
|
|
|
|
foregroundPainter: HandWritingDrawingPainter(ctrl: _vnHandWritings),
|
|
|
|
|
// size: Size(ScreenUtil().screenWidth - 60.r, widget.boxHeight),
|
|
|
|
|
child: RepaintBoundary(
|
|
|
|
|
child: $TheCachedNetworkImage(
|
|
|
|
|
imageUrl: widget.image,
|
|
|
|
|
(context, imageProvider) {
|
|
|
|
|
Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain);
|
|
|
|
|
if (imagInfoModel == null) {
|
|
|
|
|
imageStream?.removeListener(theImageStreamListener);
|
|
|
|
|
// 视图中展示图片的尺寸计算获取
|
|
|
|
|
imageStream = imageWidget.image.resolve(ImageConfiguration());
|
|
|
|
|
imageStream?.addListener(theImageStreamListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return imageWidget;
|
|
|
|
|
},
|
|
|
|
|
return imageWidget;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -597,16 +609,9 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DrawingPainter extends CustomPainter {
|
|
|
|
|
List<GestureHandwritingRecording> points;
|
|
|
|
|
|
|
|
|
|
DrawingPainter({required this.points}) : super();
|
|
|
|
|
|
|
|
|
|
// Paint paintBrush = Paint()
|
|
|
|
|
// ..color = Colors.black
|
|
|
|
|
// ..strokeCap = StrokeCap.round
|
|
|
|
|
// ..strokeWidth = 0.5.sp;
|
|
|
|
|
|
|
|
|
|
class HandWritingDrawingPainter extends CustomPainter {
|
|
|
|
|
final ValueNotifier<List<GestureHandwritingRecording>> ctrl;
|
|
|
|
|
HandWritingDrawingPainter({required this.ctrl}) : super(repaint: ctrl);
|
|
|
|
|
//[定义画笔]
|
|
|
|
|
final Paint paintBrush = Paint()
|
|
|
|
|
//画笔颜色
|
|
|
|
|
@ -614,56 +619,77 @@ class DrawingPainter extends CustomPainter {
|
|
|
|
|
//画笔笔触类型
|
|
|
|
|
..strokeCap = StrokeCap.round
|
|
|
|
|
//是否启动抗锯齿
|
|
|
|
|
// ..isAntiAlias = true
|
|
|
|
|
..isAntiAlias = true
|
|
|
|
|
//绘画风格,默认为填充
|
|
|
|
|
// ..style = PaintingStyle.fill
|
|
|
|
|
//画笔的宽度
|
|
|
|
|
..strokeWidth = 0.6.r;
|
|
|
|
|
..style = PaintingStyle.stroke
|
|
|
|
|
..strokeWidth = 0.5.r;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
|
|
// canvas.drawPoints(PointMode.points, thePoints, paintBrush);
|
|
|
|
|
canvas.save();
|
|
|
|
|
|
|
|
|
|
var points = ctrl.value;
|
|
|
|
|
var _length = points.length;
|
|
|
|
|
for (int i = 0; i < _length; i++) {
|
|
|
|
|
GestureHandwritingRecording item = points[i];
|
|
|
|
|
GestureHandwritingRecording? nextItem = i + 1 >= _length ? null : points[i + 1];
|
|
|
|
|
Offset? offsetData = item.data;
|
|
|
|
|
GestureHandwritingRecording? nextItem = i + 1 < _length ? points[i + 1] : null;
|
|
|
|
|
|
|
|
|
|
Offset offsetData = item.data;
|
|
|
|
|
Offset? nextOffsetData = nextItem?.data;
|
|
|
|
|
if (nextOffsetData != null && item.stroke == nextItem?.stroke) {
|
|
|
|
|
canvas.drawLine(offsetData, nextOffsetData, paintBrush);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
canvas.restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool shouldRepaint(DrawingPainter oldDelegate) => true;
|
|
|
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
|
|
|
|
if (oldDelegate is HandWritingDrawingPainter) {
|
|
|
|
|
var repaint = ctrl.value.length != oldDelegate.ctrl.value.length || oldDelegate.ctrl.value != ctrl.value;
|
|
|
|
|
print('调用是否绘制:$repaint');
|
|
|
|
|
return repaint;
|
|
|
|
|
}
|
|
|
|
|
return true; // 如果 oldDelegate 不是 MyCustomPainter 的实例,则总是重绘
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@swidget
|
|
|
|
|
Widget $pageNumberBox(int pageNum) {
|
|
|
|
|
Widget $pageNumberBox(int pageNum, int totalNum) {
|
|
|
|
|
return Positioned(
|
|
|
|
|
top: 6.h,
|
|
|
|
|
right: 4.w,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 2.h),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.47),
|
|
|
|
|
borderRadius: BorderRadius.circular(5.r),
|
|
|
|
|
),
|
|
|
|
|
child: quickText('第$pageNum页', color: Colors.white, size: 10.sp),
|
|
|
|
|
),
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 2.h),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.47),
|
|
|
|
|
borderRadius: BorderRadius.circular(5.r),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
quickText('$pageNum', color: Colors.white, size: 11.sp, align: TextAlign.end),
|
|
|
|
|
quickText('/', color: Colors.white, size: 10.sp, align: TextAlign.end),
|
|
|
|
|
quickText('$totalNum', color: Colors.white, size: 8.sp, align: TextAlign.end),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@hwidget
|
|
|
|
|
Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, List<PauseIntervalTime> pauseIntervals) {
|
|
|
|
|
var usePlaybar = UseBottomPlaybar.use(timeConsuming);
|
|
|
|
|
|
|
|
|
|
useValueChanged<int, void>(timeConsuming, (_, __) {
|
|
|
|
|
usePlaybar.playTimingSuspend();
|
|
|
|
|
usePlaybar.playPause.value = false;
|
|
|
|
|
var seds = timeConsuming ~/ 1000;
|
|
|
|
|
if ((timeConsuming % 1000) > 500) seds += 1;
|
|
|
|
|
usePlaybar.handwritingDuration.value = seds;
|
|
|
|
|
usePlaybar.constantFastSpeed.value = PlaybackSpeed.ORIGINAL_SPEED;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useValueChanged<int, void>(usePlaybar.handwritingDuration.value, (_, __) {
|
|
|
|
|
@ -694,11 +720,11 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
|
|
|
|
if (_val.play) {
|
|
|
|
|
// 开始播放
|
|
|
|
|
usePlaybar.playTimingStarts();
|
|
|
|
|
if (!usePlaybar.playPause.value) usePlaybar.playPause.value = true;
|
|
|
|
|
if (!usePlaybar.playPause.value) Future.delayed(Duration.zero, () => usePlaybar.playPause.value = true);
|
|
|
|
|
} else {
|
|
|
|
|
// 暂停播放
|
|
|
|
|
usePlaybar.playTimingSuspend();
|
|
|
|
|
if (usePlaybar.playPause.value) usePlaybar.playPause.value = false;
|
|
|
|
|
if (usePlaybar.playPause.value) Future.delayed(Duration.zero, () => usePlaybar.playPause.value = false);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case JobHandwritingGetReadyBus:
|
|
|
|
|
@ -730,6 +756,8 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
|
|
|
|
if (usePlaybar.handWritingReady.value)
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () => easyThrottle('job_handwriting_play_pause', () {
|
|
|
|
|
if (usePlaybar.handwritingDuration.value == 0) return ToastUtils.showInfo('没有笔迹');
|
|
|
|
|
|
|
|
|
|
usePlaybar.playPause.value = !usePlaybar.playPause.value;
|
|
|
|
|
usePlaybar.eventFire(model: JobHandwritingPlaybarBus(usePlaybar.playPause.value));
|
|
|
|
|
}),
|
|
|
|
|
@ -743,93 +771,96 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
|
|
|
|
SpinKitPouringHourGlassRefined(size: 40.sp, color: Colors.white),
|
|
|
|
|
SizedBox(width: 6.w),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LayoutBuilder(
|
|
|
|
|
builder: (context, constraints) {
|
|
|
|
|
final double containerWidth = constraints.maxWidth; // 展示区域总宽度
|
|
|
|
|
// print('总刻度:$timeConsuming,宽度:$containerWidth');
|
|
|
|
|
// print('总时长:${pauseIntervals.map((e) => e.toJson()).toList()}');
|
|
|
|
|
var unitScale = containerWidth / timeConsuming; // 单位刻度
|
|
|
|
|
var pauseIntervalsLength = pauseIntervals.length;
|
|
|
|
|
List<Widget> pauseTickMarks = pauseIntervals.asMap().keys.map((e) {
|
|
|
|
|
bool isLast = e == pauseIntervalsLength - 1;
|
|
|
|
|
bool isFirst = e == 0;
|
|
|
|
|
var item = pauseIntervals[e];
|
|
|
|
|
return Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
left: unitScale * item.startTime,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: unitScale * (item.apart ?? 0),
|
|
|
|
|
height: 8.h,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: isFirst
|
|
|
|
|
? BorderRadius.only(topLeft: Radius.circular(8.r), bottomLeft: Radius.circular(10.r))
|
|
|
|
|
: (isLast ? BorderRadius.only(topRight: Radius.circular(8.r), bottomRight: Radius.circular(10.r)) : null),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
child: LayoutBuilder(builder: (context, constraints) {
|
|
|
|
|
final double containerWidth = constraints.maxWidth; // 展示区域总宽度
|
|
|
|
|
var unitScale = containerWidth / timeConsuming; // 单位刻度
|
|
|
|
|
var pauseIntervalsLength = pauseIntervals.length;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 8.h,
|
|
|
|
|
width: containerWidth,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
// color: Color.fromRGBO(146, 146, 146, 1),
|
|
|
|
|
color: Color.fromRGBO(202, 201, 201, 1),
|
|
|
|
|
borderRadius: BorderRadius.circular(50.r),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
...pauseTickMarks,
|
|
|
|
|
Container(
|
|
|
|
|
height: 8.h,
|
|
|
|
|
// color: Theme.of(context).primaryColor,
|
|
|
|
|
child: SliderTheme(
|
|
|
|
|
data: SliderTheme.of(context).copyWith(
|
|
|
|
|
trackHeight: 8.h, // 轨道高度
|
|
|
|
|
trackShape: RoundedRectSliderTrackShape(), // 轨道形状,可以自定义
|
|
|
|
|
activeTrackColor: Theme.of(context).primaryColor, // 激活的轨道颜色
|
|
|
|
|
inactiveTrackColor: Colors.transparent, // 未激活的轨道颜色
|
|
|
|
|
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 0, disabledThumbRadius: 0),
|
|
|
|
|
thumbColor: Colors.white, // 滑块颜色
|
|
|
|
|
overlayShape: RoundSliderOverlayShape(overlayRadius: 0),
|
|
|
|
|
overlayColor: Colors.black54, // 滑块外圈颜色
|
|
|
|
|
// valueIndicatorShape: PaddleSliderValueIndicatorShape(), // 标签形状,可以自定义
|
|
|
|
|
),
|
|
|
|
|
child: Slider(
|
|
|
|
|
value: (usePlaybar.handwritingDuration.value - usePlaybar.useTime.value).toDouble(),
|
|
|
|
|
min: 0.0,
|
|
|
|
|
max: usePlaybar.handwritingDuration.value.toDouble(),
|
|
|
|
|
inactiveColor: Colors.transparent,
|
|
|
|
|
onChangeEnd: (value) {
|
|
|
|
|
usePlaybar.playTimingSuspend(); // 暂停计时器得暂停
|
|
|
|
|
usePlaybar.eventFire(model: JobHandwritingDragProgressBarBus(value.toInt(), usePlaybar.handwritingDuration.value));
|
|
|
|
|
usePlaybar.useTime.value = usePlaybar.handwritingDuration.value - value.toInt();
|
|
|
|
|
},
|
|
|
|
|
onChanged: (double value) {
|
|
|
|
|
usePlaybar.useTime.value = usePlaybar.handwritingDuration.value - value.toInt();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
List<Widget> pauseTickMarks = pauseIntervals.asMap().keys.map((e) {
|
|
|
|
|
bool isLast = e == pauseIntervalsLength - 1;
|
|
|
|
|
bool isFirst = e == 0;
|
|
|
|
|
var item = pauseIntervals[e];
|
|
|
|
|
return Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
left: unitScale * item.startTime,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: unitScale * (item.apart ?? 0),
|
|
|
|
|
height: 8.h,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Color.fromRGBO(202, 201, 201, 1),
|
|
|
|
|
borderRadius: isFirst
|
|
|
|
|
? BorderRadius.only(topLeft: Radius.circular(8.r), bottomLeft: Radius.circular(10.r))
|
|
|
|
|
: (isLast ? BorderRadius.only(topRight: Radius.circular(8.r), bottomRight: Radius.circular(10.r)) : null),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 4.h),
|
|
|
|
|
Row(
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 8.h,
|
|
|
|
|
width: containerWidth,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
// color: Color.fromRGBO(146, 146, 146, 1),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(50.r),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
...pauseTickMarks,
|
|
|
|
|
Container(
|
|
|
|
|
height: 8.h,
|
|
|
|
|
width: containerWidth,
|
|
|
|
|
// color: Theme.of(context).primaryColor,
|
|
|
|
|
child: SliderTheme(
|
|
|
|
|
data: SliderTheme.of(context).copyWith(
|
|
|
|
|
trackHeight: 8.h, // 轨道高度
|
|
|
|
|
trackShape: RoundedRectSliderTrackShape(), // 轨道形状,可以自定义
|
|
|
|
|
activeTrackColor: Theme.of(context).primaryColor, // 激活的轨道颜色
|
|
|
|
|
inactiveTrackColor: Colors.transparent, // 未激活的轨道颜色
|
|
|
|
|
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 0, disabledThumbRadius: 0),
|
|
|
|
|
thumbColor: Colors.white, // 滑块颜色
|
|
|
|
|
overlayShape: RoundSliderOverlayShape(overlayRadius: 0),
|
|
|
|
|
overlayColor: Colors.black54, // 滑块外圈颜色
|
|
|
|
|
// valueIndicatorShape: PaddleSliderValueIndicatorShape(), // 标签形状,可以自定义
|
|
|
|
|
),
|
|
|
|
|
child: Slider(
|
|
|
|
|
value: (usePlaybar.handwritingDuration.value - usePlaybar.useTime.value).toDouble(),
|
|
|
|
|
min: 0.0,
|
|
|
|
|
max: usePlaybar.handwritingDuration.value.toDouble(),
|
|
|
|
|
inactiveColor: Colors.transparent,
|
|
|
|
|
onChangeEnd: (value) {
|
|
|
|
|
if (!usePlaybar.handWritingReady.value) return;
|
|
|
|
|
usePlaybar.playTimingSuspend(); // 暂停计时器得暂停
|
|
|
|
|
usePlaybar.eventFire(model: JobHandwritingDragProgressBarBus(value.toInt(), usePlaybar.handwritingDuration.value));
|
|
|
|
|
usePlaybar.useTime.value = usePlaybar.handwritingDuration.value - value.toInt();
|
|
|
|
|
},
|
|
|
|
|
onChanged: (double value) {
|
|
|
|
|
if (!usePlaybar.handWritingReady.value) return;
|
|
|
|
|
usePlaybar.useTime.value = usePlaybar.handwritingDuration.value - value.toInt();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 4.h),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: containerWidth,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
quickText('累计停顿:$pauseCount次', color: Colors.white, size: 7.sp),
|
|
|
|
|
quickText(convertSeconds(usePlaybar.useTime.value)?.toString() ?? '', color: Colors.white, size: 7.sp),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 16.w),
|
|
|
|
|
InkWell(
|
|
|
|
|
@ -839,7 +870,7 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
|
|
|
|
theIndex = -1;
|
|
|
|
|
}
|
|
|
|
|
usePlaybar.constantFastSpeed.value = PlaybackSpeed.values[theIndex + 1];
|
|
|
|
|
}),
|
|
|
|
|
}, duration: Duration(milliseconds: 500)),
|
|
|
|
|
child: Container(
|
|
|
|
|
// alignment: Alignment.,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 1.5.h),
|
|
|
|
|
@ -857,9 +888,34 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@swidget
|
|
|
|
|
Widget $pauseTickMark() {
|
|
|
|
|
return Container();
|
|
|
|
|
class SysjTime extends StatefulWidget {
|
|
|
|
|
const SysjTime({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<SysjTime> createState() => _SysjTimeState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SysjTimeState extends State<SysjTime> with EventBusMixin<JobHandwritingRunTimeBus> {
|
|
|
|
|
int useTime = 0;
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
eventOn(callback: (JobHandwritingRunTimeBus e) {
|
|
|
|
|
useTime = e.runTimeVal;
|
|
|
|
|
toUpState(setState, () {}, mounted);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
eventCancel();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return quickText(convertSeconds(useTime)?.toString() ?? '', color: Colors.white, size: 7.sp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UseBottomPlaybar with EventBusMixin {
|
|
|
|
|
@ -902,6 +958,7 @@ class UseBottomPlaybar with EventBusMixin {
|
|
|
|
|
timer.value = Timer.periodic(Duration(milliseconds: 1000 ~/ constantFastSpeed.value.speed), (theTime) {
|
|
|
|
|
useTime.value -= 1;
|
|
|
|
|
if (useTime.value < 0) {
|
|
|
|
|
theTime.cancel();
|
|
|
|
|
timer.value?.cancel();
|
|
|
|
|
timer.value = null;
|
|
|
|
|
useTime.value = handwritingDuration.value;
|
|
|
|
|
@ -920,7 +977,8 @@ class UseBottomPlaybar with EventBusMixin {
|
|
|
|
|
// 播放按钮
|
|
|
|
|
class JobHandwritingPlaybarBus {
|
|
|
|
|
bool play;
|
|
|
|
|
JobHandwritingPlaybarBus(this.play);
|
|
|
|
|
bool recalculate;
|
|
|
|
|
JobHandwritingPlaybarBus(this.play, [this.recalculate = true]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
|
|
|
|
|
|