73 Commits

Author SHA1 Message Date
meyou
9fd877485f
修复月→年视图切换卡顿:Pager 缓存降为 0 + 移除延迟预组合
Perfetto trace 分析发现严重卡顿根因:
- MonthView→YearView 切换耗时 2435ms
- Choreographer#doFrame 单帧超时 4288ms
- compose📟cache_window:keepAroundItems 阻塞 554ms×2
- Compose:onForgotten 组件销毁 600ms

修复:
1. CalendarPager/WeekPager/年视图 Pager 的 beyondViewportPageCount 从 1→0
   月视图缓存页从 3 页(126 DayCell)降至 1 页(42 DayCell)
2. 移除 yearPagerBeyondViewport 延迟预组合机制(不再需要)
2026-05-18 22:49:59 +08:00
meyou
a478ecb1bd
修复月视图首帧行堆叠:rowHeightPx 未就绪时 alpha=0
draw 阶段已读到更新后的 rowHeightPx,但 layout 仍用旧值时会出现行堆叠。
增加 layoutReady 守卫,首帧 rowHeightPx==0 时直接隐藏月视图。
2026-05-18 22:06:58 +08:00
xfy
780a5e70dd 修复折叠态切换年视图:先展开再切换 + AnimatedContent 尺寸瞬切
折叠态下 toggleYearView 不再直接 return,而是先动画展开回月视图再进入年视图;
MonthHeader 的 AnimatedContent 添加 SizeTransform(snap()) 避免内容切换时尺寸动画;
清理未使用的 import。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 18:20:22 +08:00
xfy
3a3e6014d8 修复年视图缩放动画丢失:progress 提前到重组阶段读取
graphicsLayer { } lambda 在 draw 阶段执行,内部直接读取 viewModel.yearViewProgress
不会被 Compose 标记为可观察状态,导致 Animatable 每帧 value 变化不触发重绘,
动画只在 isYearView 翻转时重组一次然后卡到动画完成。

修复:在 if (isYearView) / if (!isYearView) 块内先读取 progress 为局部变量,
graphicsLayer lambda 通过捕获使用,让 Animatable 变化能驱动重组进而触发重绘。
2026-05-18 17:37:40 +08:00
xfy
a4bd56a8a9 优化月→年视图切换性能(第二轮):延迟预组合 + 缓存提升
- 年视图 beyondViewportPageCount 动画完成后再恢复为 1,消除切换后 283ms onMeasure 阻塞
- MiniMonth 主题色提取到 YearGridView 级别 remember 缓存(72 次 → 1 次读取)
- TextMeasurer 从每 MiniMonth 独立实例改为 YearGridView 共享(12 个 → 1 个)
- 预测量 1-31 × 3 颜色的 TextLayoutResult(93 个缓存),消除 360+ 次 measure() 调用
- 12 个月的 generateMiniMonthDays 在 YearGridView 级别预计算并缓存
2026-05-18 17:05:43 +08:00
xfy
914e882fe1 优化月→年视图切换性能:Canvas 扁平化 + 首帧组合 + 动画交错
- MiniMonth 日期网格改 Canvas 绘制,单页 Composable 从 ~600 降到 ~120
- 年视图 beyondViewportPageCount 首帧 0、首帧后恢复 1,避免一次组合 36 个 MiniMonth
- toggleYearView 先启动动画再翻转 isYearView,月视图缩小与年视图组合交错
- 添加 ComposeTrace 跨平台 trace 工具用于性能分析

