Created
January 20, 2020 05:28
-
-
Save garethpaul/00fe0384cef0a07bb43267a503a0038f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // IconView.swift | |
| // FSQNearby | |
| // | |
| // Created by GPJ on 1/19/20. | |
| // Copyright © 2020 GPJ. All rights reserved. | |
| // | |
| import SwiftUI | |
| struct IconView: View { | |
| @ObservedObject var imageLoader:ImageLoader | |
| @State var image:UIImage = UIImage() | |
| init(withURL url:String) { | |
| imageLoader = ImageLoader(urlString:url) | |
| } | |
| var body: some View { | |
| VStack { | |
| Image(uiImage: image) | |
| .resizable() | |
| .aspectRatio(contentMode: .fit) | |
| .frame(width:30, height:30) | |
| }.onReceive(imageLoader.didChange) { data in | |
| self.image = UIImage(data: data) ?? UIImage() | |
| }.background(Color.black) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment