// import 'package:flutter/material.dart';
// import 'package:flutter_hooks/flutter_hooks.dart';
// import 'package:flutter_riverpod/flutter_riverpod.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:functional_widget_annotation/functional_widget_annotation.dart';
// import 'package:marking_app/common/model/enum/KeyboardType.dart';
// import 'package:marking_app/common/model/event_bus/job_large_question_scoring_bus.dart';
// import 'package:marking_app/common/model/job/marking_text_question_job.dart';
// import 'package:marking_app/common/model/marking/do_marking_keyboard_model.dart';
// import 'package:marking_app/components/PictureOverview.dart';
// import 'package:marking_app/pages/common/event_bus_mixin.dart';
// import 'package:marking_app/pages/homework_correction/components/jobPictureOverview.dart';
// import 'package:marking_app/pages/homework_correction/hooks/use_data.dart';
// import 'package:marking_app/pages/homework_correction/hooks/use_keyboard.dart';
// import 'package:marking_app/utils/index.dart';
// import 'package:marking_app/utils/my_text.dart';

// part 'keyboardBox.g.dart';

// // 键盘
// class KeyboardBox extends HookWidget with EventBusMixin<JobLargeQuestionScoringBus> {
//   final UseData useData;
//   final DoMarkingKeyboardModel preferenceModel;
//   final GlobalKey<JobPictureOverviewState> scaffoldKeyPictureOverview;
//   KeyboardBox(
//       {required this.scaffoldKeyPictureOverview, required this.preferenceModel, required this.useData, Key? key})
//       : super(key: key);

//   @override
//   Widget build(BuildContext context) {
//     UseKeyboard _useKeyboard = UseKeyboard.use(preferenceModel);
//     MarkingTextQuestionJob job = useData.textQuestionState.value!;
//     KeyboardType keyboard = preferenceModel.keyboard;
//     bool _openAuxiliary = preferenceModel.openAuxiliary;
//     SortKeyboard sort = preferenceModel.sort!;
//     AnimationController controller = useAnimationController(
//       initialValue: _openAuxiliary ? 144 : 72, // 设置默认值
//       duration: const Duration(milliseconds: 400),
//       lowerBound: 72,
//       upperBound: 144,
//     );
//     useValueChanged<DoMarkingKeyboardModel, String>(preferenceModel, (oldValue, oldResult) {
//       _useKeyboard.init(
//         job: job,
//         sort: preferenceModel.sort!,
//         localScoreInterval: preferenceModel.getScoreStepSize(useData.taskId, job.questionNum, 1),
//       );
//     });

//     useEffect(() {
//       _useKeyboard.init(
//         job: job,
//         sort: preferenceModel.sort!,
//         localScoreInterval: preferenceModel.getScoreStepSize(useData.taskId, job.questionNum, 1),
//       );

//       return () {
//         eventCancel();
//         _useKeyboard.disBus();
//       };
//     }, []);

//     bool horizontal = preferenceModel.screenDirection == ScreenDirection.HORIZONTAL_SCREEN; // 屏幕方向
//     double animationVal = controller.value.h;

//     // 已经选中辅助键盘的分数，扣除十位分数剩余分数差值
//     double dValue = _useKeyboard.tensVal.value != null
//         ? job.totalScore - _useKeyboard.tensVal.value!.toDouble()
//         : job.totalScore; // 差值

//     return KeyBoardMainBox(
//       call: (num? value) {
//         eventFire(
//           model: JobLargeQuestionScoringBus(
//             ratingScore: value?.toDouble(),
//           ),
//         );
//       },
//       scaffoldKeyPictureOverview: scaffoldKeyPictureOverview,
//       animationVal: animationVal,
//       useKeyboard: _useKeyboard,
//       dValue: dValue,
//       horizontal: horizontal,
//       job: job,
//       keyboard: keyboard,
//       openAuxiliary: _openAuxiliary,
//       sort: sort,
//     );
//   }
// }

