feat: 进行功能分区方便后期维护
- 添加导航条目和分类数据模型 - 实现导航卡片网格展示 - 支持点击卡片打开链接 - 添加主题样式(渐变色、卡片阴影) - 区分系统默认和自定义条目 - 添加分类统计信息"
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:frontend/core/constants/app_breakpoints.dart';
|
||||
|
||||
void main() {
|
||||
group('AppBreakpoints.gridColumnsFor', () {
|
||||
test('宽度不足一个单元时退化为单列', () {
|
||||
expect(AppBreakpoints.gridColumnsFor(200), 1);
|
||||
expect(AppBreakpoints.gridColumnsFor(220), 1);
|
||||
});
|
||||
|
||||
test('刚好放下两列与放不下时的边界', () {
|
||||
// 两列 = 220 * 2 + 16 = 456
|
||||
expect(AppBreakpoints.gridColumnsFor(456), 2);
|
||||
expect(AppBreakpoints.gridColumnsFor(455), 1);
|
||||
});
|
||||
|
||||
test('宽度越大列数越多', () {
|
||||
expect(AppBreakpoints.gridColumnsFor(900), 3);
|
||||
expect(AppBreakpoints.gridColumnsFor(1200), 5);
|
||||
});
|
||||
|
||||
test('与 CSS 的 auto-fill 规则一致', () {
|
||||
// 列数 = floor((可用宽度 + 间距) / (最小单元 + 间距))
|
||||
for (final double width in <double>[300, 520, 740, 1080, 1440]) {
|
||||
final int columns = AppBreakpoints.gridColumnsFor(width);
|
||||
final double used = columns * 220 + (columns - 1) * 16;
|
||||
expect(used, lessThanOrEqualTo(width));
|
||||
expect(used + 236, greaterThan(width));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user