MonthView→YearView 总耗时 1732ms → 1033ms (↓40%),首帧 onMeasure 902ms → 129ms (↓86%)
2026-05-18 16:50:13 +08:00
xfy
996d8c104f 修复点击"今天"按钮无动画:scrollToPage 改为 animateScrollToPage
LaunchedEffect(selectedDate) 用无动画的 scrollToPage 抢先跳转,
导致 onToday 里的 animateScrollToPage 被取消。统一由
LaunchedEffect 处理滚动,onToday 只需 selectDate。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 15:43:09 +08:00
xfy
741e3de7ff 移除调试日志
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 15:27:57 +08:00
xfy
b2284c3986 回退 gridHeightPx/calendarAreaHeightPx/cardHeightPx 的 derivedStateOf
derivedStateOf 导致快照时序问题:cardHeightPx 计算时 gridHeightPx
尚未更新(仍为 0),calendarAreaHeightPx 极小,cardHeightPx 占 96% 屏幕,
BottomCard 遮挡整个日历。改回直接计算确保同一帧内值一致。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 15:23:34 +08:00
xfy
0962d13216 gridHeightPx/calendarAreaHeightPx/cardHeightPx 包裹 derivedStateOf
将依赖 collapseProgress 的中间计算移入 derivedStateOf,
确保只在被读取时才计算,避免不必要的中间对象创建。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 15:06:04 +08:00
xfy
d5b7d2cd8a 预计算固定 dp→px 转换,避免每帧重复 density 计算
cardGapExpandedPx/cardGapCollapsedPx/rowPaddingPx/horizontalPaddingPx
移入 remember,每帧只做一次浮点插值而非完整 density 转换。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 15:04:31 +08:00
xfy
3b3988251a 年视图切换动画计算移入 graphicsLayer lambda 避免重组
monthScale/yearScale/targetAlpha 从 composable body 移入 graphicsLayer lambda,
state 读取只触发 draw-phase redraw 而非重组。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 14:58:16 +08:00
xfy
72b591ab49 整理 import 排序和缩进格式
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 14:16:44 +08:00
xfy
7250d08fb7 年视图标题固定 + 交叉淡入淡出 + 移除 fadeIn/fadeOut
年视图标题行从 HorizontalPager 内移到外部,左右滑动时标题不随 pager 滚动。
年份切换时标题文字用垂直滑动动画(与 MonthHeader 一致,移除 fadeIn/fadeOut)。
月/年视图左右滑动改为交叉淡入淡出,修复原实现中间全白的问题。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 14:14:46 +08:00
xfy
62924eff3e FAB 固定在屏幕左下角,不再跟随 BottomCard 高度
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 13:29:25 +08:00
xfy
02730e54e8 实现缩放动画菜单和 Scrim 关闭
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:54:27 +08:00
xfy
5a7d1f1781 更新 KDoc: FAB 菜单切换视图描述
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:53:54 +08:00
xfy
a7bf59e42e 添加 FAB 浮动按钮和菜单状态
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:52:48 +08:00
xfy
37af18ad8d 实现缩放动画菜单和 Scrim 关闭
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:49:45 +08:00
xfy
ff3bd6629d 实现缩放动画菜单和 Scrim 关闭
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:46:43 +08:00
xfy
2b0bb7e1d8 移除 MonthHeader 点击切换年视图功能
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 11:41:33 +08:00
xfy
17146e2bc0 格式化: import 排序、长行换行、空行规范
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 10:10:59 +08:00
meyou
043bd9824b 新增法定调休开关,默认禁用,排班接管右上角
ViewModel 增加 showLegalHoliday 状态,默认 false。
关闭时:排班从左上角移到右上角,不显示法定调休角标。
开启时:回到旧布局,左上角=排班、右上角=法定调休。
DayCell 与各 Pager 透传新参数,预留后续接入设置页。
2026-05-16 19:29:06 +08:00
meyou
ecf4cf601e 新增个人轮班 MVP:左上角胶囊显示班/休
新增 ShiftPattern 数据模型,以锚点日期 + 循环序列描述周期性轮班,与法定调休完全独立。
默认配置 2026-05-15 起 [班,班,休,休] 4 天周期,DayCell 左上角渲染胶囊角标。
2026-05-16 19:12:18 +08:00
meyou
aa223db519 年月视图切换时立即移除源视图,仅对目标视图播放缩放动画
之前月↔年切换使用交叉淡入:两层同时合成,源视图渐隐、目标视图渐显。
现改为单向过渡:先翻转 isYearView 让源视图立刻从合成中移除,
withFrameNanos 等一帧后再启动目标视图的 scale/alpha 动画,避免抖动。
2026-05-16 17:42:21 +08:00
meyou
c096651e0f Revert "修复首次启动切换年视图无动画的问题"
This reverts commit 216ebbf990555f8282371199b8d1cc4bb86d9b2e.
2026-05-16 17:02:45 +08:00
meyou
216ebbf990 修复首次启动切换年视图无动画的问题
始终组合年视图 HorizontalPager 层(通过 graphicsLayer.alpha=0 隐藏),
避免首次进入时 Pager 组合延迟导致动画首帧丢失。
2026-05-16 16:59:27 +08:00
meyou
8dad07c0a0 年视图支持左右滑动切换年份
使用 HorizontalPager 包裹年视图,支持手势滑动切年。
‹ › 按钮改为 animateScrollToPage,与滑动行为一致。
2026-05-16 16:43:32 +08:00
meyou
c996d026cc Replace year view month cells with mini calendar grids
Each month in the 4x3 year grid now shows a compact calendar with
day numbers, matching the iOS Calendar year view style. Today is
highlighted with a filled circle. Selected month title uses primary color.
2026-05-16 16:35:56 +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
meyou
16b73c4373 Fix flash when expanding after navigating months in collapsed state
Sync CalendarPager's pagerState to selectedDate in CalendarMonthView
via LaunchedEffect(selectedDate), so the page is already correct when
CalendarPager re-enters composition during expand. Remove the now-
redundant LaunchedEffect(Unit) sync in CalendarPager.
2026-05-16 15:58:12 +08:00
meyou
b65856a4ae 点击月份标题跳转到今天 2026-05-16 14:54:35 +08:00
meyou
fcad070800 修复折叠态跨月周选中和展开闪跳问题
1. 展开同步逻辑移至 CalendarPager(LaunchedEffect(Unit)),减少闪帧
2. 跨月周根据滑动方向选中日期:
   - 后退到跨月周:选较晚月份1号,留在当月
   - 前进到跨月周:选该周周一,留在上个月
2026-05-16 13:38:34 +08:00
meyou
09e13e335c Revert 跨月周选中逻辑的两个提交,重新设计 2026-05-16 13:28:29 +08:00
meyou
857cf88cb0 修复跨月周选中逻辑:根据滑动方向决定选中日期
后退到跨月周(如从5月滑到4月27-5月3):选中较晚月份1号,留在当月。
前进到跨月周(如从4月滑到4月27-5月3):选中该周周一,留在上个月。
2026-05-16 13:22:47 +08:00
meyou
104c5e5baa 修复折叠态跨月周选中上个月日期的问题
跨月周(如5月第一周周一是4月27日)改为选中下个月的1号,
避免月份标题和展开内容不一致。
2026-05-16 13:10:03 +08:00
meyou
e403c683f6
Sync CalendarPager to selectedDate month when expanding from week view 2026-05-16 12:24:12 +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
d0492d02f0 Fix collapse drag not tracking finger — use dynamic dragRange based on actual height change
The fixed DRAG_RANGE_DP=200dp caused the collapse progress to advance faster
than the visual height change, making the calendar feel like it "outruns" the
finger. Now dragRangePx is computed as (weeks-1)×rowHeight, matching the
actual visual height delta during collapse so finger movement maps 1:1 to
visual change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 16:29:24 +08:00
xfy
c751b56297 Fix row height measurement order and increase row padding
Move padding after onSizeChanged in CalendarMonthPage so row height
measurement excludes padding. Rename p→collapseProgress for clarity.
Add comments explaining grid height calculation and pager switching.
Increase ROW_PADDING_DP from 4 to 6.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 14:21:57 +08:00
xfy
85fe11d9f1 Animate card gap spacing with collapse progress
Card gap now interpolates between 24dp (expanded) and 12dp (collapsed)
instead of using a fixed value, providing a smoother visual transition.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 14:08:51 +08:00
xfy
5087bceb51 Add card gap spacing and header horizontal padding
Include CARD_GAP_DP in calendar area height calculation so BottomCard
positioning accounts for the gap. Add horizontal padding to MonthHeader
for better visual alignment.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 14:05:44 +08:00
xfy
c8921e8641 Fix calendar height jitter when collapsing to week view
WeekPager had no height constraint (unlike CalendarPager which uses
pagerModifier with gridHeightPx), causing the pager to freely expand
instead of staying at the computed single-row height. Also, WeekPager
used 2dp row padding while CalendarMonthPage uses ROW_PADDING_DP (4dp),
creating a height mismatch at the switch point.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 13:12:58 +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
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
b794601134 Fix style issues in MonthHeader and CalendarMonthView
Replace hardcoded padding values with constants, use Spacer instead of
space character for spacing, remove fontSize override on bodySmall, and
fix WeekdayHeader modifier order (padding before onSizeChanged).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:18:52 +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