1. 최종 규칙
날짜칸으로 시트가 오르는 동작은
20260923_1050_바텀시트_안드로이드웹이식.html 그대로다.
이 문서가 고치는 것은 날짜+건수 클릭뿐이다.
| 조작 | 결과 |
|---|---|
| 날짜칸 클릭 | 내용에 맞춰 올린다. 최소 0.6, 잘릴 때만 0.9. 바꾸지 않는다. |
| 접힌 시트에서 날짜+건수 | 최대 높이 0.9 로 올린다. |
| 이미 올라온 시트에서 날짜+건수 | 바로 접는다. 0.6 → 0.9 로 한 단 더 올리지 않는다. |
| 핸들 드래그 · 목록 스크롤 · 닫기(X) | 1050 문서와 같다. 바꾸지 않는다. |
2. 원인
1050 문서의 calendarSheetSizeOnCountTap 은 이렇게 되어 있었다.
final atMax = current >= kCalendarSheetMax - 0.02;
return atMax ? collapsed : kCalendarSheetMax;
날짜칸으로 연 시트는 보통 0.6 ~ 0.7 이다. 0.88 미만이므로 “최대가 아님” → 0.9 로 다시 올린다. 한 번 더 눌러야 접힌다. 기대한 토글이 아니다.
판정은 “최대인가”가 아니라 “이미 올라왔는가”다.
raised = current > collapsed + 0.12
올라왔으면 collapsed
접혀 있으면 0.9
collapsed + 0.12 는 같은 파일의 다른 시트 판정과 같다.
접힘(약 0.06)과 기본 펼침(0.6) 사이에 있다.
3. 아이폰에 넣을 코드
파일: day_plan_appl_app/lib/screens/calendar_tab.dart
_raiseSheet / _openSheetSize 는 건드리지 않는다.
3.1 찾을 코드 (1050 를 넣은 뒤)
/// 날짜+건수: 최대가 아니면 최대까지, 이미 최대면 접힘 높이로.
double calendarSheetSizeOnCountTap({
required double current,
required double collapsed,
}) {
final atMax = current >= kCalendarSheetMax - 0.02;
return atMax ? collapsed : kCalendarSheetMax;
}
1050 를 아직 안 넣었고 예전 토글만 있으면 찾을 코드는 이것이다.
void _toggleSheet() {
if (!_sheetCtl.isAttached) return;
final collapsed = _lastCollapsedFrac > 0 ? _lastCollapsedFrac : 0.06;
final target = _sheetCtl.size < 0.5 ? 0.6 : collapsed;
...
}
3.2 넣을 함수
kCalendarSheetMax 바로 아래(또는 기존 calendarSheetSizeOnCountTap 자리)다.
클래스 밖 톱레벨이어야 테스트에서 부를 수 있다.
/// 날짜+건수: 올라가 있으면 접고, 접혀 있으면 최대 높이(0.9)로 올린다.
double calendarSheetSizeOnCountTap({
required double current,
required double collapsed,
}) {
final raised = current > collapsed + 0.12;
return raised ? collapsed : kCalendarSheetMax;
}
3.3 _toggleSheet
호출 형태는 1050 과 같다. 주석만 맞춘다. 지연 150ms 는 그대로 둔다.
/// 날짜+건수: 올라가 있으면 접고, 접혀 있으면 최대 높이로 올린다.
void _toggleSheet() {
if (!_sheetCtl.isAttached) return;
final collapsed = _lastCollapsedFrac > 0 ? _lastCollapsedFrac : 0.06;
final target = calendarSheetSizeOnCountTap(
current: _sheetCtl.size,
collapsed: collapsed,
);
Future.delayed(const Duration(milliseconds: 150), () {
if (!mounted || !_sheetCtl.isAttached) return;
_sheetCtl.animateTo(target,
duration: const Duration(milliseconds: 250), curve: Curves.easeOut);
});
}
날짜+건수 GestureDetector 의 onTap: _toggleSheet 는 그대로다.
4. 테스트
test/calendar_sheet_test.dart 가 있으면 아래 케이스를 추가한다.
import 패키지 이름은 아이폰 앱 이름이다
(package:day_plan_appl_app/screens/calendar_tab.dart 등).
test('날짜+건수: 올라가 있으면 접고, 접혀 있으면 최대 높이', () {
const collapsed = 0.06;
expect(
calendarSheetSizeOnCountTap(current: 0.6, collapsed: collapsed),
collapsed,
);
expect(
calendarSheetSizeOnCountTap(current: 0.63, collapsed: collapsed),
collapsed,
);
expect(
calendarSheetSizeOnCountTap(current: 0.9, collapsed: collapsed),
collapsed,
);
expect(
calendarSheetSizeOnCountTap(current: collapsed, collapsed: collapsed),
kCalendarSheetMax,
);
});
실행: flutter test test/calendar_sheet_test.dart
5. 확인
- 날짜칸을 누른다. 시트가 내용에 맞춰 올라온다(적은 날 0.6, 긴 날은 그 사이 또는 0.9).
- 그 상태에서 날짜+건수를 누른다. 바로 접힌다. 더 올라가지 않는다.
- 접힌 상태에서 날짜+건수를 누른다. 0.9 까지 올라간다.
- 다시 날짜+건수를 누른다. 접힌다.
핫 리로드 대신 앱을 완전히 다시 실행한다.