Files
class-schedule/starschedule/docs/页面与导航.md
T
2026-09-20 13:33:09 +08:00

3.5 KiB
Raw Blame History

页面与导航

导航使用 Navigation3 的 NavBackStack。目的地定义在 Navigation.kt 的 Destination,分发在 App.kt 的 ScreenContent。所有 Destination 必须在 navSerializersModule 注册,否则进程被杀后无法还原返回栈。

三个 MainDestination(今日课表、周课表、我的)切换时会 backStack.clear() 再压入,底部栏无横向滑动动画。其余页面压栈,横向滑入/滑出。

1. 目的地一览

Destination 类型 界面 用户入口
TodaySchedule 主 Tab TodayScheduleScreen 底部「今日课表」;启动页可设为它
CourseSchedule 主 Tab WeeklyScheduleScreen 底部「课表」;默认启动页
Settings 主 Tab SettingsScreen 底部「我的」
TimeSlotSettings 子页 TimeSlotManagementScreen 我的 → 自定义时间段
ManageCourseTables 子页 ManageCourseTablesScreen 我的 → 管理课表
CourseTableConversion 子页 CourseTableConversionScreen 我的 → 课表导入/导出
NotificationSettings 子页 NotificationSettingsScreen 我的 → 课程提醒设置
MoreOptions 子页 MoreOptionsScreen 我的 → 更多
QuickActions 子页 QuickActionsScreen 我的 → 快捷操作
TweakSchedule 子页 TweakScheduleScreen 快捷操作 → 调课
QuickDelete 子页 QuickDeleteScreen 快捷操作 → 快速删除课程
CourseManagementList 子页 CourseNameListScreen 我的 → 课程管理
CourseManagementDetail(courseName) 子页 CourseInstanceListScreen 课程管理 → 点某一门
StyleSettings 子页 StyleSettingsScreen 我的 → 个性化配置
ThemeSettings 子页 ThemeSettingsScreen 更多 → 主题设置
BackupAndRestore 子页 BackupScreen 课表导入/导出 → 备份与恢复
WebView(initialUrl) 子页 WebViewScreen 课表导入/导出 → 正方教务导入;默认 about:blank
AddEditCourse(courseId) 子页 AddEditCourseScreen 周课表点空白格/课程;课程管理添加。courseId == null 为新建

2. 「我的」页结构

常规设置

  • 显示非本周课程(开关,写入全局 DataStore)
  • 是否显示周末(写入当前课表 CourseTableConfig)
  • 设置开学日期
  • 本学期总周数(默认 20)
  • 当前周数(手动改会反推开学日期;可选「假期中」)
  • 每周起始日(周一或周日)
  • 快捷操作

高级功能

  • 课表导入/导出
  • 课程提醒设置
  • 管理课表
  • 课程管理
  • 自定义时间段
  • 个性化配置
  • 更多(关于、启动页面、主题)

3. 导入导出页结构

  • 正方教务导入 → Destination.WebView()
  • 课程文件导入(JSON,覆盖指定课表)
  • 课程文件导出(starschedule_<时间戳>.json)
  • 日历文件导出(starschedule_<时间戳>.ics,可选 1–60 分钟提醒)
  • 备份与恢复 → BackupAndRestore

4. 新增页面步骤

  1. 在 Destination 增加 @Serializable 类型(带参数用 data class)。
  2. 在 navSerializersModule 的 polymorphic 里 subclass(...)。
  3. 在 App.kt 的 ScreenContent 增加 when 分支。
  4. 从已有 Screen 用 onNavigate(Destination.Xxx) 跳转。
  5. 用户可见标题、说明写进 composeResources/values/strings.xml。

主 Tab 必须实现 MainDestination,并在 AdaptiveNavigationScaffold 的 Tab 列表里出现,否则底部栏对不上。