SwiftUI view that download and display image from URL and displaying Activity Indicator while loading .

Overview

ViewWithActivityIndicator

ViewWithActivityIndicator is a SwiftUI view that download and display image from URL and displaying Activity Indicator while loading .

ScreenShots

N|Solid

Demo app ViewWithActivityIndicatorDemo.

Installation

ViewWithActivityIndicator is a Swift Package and you can install it with Xcode 11:

  • Copy SSH [email protected]:blackwiz4rd/ViewWithActivityIndicator.git or HTTPS https://github.com/blackwiz4rd/ViewWithActivityIndicator.git URL from github;
  • Open File/Swift Packages/Add Package Dependency... in Xcode 11;
  • Paste the URL and follow steps.

Usage

ViewWithActivityIndicator must be initialized with a URL and optional placeholder image.

let url = ""

 ViewWithActivityIndicator(imageURL: url)

 ViewWithActivityIndicator(imageURL: url,placeHolder: "icon")

Using in a view:

import SwiftUI
import ViewWithActivityIndicator

struct ContentView : View {


    let loader: ViewLoader = ViewLoader(url: "https://picsum.photos/300")

    var body: some View {
        ViewWithActivityIndicator(placeHolder: "", showActivityIndicator: true, viewLoader: loader) {
            Image(uiImage: UIImage(data:self.loader.getData()) ?? UIImage())
        }
    } 
}

Using in a list:

import SwiftUI
import ViewWithActivityIndicator

struct ContentView : View {
let urls: [String]
let loader: ViewLoader = ViewLoader(url: "https://picsum.photos/300")

var body: some View {
List(urls, id: \.self) { url in
HStack {
ViewWithActivityIndicator(imageURL: url)
.frame(width: 100.0, height: 100.0)
Text("\(url)")
}
}
}
}

ViewLoaders allows to create multiple loaders given a String array:

@available(iOS 13.0, *)
public struct ViewLoaders {
    var loaders: [ViewLoader] = []
    init(urls: [String]) {
        for url in urls {
            loaders.append(ViewLoader(url: url))
        }
    }
}
You might also like...
ImageView - Component for loading and displaying different images aka SVG/PNG/JPG/JPEG

ImageView Component that loads and displays images(.svg/.png/.jpg/.jpeg) form as

Lightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!
Lightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!

Asyncrounously download and display images in Swift UI. Supports progress indicators, placeholders and image transitions. RemoteImageView Asyncrounous

SwiftUI Image loading and Animation framework powered by SDWebImage
SwiftUI Image loading and Animation framework powered by SDWebImage

SDWebImageSwiftUI What's for SDWebImageSwiftUI is a SwiftUI image loading framework, which based on SDWebImage. It brings all your favorite features f

Lazy image loading for SwiftUI

A missing piece in SwiftUI that provides lazy image loading.

A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.
A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.

Longinus Longinus is a pure-Swift high-performance asynchronous web image loading,caching,editing framework. It was learned from Objective-C web image

EbImagesSwiftUI - SDWebImageSwiftUI - a SwiftUI image loading framework, which based on SDWebImage
EbImagesSwiftUI - SDWebImageSwiftUI - a SwiftUI image loading framework, which based on SDWebImage

SDWebImageSwiftUI What's for SDWebImageSwiftUI is a SwiftUI image loading framew

DGLoading - A loading view that is shown at center of the current view
DGLoading - A loading view that is shown at center of the current view

DGLoading A loading view that is shown at center of the current view. Requiremen

Image loading system
Image loading system

Image Loading System Nuke ILS provides an efficient way to download and display images in your app. It's easy to learn and use thanks to a clear and c

Asynchronous image loading framework.
Asynchronous image loading framework.

YYWebImage YYWebImage is an asynchronous image loading framework (a component of YYKit). It was created as an improved replacement for SDWebImage, PIN

Comments
  • Simply doesn't work

    Simply doesn't work

    I added this to my project and followed the sample code. Simply does not work. All other swift packages work except this one. Going to find a better supported alternative.

    opened by chris-babelbark 0
  • Added support for macOS & watchOS

    Added support for macOS & watchOS

    This PR makes it possible to use the plugin on macOS & watchOS. Previews compile, but are not displayed for images that use this component.

    I had to disable the activity indicator functionality as it used APIs not available on watchOS.

    opened by Nezz 0
  • Module not found macOS or rather not working with macOS SwiftUI Projects

    Module not found macOS or rather not working with macOS SwiftUI Projects

    It doesn't display an image if I try to build it on macOS with SwiftUI. It works on iOS but if I create a project for macOS it isn't loading the module.

    opened by h4ckua11 0
Owner
Ali Adam
Skilled critical thinker who develops solutions that exceed expectations
Ali Adam
AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

Dmytro Anokhin 1k Jan 4, 2023
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

Evgenii Neumerzhitckii 330 Sep 9, 2022
This simple cordova plugin will download picture from an URL and save to IOS Photo Gallery.

Photo Viewer This plugin is intended to download a picture from an URL into IOS Photo library.. How to Install Cordova: cordova plugin add https://git

Alwin jose 1 Oct 23, 2021
A simple and customizable activity indicator.

日本語 KRActivityIndicatorView KRActivityIndicatorView is a simple and customizable activity indicator written in Swift. You can add KRActivityIndicatorV

K.R.Impedance 47 Jul 11, 2022
A UIActivityViewController to share images while displaying them as a nice preview.

PSActivityImageViewController Overview This view controller allows you to share an image the same way as a normal UIActivityViewController would, with

Peter Salz 11 Oct 19, 2022
iOS library for quickly displaying images while scrolling

Fast Image Cache is an efficient, persistent, and—above all—fast way to store and retrieve images in your iOS application. Part of any good iOS applic

Path Mobile Inc Pte. Ltd. 8.2k Jan 9, 2023
A SwiftUI view for displaying image histograms

HistogramView A SwiftUI view for displaying image histograms. How do I use it? It's as simple as: HistogramView(image: myImage) Note: Both UIImage & N

Vasilis Akoinoglou 11 Dec 14, 2022
Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

Twitter 1.8k Dec 17, 2022
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

Wei Wang 2.1k Dec 30, 2022
Advanced framework for loading, caching, processing, displaying and preheating images.

Advanced framework for loading, caching, processing, displaying and preheating images. This framework is no longer maintained. Programming in Swift? C

Alexander Grebenyuk 1.2k Dec 23, 2022