- 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.
-
Clone the repository:
git clone https://github.com/mustafos/lazy-load-img.git cd lazy-load-img
-
Open the project in Xcode:
open lazy-load-img.xcodeproj
-
Run the application:
- Select the target device or simulator.
- Press
Cmd + R
or click the Run button in Xcode.
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.
- 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.
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.