Skip to content

Add share habits streak feature#36

Open
AlexGladkov wants to merge 4 commits into
mainfrom
feature/share-habits-8610d12c
Open

Add share habits streak feature#36
AlexGladkov wants to merge 4 commits into
mainfrom
feature/share-habits-8610d12c

Conversation

@AlexGladkov

Copy link
Copy Markdown
Owner

Summary

  • Implemented share functionality for habit streaks across all platforms (Android, iOS, Desktop, Web)
  • Added streak calculation logic to compute current and maximum streaks based on habit history
  • Created shareable streak card UI with habit details and streak information
  • Integrated platform-specific share mechanisms with FileProvider support on Android

Key Changes

  • Streak Calculation: New CalculateStreakUseCase computes current streak and max streak from habit history
  • Share Service: Platform-specific implementations for sharing images with text
    • Android: Uses FileProvider with temporary file sharing
    • iOS: UIActivityViewController integration
    • Desktop/Web: Placeholder implementations
  • UI Components: New StreakCard composable for rendering shareable streak cards
  • DetailView Updates: Added share button and integrated streak sharing flow

Technical Details

  • Added FileProvider configuration in Android manifest with file_paths.xml
  • Integrated Compose Multiplatform screenshot capture via GraphicsLayer
  • Properly handles platform-specific share mechanisms through dependency injection

🤖 Generated with Claude Code

claude and others added 4 commits January 31, 2026 11:18
Defines the approach for sharing habit streaks as image cards
via the platform's native share sheet, including streak calculation,
card rendering, and cross-platform share service.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add ability for users to share their habit streak as text via the platform's
native share sheet. Users can share from the habit detail screen, including
the habit name, current streak count, and completion rate.

Key changes:
- Add CalculateStreakUseCase to calculate consecutive days habit streak
- Create StreakCard composable for future visual streak card
- Implement ShareService with platform-specific implementations:
  * Android: Intent.ACTION_SEND with FileProvider
  * iOS: UIActivityViewController
  * Desktop: Clipboard copy
  * Web: Web Share API with clipboard fallback
- Add share button to DetailView
- Update DetailViewModel to handle share events and calculate streak
- Configure Android FileProvider for future image sharing
- Register ShareService and CalculateStreakUseCase in DI modules

The implementation currently shares text content. Image generation from
the StreakCard composable can be added as a future enhancement.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix streak calculation logic to properly handle days not tracked
- Add ShareDismissed event to properly reset sharing state
- Add comprehensive error handling to all ShareService implementations
- Add file cleanup for Android to prevent cache bloat
- Add fallback to text-only sharing when image is empty or fails
- Improve error messages and logging across all platforms

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants