Last active
February 18, 2019 17:23
-
-
Save jeremyrempel/5494c8a7c021492ab86e4c87c7857d90 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
import UIKit | |
import app | |
class ViewController: UIViewController, PhotoView { | |
lazy var actions: PhotoPresenter = { | |
PhotoPresenter( | |
uiContext: UI() as KotlinCoroutineContext, | |
view: self | |
) | |
}() | |
override var isUpdating: Bool = false | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
actions.onRequestData() | |
} | |
override func showError(error: KotlinThrowable) { | |
label.text = error.message | |
} | |
override func onUpdate(data: PhotoResponse) { | |
let make = data.exif?.make ?? "" | |
label.text = "id: \(data.id)\n exif.make: \(make)" | |
let imageURLString = data.urls.full | |
let url = URL(string: imageURLString)! | |
let data = try! Data(contentsOf: url) | |
imageView.image = UIImage(data: data) | |
} | |
@IBOutlet weak var label: UILabel! | |
@IBOutlet weak var imageView: UIImageView! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment