Compare commits
No commits in common. "89e15ba6726901870447d650e57040f438c6b7eb" and "3666bea6bde2f01834eb57f98225e2892be813e3" have entirely different histories.
89e15ba672
...
3666bea6bd
|
|
@ -290,11 +290,7 @@ Widget $dropdownBoxSwitchStudentsOrTypeView(BuildContext context, {required Func
|
||||||
var _currentTab = _useSwitchStudentAndType.currentTab.value;
|
var _currentTab = _useSwitchStudentAndType.currentTab.value;
|
||||||
var _pageIndex = _currentTab?.pageIndex;
|
var _pageIndex = _currentTab?.pageIndex;
|
||||||
if (_currentTab == null || _pageIndex == null) return;
|
if (_currentTab == null || _pageIndex == null) return;
|
||||||
|
_useSwitchStudentAndType.refreshQuestionTypeData(context, taskId: taskId, exitCallback: exitCallback, getNewData: false).then((value) {
|
||||||
var theLastQuestion = _currentTab.finishCount + 1 == _currentTab.total; // 当前提交的题是最后一题
|
|
||||||
_useSwitchStudentAndType
|
|
||||||
.refreshQuestionTypeData(context, taskId: taskId, exitCallback: exitCallback, getNewData: theLastQuestion)
|
|
||||||
.then((value) {
|
|
||||||
var params = MarkingTextQuestionJobTabParamsBus(taskId, _pageIndex);
|
var params = MarkingTextQuestionJobTabParamsBus(taskId, _pageIndex);
|
||||||
if (_currentTab.finishCount < _currentTab.total) {
|
if (_currentTab.finishCount < _currentTab.total) {
|
||||||
if (_currentTab.finishCount + 1 == _currentTab.total) {
|
if (_currentTab.finishCount + 1 == _currentTab.total) {
|
||||||
|
|
@ -863,15 +859,16 @@ Widget $examPaperAndScoringKeyboardView(
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
if (question.accuracy > 0)
|
||||||
padding: EdgeInsets.only(bottom: 1.5.h),
|
Padding(
|
||||||
child: quickText(
|
padding: EdgeInsets.only(bottom: 1.5.h),
|
||||||
'正确率:${getDoubleRemoveZero(question.accuracy, question.accuracy.toString())}%',
|
child: quickText(
|
||||||
size: 8.sp,
|
'正确率:${getDoubleRemoveZero(question.accuracy, question.accuracy.toString())}%',
|
||||||
color: Colors.white,
|
size: 8.sp,
|
||||||
align: TextAlign.end,
|
color: Colors.white,
|
||||||
),
|
align: TextAlign.end,
|
||||||
)
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ class UseSwitchStudentAndType with CommonMixin, EventBusMixin {
|
||||||
return tabJob;
|
return tabJob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ToastUtils.showSuccess('最后一题提交成功');
|
ToastUtils.showSuccess('最后一题提交成功');
|
||||||
}
|
}
|
||||||
return tabJob;
|
return tabJob;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,10 +261,19 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(flex: 1, child: SizedBox()),
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
RouterManager.router.navigateTo(context, RouterManager.jobStudentGroupPath, transition: getTransition());
|
||||||
|
},
|
||||||
|
child: Icon(IconData(0xe63e, fontFamily: "AlibabaIcon"), color: Color.fromRGBO(44, 48, 63, 1), size: 24.sp),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (_tabIndex == 1)
|
if (_tabIndex == 1)
|
||||||
$CompletedJobConditionFilter(
|
$CompletedJobConditionFilter(
|
||||||
controller: _tabController2,
|
controller: _tabController2,
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,6 @@ class AnswerHandwritingMainBox extends HookWidget {
|
||||||
HandwritingInfo? _dataDetail = _useStateModel.handwritingDetail.value;
|
HandwritingInfo? _dataDetail = _useStateModel.handwritingDetail.value;
|
||||||
|
|
||||||
if (_data == null || _dataDetail == null) return Container();
|
if (_data == null || _dataDetail == null) return Container();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
@ -125,7 +124,7 @@ class AnswerHandwritingMainBox extends HookWidget {
|
||||||
_dataDetail,
|
_dataDetail,
|
||||||
key: _useStateModel.handwritingKey,
|
key: _useStateModel.handwritingKey,
|
||||||
),
|
),
|
||||||
$PageNumberBox(_data.pageNum, _data.pageCount),
|
$PageNumberBox(_data.pageNum),
|
||||||
// 上一页按钮
|
// 上一页按钮
|
||||||
$PreviousNutton(
|
$PreviousNutton(
|
||||||
_useStateModel.pageNum.value,
|
_useStateModel.pageNum.value,
|
||||||
|
|
@ -210,6 +209,7 @@ class UseMainBoxState with CommonMixin {
|
||||||
|
|
||||||
HandwritingInfo? getHandwritingDetail(JobHandwriting? theData) {
|
HandwritingInfo? getHandwritingDetail(JobHandwriting? theData) {
|
||||||
if (theData == null) return null;
|
if (theData == null) return null;
|
||||||
|
print('开始时间:${DateTime.now().millisecondsSinceEpoch}');
|
||||||
// 笔画分组
|
// 笔画分组
|
||||||
// var lattices = Map<int, List<Lattices>>.fromIterable(
|
// var lattices = Map<int, List<Lattices>>.fromIterable(
|
||||||
// theData.lattices,
|
// theData.lattices,
|
||||||
|
|
@ -374,9 +374,6 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
TestQuestionsImageInfo? imagInfoModel; // 试题图片数据
|
TestQuestionsImageInfo? imagInfoModel; // 试题图片数据
|
||||||
late ImageStreamListener theImageStreamListener;
|
late ImageStreamListener theImageStreamListener;
|
||||||
|
|
||||||
late ValueNotifier<List<GestureHandwritingRecording>> _vnHandWritings;
|
|
||||||
|
|
||||||
late RemoveListener _jobHandwritingDrawingTrajectoryListener; // 批注关闭监听
|
|
||||||
List<List<GestureHandwritingRecording>> _packagedHandwritingDatas = [];
|
List<List<GestureHandwritingRecording>> _packagedHandwritingDatas = [];
|
||||||
List<GestureHandwritingRecording> _packagedHandwritingDataAll = [];
|
List<GestureHandwritingRecording> _packagedHandwritingDataAll = [];
|
||||||
List<GestureHandwritingRecording> pendingData = []; // 待执行数据
|
List<GestureHandwritingRecording> pendingData = []; // 待执行数据
|
||||||
|
|
@ -387,10 +384,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_vnHandWritings = ValueNotifier<List<GestureHandwritingRecording>>([]);
|
|
||||||
_jobHandwritingDrawingTrajectoryListener = ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).addListener((state) {
|
|
||||||
_vnHandWritings.value = state;
|
|
||||||
}, fireImmediately: false);
|
|
||||||
eventOn(callback: (e) {
|
eventOn(callback: (e) {
|
||||||
switch (e.runtimeType) {
|
switch (e.runtimeType) {
|
||||||
case JobHandwritingRunTimeBus:
|
case JobHandwritingRunTimeBus:
|
||||||
|
|
@ -414,14 +408,15 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
toGoPlay();
|
toGoPlay();
|
||||||
} else {
|
} else {
|
||||||
// 暂停
|
// 暂停
|
||||||
toGoPause(_val.recalculate);
|
toGoPause();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlaybackSpeedBus:
|
case PlaybackSpeedBus:
|
||||||
// 播放速度
|
// 播放速度
|
||||||
var _model = (e as PlaybackSpeedBus);
|
var _model = (e as PlaybackSpeedBus);
|
||||||
speed = _model.speed;
|
speed = _model.speed;
|
||||||
dragProgressBarInitData(handwritingDuration - handwritingTime, handwritingDuration);
|
toGoPause(); // 先暂停再重新播放
|
||||||
|
dragProgressBarInitData(handwritingTime, handwritingDuration);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
@ -446,8 +441,6 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
timers.forEach((e) {
|
timers.forEach((e) {
|
||||||
if (e.isActive) e.cancel();
|
if (e.isActive) e.cancel();
|
||||||
});
|
});
|
||||||
_jobHandwritingDrawingTrajectoryListener();
|
|
||||||
_vnHandWritings.dispose();
|
|
||||||
try {
|
try {
|
||||||
imageStream?.removeListener(theImageStreamListener);
|
imageStream?.removeListener(theImageStreamListener);
|
||||||
eventCancel();
|
eventCancel();
|
||||||
|
|
@ -456,13 +449,12 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暂停播放
|
// 暂停播放
|
||||||
Future<void> toGoPause(bool recalculate) async {
|
Future<void> toGoPause() async {
|
||||||
timers.forEach((e) {
|
timers.forEach((e) {
|
||||||
if (e.isActive) e.cancel();
|
if (e.isActive) e.cancel();
|
||||||
});
|
});
|
||||||
timers = [];
|
timers = [];
|
||||||
// 总时间-剩余时间=已经执行时间
|
if (pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
||||||
if (recalculate && pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
|
||||||
// 待执行的数据不等于空 每个数据都需要减去当前暂停已经执行的时间
|
// 待执行的数据不等于空 每个数据都需要减去当前暂停已经执行的时间
|
||||||
pendingData = pendingData.map((e) {
|
pendingData = pendingData.map((e) {
|
||||||
return GestureHandwritingRecording(
|
return GestureHandwritingRecording(
|
||||||
|
|
@ -478,7 +470,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
/// 拖动进度条后重新初始化数据
|
/// 拖动进度条后重新初始化数据
|
||||||
/// @param startTime 起始时间 单位秒
|
/// @param startTime 起始时间 单位秒
|
||||||
Future<void> dragProgressBarInitData(int startTime, int totalDuration) async {
|
Future<void> dragProgressBarInitData(int startTime, int totalDuration) async {
|
||||||
eventFire(model: JobHandwritingPlaybarBus(false, false));
|
eventFire(model: JobHandwritingPlaybarBus(false));
|
||||||
timers.forEach((e) {
|
timers.forEach((e) {
|
||||||
if (e.isActive) e.cancel();
|
if (e.isActive) e.cancel();
|
||||||
});
|
});
|
||||||
|
|
@ -507,7 +499,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
stroke: item.stroke,
|
stroke: item.stroke,
|
||||||
data: item.data,
|
data: item.data,
|
||||||
usageTime: item.usageTime,
|
usageTime: item.usageTime,
|
||||||
intervalTime: intervalTime,
|
intervalTime: intervalTime < 0 ? 0 : intervalTime,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -528,23 +520,24 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
|
|
||||||
/// 开始播放
|
/// 开始播放
|
||||||
Future<void> toGoPlay() async {
|
Future<void> toGoPlay() async {
|
||||||
try {
|
handwritingTime = 0;
|
||||||
var executableData = _packagedHandwritingDataAll;
|
var executableData = _packagedHandwritingDataAll;
|
||||||
if (pendingData.isNotEmpty) {
|
if (pendingData.isNotEmpty) {
|
||||||
// 待执行的数据没有执行完成 就继续执行待执行数据
|
// 待执行的数据没有执行完成 就继续执行待执行数据
|
||||||
executableData = pendingData;
|
executableData = pendingData;
|
||||||
} else {
|
} else {
|
||||||
pendingData.addAll(_packagedHandwritingDataAll);
|
pendingData.addAll(_packagedHandwritingDataAll);
|
||||||
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
executableData.forEach((e) {
|
executableData.forEach((e) {
|
||||||
|
if (e.intervalTime == 0) {
|
||||||
|
zhixinCall(e);
|
||||||
|
} else {
|
||||||
var ter = Timer(Duration(milliseconds: e.intervalTime ~/ speed), () => zhixinCall(e));
|
var ter = Timer(Duration(milliseconds: e.intervalTime ~/ speed), () => zhixinCall(e));
|
||||||
timers.add(ter);
|
timers.add(ter);
|
||||||
});
|
}
|
||||||
} catch (e) {
|
});
|
||||||
print('播放报错:$e');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算尺寸
|
// 计算尺寸
|
||||||
|
|
@ -568,8 +561,6 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
newTrajectoryData.sort((a, b) => a.usageTime.compareTo(b.usageTime));
|
|
||||||
|
|
||||||
_packagedHandwritingDatas.add(newTrajectoryData); // 分组数据
|
_packagedHandwritingDatas.add(newTrajectoryData); // 分组数据
|
||||||
_packagedHandwritingDataAll.addAll(newTrajectoryData); // 不分组数据
|
_packagedHandwritingDataAll.addAll(newTrajectoryData); // 不分组数据
|
||||||
}
|
}
|
||||||
|
|
@ -579,29 +570,26 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
List<GestureHandwritingRecording> points = ref.watch(jobHandwritingDrawingTrajectoryProvider);
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: RepaintBoundary(
|
child: CustomPaint(
|
||||||
child: CustomPaint(
|
foregroundPainter: DrawingPainter(points: points),
|
||||||
willChange: true,
|
// size: Size(ScreenUtil().screenWidth - 60.r, widget.boxHeight),
|
||||||
isComplex: true,
|
child: RepaintBoundary(
|
||||||
foregroundPainter: HandWritingDrawingPainter(ctrl: _vnHandWritings),
|
child: $TheCachedNetworkImage(
|
||||||
// size: Size(ScreenUtil().screenWidth - 60.r, widget.boxHeight),
|
imageUrl: widget.image,
|
||||||
child: RepaintBoundary(
|
(context, imageProvider) {
|
||||||
child: $TheCachedNetworkImage(
|
Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain);
|
||||||
imageUrl: widget.image,
|
if (imagInfoModel == null) {
|
||||||
(context, imageProvider) {
|
imageStream?.removeListener(theImageStreamListener);
|
||||||
Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain);
|
// 视图中展示图片的尺寸计算获取
|
||||||
if (imagInfoModel == null) {
|
imageStream = imageWidget.image.resolve(ImageConfiguration());
|
||||||
imageStream?.removeListener(theImageStreamListener);
|
imageStream?.addListener(theImageStreamListener);
|
||||||
// 视图中展示图片的尺寸计算获取
|
}
|
||||||
imageStream = imageWidget.image.resolve(ImageConfiguration());
|
|
||||||
imageStream?.addListener(theImageStreamListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageWidget;
|
return imageWidget;
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -609,9 +597,16 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HandWritingDrawingPainter extends CustomPainter {
|
class DrawingPainter extends CustomPainter {
|
||||||
final ValueNotifier<List<GestureHandwritingRecording>> ctrl;
|
List<GestureHandwritingRecording> points;
|
||||||
HandWritingDrawingPainter({required this.ctrl}) : super(repaint: ctrl);
|
|
||||||
|
DrawingPainter({required this.points}) : super();
|
||||||
|
|
||||||
|
// Paint paintBrush = Paint()
|
||||||
|
// ..color = Colors.black
|
||||||
|
// ..strokeCap = StrokeCap.round
|
||||||
|
// ..strokeWidth = 0.5.sp;
|
||||||
|
|
||||||
//[定义画笔]
|
//[定义画笔]
|
||||||
final Paint paintBrush = Paint()
|
final Paint paintBrush = Paint()
|
||||||
//画笔颜色
|
//画笔颜色
|
||||||
|
|
@ -619,77 +614,56 @@ class HandWritingDrawingPainter extends CustomPainter {
|
||||||
//画笔笔触类型
|
//画笔笔触类型
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
//是否启动抗锯齿
|
//是否启动抗锯齿
|
||||||
..isAntiAlias = true
|
// ..isAntiAlias = true
|
||||||
//绘画风格,默认为填充
|
//绘画风格,默认为填充
|
||||||
// ..style = PaintingStyle.fill
|
// ..style = PaintingStyle.fill
|
||||||
//画笔的宽度
|
//画笔的宽度
|
||||||
..style = PaintingStyle.stroke
|
..strokeWidth = 0.6.r;
|
||||||
..strokeWidth = 0.5.r;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
// canvas.drawPoints(PointMode.points, thePoints, paintBrush);
|
// canvas.drawPoints(PointMode.points, thePoints, paintBrush);
|
||||||
canvas.save();
|
|
||||||
|
|
||||||
var points = ctrl.value;
|
|
||||||
var _length = points.length;
|
var _length = points.length;
|
||||||
for (int i = 0; i < _length; i++) {
|
for (int i = 0; i < _length; i++) {
|
||||||
GestureHandwritingRecording item = points[i];
|
GestureHandwritingRecording item = points[i];
|
||||||
GestureHandwritingRecording? nextItem = i + 1 < _length ? points[i + 1] : null;
|
GestureHandwritingRecording? nextItem = i + 1 >= _length ? null : points[i + 1];
|
||||||
|
Offset? offsetData = item.data;
|
||||||
|
|
||||||
Offset offsetData = item.data;
|
|
||||||
Offset? nextOffsetData = nextItem?.data;
|
Offset? nextOffsetData = nextItem?.data;
|
||||||
if (nextOffsetData != null && item.stroke == nextItem?.stroke) {
|
if (nextOffsetData != null && item.stroke == nextItem?.stroke) {
|
||||||
canvas.drawLine(offsetData, nextOffsetData, paintBrush);
|
canvas.drawLine(offsetData, nextOffsetData, paintBrush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
canvas.restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
bool shouldRepaint(DrawingPainter oldDelegate) => true;
|
||||||
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
|
@swidget
|
||||||
Widget $pageNumberBox(int pageNum, int totalNum) {
|
Widget $pageNumberBox(int pageNum) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
top: 6.h,
|
top: 6.h,
|
||||||
right: 4.w,
|
right: 4.w,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 2.h),
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 2.h),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.47),
|
color: Color.fromRGBO(0, 0, 0, 0.47),
|
||||||
borderRadius: BorderRadius.circular(5.r),
|
borderRadius: BorderRadius.circular(5.r),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: quickText('第$pageNum页', color: Colors.white, size: 10.sp),
|
||||||
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
|
@hwidget
|
||||||
Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, List<PauseIntervalTime> pauseIntervals) {
|
Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, List<PauseIntervalTime> pauseIntervals) {
|
||||||
var usePlaybar = UseBottomPlaybar.use(timeConsuming);
|
var usePlaybar = UseBottomPlaybar.use(timeConsuming);
|
||||||
|
|
||||||
useValueChanged<int, void>(timeConsuming, (_, __) {
|
useValueChanged<int, void>(timeConsuming, (_, __) {
|
||||||
usePlaybar.playTimingSuspend();
|
|
||||||
usePlaybar.playPause.value = false;
|
|
||||||
var seds = timeConsuming ~/ 1000;
|
var seds = timeConsuming ~/ 1000;
|
||||||
if ((timeConsuming % 1000) > 500) seds += 1;
|
if ((timeConsuming % 1000) > 500) seds += 1;
|
||||||
usePlaybar.handwritingDuration.value = seds;
|
usePlaybar.handwritingDuration.value = seds;
|
||||||
usePlaybar.constantFastSpeed.value = PlaybackSpeed.ORIGINAL_SPEED;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useValueChanged<int, void>(usePlaybar.handwritingDuration.value, (_, __) {
|
useValueChanged<int, void>(usePlaybar.handwritingDuration.value, (_, __) {
|
||||||
|
|
@ -720,11 +694,11 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
if (_val.play) {
|
if (_val.play) {
|
||||||
// 开始播放
|
// 开始播放
|
||||||
usePlaybar.playTimingStarts();
|
usePlaybar.playTimingStarts();
|
||||||
if (!usePlaybar.playPause.value) Future.delayed(Duration.zero, () => usePlaybar.playPause.value = true);
|
if (!usePlaybar.playPause.value) usePlaybar.playPause.value = true;
|
||||||
} else {
|
} else {
|
||||||
// 暂停播放
|
// 暂停播放
|
||||||
usePlaybar.playTimingSuspend();
|
usePlaybar.playTimingSuspend();
|
||||||
if (usePlaybar.playPause.value) Future.delayed(Duration.zero, () => usePlaybar.playPause.value = false);
|
if (usePlaybar.playPause.value) usePlaybar.playPause.value = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JobHandwritingGetReadyBus:
|
case JobHandwritingGetReadyBus:
|
||||||
|
|
@ -756,8 +730,6 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
if (usePlaybar.handWritingReady.value)
|
if (usePlaybar.handWritingReady.value)
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => easyThrottle('job_handwriting_play_pause', () {
|
onTap: () => easyThrottle('job_handwriting_play_pause', () {
|
||||||
if (usePlaybar.handwritingDuration.value == 0) return ToastUtils.showInfo('没有笔迹');
|
|
||||||
|
|
||||||
usePlaybar.playPause.value = !usePlaybar.playPause.value;
|
usePlaybar.playPause.value = !usePlaybar.playPause.value;
|
||||||
usePlaybar.eventFire(model: JobHandwritingPlaybarBus(usePlaybar.playPause.value));
|
usePlaybar.eventFire(model: JobHandwritingPlaybarBus(usePlaybar.playPause.value));
|
||||||
}),
|
}),
|
||||||
|
|
@ -771,96 +743,93 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
SpinKitPouringHourGlassRefined(size: 40.sp, color: Colors.white),
|
SpinKitPouringHourGlassRefined(size: 40.sp, color: Colors.white),
|
||||||
SizedBox(width: 6.w),
|
SizedBox(width: 6.w),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: LayoutBuilder(builder: (context, constraints) {
|
child: LayoutBuilder(
|
||||||
final double containerWidth = constraints.maxWidth; // 展示区域总宽度
|
builder: (context, constraints) {
|
||||||
var unitScale = containerWidth / timeConsuming; // 单位刻度
|
final double containerWidth = constraints.maxWidth; // 展示区域总宽度
|
||||||
var pauseIntervalsLength = pauseIntervals.length;
|
// print('总刻度:$timeConsuming,宽度:$containerWidth');
|
||||||
|
// print('总时长:${pauseIntervals.map((e) => e.toJson()).toList()}');
|
||||||
List<Widget> pauseTickMarks = pauseIntervals.asMap().keys.map((e) {
|
var unitScale = containerWidth / timeConsuming; // 单位刻度
|
||||||
bool isLast = e == pauseIntervalsLength - 1;
|
var pauseIntervalsLength = pauseIntervals.length;
|
||||||
bool isFirst = e == 0;
|
List<Widget> pauseTickMarks = pauseIntervals.asMap().keys.map((e) {
|
||||||
var item = pauseIntervals[e];
|
bool isLast = e == pauseIntervalsLength - 1;
|
||||||
return Positioned(
|
bool isFirst = e == 0;
|
||||||
top: 0,
|
var item = pauseIntervals[e];
|
||||||
left: unitScale * item.startTime,
|
return Positioned(
|
||||||
child: Container(
|
top: 0,
|
||||||
width: unitScale * (item.apart ?? 0),
|
left: unitScale * item.startTime,
|
||||||
height: 8.h,
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
width: unitScale * (item.apart ?? 0),
|
||||||
color: Color.fromRGBO(202, 201, 201, 1),
|
height: 8.h,
|
||||||
borderRadius: isFirst
|
decoration: BoxDecoration(
|
||||||
? BorderRadius.only(topLeft: Radius.circular(8.r), bottomLeft: Radius.circular(10.r))
|
color: Colors.white,
|
||||||
: (isLast ? BorderRadius.only(topRight: Radius.circular(8.r), bottomRight: Radius.circular(10.r)) : null),
|
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();
|
||||||
}).toList();
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: 8.h,
|
height: 8.h,
|
||||||
width: containerWidth,
|
width: containerWidth,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// color: Color.fromRGBO(146, 146, 146, 1),
|
// color: Color.fromRGBO(146, 146, 146, 1),
|
||||||
color: Colors.white,
|
color: Color.fromRGBO(202, 201, 201, 1),
|
||||||
borderRadius: BorderRadius.circular(50.r),
|
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();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
...pauseTickMarks,
|
||||||
],
|
Container(
|
||||||
),
|
height: 8.h,
|
||||||
SizedBox(height: 4.h),
|
// color: Theme.of(context).primaryColor,
|
||||||
SizedBox(
|
child: SliderTheme(
|
||||||
width: containerWidth,
|
data: SliderTheme.of(context).copyWith(
|
||||||
child: Row(
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 4.h),
|
||||||
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
quickText('累计停顿:$pauseCount次', color: Colors.white, size: 7.sp),
|
quickText('累计停顿:$pauseCount次', color: Colors.white, size: 7.sp),
|
||||||
quickText(convertSeconds(usePlaybar.useTime.value)?.toString() ?? '', color: Colors.white, size: 7.sp),
|
quickText(convertSeconds(usePlaybar.useTime.value)?.toString() ?? '', color: Colors.white, size: 7.sp),
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
)
|
],
|
||||||
],
|
);
|
||||||
);
|
},
|
||||||
}),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 16.w),
|
SizedBox(width: 16.w),
|
||||||
InkWell(
|
InkWell(
|
||||||
|
|
@ -870,7 +839,7 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
theIndex = -1;
|
theIndex = -1;
|
||||||
}
|
}
|
||||||
usePlaybar.constantFastSpeed.value = PlaybackSpeed.values[theIndex + 1];
|
usePlaybar.constantFastSpeed.value = PlaybackSpeed.values[theIndex + 1];
|
||||||
}, duration: Duration(milliseconds: 500)),
|
}),
|
||||||
child: Container(
|
child: Container(
|
||||||
// alignment: Alignment.,
|
// alignment: Alignment.,
|
||||||
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 1.5.h),
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 1.5.h),
|
||||||
|
|
@ -888,34 +857,9 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SysjTime extends StatefulWidget {
|
@swidget
|
||||||
const SysjTime({super.key});
|
Widget $pauseTickMark() {
|
||||||
|
return Container();
|
||||||
@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 {
|
class UseBottomPlaybar with EventBusMixin {
|
||||||
|
|
@ -958,7 +902,6 @@ class UseBottomPlaybar with EventBusMixin {
|
||||||
timer.value = Timer.periodic(Duration(milliseconds: 1000 ~/ constantFastSpeed.value.speed), (theTime) {
|
timer.value = Timer.periodic(Duration(milliseconds: 1000 ~/ constantFastSpeed.value.speed), (theTime) {
|
||||||
useTime.value -= 1;
|
useTime.value -= 1;
|
||||||
if (useTime.value < 0) {
|
if (useTime.value < 0) {
|
||||||
theTime.cancel();
|
|
||||||
timer.value?.cancel();
|
timer.value?.cancel();
|
||||||
timer.value = null;
|
timer.value = null;
|
||||||
useTime.value = handwritingDuration.value;
|
useTime.value = handwritingDuration.value;
|
||||||
|
|
@ -977,8 +920,7 @@ class UseBottomPlaybar with EventBusMixin {
|
||||||
// 播放按钮
|
// 播放按钮
|
||||||
class JobHandwritingPlaybarBus {
|
class JobHandwritingPlaybarBus {
|
||||||
bool play;
|
bool play;
|
||||||
bool recalculate;
|
JobHandwritingPlaybarBus(this.play);
|
||||||
JobHandwritingPlaybarBus(this.play, [this.recalculate = true]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
|
// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue