mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Create AppAsset shared class, which will replace the separate Mac and iOS AppAssets classes.
This commit is contained in:
@@ -56,7 +56,7 @@ 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.Account.image(for: .cloudKit)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
|
||||
@@ -69,7 +69,7 @@ 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.Account.image(for: .feedbin)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
|
||||
@@ -46,7 +46,7 @@ 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.Account.image(for: .onMyMac)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
|
||||
@@ -63,7 +63,7 @@ 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.Account.image(for: .newsBlur)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
|
||||
@@ -230,13 +230,13 @@ class ReaderAPIAccountViewController: UITableViewController {
|
||||
if let accountType = accountType {
|
||||
switch accountType {
|
||||
case .bazQux:
|
||||
return AppAssets.accountBazQuxImage
|
||||
return AppAsset.Account.bazQux
|
||||
case .inoreader:
|
||||
return AppAssets.accountInoreaderImage
|
||||
return AppAsset.Account.inoReader
|
||||
case .theOldReader:
|
||||
return AppAssets.accountTheOldReaderImage
|
||||
return AppAsset.Account.theOldReader
|
||||
case .freshRSS:
|
||||
return AppAssets.accountFreshRSSImage
|
||||
return AppAsset.Account.freshRSS
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,41 +13,11 @@ import Images
|
||||
|
||||
struct AppAssets {
|
||||
|
||||
static let accountBazQuxImage = UIImage(named: "accountBazQux")!
|
||||
|
||||
static let accountCloudKitImage = UIImage(named: "accountCloudKit")!
|
||||
|
||||
static let accountFeedbinImage = UIImage(named: "accountFeedbin")!
|
||||
|
||||
static let accountFeedlyImage = UIImage(named: "accountFeedly")!
|
||||
|
||||
static let accountFreshRSSImage = UIImage(named: "accountFreshRSS")!
|
||||
|
||||
static let accountInoreaderImage = UIImage(named: "accountInoreader")!
|
||||
|
||||
static let accountLocalPadImage = UIImage(named: "accountLocalPad")!
|
||||
|
||||
static let accountLocalPhoneImage = UIImage(named: "accountLocalPhone")!
|
||||
|
||||
static let accountNewsBlurImage = UIImage(named: "accountNewsBlur")!
|
||||
|
||||
static let accountTheOldReaderImage = UIImage(named: "accountTheOldReader")!
|
||||
|
||||
static let articleExtractorError = UIImage(named: "articleExtractorError")!
|
||||
|
||||
static let articleExtractorOff = UIImage(named: "articleExtractorOff")!
|
||||
|
||||
static let articleExtractorOffSF = UIImage(systemName: "doc.plaintext")!
|
||||
|
||||
@MainActor static let articleExtractorOffTinted: UIImage = {
|
||||
let image = UIImage(named: "articleExtractorOff")!
|
||||
return image.tinted(color: AppAssets.primaryAccentColor)!
|
||||
}()
|
||||
|
||||
static let articleExtractorOn = UIImage(named: "articleExtractorOn")!
|
||||
|
||||
static let articleExtractorOnSF = UIImage(named: "articleExtractorOnSF")!
|
||||
|
||||
@MainActor static let articleExtractorOnTinted: UIImage = {
|
||||
let image = UIImage(named: "articleExtractorOn")!
|
||||
return image.tinted(color: AppAssets.primaryAccentColor)!
|
||||
@@ -148,31 +118,4 @@ struct AppAssets {
|
||||
static let vibrantTextColor = UIColor(named: "vibrantTextColor")!
|
||||
|
||||
static let controlBackgroundColor = UIColor(named: "controlBackgroundColor")!
|
||||
|
||||
@MainActor 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ enum ArticleExtractorButtonState {
|
||||
switch buttonState {
|
||||
case .error:
|
||||
stripAnimatedSublayer()
|
||||
setImage(AppAssets.articleExtractorError, for: .normal)
|
||||
setImage(AppAsset.ArticleExtractor.error, for: .normal)
|
||||
case .animated:
|
||||
setImage(nil, for: .normal)
|
||||
setNeedsLayout()
|
||||
case .on:
|
||||
stripAnimatedSublayer()
|
||||
setImage(AppAssets.articleExtractorOn, for: .normal)
|
||||
setImage(AppAsset.ArticleExtractor.on, for: .normal)
|
||||
case .off:
|
||||
stripAnimatedSublayer()
|
||||
setImage(AppAssets.articleExtractorOff, for: .normal)
|
||||
setImage(AppAsset.ArticleExtractor.off, for: .normal)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ enum ArticleExtractorButtonState {
|
||||
let images = [image1, image2, image1]
|
||||
|
||||
animatedLayer = CALayer()
|
||||
let imageSize = AppAssets.articleExtractorOff.size
|
||||
let imageSize = AppAsset.ArticleExtractor.off.size
|
||||
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
|
||||
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ final class ArticleViewController: UIViewController {
|
||||
private var articleExtractorButton: ArticleExtractorButton = {
|
||||
let button = ArticleExtractorButton(type: .system)
|
||||
button.frame = CGRect(x: 0, y: 0, width: 44.0, height: 44.0)
|
||||
button.setImage(AppAssets.articleExtractorOff, for: .normal)
|
||||
button.setImage(AppAsset.ArticleExtractor.off, for: .normal)
|
||||
return button
|
||||
}()
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ private extension WebViewController {
|
||||
func toggleArticleExtractorAction() -> UIAction {
|
||||
let extracted = articleExtractorButtonState == .on
|
||||
let title = extracted ? NSLocalizedString("Show Feed Article", comment: "Show Feed Article") : NSLocalizedString("Show Reader View", comment: "Show Reader View")
|
||||
let extractorImage = extracted ? AppAssets.articleExtractorOffSF : AppAssets.articleExtractorOnSF
|
||||
let extractorImage = extracted ? AppAsset.ArticleExtractor.offSF : AppAsset.ArticleExtractor.onSF
|
||||
return UIAction(title: title, image: extractorImage) { [weak self] action in
|
||||
self?.toggleArticleExtractor()
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ extension AccountInspectorViewController {
|
||||
|
||||
if section == 0 {
|
||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||
headerView.imageView.image = AppAssets.image(for: account.accountType)
|
||||
headerView.imageView.image = AppAsset.Account.image(for: account.accountType)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
|
||||
@@ -133,17 +133,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.Account.image(for: .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.Account.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])
|
||||
if AppDefaults.shared.isDeveloperBuild || AccountManager.shared.accounts.contains(where: { $0.accountType == .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.Account.image(for: AddAccountSections.web.sectionContent[indexPath.row])
|
||||
let type = AddAccountSections.web.sectionContent[indexPath.row]
|
||||
if (type == .feedly || type == .inoreader) && AppDefaults.shared.isDeveloperBuild {
|
||||
cell.isUserInteractionEnabled = false
|
||||
@@ -151,7 +151,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.Account.image(for: AddAccountSections.selfhosted.sectionContent[indexPath.row])
|
||||
|
||||
default:
|
||||
return cell
|
||||
|
||||
@@ -146,7 +146,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.accountType)
|
||||
acctCell.comboImage?.image = AppAsset.Account.image(for: account.accountType)
|
||||
acctCell.comboNameLabel?.text = account.nameForDisplay
|
||||
cell = acctCell
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
import Account
|
||||
import Core
|
||||
|
||||
protocol ShareFolderPickerControllerDelegate: AnyObject {
|
||||
|
||||
@@ -46,7 +47,7 @@ class ShareFolderPickerController: UITableViewController {
|
||||
}()
|
||||
|
||||
if let account = container as? ExtensionAccount {
|
||||
cell.icon.image = AppAssets.image(for: account.type)
|
||||
cell.icon.image = AppAsset.Account.image(for: account.type)
|
||||
} else {
|
||||
cell.icon.image = AppAssets.folderImage.image
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user