feat: add undergraduate import and exam selection screens
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../domain/school_identity.dart';
|
||||
import '../../../domain/school_term.dart';
|
||||
import '../../../domain/undergraduate_exam_query.dart';
|
||||
|
||||
Future<UndergraduateExamQuery?> showUndergraduateExamQueryPicker(
|
||||
BuildContext context, {
|
||||
UndergraduateExamQuery? initial,
|
||||
required DateTime now,
|
||||
}) => showDialog<UndergraduateExamQuery>(
|
||||
context: context,
|
||||
builder: (_) => _ExamPicker(initial: initial, now: now),
|
||||
);
|
||||
|
||||
class _ExamPicker extends StatefulWidget {
|
||||
const _ExamPicker({this.initial, required this.now});
|
||||
final UndergraduateExamQuery? initial;
|
||||
final DateTime now;
|
||||
@override
|
||||
State<_ExamPicker> createState() => _ExamPickerState();
|
||||
}
|
||||
|
||||
class _ExamPickerState extends State<_ExamPicker> {
|
||||
late SchoolTerm _term =
|
||||
widget.initial?.term ??
|
||||
SchoolTerm(523, school: SupportedSchool.uestcUndergraduate);
|
||||
late final Set<UndergraduateExamType> _types = {
|
||||
...?widget.initial?.types,
|
||||
if (widget.initial == null) UndergraduateExamType.finalExam,
|
||||
};
|
||||
@override
|
||||
Widget build(BuildContext context) => AlertDialog(
|
||||
title: const Text('本科考试查询'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('选择一个学期和需要查询的考试类型'),
|
||||
const SizedBox(height: 14),
|
||||
DropdownButton<SchoolTerm>(
|
||||
isExpanded: true,
|
||||
value: _term,
|
||||
items: SchoolTerm.undergraduateChoices(widget.now, saved: _term)
|
||||
.map((t) => DropdownMenuItem(value: t, child: Text(t.label)))
|
||||
.toList(),
|
||||
onChanged: (t) {
|
||||
if (t != null) setState(() => _term = t);
|
||||
},
|
||||
),
|
||||
for (final type in UndergraduateExamType.values)
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(type.label),
|
||||
value: _types.contains(type),
|
||||
onChanged: (v) => setState(() {
|
||||
if (v == true) {
|
||||
_types.add(type);
|
||||
} else {
|
||||
_types.remove(type);
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: _types.isEmpty
|
||||
? null
|
||||
: () => Navigator.pop(
|
||||
context,
|
||||
UndergraduateExamQuery(term: _term, types: _types),
|
||||
),
|
||||
child: const Text('开始查询'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user