// class KeyBoardMainBox extends ConsumerWidget {
//   final KeyboardType keyboard;
//   final MarkingTextQuestionJob job;
//   final SortKeyboard sort;
//   final bool horizontal;
//   final double animationVal;
//   final UseKeyboard useKeyboard;
//   final double dValue;
//   final bool openAuxiliary;
//   final GlobalKey<JobPictureOverviewState> scaffoldKeyPictureOverview;
//   final Function(num?) call;

//   final Duration easyThrottleTime = const Duration(milliseconds: 1000);
//   const KeyBoardMainBox({
//     required this.scaffoldKeyPictureOverview,
//     required this.horizontal,
//     required this.animationVal,
//     required this.keyboard,
//     required this.job,
//     required this.sort,
//     required this.useKeyboard,
//     required this.dValue,
//     required this.openAuxiliary,
//     required this.call,
//     super.key,
//   });

//   @override
//   Widget build(BuildContext context, WidgetRef ref) {
//     return keyboard == KeyboardType.RIGHT_SELECTION
//         ? $RightKeyboard(
//             job: job,
//             tens: [],
//             sort: sort,
//             horizontal: horizontal,
//             animationVal: animationVal,
//             easyThrottleTime: easyThrottleTime,
//             combineList: useKeyboard.combineList.value,
//             dValue: dValue,
//             scoring: (fraction, isTens) {
//               useKeyboard
//                   .readOver(
//                       scaffoldKeyPictureOverview: scaffoldKeyPictureOverview,
//                       context: context,
//                       fraction: fraction,
//                       job: job)
//                   .then((value) {
//                 // ref.read(annotationGraffitiSwitchProvider.notifier).setSwitch(false);
//                 call(value);
//               });
//             },
//             openAuxiliary: openAuxiliary,
//             singleDigitList: useKeyboard.singleDigitList.value,
//             smallScoreVal: useKeyboard.smallScoreVal.value,
//             tensVal: useKeyboard.tensVal.value,
//           )
//         : $BottomKeyboard(
//             combineList: useKeyboard.combineList.value,
//             currentScore: useKeyboard.score,
//             easyThrottleTime: easyThrottleTime,
//             horizontal: horizontal,
//             job: job,
//             scoring: (fraction, isTens) {
//               useKeyboard
//                   .readOver(
//                       scaffoldKeyPictureOverview: scaffoldKeyPictureOverview,
//                       context: context,
//                       fraction: fraction,
//                       job: job)
//                   .then((value) {
//                 // ref.read(annotationGraffitiSwitchProvider.notifier).setSwitch(false);
//                 call(value);
//                 // eventFire(
//                 //   model: JobLargeQuestionScoringBus(
//                 //     ratingScore: value?.toDouble(),
//                 //   ),
//                 // );
//               });
//             },
//             sort: sort,
//           );
//   }
// }

