优化顶部打分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/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/utils.dart';
|
||||
|
||||
import '../configuration_files/index.dart';
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
|||
lowerBound: 0,
|
||||
upperBound: 1,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
)..addListener(toUp);
|
||||
);
|
||||
|
||||
_opControllisten = _logicControl.opControl.listen((e) {
|
||||
if (e) {
|
||||
|
|
@ -48,37 +47,16 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController
|
||||
..removeListener(toUp)
|
||||
..dispose();
|
||||
_animationController.dispose();
|
||||
_opControllisten?.cancel();
|
||||
|
||||
eventCancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void toUp() => toUpState(setState, () {}, mounted);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
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(
|
||||
final Widget barContent = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 7,
|
||||
|
|
@ -93,8 +71,8 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch>
|
|||
child: _buildActionButton(
|
||||
'全对',
|
||||
Icons.check_circle_outline,
|
||||
() => easyThrottle('homework_bottom_operation_bar_scoring_related',
|
||||
() => _homeworkLogic.allPairs(context)),
|
||||
() => easyThrottle(
|
||||
'homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allPairs(context)),
|
||||
isEnabled: !_homeworkLogic.state.submitLoading.value,
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -135,28 +135,22 @@ Widget $questionNumberScrollView({
|
|||
|
||||
// 移除高频日志,避免在滚动/缩放时造成不必要的 I/O 开销
|
||||
|
||||
return SingleChildScrollView(
|
||||
return ListView.builder(
|
||||
controller: scrollControllerNum,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.only(top: usePiddingTop.value > 0 ? usePiddingTop.value : 0),
|
||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||
child: SizedBox(
|
||||
height: (actualImgHeight.value ?? 0) * useZoom.value,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: studentQuestions
|
||||
.map((e) => $ScoringQuestionsView(
|
||||
itemCount: studentQuestions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final e = studentQuestions[index];
|
||||
return $ScoringQuestionsView(
|
||||
key: Key('${sateData.data.value?.templateId}_${sateData.data.value?.studentId}_${e.questionNo}'),
|
||||
sateData: sateData,
|
||||
item: e,
|
||||
logic: controller,
|
||||
scaleRatio: sateZoomData.zoomFile.value!.scaleRatio,
|
||||
initScale: useZoom.value,
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue