https://github.com/mustafos/lazy-load-img
The application fetches image data from a remote JSON file, displays a loading indicator while fetching, and uses lazy loading to only load images as they come into view. It includes error handling with a retry mechanism
https://github.com/mustafos/lazy-load-img
async-await concurrency grandcentraldispatch json-api restful-api swift swiftui
Last synced: about 2 months ago
JSON representation
The application fetches image data from a remote JSON file, displays a loading indicator while fetching, and uses lazy loading to only load images as they come into view. It includes error handling with a retry mechanism
- Host: GitHub
- URL: https://github.com/mustafos/lazy-load-img
- Owner: mustafos
- License: mit
- Created: 2024-05-29T00:36:27.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-09-12T12:57:51.000Z (8 months ago)
- Last Synced: 2024-09-13T00:36:57.751Z (8 months ago)
- Topics: async-await, concurrency, grandcentraldispatch, json-api, restful-api, swift, swiftui
- Language: Swift
- Homepage:
- Size: 2.09 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lazy Load Gallery
![]()
## Features
- **Lazy Loading**: Images load only when they are about to appear in the viewport.
- **Loading Indicators**: Displays a placeholder and loading spinner while images and data are loading.
- **Error Handling**: Shows an error message with a retry option if the data fetch fails.
- **Responsive UI**: Uses a grid layout to display images, ensuring a responsive design.## Installation
1. **Clone the repository:**
```bash
git clone https://github.com/mustafos/lazy-load-img.git
cd lazy-load-img
```2. **Open the project in Xcode:**
```bash
open lazy-load-img.xcodeproj
```3. **Run the application:**
- Select the target device or simulator.
- Press `Cmd + R` or click the Run button in Xcode.## Project Structure
- `LazyLoadGalleryApp.swift`: The main entry point of the application.
- `View/GalleryView.swift`: The main view that initializes and displays the image list.
- `Model/Post.swift`: The data model representing each image item.
- `Utils/CacheAsyncImage.swift`: The view for an async image.
- `ViewModels/NetworkManager.swift`: The view model responsible for fetching and managing image data.## Usage
- The application starts by displaying a loader.
- Once data is fetched, a grid of image cards is displayed.
- Each image card shows a placeholder until the image is fully loaded.
- If the data fetch fails, an error message with a retry button is shown.## Contribution
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/mustafos/lazy-load-img/blob/master/LICENSE) file for details.