// @swidget
// Widget $bottomKeyboard(
//   BuildContext context, {
//   required SortKeyboard sort,
//   required List<double> combineList,
//   required bool horizontal,
//   required MarkingTextQuestionJob job,
//   required Duration easyThrottleTime,
//   required num? currentScore, // 当前已经得分
//   required Function(num fraction, bool? isTens) scoring,
// }) {
//   return Container(
//     height: 62.h,
//     width: double.infinity,
//     padding: EdgeInsets.only(left: 4.h, right: 4.h),
//     decoration: BoxDecoration(
//       boxShadow: [
//         BoxShadow(
//           color: const Color.fromRGBO(46, 91, 255, 0.2),
//           offset: Offset(26.h, 0), //阴影y轴偏移量
//           blurRadius: 1, //阴影模糊程度
//           spreadRadius: 0.4, //阴影扩散程度
//         )
//       ],
//       color: Colors.white,
//     ),
//     child: Row(
//       children: [
//         Expanded(
//           child: Container(
//             padding: EdgeInsets.symmetric(horizontal: 4.h, vertical: 4.h),
//             color: const Color.fromRGBO(255, 255, 255, 1),
//             child: ListView(
//               scrollDirection: Axis.horizontal,
//               children: [
//                 if (sort == SortKeyboard.FULL_AND_AERO_TOP)
//                   InkWell(
//                     onTap: () {
//                       easyThrottle('toMarkingVal', () => scoring(job.totalScore, false), duration: easyThrottleTime);
//                     },
//                     child: Container(
//                       width: horizontal ? 28.w : 52.w,
//                       height: double.infinity,
//                       alignment: Alignment.center,
//                       decoration: BoxDecoration(
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         color: const Color.fromRGBO(249, 250, 254, 1),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                       ),
//                       child: quickText('满分', size: 15.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
//                     ),
//                   ),
//                 ...combineList.map((e) {
//                   String strScore = getDoubleRemoveZero(e);
//                   bool isCurrentSelect = currentScore == e; // 当前选中

//                   return InkWell(
//                     onTap: () {
//                       easyThrottle('toMarkingVal', () => scoring(e, false), duration: easyThrottleTime);
//                     },
//                     child: Container(
//                       width: horizontal ? 28.w : 52.w,
//                       height: double.infinity,
//                       margin: EdgeInsets.only(left: 3.h),
//                       alignment: Alignment.center,
//                       decoration: BoxDecoration(
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         color:
//                             isCurrentSelect ? Theme.of(context).primaryColor : const Color.fromRGBO(249, 250, 254, 1),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                       ),
//                       child: quickText(
//                         strScore == '0' ? '零分' : strScore,
//                         size: 15.sp,
//                         color: isCurrentSelect ? Colors.white : const Color.fromRGBO(148, 163, 182, 1),
//                       ),
//                     ),
//                   );
//                 }).toList(),
//                 if (sort != SortKeyboard.FULL_AND_AERO_TOP)
//                   InkWell(
//                     onTap: () {
//                       easyThrottle('toMarkingVal', () => scoring(job.totalScore, true), duration: easyThrottleTime);
//                     },
//                     child: Container(
//                       width: horizontal ? 28.w : 52.w,
//                       height: double.infinity,
//                       margin: EdgeInsets.only(left: 3.h),
//                       alignment: Alignment.center,
//                       decoration: BoxDecoration(
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         color: const Color.fromRGBO(249, 250, 254, 1),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                       ),
//                       child: quickText('满分', size: 15.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
//                     ),
//                   ),
//               ],
//             ),
//           ),
//         )
//       ],
//     ),
//   );
// }

