Commit 43d04807 authored by ueshiba's avatar ueshiba
Browse files

Update SwiftGen

parent 5fdc4099
......@@ -2,24 +2,24 @@
#if os(OSX)
import AppKit.NSImage
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
internal typealias AssetColorTypeAlias = NSColor
internal typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
internal typealias AssetColorTypeAlias = UIColor
internal typealias Image = UIImage
#endif
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
@available(*, deprecated, renamed: "ImageAsset")
typealias AssetType = ImageAsset
internal typealias AssetType = ImageAsset
struct ImageAsset {
fileprivate var name: String
internal struct ImageAsset {
internal fileprivate(set) var name: String
var image: Image {
internal var image: Image {
let bundle = Bundle(for: BundleToken.self)
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
......@@ -33,30 +33,33 @@ struct ImageAsset {
}
}
struct ColorAsset {
fileprivate var name: String
internal struct ColorAsset {
internal fileprivate(set) var name: String
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: AssetColorTypeAlias {
internal var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
}
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
enum Asset {
static let imageAccountFailed = ImageAsset(name: "image-account-failed")
static let imageNoInternet = ImageAsset(name: "image-no-internet")
static let imagePurchaseSuccess = ImageAsset(name: "image-purchase-success")
static let imageReceiptBackground = ImageAsset(name: "image-receipt-background")
static let imageRedeemClaimed = ImageAsset(name: "image-redeem-claimed")
static let imageRedeemInvalid = ImageAsset(name: "image-redeem-invalid")
static let imageRedeemSuccess = ImageAsset(name: "image-redeem-success")
static let navLogo = ImageAsset(name: "nav-logo")
internal enum Asset {
internal static let closeIcon = ImageAsset(name: "close-icon")
internal static let imageAccountFailed = ImageAsset(name: "image-account-failed")
internal static let imageNoInternet = ImageAsset(name: "image-no-internet")
internal static let imagePurchaseSuccess = ImageAsset(name: "image-purchase-success")
internal static let imageReceiptBackground = ImageAsset(name: "image-receipt-background")
internal static let imageRedeemClaimed = ImageAsset(name: "image-redeem-claimed")
internal static let imageRedeemInvalid = ImageAsset(name: "image-redeem-invalid")
internal static let imageRedeemSuccess = ImageAsset(name: "image-redeem-success")
internal static let navLogo = ImageAsset(name: "nav-logo")
internal static let qrCode = ImageAsset(name: "qr-code")
// swiftlint:disable trailing_comma
static let allColors: [ColorAsset] = [
internal static let allColors: [ColorAsset] = [
]
static let allImages: [ImageAsset] = [
internal static let allImages: [ImageAsset] = [
closeIcon,
imageAccountFailed,
imageNoInternet,
imagePurchaseSuccess,
......@@ -65,14 +68,15 @@ enum Asset {
imageRedeemInvalid,
imageRedeemSuccess,
navLogo,
qrCode,
]
// swiftlint:enable trailing_comma
@available(*, deprecated, renamed: "allImages")
static let allValues: [AssetType] = allImages
internal static let allValues: [AssetType] = allImages
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
extension Image {
internal extension Image {
@available(iOS 1.0, tvOS 1.0, watchOS 1.0, *)
@available(OSX, deprecated,
message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
......@@ -88,7 +92,7 @@ extension Image {
}
}
extension AssetColorTypeAlias {
internal extension AssetColorTypeAlias {
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
let bundle = Bundle(for: BundleToken.self)
......
......@@ -7,22 +7,22 @@ import UIKit
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
protocol StoryboardType {
internal protocol StoryboardType {
static var storyboardName: String { get }
}
extension StoryboardType {
internal extension StoryboardType {
static var storyboard: UIStoryboard {
let name = self.storyboardName
return UIStoryboard(name: name, bundle: Bundle(for: BundleToken.self))
}
}
struct SceneType<T: Any> {
let storyboard: StoryboardType.Type
let identifier: String
internal struct SceneType<T: Any> {
internal let storyboard: StoryboardType.Type
internal let identifier: String
func instantiate() -> T {
internal func instantiate() -> T {
let identifier = self.identifier
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).")
......@@ -31,10 +31,10 @@ struct SceneType<T: Any> {
}
}
struct InitialSceneType<T: Any> {
let storyboard: StoryboardType.Type
internal struct InitialSceneType<T: Any> {
internal let storyboard: StoryboardType.Type
func instantiate() -> T {
internal func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else {
fatalError("ViewController is not of the expected class \(T.self).")
}
......@@ -42,9 +42,9 @@ struct InitialSceneType<T: Any> {
}
}
protocol SegueType: RawRepresentable { }
internal protocol SegueType: RawRepresentable { }
extension UIViewController {
internal extension UIViewController {
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
let identifier = segue.rawValue
performSegue(withIdentifier: identifier, sender: sender)
......@@ -52,39 +52,39 @@ extension UIViewController {
}
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
enum StoryboardScene {
enum Signup: StoryboardType {
static let storyboardName = "Signup"
internal enum StoryboardScene {
internal enum Signup: StoryboardType {
internal static let storyboardName = "Signup"
static let initialScene = InitialSceneType<UINavigationController>(storyboard: Signup.self)
internal static let initialScene = InitialSceneType<UINavigationController>(storyboard: Signup.self)
}
enum Welcome: StoryboardType {
static let storyboardName = "Welcome"
internal enum Welcome: StoryboardType {
internal static let storyboardName = "Welcome"
static let initialScene = InitialSceneType<UINavigationController>(storyboard: Welcome.self)
internal static let initialScene = InitialSceneType<UINavigationController>(storyboard: Welcome.self)
static let loginViewController = SceneType<PIALibrary.LoginViewController>(storyboard: Welcome.self, identifier: "LoginViewController")
internal static let loginViewController = SceneType<PIALibrary.LoginViewController>(storyboard: Welcome.self, identifier: "LoginViewController")
static let purchaseViewController = SceneType<PIALibrary.PurchaseViewController>(storyboard: Welcome.self, identifier: "PurchaseViewController")
internal static let purchaseViewController = SceneType<PIALibrary.PurchaseViewController>(storyboard: Welcome.self, identifier: "PurchaseViewController")
static let redeemViewController = SceneType<PIALibrary.RedeemViewController>(storyboard: Welcome.self, identifier: "RedeemViewController")
internal static let redeemViewController = SceneType<PIALibrary.RedeemViewController>(storyboard: Welcome.self, identifier: "RedeemViewController")
}
}
enum StoryboardSegue {
enum Signup: String, SegueType {
internal enum StoryboardSegue {
internal enum Signup: String, SegueType {
case failureSegueIdentifier = "FailureSegueIdentifier"
case internetUnreachableSegueIdentifier = "InternetUnreachableSegueIdentifier"
case successSegueIdentifier = "SuccessSegueIdentifier"
case unwindFailureSegueIdentifier = "UnwindFailureSegueIdentifier"
case unwindInternetUnreachableSegueIdentifier = "UnwindInternetUnreachableSegueIdentifier"
}
enum Welcome: String, SegueType {
internal enum Welcome: String, SegueType {
case signupQRCameraScannerSegue = "SignupQRCameraScannerSegue"
case signupViaPurchaseSegue = "SignupViaPurchaseSegue"
case signupViaRecoverSegue = "SignupViaRecoverSegue"
case signupViaRedeemSegue = "SignupViaRedeemSegue"
case signupViaRestoreSegue = "SignupViaRestoreSegue"
case signupQRCameraScannerSegue = "SignupQRCameraScannerSegue"
}
}
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
......
......@@ -6,305 +6,303 @@ import Foundation
// swiftlint:disable file_length
// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name
enum L10n {
enum Welcome {
internal enum L10n {
internal enum Welcome {
enum Agreement {
internal enum Agreement {
/// Signing up constitutes acceptance of the $1 and the $2.
static let message = L10n.tr("Welcome", "agreement.message")
internal static let message = L10n.tr("Welcome", "agreement.message")
enum Message {
internal enum Message {
/// Privacy Policy
static let privacy = L10n.tr("Welcome", "agreement.message.privacy")
internal static let privacy = L10n.tr("Welcome", "agreement.message.privacy")
/// Terms of Service
static let tos = L10n.tr("Welcome", "agreement.message.tos")
internal static let tos = L10n.tr("Welcome", "agreement.message.tos")
}
}
enum Iap {
internal enum Camera {
enum Error {
internal enum Access {
internal enum Denied {
/// Enable camera access so you can scan QR codes to redeem a gift card.
internal static let message = L10n.tr("Welcome", "camera.access.denied.message")
}
internal enum Error {
/// Your device does not support scanning QR codes. Please use a device with a camera.
internal static let message = L10n.tr("Welcome", "camera.access.error.message")
/// Camera not available
internal static let title = L10n.tr("Welcome", "camera.access.error.title")
}
}
}
internal enum Iap {
internal enum Error {
/// Error
static let title = L10n.tr("Welcome", "iap.error.title")
internal static let title = L10n.tr("Welcome", "iap.error.title")
enum Message {
internal enum Message {
/// Apple servers currently unavailable. Please try again later.
static let unavailable = L10n.tr("Welcome", "iap.error.message.unavailable")
internal static let unavailable = L10n.tr("Welcome", "iap.error.message.unavailable")
}
}
}
enum Login {
internal enum Login {
/// LOGIN
static let submit = L10n.tr("Welcome", "login.submit")
internal static let submit = L10n.tr("Welcome", "login.submit")
/// Sign in to your account
static let title = L10n.tr("Welcome", "login.title")
internal static let title = L10n.tr("Welcome", "login.title")
enum Error {
internal enum Error {
/// Too many failed login attempts with this username. Please try again later.
static let throttled = L10n.tr("Welcome", "login.error.throttled")
internal static let throttled = L10n.tr("Welcome", "login.error.throttled")
/// Log in
static let title = L10n.tr("Welcome", "login.error.title")
internal static let title = L10n.tr("Welcome", "login.error.title")
/// Your username or password is incorrect.
static let unauthorized = L10n.tr("Welcome", "login.error.unauthorized")
internal static let unauthorized = L10n.tr("Welcome", "login.error.unauthorized")
/// You must enter an username and password.
static let validation = L10n.tr("Welcome", "login.error.validation")
internal static let validation = L10n.tr("Welcome", "login.error.validation")
}
enum Password {
internal enum Password {
/// Password
static let placeholder = L10n.tr("Welcome", "login.password.placeholder")
internal static let placeholder = L10n.tr("Welcome", "login.password.placeholder")
}
enum Purchase {
/// Buy now!
static let button = L10n.tr("Welcome", "login.purchase.button")
internal enum Purchase {
/// Buy now
internal static let button = L10n.tr("Welcome", "login.purchase.button")
/// Don’t have an account?
static let footer = L10n.tr("Welcome", "login.purchase.footer")
internal static let footer = L10n.tr("Welcome", "login.purchase.footer")
}
enum Redeem {
/// Redeem now!
static let button = L10n.tr("Welcome", "login.redeem.button")
internal enum Redeem {
/// Redeem now
internal static let button = L10n.tr("Welcome", "login.redeem.button")
/// Have a gift card or trial card?
static let footer = L10n.tr("Welcome", "login.redeem.footer")
internal static let footer = L10n.tr("Welcome", "login.redeem.footer")
}
enum Restore {
internal enum Restore {
/// Couldn't get your plan?
static let button = L10n.tr("Welcome", "login.restore.button")
internal static let button = L10n.tr("Welcome", "login.restore.button")
}
enum Username {
internal enum Username {
/// Username (p1234567)
static let placeholder = L10n.tr("Welcome", "login.username.placeholder")
internal static let placeholder = L10n.tr("Welcome", "login.username.placeholder")
}
}
enum Plan {
internal enum Plan {
/// Best value
static let bestValue = L10n.tr("Welcome", "plan.best_value")
internal static let bestValue = L10n.tr("Welcome", "plan.best_value")
/// %@/mo
static func priceFormat(_ p1: String) -> String {
internal static func priceFormat(_ p1: String) -> String {
return L10n.tr("Welcome", "plan.price_format", p1)
}
enum Accessibility {
internal enum Accessibility {
/// per month
static let perMonth = L10n.tr("Welcome", "plan.accessibility.per_month")
internal static let perMonth = L10n.tr("Welcome", "plan.accessibility.per_month")
}
enum Monthly {
internal enum Monthly {
/// Monthly
static let title = L10n.tr("Welcome", "plan.monthly.title")
internal static let title = L10n.tr("Welcome", "plan.monthly.title")
}
enum Yearly {
internal enum Yearly {
/// %@%@ per year
static func detailFormat(_ p1: String, _ p2: String) -> String {
internal static func detailFormat(_ p1: String, _ p2: String) -> String {
return L10n.tr("Welcome", "plan.yearly.detail_format", p1, p2)
}
/// Yearly
static let title = L10n.tr("Welcome", "plan.yearly.title")
internal static let title = L10n.tr("Welcome", "plan.yearly.title")
}
}
enum Purchase {
internal enum Purchase {
/// BUY NOW
static let submit = L10n.tr("Welcome", "purchase.submit")
internal static let submit = L10n.tr("Welcome", "purchase.submit")
/// 7-day money back guarantee
static let subtitle = L10n.tr("Welcome", "purchase.subtitle")
internal static let subtitle = L10n.tr("Welcome", "purchase.subtitle")
/// Select a VPN plan
static let title = L10n.tr("Welcome", "purchase.title")
internal static let title = L10n.tr("Welcome", "purchase.title")
enum Email {
internal enum Email {
/// Email address
static let placeholder = L10n.tr("Welcome", "purchase.email.placeholder")
internal static let placeholder = L10n.tr("Welcome", "purchase.email.placeholder")
}
enum Error {
internal enum Error {
/// Purchase
static let title = L10n.tr("Welcome", "purchase.error.title")
internal static let title = L10n.tr("Welcome", "purchase.error.title")
/// You must enter an email address.
static let validation = L10n.tr("Welcome", "purchase.error.validation")
enum Connectivity {
/// Connection Failure
static let title = L10n.tr("Welcome", "purchase.error.connectivity.title")
/// We are unable to reach Private Internet Access. This may due to poor internet or our service is blocked in your country.
static let description = L10n.tr("Welcome", "purchase.error.connectivity.description")
}
internal static let validation = L10n.tr("Welcome", "purchase.error.validation")
internal enum Connectivity {
/// We are unable to reach Private Internet Access. This may due to poor internet or our service is blocked in your country.
internal static let description = L10n.tr("Welcome", "purchase.error.connectivity.description")
/// Connection Failure
internal static let title = L10n.tr("Welcome", "purchase.error.connectivity.title")
}
}
enum Login {
/// Sign in!
static let button = L10n.tr("Welcome", "purchase.login.button")
internal enum Login {
/// Sign in
internal static let button = L10n.tr("Welcome", "purchase.login.button")
/// Already have an account?
static let footer = L10n.tr("Welcome", "purchase.login.footer")
internal static let footer = L10n.tr("Welcome", "purchase.login.footer")
}
}
enum Redeem {
internal enum Redeem {
/// SUBMIT
static let submit = L10n.tr("Welcome", "redeem.submit")
internal static let submit = L10n.tr("Welcome", "redeem.submit")
/// Type in your email address and the %lu digit PIN from your gift card or trial card below.
static func subtitle(_ p1: Int) -> String {
internal static func subtitle(_ p1: Int) -> String {
return L10n.tr("Welcome", "redeem.subtitle", p1)
}
/// Redeem gift card
static let title = L10n.tr("Welcome", "redeem.title")
internal static let title = L10n.tr("Welcome", "redeem.title")
enum Email {
internal enum Email {
/// Email address
static let placeholder = L10n.tr("Welcome", "redeem.email.placeholder")
internal static let placeholder = L10n.tr("Welcome", "redeem.email.placeholder")
}
enum Error {
internal enum Error {
/// Code must be %lu numeric digits.
static func code(_ p1: Int) -> String {
internal static func code(_ p1: Int) -> String {
return L10n.tr("Welcome", "redeem.error.code", p1)
}
/// Redeem
static let title = L10n.tr("Welcome", "redeem.error.title")
enum Qrcode {
/// Invalid QR code sequence. Please try again.
static let invalid = L10n.tr("Welcome", "redeem.error.qrcode.invalid")
internal static let title = L10n.tr("Welcome", "redeem.error.title")
internal enum Qrcode {
/// Invalid QR code sequence. Please try again.
internal static let invalid = L10n.tr("Welcome", "redeem.error.qrcode.invalid")
}
}
}
enum Restore {
internal enum Restore {
/// CONFIRM
static let submit = L10n.tr("Welcome", "restore.submit")
internal static let submit = L10n.tr("Welcome", "restore.submit")
/// If you purchased a plan through this app and didn't receive your credentials, you can send them again from here.\nYou will not be charged during this process.
static let subtitle = L10n.tr("Welcome", "restore.subtitle")
internal static let subtitle = L10n.tr("Welcome", "restore.subtitle")
/// Restore uncredited purchase
static let title = L10n.tr("Welcome", "restore.title")
internal static let title = L10n.tr("Welcome", "restore.title")
enum Email {
internal enum Email {
/// Email address
static let placeholder = L10n.tr("Welcome", "restore.email.placeholder")
internal static let placeholder = L10n.tr("Welcome", "restore.email.placeholder")
}
}
enum Camera {
enum Access {
enum Error {
/// Camera not available
static let title = L10n.tr("Welcome", "camera.access.error.title")
/// Your device does not support scanning a code. Please use a device with a camera.
static let message = L10n.tr("Welcome", "camera.access.error.message")
}
enum Denied {
/// Please grant permission to use the Camera.
static let message = L10n.tr("Welcome", "camera.access.denied.message")
}
}
}
}
enum Ui {
internal enum Ui {
enum Global {
internal enum Global {
/// Cancel
static let cancel = L10n.tr("UI", "global.cancel")
internal static let cancel = L10n.tr("UI", "global.cancel")
/// Close
static let close = L10n.tr("UI", "global.close")
internal static let close = L10n.tr("UI", "global.close")
/// OK
static let ok = L10n.tr("UI", "global.ok")
internal static let ok = L10n.tr("UI", "global.ok")
enum Version {
internal enum Version {
/// Version %@ (%@)
static func format(_ p1: String, _ p2: String) -> String {
internal static func format(_ p1: String, _ p2: String) -> String {
return L10n.tr("UI", "global.version.format", p1, p2)
}
}
}
}
enum Signup {
internal enum Signup {
enum Failure {
internal enum Failure {
/// We're unable to create an account at this time. Please try again later. Reopening the app will re-attempt to create an account.
static let message = L10n.tr("Signup", "failure.message")
internal static let message = L10n.tr("Signup", "failure.message")
/// GO BACK
static let submit = L10n.tr("Signup", "failure.submit")
internal static let submit = L10n.tr("Signup", "failure.submit")
/// Account creation failed
static let title = L10n.tr("Signup", "failure.title")
internal static let title = L10n.tr("Signup", "failure.title")
/// Sign-up failed
static let vcTitle = L10n.tr("Signup", "failure.vc_title")
internal static let vcTitle = L10n.tr("Signup", "failure.vc_title")
enum Redeem {
internal enum Redeem {
enum Claimed {
internal enum Claimed {
/// Looks like this card has already been claimed by another account. You can try entering a different PIN.
static let message = L10n.tr("Signup", "failure.redeem.claimed.message")
internal static let message = L10n.tr("Signup", "failure.redeem.claimed.message")
/// Card claimed already
static let title = L10n.tr("Signup", "failure.redeem.claimed.title")
internal static let title = L10n.tr("Signup", "failure.redeem.claimed.title")
}
enum Invalid {
internal enum Invalid {
/// Looks like you entered an invalid card PIN. Please try again.
static let message = L10n.tr("Signup", "failure.redeem.invalid.message")
internal static let message = L10n.tr("Signup", "failure.redeem.invalid.message")
/// Invalid card PIN
static let title = L10n.tr("Signup", "failure.redeem.invalid.title")
internal static let title = L10n.tr("Signup", "failure.redeem.inval