Create shared AppAsset and start using it.

This commit is contained in:
Brent Simmons
2025-01-26 21:38:40 -08:00
parent 1bfd0ee12c
commit 69ae436ea4
16 changed files with 224 additions and 145 deletions

View File

@@ -57,7 +57,7 @@ final class CloudKitAccountViewController: UITableViewController {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
headerView.imageView.image = AppAssets.image(for: .cloudKit)
headerView.imageView.image = AppAsset.image(accountType: .cloudKit)
return headerView
} else {
return super.tableView(tableView, viewForHeaderInSection: section)

View File

@@ -59,7 +59,7 @@ final class FeedbinAccountViewController: UITableViewController {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
headerView.imageView.image = AppAssets.image(for: .feedbin)
headerView.imageView.image = AppAsset.image(accountType: .feedbin)
return headerView
} else {
return super.tableView(tableView, viewForHeaderInSection: section)

View File

@@ -46,7 +46,7 @@ final class LocalAccountViewController: UITableViewController {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
headerView.imageView.image = AppAssets.image(for: .onMyMac)
headerView.imageView.image = AppAsset.image(accountType: .onMyMac)
return headerView
} else {
return super.tableView(tableView, viewForHeaderInSection: section)

View File

@@ -58,7 +58,7 @@ final class NewsBlurAccountViewController: UITableViewController {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
headerView.imageView.image = AppAssets.image(for: .newsBlur)
headerView.imageView.image = AppAsset.image(accountType: .newsBlur)
return headerView
} else {
return super.tableView(tableView, viewForHeaderInSection: section)

View File

@@ -210,13 +210,13 @@ final class ReaderAPIAccountViewController: UITableViewController {
if let accountType = accountType {
switch accountType {
case .bazQux:
return AppAssets.accountBazQuxImage
return AppAsset.image(accountType: .bazQux)
case .inoreader:
return AppAssets.accountInoreaderImage
return AppAsset.image(accountType: .inoreader)
case .theOldReader:
return AppAssets.accountTheOldReaderImage
return AppAsset.image(accountType: .theOldReader)
case .freshRSS:
return AppAssets.accountFreshRSSImage
return AppAsset.image(accountType: .freshRSS)
default:
return nil
}

View File

@@ -11,47 +11,47 @@ import Account
struct AppAssets {
static var accountBazQuxImage: UIImage = {
return UIImage(named: "accountBazQux")!
}()
// static var accountBazQuxImage: UIImage = {
// return UIImage(named: "accountBazQux")!
// }()
static var accountCloudKitImage: UIImage = {
return UIImage(named: "accountCloudKit")!
}()
// static var accountCloudKitImage: UIImage = {
// return UIImage(named: "accountCloudKit")!
// }()
//
// static var accountFeedbinImage: UIImage = {
// return UIImage(named: "accountFeedbin")!
// }()
//
// static var accountFeedlyImage: UIImage = {
// return UIImage(named: "accountFeedly")!
// }()
//
// static var accountFreshRSSImage: UIImage = {
// return UIImage(named: "accountFreshRSS")!
// }()
//
// static var accountInoreaderImage: UIImage = {
// return UIImage(named: "accountInoreader")!
// }()
//
// static var accountLocalPadImage: UIImage = {
// return UIImage(named: "accountLocalPad")!
// }()
//
// static var accountLocalPhoneImage: UIImage = {
// return UIImage(named: "accountLocalPhone")!
// }()
//
// static var accountNewsBlurImage: UIImage = {
// return UIImage(named: "accountNewsBlur")!
// }()
//
// static var accountTheOldReaderImage: UIImage = {
// return UIImage(named: "accountTheOldReader")!
// }()
static var accountFeedbinImage: UIImage = {
return UIImage(named: "accountFeedbin")!
}()
static var accountFeedlyImage: UIImage = {
return UIImage(named: "accountFeedly")!
}()
static var accountFreshRSSImage: UIImage = {
return UIImage(named: "accountFreshRSS")!
}()
static var accountInoreaderImage: UIImage = {
return UIImage(named: "accountInoreader")!
}()
static var accountLocalPadImage: UIImage = {
return UIImage(named: "accountLocalPad")!
}()
static var accountLocalPhoneImage: UIImage = {
return UIImage(named: "accountLocalPhone")!
}()
static var accountNewsBlurImage: UIImage = {
return UIImage(named: "accountNewsBlur")!
}()
static var accountTheOldReaderImage: UIImage = {
return UIImage(named: "accountTheOldReader")!
}()
static let nnwFeedIcon = RSImage(named: "nnwFeedIcon")!
// static let nnwFeedIcon = RSImage(named: "nnwFeedIcon")!
static var articleExtractorError: UIImage = {
return UIImage(named: "articleExtractorError")!
@@ -251,31 +251,31 @@ struct AppAssets {
return UIColor(named: "controlBackgroundColor")!
}()
static func image(for accountType: AccountType) -> UIImage? {
switch accountType {
case .onMyMac:
if UIDevice.current.userInterfaceIdiom == .pad {
return AppAssets.accountLocalPadImage
} else {
return AppAssets.accountLocalPhoneImage
}
case .cloudKit:
return AppAssets.accountCloudKitImage
case .feedbin:
return AppAssets.accountFeedbinImage
case .feedly:
return AppAssets.accountFeedlyImage
case .freshRSS:
return AppAssets.accountFreshRSSImage
case .newsBlur:
return AppAssets.accountNewsBlurImage
case .inoreader:
return AppAssets.accountInoreaderImage
case .bazQux:
return AppAssets.accountBazQuxImage
case .theOldReader:
return AppAssets.accountTheOldReaderImage
}
}
// static func image(for accountType: AccountType) -> UIImage? {
// switch accountType {
// case .onMyMac:
// if UIDevice.current.userInterfaceIdiom == .pad {
// return AppAssets.accountLocalPadImage
// } else {
// return AppAssets.accountLocalPhoneImage
// }
// case .cloudKit:
// return AppAssets.accountCloudKitImage
// case .feedbin:
// return AppAssets.accountFeedbinImage
// case .feedly:
// return AppAssets.accountFeedlyImage
// case .freshRSS:
// return AppAssets.accountFreshRSSImage
// case .newsBlur:
// return AppAssets.accountNewsBlurImage
// case .inoreader:
// return AppAssets.accountInoreaderImage
// case .bazQux:
// return AppAsset.accountBazQuxImage
// case .theOldReader:
// return AppAssets.accountTheOldReaderImage
// }
// }
}

View File

@@ -169,7 +169,7 @@ extension AccountInspectorViewController {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
headerView.imageView.image = AppAssets.image(for: account.type)
headerView.imageView.image = AppAsset.image(accountType: account.type)
return headerView
} else {
return super.tableView(tableView, viewForHeaderInSection: section)

View File

@@ -127,17 +127,17 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
switch indexPath.section {
case AddAccountSections.local.rawValue:
cell.comboNameLabel?.text = AddAccountSections.local.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: .onMyMac)
cell.comboImage?.image = AppAsset.image(accountType: .onMyMac)
case AddAccountSections.icloud.rawValue:
cell.comboNameLabel?.text = AddAccountSections.icloud.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])
cell.comboImage?.image = AppAsset.image(accountType: AddAccountSections.icloud.sectionContent[indexPath.row])
if AppDefaults.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
cell.isUserInteractionEnabled = false
cell.comboNameLabel?.isEnabled = false
}
case AddAccountSections.web.rawValue:
cell.comboNameLabel?.text = AddAccountSections.web.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.web.sectionContent[indexPath.row])
cell.comboImage?.image = AppAsset.image(accountType: AddAccountSections.web.sectionContent[indexPath.row])
let type = AddAccountSections.web.sectionContent[indexPath.row]
if (type == .feedly || type == .inoreader) && AppDefaults.isDeveloperBuild {
cell.isUserInteractionEnabled = false
@@ -145,7 +145,7 @@ final class AddAccountViewController: UITableViewController, AddAccountDismissDe
}
case AddAccountSections.selfhosted.rawValue:
cell.comboNameLabel?.text = AddAccountSections.selfhosted.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.selfhosted.sectionContent[indexPath.row])
cell.comboImage?.image = AppAsset.image(accountType: AddAccountSections.selfhosted.sectionContent[indexPath.row])
default:
return cell

View File

@@ -121,7 +121,7 @@ final class SettingsViewController: UITableViewController {
let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsComboTableViewCell", for: indexPath) as! SettingsComboTableViewCell
acctCell.applyThemeProperties()
let account = sortedAccounts[indexPath.row]
acctCell.comboImage?.image = AppAssets.image(for: account.type)
acctCell.comboImage?.image = AppAsset.image(accountType: account.type)
acctCell.comboNameLabel?.text = account.nameForDisplay
cell = acctCell
}

View File

@@ -46,7 +46,7 @@ final class ShareFolderPickerController: UITableViewController {
}()
if let account = container as? ExtensionAccount {
cell.icon.image = AppAssets.image(for: account.type)
cell.icon.image = AppAsset.image(accountType: account.type)
} else {
cell.icon.image = AppAssets.folderImage.image
}