Files
school-attendance/lib/models/dashboard_tile_layout.dart
T
sihooandClaude Sonnet 5 c94f51a033 타일 UI 편집 기능 임시 보류 + 로그인 유지 체크박스 추가
- 폰처럼 작은 화면에서 6칸 고정 격자 때문에 레이아웃이 깨지는 문제로,
  타일 드래그 이동/크기조절 기능을 kTileEditingEnabled 플래그로 임시 비활성화
  (관련 코드는 그대로 유지 - 작은 화면 대응 방안 마련 후 플래그만 켜면 재사용 가능)
- 비활성화 상태에서는 화면 폭에 따라 열이 자동으로 줄어드는 기본 그리드 사용
- 설정 화면의 "UI 편집" 항목은 비활성화 표시로 안내
- 로그인 화면에 "로그인 상태 유지" 체크박스 추가 (기본 체크됨, 해제 시 세션 저장 안 함)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 22:47:07 +09:00

63 lines
1.7 KiB
Dart

// 🧩 대시보드 타일의 격자 위치/크기(1x1 ~ 4x4)를 표현하는 값 객체.
// 전체 배치 캔버스는 가로 6칸 × 세로 4칸으로 고정한다.
// 📱 [기능 보류] 데스크탑에서는 잘 나오지만, 폰처럼 화면이 작은 기기에서는
// 6칸 고정 격자 때문에 타일이 너무 작아져 레이아웃이 깨진다.
// 작은 화면 대응 방안을 마련하기 전까지 편집 기능을 임시로 꺼둔다.
// (다시 켜려면 이 값만 true로 바꾸면 됨 — 관련 코드는 그대로 남겨둠)
const bool kTileEditingEnabled = false;
const int kGridCols = 6;
const int kGridRows = 4;
const int kMinTileSize = 1;
const int kMaxTileSize = 4;
class TileRect {
final int x;
final int y;
final int w;
final int h;
const TileRect({
required this.x,
required this.y,
required this.w,
required this.h,
});
factory TileRect.fromJson(Map<String, dynamic> json) => TileRect(
x: (json['x'] as num).toInt(),
y: (json['y'] as num).toInt(),
w: (json['w'] as num).toInt(),
h: (json['h'] as num).toInt(),
);
Map<String, dynamic> toJson(String id) => {
'id': id,
'x': x,
'y': y,
'w': w,
'h': h,
};
TileRect copyWith({int? x, int? y, int? w, int? h}) =>
TileRect(x: x ?? this.x, y: y ?? this.y, w: w ?? this.w, h: h ?? this.h);
bool overlaps(TileRect other) {
return x < other.x + other.w &&
x + w > other.x &&
y < other.y + other.h &&
y + h > other.y;
}
bool get isWithinCanvas =>
x >= 0 &&
y >= 0 &&
x + w <= kGridCols &&
y + h <= kGridRows &&
w >= kMinTileSize &&
h >= kMinTileSize &&
w <= kMaxTileSize &&
h <= kMaxTileSize;
}