Created
August 7, 2019 22:56
-
-
Save PaulWoodIII/61c9be0dac47499f310e9eebbbe7250c to your computer and use it in GitHub Desktop.
Example code for https://github.com/RuiAAPeres/Tangerine
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
| //: [Previous](@previous) | |
| import SwiftUI | |
| import PlaygroundSupport | |
| struct ExampleView: View { | |
| @ObservedObject var fetcher: ImageFetcher | |
| init(fetcher: ImageFetcher) { | |
| self.fetcher = fetcher | |
| } | |
| var body: some View { | |
| VStack { | |
| if fetcher.image != nil { | |
| Image(uiImage: fetcher.image!) | |
| .resizable() | |
| .aspectRatio(contentMode: .fit) | |
| } | |
| else { | |
| EmptyView() | |
| } | |
| } | |
| .onAppear(perform: fetcher.refresh) | |
| } | |
| } | |
| let viewController = UIHostingController(rootView: | |
| ExampleView(fetcher: ImageFetcher(url: URL(string: "https://avatars3.githubusercontent.com/u/949286?s=400&v=4")!)) | |
| ) | |
| PlaygroundPage.current.liveView = viewController | |
| //: [Next](@next) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment