Use placeholder when provider logo is missing

So far it's what happens for dynamically added providers, because
there is no local asset.
This commit is contained in:
Davide De Rosa 2019-11-28 11:42:23 +01:00
parent 28a7dcdcf7
commit 1619c7f46c
6 changed files with 32 additions and 4 deletions

View File

@ -284,6 +284,7 @@ internal enum Asset {
internal static let mullvad = ImageAsset(name: "mullvad") internal static let mullvad = ImageAsset(name: "mullvad")
internal static let nordvpn = ImageAsset(name: "nordvpn") internal static let nordvpn = ImageAsset(name: "nordvpn")
internal static let pia = ImageAsset(name: "pia") internal static let pia = ImageAsset(name: "pia")
internal static let placeholder = ImageAsset(name: "placeholder")
internal static let protonvpn = ImageAsset(name: "protonvpn") internal static let protonvpn = ImageAsset(name: "protonvpn")
internal static let tunnelbear = ImageAsset(name: "tunnelbear") internal static let tunnelbear = ImageAsset(name: "tunnelbear")
internal static let vyprvpn = ImageAsset(name: "vyprvpn") internal static let vyprvpn = ImageAsset(name: "vyprvpn")

View File

@ -191,7 +191,7 @@ extension MFMailComposeViewController {
// FIXME: load from index JSON // FIXME: load from index JSON
extension Infrastructure.Metadata { extension Infrastructure.Metadata {
var logo: UIImage? { var logo: UIImage {
return ImageAsset(name: name.lowercased()).image return ImageAsset(name: name.lowercased()).image
} }
} }

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "placeholder@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "placeholder@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

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