NetNewsWire/Shared/AccountType+Helpers.swift

90 lines
2.2 KiB
Swift
Raw Normal View History

//
// AccountType+Helpers.swift
// NetNewsWire
//
// Created by Stuart Breckenridge on 27/10/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import Foundation
import Account
#if os(macOS)
import AppKit
#else
import UIKit
#endif
2020-10-29 05:07:18 +01:00
import SwiftUI
extension AccountType {
// TODO: Move this to the Account Package.
func localizedAccountName() -> String {
switch self {
case .onMyMac:
let defaultName: String
#if os(macOS)
defaultName = NSLocalizedString("On My Mac", comment: "Account name")
#else
if UIDevice.current.userInterfaceIdiom == .pad {
defaultName = NSLocalizedString("On My iPad", comment: "Account name")
} else {
defaultName = NSLocalizedString("On My iPhone", comment: "Account name")
}
#endif
return defaultName
case .bazQux:
return NSLocalizedString("BazQux", comment: "Account name")
case .cloudKit:
return NSLocalizedString("iCloud", comment: "Account name")
case .feedbin:
return NSLocalizedString("Feedbin", comment: "Account name")
case .feedly:
return NSLocalizedString("Feedly", comment: "Account name")
case .freshRSS:
return NSLocalizedString("FreshRSS", comment: "Account name")
case .inoreader:
return NSLocalizedString("Inoreader", comment: "Account name")
case .newsBlur:
return NSLocalizedString("NewsBlur", comment: "Account name")
case .theOldReader:
return NSLocalizedString("The Old Reader", comment: "Account name")
}
2020-10-29 05:07:18 +01:00
}
// MARK: - SwiftUI Images
func image() -> Image {
switch self {
case .onMyMac:
2020-12-07 12:22:35 +01:00
// If it's the multiplatform app, the asset catalog contains assets for
2020-12-07 12:52:35 +01:00
#if os(macOS)
2020-12-07 20:35:00 +01:00
return Image("accountLocal")
2020-12-07 12:52:35 +01:00
#else
if UIDevice.current.userInterfaceIdiom == .pad {
2020-12-07 20:35:00 +01:00
return Image("accountLocalPad")
2020-12-07 12:52:35 +01:00
} else {
2020-12-07 20:35:00 +01:00
return Image("accountLocalPhone")
2020-12-07 12:52:35 +01:00
}
#endif
2020-10-29 05:07:18 +01:00
case .bazQux:
2020-12-07 20:35:00 +01:00
return Image("accountBazQux")
2020-10-29 05:07:18 +01:00
case .cloudKit:
2020-12-07 20:35:00 +01:00
return Image("accountCloudKit")
2020-10-29 05:07:18 +01:00
case .feedbin:
2020-12-07 20:35:00 +01:00
return Image("accountFeedbin")
2020-10-29 05:07:18 +01:00
case .feedly:
2020-12-07 20:35:00 +01:00
return Image("accountFeedly")
2020-10-29 05:07:18 +01:00
case .freshRSS:
2020-12-07 20:35:00 +01:00
return Image("accountFreshRSS")
2020-10-29 05:07:18 +01:00
case .inoreader:
2020-12-07 20:35:00 +01:00
return Image("accountInoreader")
2020-10-29 05:07:18 +01:00
case .newsBlur:
2020-12-07 20:35:00 +01:00
return Image("accountNewsBlur")
2020-10-29 05:07:18 +01:00
case .theOldReader:
2020-12-07 20:35:00 +01:00
return Image("accountTheOldReader")
2020-10-29 05:07:18 +01:00
}
}
}