Fall back to placeholder logo

This commit is contained in:
Davide De Rosa 2019-11-30 11:04:16 +01:00
parent 4a659b8f8d
commit d302e504df
2 changed files with 9 additions and 9 deletions

View File

@ -187,8 +187,12 @@ extension MFMailComposeViewController {
// FIXME: load from index JSON
extension Infrastructure.Metadata {
var logo: UIImage {
return ImageAsset(name: name.lowercased()).image
var logo: UIImage? {
let bundle = Bundle(for: AppDelegate.self)
guard let image = AssetImageTypeAlias(named: name.lowercased(), in: bundle, compatibleWith: nil) else {
return Asset.Providers.placeholder.image
}
return image
}
}

View File

@ -474,13 +474,9 @@ extension OrganizerViewController {
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
let rowProfile = profileKey(at: indexPath)
if rowProfile.context == .provider {
if let metadata = InfrastructureFactory.shared.metadata(forName: rowProfile.id) {
cell.imageView?.image = metadata.logo
cell.leftText = metadata.description
} else {
cell.imageView?.image = Asset.Providers.placeholder.image
cell.leftText = rowProfile.id
}
let metadata = InfrastructureFactory.shared.metadata(forName: rowProfile.id)
cell.imageView?.image = metadata?.logo
cell.leftText = metadata?.description ?? rowProfile.id
} else {
cell.imageView?.image = nil
cell.leftText = rowProfile.id