How chaoqinliu/composewechat works
Main Components (Nodes)
• UI / Presentation Layer:
• Activities: MainActivity, ChatActivity, LoginActivity, ImagePreviewActivity, MomentActivity, UserActivity.
• Compose Screens: Located under ui/screen (e.g., LoginScreen, ChatScreen, HomeScreen, MomentScreen, etc.), as well as dialogs and loading screens.
• UI Widgets and Views: custom components such as ActionBook, ActionTitle, CQDivider.
• ViewModel / Business Logic Layer:
• Individual ViewModels for each screen (ChatSessionViewModel, ChatViewModel, HomeViewModel, MomentViewModel, UserViewModel) and additional paged data sources.
• This layer bridges the UI and the underlying data operations.
• Data Access / Persistence Layer:
• Local Database: COMChatDataBase indicates usage of a Room or SQLite database.
• DAO: ChatSmsDao for handling database CRUD operations.
• Entities: chat and user entities found in entitys (e.g., ChatSmsEntity.kt).
• Data Models: Data classes for various UI or domain models (ChatSession, User, MomentData, AddrBookData, etc.).
• Network / API Communication Layer:
• API Service: UserService.kt provides an API interface possibly for user-related HTTP operations.
• Network Client: HttpClient.kt helps manage networking tasks.
• Utilities and Extensions:
• Common utility classes (e.g., ToastUtils, TimeUtils, DensityUtils).
• Extensions and modifiers aiding UI and other common operations.
• Additional Modules:
• Routing and Navigation: ui/route (Routes.kt) coordinate navigation within the app.
Relationships and Interactions
• The UI layer (activities, composable screens, custom views) interacts with the ViewModel layer through observers, ensuring that any changes in data are reflected in the UI.
• ViewModels coordinate with the data layer by calling methods on DAOs, accessing the local database, or querying remote APIs via the HttpClient and service interfaces.
• The data layer (DAO, entities, models) feeds information into the viewmodels, which in turn update the composables.
• Utilities and extensions support various cross-cutting concerns, such as displaying Toast messages, handling density conversions, and applying UI modifiers.
Architectural Patterns / Design Principles
• MVVM: Clear separation of presentation (activities, screens), business logic (viewmodels), and data handling (DAO, entities, API services).
• Modular organization: Each feature (chat, login, moments, user profile) is managed in its own sub-package, promoting separation of concerns.
• Composable UI: The use of Jetpack Compose elements is evident in the “ui” package, where each screen is designed as a composable function.
Technologies & Frameworks
• Android (Kotlin): Standard Android app with Kotlin code.
• Jetpack Compose: For building modern UI components/screen.
• Gradle: For building and dependency management (with associated gradle files).
• (Possibly) Room or SQLite: For the local database via COMChatDataBase and DAO patterns.
• Custom HTTP client: For network interactions (could be leveraging underlying libraries if expanded upon).