mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-24 17:20:59 +00:00
Alert image loading errors
This commit is contained in:
parent
7a28cf90b0
commit
b148930801
2 changed files with 22 additions and 1 deletions
|
@ -162,6 +162,7 @@
|
||||||
"identities.browsing" = "Browsing";
|
"identities.browsing" = "Browsing";
|
||||||
"identities.log-out" = "Log out";
|
"identities.log-out" = "Log out";
|
||||||
"identities.pending" = "Pending";
|
"identities.pending" = "Pending";
|
||||||
|
"image-error.unable-to-load" = "Unable to load image";
|
||||||
"lists.new-list-title" = "New List Title";
|
"lists.new-list-title" = "New List Title";
|
||||||
"load-more" = "Load More";
|
"load-more" = "Load More";
|
||||||
"load-more.above.accessibility.post" = "Load from post above";
|
"load-more.above.accessibility.post" = "Load from post above";
|
||||||
|
|
|
@ -7,6 +7,19 @@ import SDWebImage
|
||||||
import UIKit
|
import UIKit
|
||||||
import ViewModels
|
import ViewModels
|
||||||
|
|
||||||
|
enum ImageError: Error {
|
||||||
|
case unableToLoad
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ImageError: LocalizedError {
|
||||||
|
var errorDescription: String? {
|
||||||
|
switch self {
|
||||||
|
case .unableToLoad:
|
||||||
|
return NSLocalizedString("image-error.unable-to-load", comment: "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final class ImageViewController: UIViewController {
|
final class ImageViewController: UIViewController {
|
||||||
let scrollView = UIScrollView()
|
let scrollView = UIScrollView()
|
||||||
let imageView = SDAnimatedImageView()
|
let imageView = SDAnimatedImageView()
|
||||||
|
@ -124,7 +137,14 @@ final class ImageViewController: UIViewController {
|
||||||
placeholderImage = nil
|
placeholderImage = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
imageView.sd_setImage(with: viewModel.attachment.url, placeholderImage: placeholderImage)
|
imageView.sd_setImage(with: viewModel.attachment.url,
|
||||||
|
placeholderImage: placeholderImage) { _, error, _, _ in
|
||||||
|
if error != nil {
|
||||||
|
let alertItem = AlertItem(error: ImageError.unableToLoad)
|
||||||
|
|
||||||
|
self.present(alertItem: alertItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
case .gifv:
|
case .gifv:
|
||||||
playerView.tag = viewModel.tag
|
playerView.tag = viewModel.tag
|
||||||
imageView.isHidden = true
|
imageView.isHidden = true
|
||||||
|
|
Loading…
Reference in a new issue