CCExtractor / CCExtractor/taskwarrior-flutter

refactor: reduce duplication and improve readability of settings page

Đang mở
#641 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
244
Fork
179
Merge trung bình
12 giờ 42 phút
Pull request đã merge (30 ngày)
2

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong lib/app/modules/settings/views/ và đọc trang cài đặt cùng với bốn tệp trailing của toggle được liệt kê. Theo dõi SupportedLanguage và xác nhận inline về việc xóa tác vụ trước khi lập kế hoạch cho SettingsGroup dùng chung, getter tên ngôn ngữ và tile delete-tasks được tách ra. Hoàn tất có nghĩa là logic lặp lại của các section và toggle được hợp nhất, tên ngôn ngữ có một nguồn duy nhất, dialog được tách ra và năm tệp được gộp vào đã bị xóa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart, flutter
Lĩnh vực
mobile
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.