20 Commits

Author SHA1 Message Date
meyou
502f1efc0a Fix year view showing stale year: reset to selectedDate.year on enter 2026-05-16 16:39:58 +08:00
meyou
731a1bb6a1 Wire year view into CalendarMonthView, MonthHeader and ViewModel
- CalendarViewModel: year view state and animation methods
- CalendarMonthView: graphicsLayer zoom overlay, BottomCard hiding
- MonthHeader: toggle year view on click, "今天" button
2026-05-16 16:29:37 +08:00
xfy
f618d09458 Reformat code style across shared module
Apply consistent formatting: import ordering, line wrapping,
indentation, and XML normalization. No functional changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 17:57:18 +08:00
xfy
6351caf776 Add KDoc for public APIs, suppress monthNumber deprecation, and refine comments
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 17:41:54 +08:00
xfy
270346e6ef Lower collapse threshold to 25% for easier fold/unfold triggering
Collapse triggers when progress > 0.25 (was 0.5). Expand triggers when
progress < 0.75 (1 - threshold), creating asymmetric thresholds that make
both fold and unfold easy to trigger with a short drag.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 16:52:23 +08:00
xfy
69e49b5d81 Add fling velocity threshold to collapse/expand drag gesture
Quick swipe now snaps to the target state regardless of progress position,
matching the behavior of HorizontalPager's fling logic. Uses VelocityTracker
to measure release velocity and a 800 dp/s threshold (FLING_VELOCITY_THRESHOLD_DP).
Slow drags still use the positional COLLAPSE_THRESHOLD (50%) as before.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 16:49:32 +08:00
xfy
9648afc561 Add unit tests for CalendarViewModel and CalendarUtils
Inject Clock into CalendarViewModel for testability, add kotlinx-coroutines-test dependency, replace placeholder test with real coverage for ISO week numbers, month day grids, page mapping, and utility functions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 15:42:01 +08:00
xfy
f189c188c7 Remove debug println logging and unused TAG constant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 11:24:30 +08:00
xfy
c74de5f151 Add debug logging and fix gridHeightPx derivedStateOf state tracking
gridHeightPx changed from derivedStateOf to direct computation because
derivedStateOf cannot track non-State local variable changes, causing
gridHeightPx to not update when rowHeightPx transitions from 0 to measured value.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 11:21:29 +08:00
xfy
ddc852a667 Extract calendar utilities and use derivedStateOf for reactive state
Move shared constants and helper functions into CalendarUtils.kt,
replace manual state synchronization with derivedStateOf in
CalendarViewModel and UI composables.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 11:08:31 +08:00
xfy
3612efb665 Replace deprecated dayOfMonth with day and fix naming conventions
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:55:04 +08:00
xfy
7e972bb4fb Fix lint warnings: remove unused variable, replace monthNumber, use range check
- Remove unused currentWeeksCount variable and onWeeksChanged callback
- Replace deprecated monthNumber with month.number (requires explicit import)
- Remove all @Suppress("DEPRECATION") annotations for monthNumber
- Convert double comparison to range check (today in weekMonday..weekSunday)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:38:26 +08:00
xfy
ce6da44c52 Fix swipe interpolation discontinuity and remove debug println
Use currentPage instead of settledPage for interpolatedWeeks calculation
to prevent gridH jumps during month transitions. When offsetFraction is
near zero, compute weeks from currentPage rather than stale callback
state. Remove all debug println statements and TAG constants.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:08:25 +08:00
xfy
b94b264d5c Use dynamic row count (4/5/6) for calendar grid instead of fixed 6 rows
Calculate actual weeks needed per month and interpolate row count during
page swipe so BottomCard follows the grid height smoothly. Remove debug
println statements.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 18:31:29 +08:00
xfy
c1e0484cba Add pull-down gesture to expand from collapsed week view back to month view
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 17:02:44 +08:00
xfy
d7552e469f Add KDoc and inline comments per COMMENTS.md conventions
- Add KDoc to all public Composable functions with parameter descriptions
- Add inline comments for non-obvious algorithms (42-cell grid, pager mapping)
- Add @Suppress reason comments for monthNumber deprecation
- Document collapseProgress range and physical meaning
- Add named constant comments for START_PAGE
- Add Preview name to App()

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 15:22:49 +08:00
xfy
b734e26645 Replace button-triggered collapse with vertical drag gesture
ViewModel now exposes onDrag/onDragEnd so BottomCard drives the
collapse animation via detectVerticalDragGestures instead of a
discrete collapse() call. Drag maps to 0–1 progress over 200dp;
on release the animatable snaps to the nearest end with spring.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 14:39:50 +08:00
xfy
35cbcaf430 Move collapse animation from animateFloatAsState to ViewModel Animatable with spring spec
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 14:32:43 +08:00
xfy
e53c3d8705 Add week/month view toggle with collapse animation and bottom card
Add isCollapsed/collapseProgress state to CalendarViewModel for toggling
between month and week views. CalendarMonthPage animates non-selected
weeks out with offset and alpha. Introduce WeekPager for single-week
HorizontalPager and BottomCard with drag-to-collapse gesture.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 14:28:05 +08:00
xfy
298631c8b5 Add CalendarViewModel with ISO week calculation and month grid generation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 13:18:49 +08:00