64 lines
2.1 KiB
Dart
64 lines
2.1 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:marking_app/common/model/enum/KeyboardType.dart';
|
|
import 'package:marking_app/common/model/marking/marking_text_question.dart';
|
|
import 'package:marking_app/components/marking/Input_keyboard.dart';
|
|
import 'package:marking_app/components/marking/selectable_keyboard.dart';
|
|
import 'package:marking_app/provider/do_marking_provider.dart';
|
|
import 'package:marking_app/utils/marking_utils/index.dart';
|
|
|
|
// 键盘切换
|
|
class MarkingKeyboardSwitch extends ConsumerWidget {
|
|
final MarkingTextQuestion data;
|
|
final int markingUserId;
|
|
String questScore; // 当前分值
|
|
String totalScore; // 总分
|
|
int subtopicIndex; // 小题下标
|
|
SynchroScoreCallback synchroScore;
|
|
GestureTapCallback submitCall;
|
|
GestureTapCallback closeKeyboard;
|
|
|
|
MarkingKeyboardSwitch({
|
|
required this.data,
|
|
required this.markingUserId,
|
|
required this.questScore,
|
|
required this.totalScore,
|
|
required this.synchroScore,
|
|
required this.subtopicIndex,
|
|
required this.submitCall,
|
|
required this.closeKeyboard,
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final marking = ref.watch(markingKeyboardProvider);
|
|
|
|
switch (marking.keyboard) {
|
|
case KeyboardType.INPUT_TYPE:
|
|
// 输入键盘
|
|
return InputKeyboard(
|
|
data: data,
|
|
subtopicIndex: subtopicIndex,
|
|
questScore: questScore,
|
|
totalScore: data.totalScore.toString(),
|
|
closeKeyboard: closeKeyboard,
|
|
submitCall: submitCall,
|
|
synchroScore: synchroScore,
|
|
);
|
|
case KeyboardType.RIGHT_SELECTION: // 右侧选择键盘
|
|
return SelectableKeyboard(
|
|
data: data,
|
|
markingUserId: markingUserId,
|
|
subtopicIndex: subtopicIndex,
|
|
questScore: questScore,
|
|
totalScore: data.totalScore,
|
|
submitCall: submitCall,
|
|
synchroScore: synchroScore,
|
|
);
|
|
case KeyboardType.BOTTOM_SELECTION:
|
|
return const SizedBox();
|
|
}
|
|
}
|
|
}
|