feat: add course bar length setting and clear blue glass Dock
This commit is contained in:
@@ -17,6 +17,8 @@ class SettingsPage extends StatefulWidget {
|
||||
class _SettingsPageState extends State<SettingsPage> {
|
||||
late TextEditingController _weeks;
|
||||
DateTime? _start;
|
||||
double? _courseHeightDraft;
|
||||
bool _savingHeight = false;
|
||||
String? _weeksError, _dateError;
|
||||
@override
|
||||
void initState() {
|
||||
@@ -100,6 +102,21 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _saveCourseHeight(double value) async {
|
||||
setState(() => _savingHeight = true);
|
||||
await widget.controller.updateSettings(
|
||||
(current) => current.copyWith(courseHeightScale: value),
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_courseHeightDraft = null;
|
||||
_savingHeight = false;
|
||||
});
|
||||
if (widget.controller.lastError != null) {
|
||||
_notice(widget.controller.lastError!);
|
||||
}
|
||||
}
|
||||
|
||||
void _notice(String text) =>
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(text)));
|
||||
@override
|
||||
@@ -203,6 +220,68 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 22),
|
||||
_heading('课程条长度'),
|
||||
SurfaceCard(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${((_courseHeightDraft ?? s.courseHeightScale) * 100).round()}%',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: river,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _savingHeight
|
||||
? null
|
||||
: () => _saveCourseHeight(
|
||||
AppSettings.defaultCourseHeightScale,
|
||||
),
|
||||
child: const Text('恢复默认'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Slider(
|
||||
key: const Key('course-height-slider'),
|
||||
value: _courseHeightDraft ?? s.courseHeightScale,
|
||||
min: AppSettings.minCourseHeightScale,
|
||||
max: AppSettings.maxCourseHeightScale,
|
||||
divisions: 24,
|
||||
label:
|
||||
'${((_courseHeightDraft ?? s.courseHeightScale) * 100).round()}%',
|
||||
semanticFormatterCallback: (value) =>
|
||||
'${(value * 100).round()}%',
|
||||
onChanged: _savingHeight
|
||||
? null
|
||||
: (value) => setState(() => _courseHeightDraft = value),
|
||||
onChangeEnd: _saveCourseHeight,
|
||||
),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('较短', style: TextStyle(fontSize: 11)),
|
||||
Text('较长', style: TextStyle(fontSize: 11)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'统一调整课程条长度,老师和教室始终完整显示。',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
height: 1.6,
|
||||
color: ink.withValues(alpha: 0.55),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 22),
|
||||
_heading('课前提醒'),
|
||||
SurfaceCard(
|
||||
child: Column(
|
||||
|
||||
Reference in New Issue
Block a user