feat: add elastic glass dock motion and Android tablet layouts

This commit is contained in:
david1465833828
2026-10-28 11:09:43 +08:00
parent fbcb7fb637
commit 9da5864d29
16 changed files with 1321 additions and 874 deletions
+48 -20
View File
@@ -53,6 +53,11 @@ class WeekGrid extends StatelessWidget {
final scale = scaler.scale(10) / 10;
const gutter = 34.0, gap = 16.0;
final width = (constraints.maxWidth - gutter) / 7;
final spacious = width >= 76;
final nameStyle = _nameStyle.copyWith(fontSize: spacious ? 13 : 10.5);
final metadataStyle = _metadataStyle.copyWith(
fontSize: spacious ? 11.5 : 9.5,
);
final header = 56.0 * scale.clamp(1, 2.5);
final groups = {for (final e in events) e: _group(e)};
final defaultStyle = DefaultTextStyle.of(context).style;
@@ -84,14 +89,14 @@ class WeekGrid extends StatelessWidget {
var entryHeight = 0.0;
for (final value in group) {
final required =
measure(value.course.name, _nameStyle, available, lines: 2) +
measure(value.course.teacher, _metadataStyle, available) +
measure(value.course.room, _metadataStyle, available) +
measure(value.course.name, nameStyle, available, lines: 2) +
measure(value.course.teacher, metadataStyle, available) +
measure(value.course.room, metadataStyle, available) +
21;
final periodHeight = group.length > 1
? measure(
'${value.course.startPeriod}–${value.course.endPeriod}节',
_metadataStyle,
metadataStyle,
available,
) +
3
@@ -101,7 +106,7 @@ class WeekGrid extends StatelessWidget {
final first = group.map((v) => v.course.startPeriod).reduce(math.min);
final last = group.map((v) => v.course.endPeriod).reduce(math.max);
final warning = group.length > 1
? measure('冲突列表', _metadataStyle, width - 12) + 8
? measure('冲突列表', metadataStyle, width - 12) + 8
: 0.0;
rowHeight = math.max(
rowHeight,
@@ -133,8 +138,8 @@ class WeekGrid extends StatelessWidget {
children: [
Text(
'${slot.period}',
style: const TextStyle(
fontSize: 11,
style: TextStyle(
fontSize: spacious ? 13 : 11,
fontWeight: FontWeight.w700,
),
),
@@ -143,7 +148,7 @@ class WeekGrid extends StatelessWidget {
child: Text(
minuteLabel(slot.startMinute),
style: TextStyle(
fontSize: 8,
fontSize: spacious ? 10 : 8,
color: ink.withValues(alpha: 0.55),
),
),
@@ -152,7 +157,7 @@ class WeekGrid extends StatelessWidget {
child: Text(
minuteLabel(slot.endMinute),
style: TextStyle(
fontSize: 8,
fontSize: spacious ? 10 : 8,
color: ink.withValues(alpha: 0.4),
),
),
@@ -192,7 +197,7 @@ class WeekGrid extends StatelessWidget {
][i],
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10,
fontSize: spacious ? 12 : 10,
color: active
? river
: ink.withValues(alpha: 0.6),
@@ -211,7 +216,7 @@ class WeekGrid extends StatelessWidget {
child: Text(
'${date.day}',
style: TextStyle(
fontSize: 11,
fontSize: spacious ? 13 : 11,
fontWeight: FontWeight.w700,
color: active ? Colors.white : ink,
),
@@ -258,7 +263,15 @@ class WeekGrid extends StatelessWidget {
),
for (final e in events)
if (groups[e]!.first == e)
_block(context, groups[e]!, width, rowHeight, top),
_block(
context,
groups[e]!,
width,
rowHeight,
top,
nameStyle,
metadataStyle,
),
],
),
),
@@ -276,6 +289,8 @@ class WeekGrid extends StatelessWidget {
double width,
double rowHeight,
double Function(int) top,
TextStyle nameStyle,
TextStyle metadataStyle,
) {
final first = group.map((e) => e.course.startPeriod).reduce(math.min);
final last = group.map((e) => e.course.endPeriod).reduce(math.max);
@@ -285,7 +300,12 @@ class WeekGrid extends StatelessWidget {
width: width - 4,
height: (last - first + 1) * rowHeight - 8,
child: group.length == 1
? _entry(context, group.first)
? _entry(
context,
group.first,
nameStyle: nameStyle,
metadataStyle: metadataStyle,
)
: Container(
decoration: BoxDecoration(
color: river.withValues(alpha: 0.06),
@@ -308,7 +328,15 @@ class WeekGrid extends StatelessWidget {
),
),
for (final e in group)
Expanded(child: _entry(context, e, inConflict: true)),
Expanded(
child: _entry(
context,
e,
inConflict: true,
nameStyle: nameStyle,
metadataStyle: metadataStyle,
),
),
],
),
),
@@ -319,6 +347,8 @@ class WeekGrid extends StatelessWidget {
BuildContext context,
CourseOccurrence e, {
bool inConflict = false,
required TextStyle nameStyle,
required TextStyle metadataStyle,
}) => Semantics(
label: '${e.course.name},${e.course.teacher},${e.course.room}',
button: true,
@@ -343,26 +373,24 @@ class WeekGrid extends StatelessWidget {
e.course.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: _nameStyle,
style: nameStyle,
),
if (inConflict) ...[
const SizedBox(height: 3),
Text(
'${e.course.startPeriod}–${e.course.endPeriod}节',
style: _metadataStyle,
style: metadataStyle,
),
],
const SizedBox(height: 4),
Text(
e.course.teacher,
style: _metadataStyle.copyWith(
color: ink.withValues(alpha: 0.85),
),
style: metadataStyle.copyWith(color: ink.withValues(alpha: 0.85)),
),
const SizedBox(height: 3),
Text(
e.course.room,
style: _metadataStyle.copyWith(color: ink.withValues(alpha: 0.7)),
style: metadataStyle.copyWith(color: ink.withValues(alpha: 0.7)),
),
],
),