summaryrefslogtreecommitdiff
path: root/JuickNext/View/LoadableImageView.swift
blob: 6a41dc299dd75b7e07822fe175cb31b6127b88ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
//  LoadableImageView.swift
//  tst
//
//  Created by Vitaly Takmazov on 10.12.2019.
//  Copyright © 2019 com.juick. All rights reserved.
//

import SwiftUI

struct LoadableImageView: View {
    @ObservedObject var imageFetcher: ImageFetcher
    
    init(with urlString: String) {
        imageFetcher = ImageFetcher(url: urlString)
    }
    
    var body: some View {
        if let image = Image(data: imageFetcher.data) {
            return AnyView(
                image.resizable()
            )
        } else {
            return AnyView(
                ProgressView()
            )
        }
    }
}