This is a SwiftUI-based Instagram Stories-like feature that allows users to view, like, and mark stories as seen.
It supports pagination, persistence, and dependency injection for scalability.
- Story List Screen – Horizontally scrollable stories with seen/unseen states.
- Story View Screen – Users can open, like/unlike, and mark stories as seen.
- Persistent State – Stories' seen and liked states persist across app sessions.
- Pagination – Supports infinite scrolling with multiple pages of stories.
- Dependency Injection – Uses
@EnvironmentObject
forStoriesRepository
. - Optimized for SwiftUI – Uses
@StateObject
,@Binding
, and@MainActor
for smooth UI updates.
- Swift 5.9
- SwiftUI
- MVVM Architecture
- Dependency Injection
- Local JSON Storage (for initial data)
- macOS with Xcode installed (version 16.1 or later).
- A device or simulator running iOS 18.1 or later.
-
Clone the Repository
git clone https://github.com/malayli/StoriesSharing.git cd StoriesSharing
-
Open the Project in Xcode Open the
StoryApp.xcodeproj
file in Xcode. -
Set the Build Target Ensure the build target is set to an appropriate iOS device or simulator.
-
Run the App Click the Run button in Xcode or press
Cmd + R
to build and run the app.
-
View Stories
- Scroll horizontally to browse available stories.
- Tap a story to open it.
-
Mark as Seen
- Once a story is opened, it will appear faded (gray overlay).
- The app remembers seen stories across sessions.
-
Like/Unlike a Story
- Inside a story, tap the heart button to like or unlike it.
- Liked stories persist across app restarts.
-
Pagination
- Scroll to the end of the list to automatically load the next page of stories.
The app follows MVVM (Model-View-ViewModel) for better separation of concerns:
- Model: Defines the story structure.
- ViewModel: Handles business logic, persistence, and API interactions.
- View: UI components that bind to the ViewModel.
- The app injects StoriesRepository into StoriesViewModel to decouple dependencies.
- SwiftUI’s @EnvironmentObject is used for better state management.
- StoryListView – Displays horizontally scrollable stories.
- StoryView – Shows a full-screen view of a story.
- StoriesViewModel and StoryViewModel – Manages pagination and state updates.
- StoriesRepository – Handles local JSON storage and persistence.