Files
reader-app/.github/copilot-instructions.md
T
virtus 6946083aee
Build Android APK / build-apk (push) Failing after 4m37s
feat: Enhance chapter list and TTS functionality
- Introduced ChapterListQuery and ChapterListPage classes for better chapter management.
- Updated chapterListProvider to handle pagination and canonical ID resolution.
- Improved ReaderScreen with enhanced TTS features, including auto-scroll to active paragraph and better handling of TTS state.
- Added TtsPlayerWidget with compact mode and improved UI for TTS controls.
- Enhanced TtsService to manage speech segments and background mode for TTS.
- Implemented battery optimization checks for TTS background mode on Android.
- Updated main.dart to ensure proper error handling in a zoned environment.
2026-04-07 18:49:29 +07:00

2.3 KiB

Project Guidelines

Code Style

  • Dùng Dart/Flutter theo lint mặc định trong analysis_options.yaml (flutter_lints).
  • Tổ chức theo feature-first: code mới đặt đúng module trong lib/features/**, phần dùng chung đặt ở lib/core/** hoặc lib/shared/**.
  • Tránh logic nghiệp vụ trong widget build; chuyển sang provider/notifier.
  • Giữ naming nhất quán: file snake_case, class PascalCase, provider rõ nghĩa theo tính năng.

Architecture

  • lib/main.dart: bootstrap app + ProviderScope.
  • lib/app/: app shell, router và route names.
  • lib/core/: config, network, storage, theme, models dùng toàn app.
  • lib/features/: từng domain (auth, home, search, novel, reader, bookshelf, comments, profile, settings...).
  • lib/shared/: widgets dùng chung.
  • State management chính: Riverpod; networking: Dio; routing: go_router.

Build and Test

  • Cài dependencies: flutter pub get
  • Chạy app: flutter run
  • Khuyến nghị local: bash scripts/flutter_run_with_env.sh
  • Phân tích lint/static: flutter analyze
  • Chạy test hiện có: flutter test

Conventions

  • Cấu hình API base URL lấy từ AppConfig/env; không hardcode URL trực tiếp trong feature code.
  • Token/session xử lý qua tầng storage/network ở lib/core, tránh duplicate auth flow trong từng feature.
  • Khi thêm màn hình mới, cập nhật router tập trung ở lib/app/router/app_router.dart.
  • Ưu tiên tái sử dụng models trong lib/core/models thay vì tạo kiểu dữ liệu rời rạc.

Pitfalls

  • Android emulator phải dùng 10.0.2.2 để gọi localhost backend; iOS simulator/web thường dùng localhost.
  • Google Sign-In Android dễ lỗi ApiException: 10 nếu cấu hình SHA/OAuth client không khớp.
  • Thiếu .env.mobile hoặc thiếu GOOGLE_SERVER_CLIENT_ID có thể làm luồng đăng nhập thất bại.
  • Thiết bị thật cần LAN IP đúng mạng nội bộ; không dùng VPN IP nếu điện thoại không cùng tunnel.

Key References

  • Tổng quan setup + Google Sign-In: README.md
  • Lint rules: analysis_options.yaml
  • App config/env: lib/core/config/app_config.dart
  • API client + interceptor: lib/core/network/api_client.dart
  • Router trung tâm: lib/app/router/app_router.dart
  • Script chạy với env: scripts/flutter_run_with_env.sh