Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bullinnyc committed Oct 2, 2023
1 parent 0c08f4c commit b0a1632
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)

Async image loading with cache for SwiftUI.
Async image loading with progress and cache for SwiftUI.

## Screenshots
![](./demo.png)

## Installation
### [Swift Package Manager](https://swift.org/package-manager/)

Going to Xcode `File` > `Add Packages...` and add the repository by giving the URL `https://github.com/bullinnyc/CachedAsyncImage`
Going to Xcode `File` > `Add Packages...` and add the repository by giving the URL
`https://github.com/bullinnyc/CachedAsyncImage`
Enjoy!

## Usage
Expand All @@ -19,7 +20,7 @@ Enjoy!
import CachedAsyncImage
```

### Create any view for placeholder and customize image
### Quick start
**Note:** `placeholder` is an optional parameter.

```swift
Expand All @@ -28,7 +29,7 @@ let exampleUrl = "https://example.com/image.jpg"
CachedAsyncImage(
url: exampleUrl,
placeholder: {
// Create any view for placeholder.
// Create any view for placeholder (optional).
ZStack {
Color.yellow
ProgressView()
Expand All @@ -43,6 +44,53 @@ CachedAsyncImage(
)
```

### Use it to the fullest
**Note:** `placeholder` and `error` is an optional parameters.

```swift
let exampleUrl = "https://example.com/image.jpg"

CachedAsyncImage(
url: exampleUrl,
placeholder: { progress in
// Create any view for placeholder (optional).
ZStack {
Color.yellow

ProgressView() {
VStack {
Text("Downloading...")
Text("\(progress) %")
}
}
}
},
image: {
// Customize image.
Image(uiImage: $0)
.resizable()
.scaledToFill()
},
error: { error in
// Create any view for error (optional).
ZStack {
Color.yellow

VStack {
Text("Error:")
.bold()

Text(error)
}
.font(.footnote)
.multilineTextAlignment(.center)
.foregroundColor(.red)
.frame(width: 120)
}
}
)
```

### Set image cache limit (optional)
**Note:** The default value is `0`, e.g. is no count limit and is no total cost limit.

Expand Down

0 comments on commit b0a1632

Please sign in to comment.