This commit introduces a new "Create Post" screen, enabling users to compose and publish posts with text and up to three images. The implementation includes a dedicated ViewModel, robust state management, and an asynchronous image upload flow.
**Key Changes:**
* **feat(Create Post Screen):**
* Added `CreatePostScreen.kt`, a new Composable screen for creating posts.
* The UI includes a text input field, selectors for "Section" and "Category," and an image picker/preview area.
* Implemented `SelectionBottomSheet` as a reusable component for picking sections and categories from a modal bottom sheet.
* The "Publish" button is dynamically enabled based on content validation and image upload status.
* Error messages are displayed to the user via a snackbar-like component.
* **feat(CreatePostViewModel):**
* Created a new `CreatePostViewModel` to manage the logic and state (`CreatePostState`) of the creation process.
* Fetches post categories on initialization.
* Handles image selection and manages an asynchronous upload queue. Each selected image is immediately uploaded to the backend via `MediaRepository`.
* The ViewModel tracks the upload progress for each image and updates the UI accordingly.
* The `createPost` function validates all inputs, compiles the post data (including uploaded image UUIDs), and sends it to the repository.
* **feat(Navigation):**
* Added a `CreatePost` route to the navigation graph (`Screen.kt`).
* Integrated the new screen into `App.kt` with custom horizontal slide transitions.
* The publish button on the main screen's top bar now navigates to the `CreatePostScreen`.
* Upon successful post creation, the user is navigated back to the main screen.
* **refactor(PostDetailViewModel):**
* Adjusted the `createComment` logic to correctly handle `parentCommentId`, sending `0L` instead of `null` when there is no parent comment.
This commit introduces a new "Design System" screen for developers and designers, refines navigation animations for a smoother experience, and improves typography consistency across various UI components.
**Key Changes:**
* **feat(Design System):**
* Added a new `DesignSystemScreen.kt` to visually showcase the app's color palette, typography styles, and shape system.
* The screen features animated guides and detailed specifications for each design token (e.g., font size, weight, color roles).
* A new "About Tangyuan Design System" menu item has been added to the `UserScreen` (for both logged-in and logged-out states), navigating to this new screen.
* **refactor(Navigation):**
* Replaced default navigation transitions with custom animations using `CubicBezierEasing` for a more fluid and responsive feel (e.g., quick spring and fade effects).
* Detail screens (`PostDetail`, `UserDetail`, `ImageDetail`) now use a `fadeIn`/`fadeOut` transition to prevent conflicts with shared element animations.
* Side-panel screens (`About`, `DesignSystem`) now use a horizontal slide transition.
* Navigation between main tabs (`Talk`, `Message`, `User`) is now animated with a horizontal slide and fade.
* **refactor(Typography & UI):**
* Standardized the font weight for titles and important text to `SemiBold` across `PostCardItem`, `PostDetailScreen`, and `CommentComponents` for better visual hierarchy.
* Updated the `PostDetailScreen` top bar title to "帖子详情" for clarity.
* Replaced the literary font with the general-purpose font in some UI elements like comment interaction labels for improved readability.
* Enabled image click navigation from the `UserDetailScreen`'s post feed.
* **feat(Create Post):**
* Introduced `CreatePostDto.kt` and `CreatePostRepository.kt` to support post creation.
* The repository now handles fetching categories and creating posts through a two-step process: creating post metadata and then the post body.
* Added `CreatePostState` to manage the UI state for the post creation screen, including validation for content length and image limits.
This commit enhances the post detail and creation flows by integrating user authentication and activating the post creation functionality.
**Key Changes:**
* **refactor(PostDetailViewModel):**
* The `loadPostDetail` function no longer requires `userId` as a parameter. It now retrieves the current user's ID directly from the JWT using `TokenManager`.
* When creating a new comment (`CreateCommentDto`), the current `commentDateTime` (using `java.util.Date`) is now included.
* **feat(PostViewModel):**
* The previously stubbed `createPost` function has been fully implemented.
* It now makes sequential repository calls: first to `createPostMetadata` to get a new `postId`, and then to `createPostBody` with that ID.
* The UI state is updated to reflect success or failure throughout the creation process.
This commit introduces the ability for users to save images to their device's gallery and includes several enhancements to the image detail screen and comment section.
**Key Changes:**
* **feat(Image Saving):**
* **ImageSaveUtils:** Added a new `ImageSaveUtils.kt` utility to handle saving images to the device gallery. It supports both modern (Android Q+) and legacy storage APIs.
* **Save Button:** Implemented a "Save" icon button in the `ImageDetailScreen` top bar, allowing users to download the currently viewed image.
* **Feedback:** The app now displays a `Snackbar` message (e.g., "Image saved to gallery") upon successful or failed save operations.
* **feat(Image Detail Screen):**
* **Improved Zoom/Pan:** Reworked the zoom and pan logic in `ZoomableImage` for a smoother experience. The `HorizontalPager` is now disabled when an image is zoomed in to prevent accidental swiping.
* **Double-Tap to Zoom:** Added double-tap-to-zoom functionality on the `ImageDetailScreen`.
* **refactor(Comments):**
* **Improved Reply UI:** The comment input bar now shows a preview of the comment being replied to (e.g., "Replying to User: This is the comment...").
* **Deprecated DTO Fields:** Marked `commentDateTime` and `imageGuid` in `CreateCommentDto` as deprecated, as they are now handled by the backend.
* **refactor(Permissions):**
* Added `WRITE_EXTERNAL_STORAGE`, `READ_EXTERNAL_STORAGE`, and `READ_MEDIA_IMAGES` permissions to `AndroidManifest.xml` to support the new image saving feature across different Android versions.
* **fix(Login):**
* Ensured that the user's profile information is fetched immediately after the login token is successfully saved, fixing a potential race condition.
This commit introduces a new "About" screen that displays application information, including version, development team credits, and other acknowledgments.
**Key Changes:**
* **feat(AboutScreen):**
* Added a new `AboutScreen.kt` Composable to display app logo, version, development team roles, and other details.
* Created modular `InfoSection` and `InfoItem` components to structure the content.
* The screen features a top app bar with a back button.
* **feat(Navigation):**
* Added a new `Screen.About` destination to the navigation graph.
* The "About" option in the `UserScreen` now navigates to the newly created `AboutScreen`.
This commit introduces a dedicated user profile screen (`UserScreen`) and significantly enhances the authentication system by adding registration, auto-login, and robust form validation.
**Key Changes:**
* **feat(UserScreen):**
* Added a new `UserScreen` to display the logged-in user's profile.
* Displays user details including avatar, nickname, ID, bio, location, and email in a styled card.
* Includes a menu section for actions like "Post Management," "Settings," and "About."
* Shows a "not logged in" state to prompt users to log in.
* **feat(Auth):**
* **Registration:** Implemented a registration flow alongside the login flow on the `LoginScreen`. Users can now switch between Login and Register modes.
* **Auto-Login:** The app now automatically logs in the user on startup if a valid token or saved credentials exist, improving user experience.
* **Token Management:** Enhanced `TokenManager` to handle JWT parsing to extract `userId`, check token validity (expiration), and securely store credentials. Added `java-jwt` dependency for this.
* **Logout:** Improved the logout function to clear all stored tokens and user credentials from `SharedPreferences`.
* **feat(Validation):**
* Introduced `ValidationUtils` to provide real-time validation for phone number, password, and nickname fields on the `LoginScreen`.
* Input fields now display specific error messages to guide the user (e.g., "Password must contain a letter," "Invalid phone number format").
* **refactor(LoginScreen):**
* Redesigned the `LoginScreen` to support both login and registration (`AuthMode`) with animated transitions between modes and form fields.
* Form submission buttons are dynamically enabled based on validation results.
* After successful registration, the user is now automatically logged in.
* **refactor(UserViewModel):**
* Integrated auto-login logic (`checkAutoLogin`) that runs on initialization.
* Refactored `login` and `register` flows to handle token storage and fetch user profile data immediately after authentication.
* Added `isLoggedIn()` to provide a reliable check of the current authentication state.
* **refactor(TopBar):**
* The top bar avatar now correctly reflects the user's login state. It displays the user's avatar when logged in and a generic app icon when logged out.
* Clicking the avatar/icon now navigates to the `UserScreen` if logged in, or the `LoginScreen` if not.
This commit introduces a significant redesign of the `UserDetailScreen`, transforming it from a simple card-based layout to a more modern and refined profile view. It also replaces the basic list of user posts with a full-featured `PostCardItem` feed.
**Key Changes:**
* **feat(UserDetailScreen):**
* Redesigned the user profile section with a cleaner, borderless layout, moving from a `Card` to a `Column`-based design.
* Enhanced user info display to include email and location as decorative "pills."
* Replaced the previous list of post metadata with a full `PostCardItem`-based feed, showing complete post content directly on the user's profile.
* Added loading skeletons for the profile and post list, as well as an improved empty state for users with no posts.
* Added a "bottom indicator" to signify the end of the post list.
* **refactor(ViewModel):**
* Modified `UserDetailViewModel` to fetch and construct full `PostCard` objects for the user's posts, instead of just `PostMetadata`.
* This involves fetching `PostBody` and `Category` details for each post to provide a rich feed experience.
* **refactor(Shared Element Transition):**
* Introduced `sharedElementPrefix` to `PostCardItem` and `UserDetailScreen` to create unique transition keys for elements (like avatars and names) that appear in multiple screens (e.g., `talk_post_...`, `userdetail_post_...`).
* This ensures that shared element animations are correctly scoped and avoids conflicts when navigating between different feeds and detail screens.
* The shared element transition for user avatar and name now works correctly from any `PostCard` to the `UserDetailScreen`.
* **feat(Repository):**
* Added `getPostBody(postId)` and `getCategory(categoryId)` methods to `UserRepository` to support fetching the detailed data required for constructing `PostCard` objects.
This commit introduces a dedicated user detail screen, enabling users to view profiles, and refactors the navigation flow, particularly for post and image details, to be more modular and robust.
**Key Changes:**
* **feat(UserDetailScreen):**
* Added a new `UserDetailScreen` to display user information, including their avatar, name, bio, and a list of their posts.
* Implemented a `UserDetailViewModel` to fetch user data and their associated posts from the repository.
* The screen is composed of several modular components: `UserDetailCard`, `UserStatsSection`, and `PostsSection`.
* Includes loading skeletons and an empty state for the user's post list.
* Integrated a pull-to-refresh mechanism to update user data.
* **feat(Navigation):**
* Added a new `UserDetail` route (`user_detail/{userId}`) to the navigation graph.
* Users can now navigate from a post card or post detail view to the author's `UserDetailScreen`.
* Clicking a post in the `UserDetailScreen` navigates to the corresponding `PostDetailScreen`.
* **refactor(Navigation & Post/Image Detail):**
* Decoupled the text and image detail views, removing the `PostDetailContainer` that previously managed mode switching with `AnimatedContent`.
* `PostDetailScreen` and `ImageDetailScreen` are now independent navigation destinations.
* Navigation from a post to its image view is now a direct navigation action to `ImageDetailScreen`, simplifying the logic.
* The route for `PostDetail` has been simplified to `post_detail/{postId}`, removing the `mode` parameter.
* **feat(Shared Element Transition):**
* Implemented a shared element transition for the user avatar, animating it from `PostCardItem` to `UserDetailScreen`.
* The avatar transition key is based on `user_avatar_{userId}` for consistent animations.
* **refactor(ImageDetailScreen):**
* Improved the shared element transition for images by setting `placeHolderSize` to `animatedSize` and disabling `renderInOverlayDuringTransition`, which can resolve certain animation artifacts.
* **refactor(Repository):**
* Added `getUserPosts(userId)` to the `UserRepository` to fetch all post metadata for a specific user.
This commit refactors the shared element transitions for images to be more specific and robust, creating a smoother animation between the post list/detail and the full-screen image viewer.
**Key Changes:**
* **Refined Shared Element Keys:**
* The shared element key for images is now based on both `postId` and `imageIndex` (e.g., `post_image_{postId}_{imageIndex}`). This replaces the previous, less specific key (`post_card_{postId}`), ensuring that the correct image animates, especially in multi-image posts.
* **Improved Animation:**
* The animation `tween` duration has been standardized to 400ms with a `FastOutSlowInEasing` curve for a more polished and consistent feel across all image transitions.
* **Navigation & State Handling:**
* The navigation route for `PostDetail` now accepts an `imageIndex` parameter, allowing direct navigation to a specific image within the image detail view.
* The `PostDetailContainer` now uses the passed `initialImageIndex` to correctly display the selected image when entering image mode.
* Shared element transitions are now conditionally applied only during the initial navigation into a mode (text or image) to prevent animation conflicts when switching between them.
* **Component Updates:**
* `PostCardImages` and `PostDetailImages` now accept `sharedTransitionScope` and `animatedContentScope` to correctly apply the shared element modifier to each image.
* `ImageDetailScreen` has been updated to use the new `imageIndex`-based keying for its `ZoomableImage`.
This commit introduces a dedicated image detail screen and integrates it with the post detail view, allowing users to switch between a text-focused layout and an immersive, image-centric one.
**Key Changes:**
* **feat(ImageDetailScreen):**
* Added a new `ImageDetailScreen` for a full-screen, immersive image viewing experience.
* Implemented a `HorizontalPager` to allow swiping between multiple images.
* Included zoom (pinch-to-zoom) and double-tap-to-zoom functionality for images.
* Overlaid post information (author, content snippet) on a blurred background, which can be swiped up to switch back to the text detail view.
* The background is a blurred version of the current image, creating an ambient effect.
* **feat(Navigation):**
* Created a `PostDetailContainer` to manage the animated transition between `PostDetailScreen` (text mode) and `ImageDetailScreen` (image mode).
* Updated the navigation route for `PostDetail` to accept a `mode` parameter (`text` or `image`) to handle deep linking directly into the image view.
* Clicking an image in the feed or post details now navigates to the image mode, preserving the shared element transition.
* **refactor(PostDetail):**
* Modified `PostCardItem` and `PostDetailScreen` to pass both `postId` and the image `index` on image clicks.
* Refactored the image click handler to trigger the navigation to the new image detail mode.
This commit introduces a comprehensive set of features, establishing the core functionality of the application using an MVVM architecture with Hilt for dependency injection.
**Key Changes:**
* **UI & Navigation:**
* Implemented navigation between the main feed, post details, and login screens using Jetpack Navigation Compose.
* Added `TalkScreen` for displaying a feed of posts and `PostDetailScreen` for viewing individual posts and their comments.
* Created a `LoginScreen` with input fields and authentication logic.
* Introduced `PostCardItem` and `CommentItem` Composables for a consistent and reusable UI.
* Added shared element transitions for a smoother user experience when navigating to post details.
* **Architecture & State Management:**
* Integrated Hilt for dependency injection across ViewModels and Repositories.
* Created ViewModels (`TalkViewModel`, `PostDetailViewModel`, `UserViewModel`, `CommentViewModel`, etc.) to manage UI state and business logic.
* Implemented Repository pattern for abstracting data sources from the backend API.
* Defined UI state data classes to ensure a predictable and observable state flow.
* **Data & Models:**
* Introduced data models for `PostCard` and `CommentCard` to aggregate and display complex data structures.
* Added `PostDetailRepository` to orchestrate fetching of post and comment data concurrently.
* Refined DTOs, such as `CreateCommentDto`, for API interactions.
* **Dependencies & Tooling:**
* Added Hilt, Navigation Compose, and Lifecycle ViewModel dependencies.
* Included the `pangu-jvm` library for improved text formatting with spacing between Chinese and English characters.