优化顶部打分bar 和 number 打分栏的rebuild 性能优化
This commit is contained in:
parent
2ac88000cc
commit
4161a9fcc8
|
|
@ -6,7 +6,6 @@ import 'package:get/get.dart';
|
||||||
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart';
|
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart';
|
||||||
import 'package:making_school_asignment_app/common/mixins/event_bus_mixin.dart';
|
import 'package:making_school_asignment_app/common/mixins/event_bus_mixin.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/anti_shake_throttling.dart';
|
import 'package:making_school_asignment_app/common/utils/anti_shake_throttling.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/utils.dart';
|
|
||||||
|
|
||||||
import '../configuration_files/index.dart';
|
import '../configuration_files/index.dart';
|
||||||
|
|
||||||
|
|
@ -33,7 +32,7 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
||||||
lowerBound: 0,
|
lowerBound: 0,
|
||||||
upperBound: 1,
|
upperBound: 1,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
)..addListener(toUp);
|
);
|
||||||
|
|
||||||
_opControllisten = _logicControl.opControl.listen((e) {
|
_opControllisten = _logicControl.opControl.listen((e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
|
|
@ -48,37 +47,16 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_animationController
|
_animationController.dispose();
|
||||||
..removeListener(toUp)
|
|
||||||
..dispose();
|
|
||||||
_opControllisten?.cancel();
|
_opControllisten?.cancel();
|
||||||
|
|
||||||
eventCancel();
|
eventCancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toUp() => toUpState(setState, () {}, mounted);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
final Widget barContent = Row(
|
||||||
left: false,
|
|
||||||
right: false,
|
|
||||||
top: false,
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: _animationController.value * 70.h,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color.fromRGBO(83, 83, 83, 1),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.1),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, -2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 7,
|
flex: 7,
|
||||||
|
|
@ -93,8 +71,8 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
||||||
child: _buildActionButton(
|
child: _buildActionButton(
|
||||||
'全对',
|
'全对',
|
||||||
Icons.check_circle_outline,
|
Icons.check_circle_outline,
|
||||||
() => easyThrottle('homework_bottom_operation_bar_scoring_related',
|
() => easyThrottle(
|
||||||
() => _homeworkLogic.allPairs(context)),
|
'homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allPairs(context)),
|
||||||
isEnabled: !_homeworkLogic.state.submitLoading.value,
|
isEnabled: !_homeworkLogic.state.submitLoading.value,
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
),
|
),
|
||||||
|
|
@ -210,8 +188,33 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
return SafeArea(
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
top: false,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: _animationController,
|
||||||
|
builder: (context, _) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: _animationController.value * 70.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color.fromRGBO(83, 83, 83, 1),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.1),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, -2),
|
||||||
),
|
),
|
||||||
));
|
],
|
||||||
|
),
|
||||||
|
child: barContent,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildActionButton(
|
Widget _buildActionButton(
|
||||||
|
|
|
||||||
|
|
@ -135,28 +135,22 @@ Widget $questionNumberScrollView({
|
||||||
|
|
||||||
// 移除高频日志,避免在滚动/缩放时造成不必要的 I/O 开销
|
// 移除高频日志,避免在滚动/缩放时造成不必要的 I/O 开销
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return ListView.builder(
|
||||||
controller: scrollControllerNum,
|
controller: scrollControllerNum,
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
padding: EdgeInsets.only(top: usePiddingTop.value > 0 ? usePiddingTop.value : 0),
|
padding: EdgeInsets.only(top: usePiddingTop.value > 0 ? usePiddingTop.value : 0),
|
||||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
itemCount: studentQuestions.length,
|
||||||
child: SizedBox(
|
itemBuilder: (context, index) {
|
||||||
height: (actualImgHeight.value ?? 0) * useZoom.value,
|
final e = studentQuestions[index];
|
||||||
child: Column(
|
return $ScoringQuestionsView(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: studentQuestions
|
|
||||||
.map((e) => $ScoringQuestionsView(
|
|
||||||
key: Key('${sateData.data.value?.templateId}_${sateData.data.value?.studentId}_${e.questionNo}'),
|
key: Key('${sateData.data.value?.templateId}_${sateData.data.value?.studentId}_${e.questionNo}'),
|
||||||
sateData: sateData,
|
sateData: sateData,
|
||||||
item: e,
|
item: e,
|
||||||
logic: controller,
|
logic: controller,
|
||||||
scaleRatio: sateZoomData.zoomFile.value!.scaleRatio,
|
scaleRatio: sateZoomData.zoomFile.value!.scaleRatio,
|
||||||
initScale: useZoom.value,
|
initScale: useZoom.value,
|
||||||
))
|
);
|
||||||
.toList(),
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue