Commit f23abd39 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Thibault Wittemberg

swiftgen: migrate to version 5.1.1

Change project to support 5.1.1 version of swiftgen (swiftgen 4.x is not
supported anymore)

We use default templates provided by Swiftgen

Change-Id: I78da863f4fb3664cb0becbf93dadf68aa339826f
parent 51c46ad8
......@@ -140,11 +140,11 @@ class CreateRingAccountViewModel {
.asObservable().map ({ status in
switch status {
case .lookingUp:
return L10n.Createaccount.lookingForUsernameAvailability.smartString
return L10n.Createaccount.lookingForUsernameAvailability
case .invalid:
return L10n.Createaccount.invalidUsername.smartString
return L10n.Createaccount.invalidUsername
case .alreadyTaken:
return L10n.Createaccount.usernameAlreadyTaken.smartString
return L10n.Createaccount.usernameAlreadyTaken
default:
return ""
}
......@@ -232,22 +232,22 @@ extension AccountCreationError: LocalizedError {
var title: String {
switch self {
case .generic:
return L10n.Alerts.accountCannotBeFoundTitle.smartString
return L10n.Alerts.accountCannotBeFoundTitle
case .network:
return L10n.Alerts.accountNoNetworkTitle.smartString
return L10n.Alerts.accountNoNetworkTitle
default:
return L10n.Alerts.accountDefaultErrorTitle.smartString
return L10n.Alerts.accountDefaultErrorTitle
}
}
var message: String {
switch self {
case .generic:
return L10n.Alerts.accountDefaultErrorMessage.smartString
return L10n.Alerts.accountDefaultErrorMessage
case .network:
return L10n.Alerts.accountNoNetworkMessage.smartString
return L10n.Alerts.accountNoNetworkMessage
default:
return L10n.Alerts.accountDefaultErrorMessage.smartString
return L10n.Alerts.accountDefaultErrorMessage
}
}
}
// Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen
#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
public typealias Image = UIImage
#elseif os(OSX)
#if os(OSX)
import AppKit.NSImage
public typealias Image = NSImage
typealias AssetColorTypeAlias = NSColor
typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIImage
typealias AssetColorTypeAlias = UIColor
typealias Image = UIImage
#endif
private class RingImagesBundleToken {}
// swiftlint:disable file_length
// swiftlint:disable line_length
// swiftlint:disable type_body_length
public enum RingAsset: String {
case icContactPicture = "ic_contact_picture"
case logoRingBeta2Blanc = "logo-ring-beta2-blanc"
/**
Loads from application's Bundle if image exists, then loads from current bundle, fatalError if image does not exist
*/
public var smartImage: Image {
if let appimage = Image(named: self.rawValue, in: nil, compatibleWith: nil) {
return appimage
} else if let fmkImage = Image(named: self.rawValue, in: Bundle(for: RingImagesBundleToken.self), compatibleWith: nil) {
return fmkImage
} else {
fatalError("Impossible to load image \(self.rawValue)")
}
}
@available(*, deprecated, renamed: "ImageAsset")
typealias AssetType = ImageAsset
struct ImageAsset {
fileprivate var name: String
var image: Image {
if let img = Image(named: self.rawValue, in: Bundle(for: RingImagesBundleToken.self), compatibleWith: nil) {
return img
}
fatalError("Impossible to load image \(self.rawValue)")
let bundle = Bundle(for: BundleToken.self)
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
#elseif os(OSX)
let image = bundle.image(forResource: name)
#elseif os(watchOS)
let image = Image(named: name)
#endif
guard let result = image else { fatalError("Unable to load image named \(name).") }
return result
}
}
// swiftlint:enable type_body_length
public extension Image {
convenience init!(asset: RingAsset) {
self.init(named: asset.rawValue)
struct ColorAsset {
fileprivate var name: String
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
var color: AssetColorTypeAlias {
return AssetColorTypeAlias(asset: self)
}
#endif
}
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
enum Asset {
static let icContactPicture = ImageAsset(name: "ic_contact_picture")
static let logoRingBeta2Blanc = ImageAsset(name: "logo-ring-beta2-blanc")
// swiftlint:disable trailing_comma
static let allColors: [ColorAsset] = [
]
static let allImages: [ImageAsset] = [
icContactPicture,
logoRingBeta2Blanc,
]
// swiftlint:enable trailing_comma
@available(*, deprecated, renamed: "allImages")
static let allValues: [AssetType] = allImages
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
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")
convenience init!(asset: ImageAsset) {
#if os(iOS) || os(tvOS)
let bundle = Bundle(for: BundleToken.self)
self.init(named: asset.name, in: bundle, compatibleWith: nil)
#elseif os(OSX) || os(watchOS)
self.init(named: asset.name)
#endif
}
}
extension AssetColorTypeAlias {
#if swift(>=3.2)
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
convenience init!(asset: ColorAsset) {
let bundle = Bundle(for: BundleToken.self)
#if os(iOS) || os(tvOS)
self.init(named: asset.name, in: bundle, compatibleWith: nil)
#elseif os(OSX)
self.init(named: asset.name, bundle: bundle)
#elseif os(watchOS)
self.init(named: asset.name)
#endif
}
#endif
}
private final class BundleToken {}
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen
// swiftlint:disable sorted_imports
import Foundation
import UIKit
// swiftlint:disable file_length
// swiftlint:disable line_length
// swiftlint:disable type_body_length
protocol StoryboardSceneType {
protocol StoryboardType {
static var storyboardName: String { get }
}
extension StoryboardSceneType {
static func storyboard() -> UIStoryboard {
extension StoryboardType {
static var storyboard: UIStoryboard {
return UIStoryboard(name: self.storyboardName, bundle: Bundle(for: BundleToken.self))
}
}
struct SceneType<T: Any> {
let storyboard: StoryboardType.Type
let identifier: String
static func initialViewController() -> UIViewController {
guard let vc = storyboard().instantiateInitialViewController() else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).")
}
return vc
return controller
}
}
extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String {
func viewController() -> UIViewController {
return Self.storyboard().instantiateViewController(withIdentifier: self.rawValue)
}
static func viewController(identifier: Self) -> UIViewController {
return identifier.viewController()
struct InitialSceneType<T: Any> {
let storyboard: StoryboardType.Type
func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else {
fatalError("ViewController is not of the expected class \(T.self).")
}
return controller
}
}
protocol StoryboardSegueType: RawRepresentable { }
protocol SegueType: RawRepresentable { }
extension UIViewController {
func perform<S: StoryboardSegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
performSegue(withIdentifier: segue.rawValue, sender: sender)
}
}
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
enum StoryboardScene {
enum LaunchScreen: StoryboardSceneType {
enum LaunchScreen: StoryboardType {
static let storyboardName = "LaunchScreen"
static let initialScene = InitialSceneType<UIViewController>(storyboard: LaunchScreen.self)
}
enum Main: String, StoryboardSceneType {
enum Main: StoryboardType {
static let storyboardName = "Main"
static func initialViewController() -> Ring.MainTabBarViewController {
guard let vc = storyboard().instantiateInitialViewController() as? Ring.MainTabBarViewController else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
}
static let initialScene = InitialSceneType<Ring.MainTabBarViewController>(storyboard: Main.self)
case mainStoryboardScene = "MainStoryboard"
static func instantiateMainStoryboard() -> Ring.MainTabBarViewController {
guard let vc = StoryboardScene.Main.mainStoryboardScene.viewController() as? Ring.MainTabBarViewController
else {
fatalError("ViewController 'MainStoryboard' is not of the expected class Ring.MainTabBarViewController.")
}
return vc
}
static let mainStoryboard = SceneType<Ring.MainTabBarViewController>(storyboard: Main.self, identifier: "MainStoryboard")
}
enum WalkthroughStoryboard: StoryboardSceneType {
enum WalkthroughStoryboard: StoryboardType {
static let storyboardName = "WalkthroughStoryboard"
static func initialViewController() -> UINavigationController {
guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
}
static let initialScene = InitialSceneType<UINavigationController>(storyboard: WalkthroughStoryboard.self)
}
}
enum StoryboardSegue {
enum Main: String, StoryboardSegueType {
enum Main: String, SegueType {
case showMessages = "ShowMessages"
case accountDetails
}
enum WalkthroughStoryboard: String, StoryboardSegueType {
enum WalkthroughStoryboard: String, SegueType {
case accountToPermissionsSegue = "AccountToPermissionsSegue"
case createProfileSegue = "CreateProfileSegue"
case linkDeviceToAccountSegue = "LinkDeviceToAccountSegue"
......@@ -89,5 +81,6 @@ enum StoryboardSegue {
case profileToLinkSegue = "ProfileToLinkSegue"
}
}
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
private final class BundleToken {}
// Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen
import Foundation
private class RingStringsBundleToken {}
// swiftlint:disable file_length
// swiftlint:disable line_length
// swiftlint:disable type_body_length
// swiftlint:disable nesting
// swiftlint:disable variable_name
// swiftlint:disable valid_docs
// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name
enum L10n {
enum Alerts {
/// Account Added
static let accountAddedTitle = L10n.tr("alerts.accountAddedTitle")
static let accountAddedTitle = L10n.tr("Localizable", "alerts.accountAddedTitle")
/// Can't find account
static let accountCannotBeFoundTitle = L10n.tr("alerts.accountCannotBeFoundTitle")
static let accountCannotBeFoundTitle = L10n.tr("Localizable", "alerts.accountCannotBeFoundTitle")
/// The account couldn't be created.
static let accountDefaultErrorMessage = L10n.tr("alerts.accountDefaultErrorMessage")
static let accountDefaultErrorMessage = L10n.tr("Localizable", "alerts.accountDefaultErrorMessage")
/// Unknown error
static let accountDefaultErrorTitle = L10n.tr("alerts.accountDefaultErrorTitle")
static let accountDefaultErrorTitle = L10n.tr("Localizable", "alerts.accountDefaultErrorTitle")
/// Could not add account because Ring couldn't connect to the distributed network. Check your device connectivity.
static let accountNoNetworkMessage = L10n.tr("alerts.accountNoNetworkMessage")
static let accountNoNetworkMessage = L10n.tr("Localizable", "alerts.accountNoNetworkMessage")
/// Can't connect to the network
static let accountNoNetworkTitle = L10n.tr("alerts.accountNoNetworkTitle")
static let accountNoNetworkTitle = L10n.tr("Localizable", "alerts.accountNoNetworkTitle")
/// Account couldn't be found on the Ring network. Make sure it was exported on Ring from an existing device, and that provided credentials are correct.
static let acountCannotBeFoundMessage = L10n.tr("alerts.acountCannotBeFoundMessage")
static let acountCannotBeFoundMessage = L10n.tr("Localizable", "alerts.acountCannotBeFoundMessage")
}
enum Createaccount {
/// Choose strong password you will remember to protect your Ring account.
static let chooseStrongPassword = L10n.tr("createAccount.chooseStrongPassword")
static let chooseStrongPassword = L10n.tr("Localizable", "createAccount.chooseStrongPassword")
/// Create your Ring account
static let createAccountFormTitle = L10n.tr("createAccount.createAccountFormTitle")
static let createAccountFormTitle = L10n.tr("Localizable", "createAccount.createAccountFormTitle")
/// Enter new username
static let enterNewUsernamePlaceholder = L10n.tr("createAccount.enterNewUsernamePlaceholder")
static let enterNewUsernamePlaceholder = L10n.tr("Localizable", "createAccount.enterNewUsernamePlaceholder")
/// Invalid username
static let invalidUsername = L10n.tr("createAccount.invalidUsername")
static let invalidUsername = L10n.tr("Localizable", "createAccount.invalidUsername")
/// Loading...
static let loading = L10n.tr("createAccount.loading")
static let loading = L10n.tr("Localizable", "createAccount.loading")
/// Looking for username availability...
static let lookingForUsernameAvailability = L10n.tr("createAccount.lookingForUsernameAvailability")
static let lookingForUsernameAvailability = L10n.tr("Localizable", "createAccount.lookingForUsernameAvailability")
/// New Password
static let newPasswordPlaceholder = L10n.tr("createAccount.newPasswordPlaceholder")
static let newPasswordPlaceholder = L10n.tr("Localizable", "createAccount.newPasswordPlaceholder")
/// 6 characters minimum
static let passwordCharactersNumberError = L10n.tr("createAccount.passwordCharactersNumberError")
static let passwordCharactersNumberError = L10n.tr("Localizable", "createAccount.passwordCharactersNumberError")
/// Passwords do not match
static let passwordNotMatchingError = L10n.tr("createAccount.passwordNotMatchingError")
static let passwordNotMatchingError = L10n.tr("Localizable", "createAccount.passwordNotMatchingError")
/// Register public username (experimental)
static let registerPublicUsername = L10n.tr("createAccount.registerPublicUsername")
static let registerPublicUsername = L10n.tr("Localizable", "createAccount.registerPublicUsername")
/// Repeat new password
static let repeatPasswordPlaceholder = L10n.tr("createAccount.repeatPasswordPlaceholder")
static let repeatPasswordPlaceholder = L10n.tr("Localizable", "createAccount.repeatPasswordPlaceholder")
/// Username already taken
static let usernameAlreadyTaken = L10n.tr("createAccount.usernameAlreadyTaken")
static let usernameAlreadyTaken = L10n.tr("Localizable", "createAccount.usernameAlreadyTaken")
/// Adding account
static let waitCreateAccountTitle = L10n.tr("createAccount.waitCreateAccountTitle")
static let waitCreateAccountTitle = L10n.tr("Localizable", "createAccount.waitCreateAccountTitle")
}
enum Global {
/// Home
static let homeTabBarTitle = L10n.tr("global.homeTabBarTitle")
static let homeTabBarTitle = L10n.tr("Localizable", "global.homeTabBarTitle")
/// Me
static let meTabBarTitle = L10n.tr("global.meTabBarTitle")
static let meTabBarTitle = L10n.tr("Localizable", "global.meTabBarTitle")
/// Ok
static let ok = L10n.tr("global.ok")
static let ok = L10n.tr("Localizable", "global.ok")
}
enum Smartlist {
/// Conversations
static let conversations = L10n.tr("smartlist.conversations")
static let conversations = L10n.tr("Localizable", "smartlist.conversations")
/// No results
static let noResults = L10n.tr("smartlist.noResults")
static let noResults = L10n.tr("Localizable", "smartlist.noResults")
/// Searching...
static let searching = L10n.tr("smartlist.searching")
static let searching = L10n.tr("Localizable", "smartlist.searching")
/// User found
static let userFound = L10n.tr("smartlist.userFound")
static let userFound = L10n.tr("Localizable", "smartlist.userFound")
/// Yesterday
static let yesterday = L10n.tr("smartlist.yesterday")
static let yesterday = L10n.tr("Localizable", "smartlist.yesterday")
}
enum Welcome {
/// Create a Ring account
static let createAccount = L10n.tr("welcome.createAccount")
static let createAccount = L10n.tr("Localizable", "welcome.createAccount")
/// Link this device to an account
static let linkDeviceButton = L10n.tr("welcome.linkDeviceButton")
static let linkDeviceButton = L10n.tr("Localizable", "welcome.linkDeviceButton")
/// A Ring account allows you to reach people securely in peer to peer through fully distributed network
static let text = L10n.tr("welcome.text")
static let text = L10n.tr("Localizable", "welcome.text")
/// Welcome to Ring
static let title = L10n.tr("welcome.title")
static let title = L10n.tr("Localizable", "welcome.title")
}
}
struct LocalizableString {
let key: String
let args: [CVarArg]
/**
Returns String from Current Bundle
*/
public var string: String {
let format: String = NSLocalizedString(key, tableName: nil, bundle: Bundle(for: RingStringsBundleToken.self), value: "", comment: "")
return String(format: format, locale: Locale.current, arguments: args)
}
/**
Returns String translated from App's Bundle is found, otherwise from Current Bundle
*/
public var smartString: String {
// Load from App's Bundle first
var format: String = NSLocalizedString(key, tableName: nil, bundle: Bundle.main, value: "", comment: "")
if format != "" && format != key {
return String(format: format, locale: Locale.current, arguments: args)
}
// Load from Current Bundle
format = NSLocalizedString(key, tableName: nil, bundle: Bundle(for: RingStringsBundleToken.self), value: "", comment: "")
return String(format: format, locale: Locale.current, arguments: args)
}
}
// swiftlint:enable explicit_type_interface identifier_name line_length nesting type_body_length type_name
extension L10n {
fileprivate static func tr(_ key: String, _ args: CVarArg...) -> LocalizableString {
return LocalizableString(key: key, args: args)
fileprivate static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
return String(format: format, locale: Locale.current, arguments: args)
}
}
// swiftlint:enable type_body_length
// swiftlint:enable nesting
// swiftlint:enable variable_name
// swiftlint:enable valid_docs
private final class BundleToken {}
......@@ -138,7 +138,7 @@ class ConversationViewModel {
if todayDay == day && todayMonth == month && todayYear == year {
return hourFormatter.string(from: lastMessageDate)
} else if day == todayDay - 1 {
return L10n.Smartlist.yesterday.smartString
return L10n.Smartlist.yesterday
} else if todayYear == year && todayWeekOfYear == weekOfYear {
return lastMessageDate.dayOfWeek()
} else {
......
......@@ -32,8 +32,8 @@ class MeViewController: UIViewController, UITableViewDelegate, UITableViewDataSo
override func viewDidLoad() {
super.viewDidLoad()
self.title = L10n.Global.meTabBarTitle.smartString
self.navigationItem.title = L10n.Global.meTabBarTitle.smartString
self.title = L10n.Global.meTabBarTitle
self.navigationItem.title = L10n.Global.meTabBarTitle
if !accountService.accounts.isEmpty {
// let acc = accountService.accounts[0]
......
......@@ -70,8 +70,8 @@ class SmartlistViewController: UIViewController {
func setupUI() {
self.title = L10n.Global.homeTabBarTitle.smartString
self.navigationItem.title = L10n.Global.homeTabBarTitle.smartString
self.title = L10n.Global.homeTabBarTitle
self.navigationItem.title = L10n.Global.homeTabBarTitle
self.viewModel.hideNoConversationsMessage
.bind(to: self.noConversationsView.rx.isHidden)
......
......@@ -88,11 +88,11 @@ class SmartlistViewModel {
var sections = [ConversationSection]()
if contactFoundConversation != nil {
sections.append(ConversationSection(header: L10n.Smartlist.userFound.smartString, items: [contactFoundConversation!]))
sections.append(ConversationSection(header: L10n.Smartlist.userFound, items: [contactFoundConversation!]))
}
if !filteredResults.isEmpty {
sections.append(ConversationSection(header: L10n.Smartlist.conversations.smartString, items: filteredResults))
sections.append(ConversationSection(header: L10n.Smartlist.conversations, items: filteredResults))
}
return sections
......@@ -133,7 +133,7 @@ class SmartlistViewModel {
self.searchStatus.onNext("")
} else {
if self.filteredResults.value.isEmpty {
self.searchStatus.onNext(L10n.Smartlist.noResults.smartString)
self.searchStatus.onNext(L10n.Smartlist.noResults)
} else {
self.searchStatus.onNext("")
}
......@@ -166,7 +166,7 @@ class SmartlistViewModel {
}
self.nameService.lookupName(withAccount: "", nameserver: "", name: text)
self.searchStatus.onNext(L10n.Smartlist.searching.smartString)
self.searchStatus.onNext(L10n.Smartlist.searching)
}
}
......
......@@ -122,31 +122,31 @@ class CreateRingAccountViewController: UITableViewController {
fileprivate func setupUI() {
self.tableView.estimatedRowHeight = 44.0
self.tableView.rowHeight = UITableViewAutomaticDimension
self.createAccountTitleLabel.text = L10n.Createaccount.createAccountFormTitle.smartString
self.createAccountTitleLabel.text = L10n.Createaccount.createAccountFormTitle
}
fileprivate func setCreateAccountAsLoading() {
log.debug("Creating account...")
self.createAccountButton.setTitle(L10n.Createaccount.loading.smartString, for: .normal)
self.createAccountButton.setTitle(L10n.Createaccount.loading, for: .normal)
self.createAccountButton.isUserInteractionEnabled = false
HUD.show(.labeledProgress(title: L10n.Createaccount.waitCreateAccountTitle.smartString, subtitle: nil))
HUD.show(.labeledProgress(title: L10n.Createaccount.waitCreateAccountTitle, subtitle: nil))
}
fileprivate func setCreateAccountAsIdle() {
self.createAccountButton.setTitle(L10n.Welcome.createAccount.smartString, for: .normal)
self.createAccountButton.setTitle(L10n.Welcome.createAccount, for: .normal)
self.createAccountButton.isUserInteractionEnabled = true
HUD.hide()
}
fileprivate func showDeviceAddedAlert() {
HUD.flash(.labeledSuccess(title: L10n.Alerts.accountAddedTitle.smartString, subtitle: nil), delay: Durations.alertFlashDuration.value)
HUD.flash(.labeledSuccess(title: L10n.Alerts.accountAddedTitle, subtitle: nil), delay: Durations.alertFlashDuration.value)
}
fileprivate func showErrorAlert(_ error: AccountCreationError) {
let alert = UIAlertController.init(title: error.title,
message: error.message,
preferredStyle: .alert)
alert.addAction(UIAlertAction.init(title: L10n.Global.ok.smartString, style: .default, handler: nil))
alert.addAction(UIAlertAction.init(title: L10n.Global.ok, style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
<