// @swidget
// Widget $rightKeyboard(
//   BuildContext context, {
//   required MarkingTextQuestionJob job,
//   required bool horizontal,
//   required double animationVal,
//   required Duration easyThrottleTime,
//   required List<int> tens,
//   required List<double> combineList,
//   required List<double> singleDigitList,
//   required SortKeyboard sort,
//   required bool openAuxiliary,
//   required num? tensVal,
//   required String? smallScoreVal,
//   required double dValue,
//   required Function(num fraction, bool? isTens) scoring,
// }) {
//   return Container(
//     width: horizontal ? animationVal : animationVal - 16.h,
//     margin: EdgeInsets.only(top: 0.6.w),
//     child: Row(
//       children: [
//         // 辅助栏
//         SizedBox(
//           width: animationVal - (horizontal ? 72.h : 72.h),
//           child: Column(mainAxisSize: MainAxisSize.min, children: [
//             GestureDetector(
//               onTap: () =>
//                   easyThrottle('toMarkingVal', () => scoring(job.totalScore, false), duration: easyThrottleTime),
//               child: Container(
//                 height: 58.h,
//                 alignment: Alignment.center,
//                 decoration: BoxDecoration(
//                   color: const Color.fromRGBO(4, 201, 208, 1),
//                   borderRadius: BorderRadius.all(Radius.circular(1.w)),
//                 ),
//                 child: quickText(
//                   '满分',
//                   size: 17.sp,
//                   fontWeight: FontWeight.w400,
//                   color: const Color.fromRGBO(255, 255, 255, 1),
//                 ),
//               ),
//             ),
//             ...tens.map((e) {
//               return InkWell(
//                 onTap: () {
//                   easyThrottle(
//                     'toMarkingVal',
//                     () => scoring(e, true),
//                     // () {
//                     //   _useKeyboard.readOver(fraction: e, isTens: true, job: job).then(
//                     //         (value) => eventFire(
//                     //           model: JobLargeQuestionScoringBus(ratingScore: value?.toDouble()),
//                     //         ),
//                     //       );
//                     // },
//                     duration: easyThrottleTime,
//                   );
//                 },
//                 child: Container(
//                   height: 58.h,
//                   margin: EdgeInsets.only(top: 1.w),
//                   alignment: Alignment.center,
//                   decoration: BoxDecoration(
//                     color: tensVal == e ? Colors.amber[800] : Theme.of(context).primaryColor,
//                     borderRadius: BorderRadius.all(Radius.circular(1.w)),
//                   ),
//                   child: quickText(
//                     '$e+',
//                     size: 17.sp,
//                     fontWeight: FontWeight.w500,
//                     color: const Color.fromRGBO(255, 255, 255, 1),
//                   ),
//                 ),
//               );
//             }).toList()
//           ]),
//         ),
//         // 小分栏
//         Expanded(
//           child: Container(
//             width: horizontal ? 72.h : 60.h,
//             // width: 72.h,
//             padding: EdgeInsets.symmetric(horizontal: 4.h, vertical: 4.h),
//             decoration: BoxDecoration(
//               boxShadow: [
//                 BoxShadow(
//                   color: const Color.fromRGBO(46, 91, 255, 0.2),
//                   offset: Offset(0, 8.w), //阴影y轴偏移量
//                   blurRadius: 1, //阴影模糊程度
//                   spreadRadius: 2, //阴影扩散程度
//                 )
//               ],
//               color: const Color.fromRGBO(255, 255, 255, 1),
//             ),
//             child: ListView(
//               children: [
//                 if ([SortKeyboard.FULL_AND_AERO_TOP, SortKeyboard.FULL_AND_AERO_TOP_INVERTED_ORDER].contains(sort))
//                   Material(
//                     child: Ink(
//                       decoration: BoxDecoration(
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                         color: const Color.fromRGBO(249, 250, 254, 1),
//                       ),
//                       child: InkWell(
//                         splashColor: Theme.of(context).primaryColor,
//                         onTap: () {
//                           easyThrottle(
//                             'toMarkingVal',
//                             () => scoring(job.totalScore, true),
//                             // () {
//                             //   _useKeyboard.readOver(fraction: job.totalScore, isTens: true, job: job).then(
//                             //         (value) => eventFire(
//                             //           model: JobLargeQuestionScoringBus(ratingScore: value?.toDouble()),
//                             //         ),
//                             //       );
//                             // },
//                             duration: easyThrottleTime,
//                           );
//                         },
//                         child: Container(
//                           width: double.infinity,
//                           height: 56.h,
//                           alignment: Alignment.center,
//                           child: quickText('满分', size: 15.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
//                         ),
//                       ),
//                     ),
//                   ),
//                 if (SortKeyboard.FULL_AND_AERO_TOP_INVERTED_ORDER == sort)
//                   Material(
//                     child: Ink(
//                       padding: EdgeInsets.only(top: 3.h),
//                       decoration: BoxDecoration(
//                         color: const Color.fromRGBO(249, 250, 254, 1),
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                       ),
//                       child: InkWell(
//                         splashColor: Theme.of(context).primaryColor,
//                         onTap: () => easyThrottle('toMarkingVal', () => scoring(job.totalScore, true),
//                             duration: easyThrottleTime),
//                         child: Container(
//                           width: double.infinity,
//                           height: 56.h,
//                           alignment: Alignment.center,
//                           child: quickText('零分', size: 15.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
//                         ),
//                       ),
//                     ),
//                   ),
//                 ...(!openAuxiliary && job.totalScore > 10 ? combineList : singleDigitList).map((e) {
//                   String strScore = getDoubleRemoveZero(e);
//                   bool isCurrentSelect = smallScoreVal == strScore; // 当前选中

