Migrate to Swift 4.

pull/1/head
Matthew Chen 7 years ago
parent 4d8c764789
commit f63d25a172

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -9,6 +9,7 @@ extension UIStoryboard {
case main = "Main"
}
@objc
class var main: UIStoryboard {
return UIStoryboard(name: StoryboardName.main.rawValue, bundle: Bundle.main)
}

@ -15,10 +15,12 @@ public protocol ContactShareViewHelperDelegate: class {
@objc
public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
@objc
weak var delegate: ContactShareViewHelperDelegate?
let contactsManager: OWSContactsManager
@objc
public required init(contactsManager: OWSContactsManager) {
SwiftAssertIsOnMainThread(#function)
@ -89,6 +91,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
inviteFlow.sendSMSTo(phoneNumbers: phoneNumbers)
}
@objc
func showAddToContacts(contactShare: ContactShareViewModel, fromViewController: UIViewController) {
Logger.info("\(logTag) \(#function)")

@ -48,6 +48,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
fatalError("Unimplemented")
}
@objc
required init(contactShare: ContactShareViewModel) {
contactsManager = Environment.current().contactsManager
self.contactShare = contactShare

@ -72,6 +72,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
private lazy var selectedContacts = [Contact]()
// Configuration
@objc
public weak var contactsPickerDelegate: ContactsPickerDelegate?
private let subtitleCellType: SubtitleCellValue
private let allowsMultipleSelection: Bool

@ -12,8 +12,10 @@ public protocol ConversationHeaderViewDelegate {
@objc
public class ConversationHeaderView: UIStackView {
@objc
public weak var delegate: ConversationHeaderViewDelegate?
@objc
public var attributedTitle: NSAttributedString? {
get {
return self.titleLabel.attributedText
@ -23,6 +25,7 @@ public class ConversationHeaderView: UIStackView {
}
}
@objc
public var attributedSubtitle: NSAttributedString? {
get {
return self.subtitleLabel.attributedText
@ -41,14 +44,18 @@ public class ConversationHeaderView: UIStackView {
}
}
@objc
public let titlePrimaryFont: UIFont = UIFont.ows_boldFont(withSize: 17)
@objc
public let titleSecondaryFont: UIFont = UIFont.ows_regularFont(withSize: 9)
@objc
public let subtitleFont: UIFont = UIFont.ows_regularFont(withSize: 12)
private let titleLabel: UILabel
private let subtitleLabel: UILabel
private let avatarView: AvatarImageView
@objc
public required init(thread: TSThread, contactsManager: OWSContactsManager) {
let avatarView = ConversationAvatarImageView(thread: thread, diameter: 36, contactsManager: contactsManager)

@ -33,6 +33,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
var lastQuery: String = ""
@objc
public weak var delegate: GifPickerViewControllerDelegate?
let thread: TSThread
@ -60,6 +61,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
fatalError("\(#function) is unimplemented.")
}
@objc
required init(thread: TSThread, messageSender: MessageSender) {
self.thread = thread
self.messageSender = messageSender

@ -24,6 +24,7 @@ public class LongTextViewController: OWSViewController {
fatalError("\(#function) is unimplemented.")
}
@objc
public required init(viewItem: ConversationViewItem) {
self.viewItem = viewItem
@ -76,7 +77,7 @@ public class LongTextViewController: OWSViewController {
view.addSubview(messageTextView)
messageTextView.autoPinEdge(toSuperviewEdge: .leading)
messageTextView.autoPinEdge(toSuperviewEdge: .trailing)
messageTextView.textContainerInset = UIEdgeInsetsMake(0, view.layoutMargins.left, 0, view.layoutMargins.right)
messageTextView.textContainerInset = UIEdgeInsets(top: 0, left: view.layoutMargins.left, bottom: 0, right: view.layoutMargins.right)
messageTextView.autoPin(toTopLayoutGuideOf: self, withInset: 0)
let footer = UIToolbar()

@ -278,6 +278,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
// TODO rename to replacingOriginRect
private var originRect: CGRect?
@objc
public func presentDetailView(fromViewController: UIViewController, mediaMessage: TSMessage, replacingView: UIView) {
var galleryItem: MediaGalleryItem?
uiDatabaseConnection.read { transaction in

@ -49,6 +49,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
fatalError("\(#function) is unimplemented.")
}
@objc
required init(viewItem: ConversationViewItem, message: TSMessage, mode: MessageMetadataViewMode) {
self.contactsManager = Environment.current().contactsManager
self.viewItem = viewItem

@ -23,6 +23,7 @@ class QuotedReplyPreview: UIView {
fatalError("init(coder:) has not been implemented")
}
@objc
init(quotedReply: OWSQuotedReplyModel) {
self.quotedReply = quotedReply

@ -48,6 +48,7 @@ public class ContactShareViewModel: NSObject {
}
}
@objc
public func getAvatarImage(diameter: CGFloat, contactsManager: OWSContactsManager) -> UIImage {
if let avatarImage = avatarImage {
return avatarImage

@ -16,6 +16,7 @@ public protocol DisappearingTimerConfigurationViewDelegate: class {
@objc
public class DisappearingTimerConfigurationView: UIView {
@objc
public weak var delegate: DisappearingTimerConfigurationViewDelegate? {
didSet {
// gesture recognizer is only enabled when a delegate is assigned.

@ -1011,6 +1011,7 @@ public class SignalAttachment: NSObject {
return VideoCompressionResult(attachmentPromise: attachmentPromise, exportSession: exportSession)
}
@objc
public class func isInvalidVideo(dataSource: DataSource, dataUTI: String) -> Bool {
guard videoUTISet.contains(dataUTI) else {
// not a video

@ -7,6 +7,7 @@ import AVFoundation
@objc
public class VideoPlayerView: UIView {
@objc
var player: AVPlayer? {
get {
return playerLayer.player

@ -1,19 +1,22 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import PromiseKit
@objc
public extension AnyPromise {
/**
* Sometimes there isn't a straight forward candidate to retain a promise, in that case we tell the
* promise to self retain, until it completes to avoid the risk it's GC'd before completion.
*/
@objc
func retainUntilComplete() {
// Unfortunately, there is (currently) no way to surpress the
// compiler warning: "Variable 'retainCycle' was written to, but never read"
var retainCycle: AnyPromise? = self
self.always {
assert(retainCycle != nil)
retainCycle = nil
}
}
@ -29,6 +32,7 @@ public extension Promise {
// compiler warning: "Variable 'retainCycle' was written to, but never read"
var retainCycle: Promise<T>? = self
self.always {
assert(retainCycle != nil)
retainCycle = nil
}
}

@ -14,6 +14,7 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
private static var sharedCompleteRegistrationFixerJob: CompleteRegistrationFixerJob?
// increment a similar constant for each migration.
@objc
class func migrationId() -> String {
return "106"
}

Loading…
Cancel
Save