CCExtractor / CCExtractor/taskwarrior-flutter

refactor: reduce duplication and improve readability of settings page

未关闭
#641 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Dart
星标
244
派生
179
平均合并
12 小时 42 分钟
30 天内合并 PR
2

描述

The settings page ([lib/app/modules/settings/views/](https://github.com/CCExtractor/taskwarrior-flutter/tree/main/lib/app/modules/settings/views)) has significant code duplication and readability
issues:

- Repeated section boilerplate - _buildSectionHeader() and _buildSettingsCard() are called manually for
every settings group with the same styling logic.
- Near-identical toggle widgets - 4 separate files (settings_page_on_task_start_list_tile_trailing.dart,
settings_page_on_task_create_list_tile_trailing.dart, settings_page_highlist_task_list_tile_trailing.dart,
settings_page_enable_24hr_format_list_tile_trailing.dart) each containing ~30 lines that all do the same
thing: Obx(() => Switch(...)).
- Hardcoded language names - _getLanguageName() duplicates what should be part of the SupportedLanguage enum, requiring updates in multiple places when a language is added.
- Large inline widgets - The delete-tasks confirmation dialog (~80 lines) is inlined directly in the body,
hurting readability.

---

Proposed Changes

1. Introduce SettingsGroup widget + SettingsItemConfig sealed class
A single reusable widget that accepts title, icon, and a List and handles section
header, card styling, and dividers internally. Three item types:
- SettingsToggleItem - title, subtitle, RxBool value, optional prefsKey (auto-saves to SharedPreferences),
optional onChanged for extra side effects
- SettingsDropdownItem - title, subtitle, Rx value, options list, labelBuilder, onChanged
- SettingsCustomItem wraps any custom widget

2. Add nativeName getter to SupportedLanguage
Centralizes display names so Dart's exhaustive switch enforces updates when new languages are added.

3. Extract delete-tasks tile into SettingsPageDeleteTasksTile
Moves the FutureBuilder + confirmation dialog into its own widget file.

4. Delete absorbed files
Remove the 5 single-purpose trailing widget files whose logic is now handled by SettingsGroup.

贡献指南

打开贡献指南

调研方向

从 lib/app/modules/settings/views/ 开始,阅读设置页面以及列出的四个 toggle trailing 文件。在规划共享的 SettingsGroup、语言名称 getter 和提取出的 delete-tasks tile 之前,追踪 SupportedLanguage 和内联的删除任务确认。完成意味着重复的 section 和 toggle 逻辑已合并,语言名称只有一个来源,对话框已提取,并且五个被吸收的文件已删除。

由索引模型根据 Issue 内容生成。

评估

技术栈
dart, flutter
领域
mobile
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。