//                   if (e == 0 && SortKeyboard.FULL_AND_AERO_TOP_INVERTED_ORDER == sort) {
//                     return Container();
//                   }
//                   bool effective = e <= dValue;

//                   return Padding(
//                     padding: EdgeInsets.only(top: 3.h),
//                     child: Material(
//                       child: Ink(
//                         decoration: BoxDecoration(
//                           border: Border.all(
//                             width: 1.h,
//                             color: const Color.fromRGBO(224, 230, 255, 1),
//                           ),
//                           color: isCurrentSelect
//                               ? Theme.of(context).primaryColor
//                               : effective
//                                   ? const Color.fromRGBO(249, 250, 254, 1)
//                                   : Colors.grey[300],
//                           borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                         ),
//                         width: double.infinity,
//                         height: 56.h,
//                         child: InkWell(
//                           splashColor: Theme.of(context).primaryColor,
//                           onTap: effective
//                               ? () {
//                                   easyThrottle('toMarkingVal', () => scoring(e, false),
//                                       //  () {
//                                       //   _useKeyboard.readOver(fraction: e, job: job).then(
//                                       //         (value) => eventFire(
//                                       //           model: JobLargeQuestionScoringBus(ratingScore: value?.toDouble()),
//                                       //         ),
//                                       //       );
//                                       // },
//                                       duration: easyThrottleTime);
//                                 }
//                               : null,
//                           child: Container(
//                             width: double.infinity,
//                             height: 56.h,
//                             alignment: Alignment.center,
//                             child: quickText(
//                               strScore == '0' ? '零分' : strScore,
//                               size: 15.sp,
//                               color: isCurrentSelect ? Colors.white : const Color.fromRGBO(148, 163, 182, 1),
//                             ),
//                           ),
//                         ),
//                       ),
//                     ),
//                   );
//                 }).toList(),
//                 if (sort == SortKeyboard.INVERTED_ORDER)
//                   Material(
//                     child: Ink(
//                       padding: EdgeInsets.only(top: 3.h),
//                       decoration: BoxDecoration(
//                         color: const Color.fromRGBO(249, 250, 254, 1),
//                         border: Border.all(
//                           width: 1.h,
//                           color: const Color.fromRGBO(224, 230, 255, 1),
//                         ),
//                         borderRadius: BorderRadius.all(Radius.circular(2.w)),
//                       ),
//                       child: InkWell(
//                         splashColor: Theme.of(context).primaryColor,
//                         onTap: () => easyThrottle('toMarkingVal', () => scoring(job.totalScore, false),
//                             // () {
//                             //   _useKeyboard.readOver(fraction: job.totalScore, job: job).then(
//                             //         (value) => eventFire(
//                             //           model: JobLargeQuestionScoringBus(ratingScore: value?.toDouble()),
//                             //         ),
//                             //       );
//                             // },
//                             duration: easyThrottleTime),
//                         child: Container(
//                           width: double.infinity,
//                           height: 56.h,
//                           alignment: Alignment.center,
//                           child: quickText('满分', size: 15.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
//                         ),
//                       ),
//                     ),
//                   ),
//               ],
//             ),
//           ),
//         ),
//       ],
//     ),
//   );
// }
