feat: add course bar length setting and clear blue glass Dock

This commit is contained in:
Codex
2026-10-13 12:51:27 +08:00
parent 8403be05da
commit 9193fd8e43
11 changed files with 444 additions and 138 deletions
@@ -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(
+1 -1
View File
@@ -74,7 +74,7 @@ class WeekGrid extends StatelessWidget {
// A single shared lesson height keeps equal-duration cards identical in size.
// Increase that height for full metadata, never stretch one card independently.
var rowHeight = 54.0 * scale.clamp(1, 2.5);
var rowHeight = 54.0 * settings.courseHeightScale * scale.clamp(1, 2.5);
for (final e in events) {
final group = groups[e]!;
if (group.first != e) continue;