URLImage

1.0.2

A view for instant images on SwiftUI.
ramoliveira/URLImage

What's New

v1.0.2

2021-10-22T23:53:10Z

URLImage

Overview

URLImage is a package that holds an easy way of showing images from an URL.

Usually this processes should take the following process:

A View requires to a ViewController (Controller layer) on MVC, or ViewModel on MVVM, or Presenter on VIPER, then this request should pass through a service. There, this request is processed returning data that will be used to build an UIImage and finally showing in a View.

This whole process is too long if you just want to show an image on your screen. You need to build many layers to achieve that.

Hence, why not create a shortcut?

How to use it?

URLImage is very straight foward to use.

URLImage(URL(string: "https://cdn.pixabay.com/photo/2020/12/03/14/35/horror-5800684_960_720.jpg")!)

Add this to your SwiftUI View and it should render as the view is presented.

Like this:

Rendered URLImage

But, if you want to resize your view. Use like this:

URLImage(URL(string: "https://cdn.pixabay.com/photo/2020/12/03/14/35/horror-5800684_960_720.jpg")!) { image in
    image.resizable()
}.frame(width: 200, height: 200)

This will create an image with 200 width and 200 height.

There are any native option?

Yes! I started to work on this package and then realized that there is a native option build by Apple. It's called AsyncImage. However, AsyncImage is restricted to iOS 15.0 or greater.

URLImage work on later versions.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Oct 19 2024 04:27:56 GMT-0900 (Hawaii-Aleutian Daylight Time)