Skip to content

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

License

Notifications You must be signed in to change notification settings

mustafos/lazy-load-img

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lazy Load Gallery

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:

    git clone https://github.com/mustafos/lazy-load-img.git
    cd lazy-load-img
  2. Open the project in Xcode:

    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 file for details.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages