project: Improve Swift 4 compliance
This commit adapts the code to Swift 4 syntax in order to
to lower the amount of XCode warnings.
It also adapts the RxSwift syntaxt to the last version.
Change-Id: I63b1bcae5115c1a7641172ad2c39e7622ac436a4
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
diff --git a/Ring/Ring.xcodeproj/project.pbxproj b/Ring/Ring.xcodeproj/project.pbxproj
index 570b2d9..bc76aa4 100644
--- a/Ring/Ring.xcodeproj/project.pbxproj
+++ b/Ring/Ring.xcodeproj/project.pbxproj
@@ -1243,13 +1243,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
- LastUpgradeCheck = 0820;
+ LastUpgradeCheck = 0910;
ORGANIZATIONNAME = "Savoir-faire Linux";
TargetAttributes = {
043999F21D1C2D9D00E99CD9 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = MSHYCBXK85;
- LastSwiftMigration = 0810;
+ LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
@@ -1259,13 +1259,13 @@
};
04399A0B1D1C2D9D00E99CD9 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0810;
+ LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
TestTargetID = 043999F21D1C2D9D00E99CD9;
};
04399A161D1C2D9D00E99CD9 = {
CreatedOnToolsVersion = 7.3.1;
- LastSwiftMigration = 0810;
+ LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
TestTargetID = 043999F21D1C2D9D00E99CD9;
};
@@ -1585,14 +1585,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -1634,14 +1640,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -1695,7 +1707,8 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Off;
+ SWIFT_VERSION = 4.0;
VALID_ARCHS = arm64;
};
name = Debug;
@@ -1727,7 +1740,8 @@
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Off;
+ SWIFT_VERSION = 4.0;
VALID_ARCHS = arm64;
};
name = Release;
@@ -1747,7 +1761,8 @@
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "RingTests/RingTests-Bridging-Header.h";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Ring.app/Ring";
};
name = Debug;
@@ -1767,7 +1782,8 @@
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "RingTests/RingTests-Bridging-Header.h";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Ring.app/Ring";
};
name = Release;
@@ -1779,7 +1795,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingUITest;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = Ring;
};
name = Debug;
@@ -1791,7 +1808,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingUITest;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = Ring;
};
name = Release;
@@ -1806,14 +1824,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -1873,7 +1897,8 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = Off;
+ SWIFT_VERSION = 4.0;
VALID_ARCHS = arm64;
};
name = Development;
@@ -1893,7 +1918,8 @@
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "RingTests/RingTests-Bridging-Header.h";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Ring.app/Ring";
};
name = Development;
@@ -1905,7 +1931,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cx.ring.RingUITest;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = Ring;
};
name = Development;
diff --git a/Ring/Ring.xcodeproj/xcshareddata/xcschemes/Ring.xcscheme b/Ring/Ring.xcodeproj/xcshareddata/xcschemes/Ring.xcscheme
index 2bfbde2..df974f9 100644
--- a/Ring/Ring.xcodeproj/xcshareddata/xcschemes/Ring.xcscheme
+++ b/Ring/Ring.xcodeproj/xcshareddata/xcschemes/Ring.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0820"
+ LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/Ring/Ring/Constants/Generated/Images.swift b/Ring/Ring/Constants/Generated/Images.swift
index 348eefb..134e648 100644
--- a/Ring/Ring/Constants/Generated/Images.swift
+++ b/Ring/Ring/Constants/Generated/Images.swift
@@ -10,7 +10,6 @@
typealias Image = UIImage
#endif
-// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
@available(*, deprecated, renamed: "ImageAsset")
@@ -46,29 +45,29 @@
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
enum Asset {
- static let accountIcon = ImageAsset(name: "account_icon")
static let addPerson = ImageAsset(name: "add_person")
static let backgroundRing = ImageAsset(name: "background_ring")
- static let contactRequestIcon = ImageAsset(name: "contact_request_icon")
- static let conversationIcon = ImageAsset(name: "conversation_icon")
- static let device = ImageAsset(name: "device")
+ static let accountIcon = ImageAsset(name: "account_icon")
static let icContactPicture = ImageAsset(name: "ic_contact_picture")
- static let logoRingBeta2Blanc = ImageAsset(name: "logo-ring-beta2-blanc")
static let settingsIcon = ImageAsset(name: "settings_icon")
+ static let conversationIcon = ImageAsset(name: "conversation_icon")
+ static let contactRequestIcon = ImageAsset(name: "contact_request_icon")
+ static let device = ImageAsset(name: "device")
+ static let logoRingBeta2Blanc = ImageAsset(name: "logo-ring-beta2-blanc")
// swiftlint:disable trailing_comma
static let allColors: [ColorAsset] = [
]
static let allImages: [ImageAsset] = [
- accountIcon,
addPerson,
backgroundRing,
- contactRequestIcon,
- conversationIcon,
- device,
+ accountIcon,
icContactPicture,
- logoRingBeta2Blanc,
settingsIcon,
+ conversationIcon,
+ contactRequestIcon,
+ device,
+ logoRingBeta2Blanc,
]
// swiftlint:enable trailing_comma
@available(*, deprecated, renamed: "allImages")
diff --git a/Ring/Ring/Constants/Generated/Storyboards.swift b/Ring/Ring/Constants/Generated/Storyboards.swift
index a9d66db..1e43a4e 100644
--- a/Ring/Ring/Constants/Generated/Storyboards.swift
+++ b/Ring/Ring/Constants/Generated/Storyboards.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
protocol StoryboardType {
diff --git a/Ring/Ring/Constants/Generated/Strings.swift b/Ring/Ring/Constants/Generated/Strings.swift
index 572d918..91a6f47 100644
--- a/Ring/Ring/Constants/Generated/Strings.swift
+++ b/Ring/Ring/Constants/Generated/Strings.swift
@@ -2,7 +2,6 @@
import Foundation
-// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name
diff --git a/Ring/Ring/Coordinators/AppCoordinator.swift b/Ring/Ring/Coordinators/AppCoordinator.swift
index e431c56..6496141 100644
--- a/Ring/Ring/Coordinators/AppCoordinator.swift
+++ b/Ring/Ring/Coordinators/AppCoordinator.swift
@@ -52,7 +52,6 @@
switch state {
case .needToOnboard:
self.showWalkthrough()
- break
}
}).disposed(by: self.disposeBag)
diff --git a/Ring/Ring/EditProfileViewController.swift b/Ring/Ring/EditProfileViewController.swift
index 11efd79..c0eaee5 100644
--- a/Ring/Ring/EditProfileViewController.swift
+++ b/Ring/Ring/EditProfileViewController.swift
@@ -60,7 +60,7 @@
}).disposed(by: disposeBag)
}
- func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
+ @objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
let alert = UIAlertController.init(title: nil,
message: nil,
diff --git a/Ring/Ring/Extensions/String+Helpers.swift b/Ring/Ring/Extensions/String+Helpers.swift
index cf4a96f..327971d 100644
--- a/Ring/Ring/Extensions/String+Helpers.swift
+++ b/Ring/Ring/Extensions/String+Helpers.swift
@@ -34,7 +34,7 @@
}
func toMD5HexString() -> String {
- let messageData = self.data(using:.utf8)!
+ let messageData = self.data(using: .utf8)!
var digestData = Data(count: Int(CC_MD5_DIGEST_LENGTH))
_ = digestData.withUnsafeMutableBytes { digestBytes in
diff --git a/Ring/Ring/Extensions/UIColor+Ring.swift b/Ring/Ring/Extensions/UIColor+Ring.swift
index db4ec9c..422ff4c 100644
--- a/Ring/Ring/Extensions/UIColor+Ring.swift
+++ b/Ring/Ring/Extensions/UIColor+Ring.swift
@@ -23,39 +23,39 @@
extension UIColor {
- static let ringMain = UIColor(colorLiteralRed: 58.0/255.0,
+ static let ringMain = UIColor(red: 58.0/255.0,
green: 192.0/255.0,
blue: 210.0/255.0,
alpha: 1.0)
- static let ringSecondary = UIColor(colorLiteralRed: 0.0/255.0,
- green: 76.0/255.0,
- blue: 96.0/255.0,
- alpha: 1.0)
-
- static let ringMsgCellSent = UIColor(colorLiteralRed: 58.0/255.0,
- green: 192.0/255.0,
- blue: 210.0/255.0,
- alpha: 1.0)
-
- static let ringMsgCellSentText = UIColor(colorLiteralRed: 255.0/255.0,
- green: 255.0/255.0,
- blue: 255.0/255.0,
- alpha: 1.0)
-
- static let ringMsgCellReceived = UIColor(colorLiteralRed: 235.0/255.0,
- green: 239.0/255.0,
- blue: 239.0/255.0,
+ static let ringSecondary = UIColor(red: 0.0/255.0,
+ green: 76.0/255.0,
+ blue: 96.0/255.0,
alpha: 1.0)
- static let ringMsgCellReceivedText = UIColor(colorLiteralRed: 48.0/255.0,
- green: 48.0/255.0,
- blue: 48.0/255.0,
+ static let ringMsgCellSent = UIColor(red: 58.0/255.0,
+ green: 192.0/255.0,
+ blue: 210.0/255.0,
alpha: 1.0)
- static let ringMsgCellTimeText = UIColor(colorLiteralRed: 128.0/255.0,
- green: 128.0/255.0,
- blue: 128.0/255.0,
+ static let ringMsgCellSentText = UIColor(red: 255.0/255.0,
+ green: 255.0/255.0,
+ blue: 255.0/255.0,
+ alpha: 1.0)
+
+ static let ringMsgCellReceived = UIColor(red: 235.0/255.0,
+ green: 239.0/255.0,
+ blue: 239.0/255.0,
+ alpha: 1.0)
+
+ static let ringMsgCellReceivedText = UIColor(red: 48.0/255.0,
+ green: 48.0/255.0,
+ blue: 48.0/255.0,
alpha: 1.0)
+ static let ringMsgCellTimeText = UIColor(red: 128.0/255.0,
+ green: 128.0/255.0,
+ blue: 128.0/255.0,
+ alpha: 1.0)
+
}
diff --git a/Ring/Ring/Extensions/UIImage+Helpers.swift b/Ring/Ring/Extensions/UIImage+Helpers.swift
index 5a4f242..3e0c72b 100644
--- a/Ring/Ring/Extensions/UIImage+Helpers.swift
+++ b/Ring/Ring/Extensions/UIImage+Helpers.swift
@@ -37,7 +37,7 @@
}
// convenience function in UIImage extension to resize a given image
func convert(toSize size: CGSize, scale: CGFloat) -> UIImage {
- let imgRect = CGRect(origin: CGPoint(x:0.0, y:0.0), size: size)
+ let imgRect = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)
UIGraphicsBeginImageContextWithOptions(size, false, scale)
self.draw(in: imgRect)
let copied = UIGraphicsGetImageFromCurrentImageContext()
diff --git a/Ring/Ring/Extensions/UILabel+Ring.swift b/Ring/Ring/Extensions/UILabel+Ring.swift
index 106c380..f4ed5a3 100644
--- a/Ring/Ring/Extensions/UILabel+Ring.swift
+++ b/Ring/Ring/Extensions/UILabel+Ring.swift
@@ -25,7 +25,7 @@
let attrString = NSMutableAttributedString(string: withText)
let style = NSMutableParagraphStyle()
style.lineSpacing = withLineSpacing
- attrString.addAttribute(NSParagraphStyleAttributeName,
+ attrString.addAttribute(NSAttributedStringKey.paragraphStyle,
value: style,
range: NSRange(location: 0, length: withText.utf16.count))
self.attributedText = attrString
diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
index deacaad..5c8753c 100644
--- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
@@ -68,7 +68,7 @@
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
- func keyboardWillShow(withNotification notification: Notification) {
+ @objc func keyboardWillShow(withNotification notification: Notification) {
let userInfo: Dictionary = notification.userInfo!
guard let keyboardFrame: NSValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }
@@ -83,7 +83,7 @@
self.updateBottomOffset()
}
- func keyboardWillHide(withNotification notification: Notification) {
+ @objc func keyboardWillHide(withNotification notification: Notification) {
self.tableView.contentInset.bottom = 0
self.tableView.scrollIndicatorInsets.bottom = 0
self.updateBottomOffset()
@@ -396,6 +396,7 @@
}
+ // swiftlint:disable cyclomatic_complexity
func formatCell(withCell cell: MessageCell,
cellForRowAt indexPath: IndexPath,
withMessageVM messageVM: MessageViewModel) {
@@ -486,6 +487,7 @@
}
}
}
+ // swiftlint:enable cyclomatic_complexity
}
extension ConversationViewController: UITableViewDataSource {
diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
index 2fd81bc..30cddf3 100644
--- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
@@ -26,7 +26,7 @@
import SwiftyBeaver
//Constants
-fileprivate struct SmartlistConstants {
+private struct SmartlistConstants {
static let smartlistRowHeight: CGFloat = 64.0
static let tableHeaderViewHeight: CGFloat = 24.0
static let firstSectionHeightForHeader: CGFloat = 31.0 //Compensate the offset due to the label on the top of the tableView
@@ -113,7 +113,7 @@
self.conversationsTableView.setEditing(editing, animated: true)
}
- func keyboardWillShow(withNotification notification: Notification) {
+ @objc func keyboardWillShow(withNotification notification: Notification) {
let userInfo: Dictionary = notification.userInfo!
guard let keyboardFrame: NSValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }
let keyboardRectangle = keyboardFrame.cgRectValue
@@ -126,7 +126,7 @@
self.searchResultsTableView.scrollIndicatorInsets.bottom = keyboardHeight - tabBarHeight
}
- func keyboardWillHide(withNotification notification: Notification) {
+ @objc func keyboardWillHide(withNotification notification: Notification) {
self.conversationsTableView.contentInset.bottom = 0
self.searchResultsTableView.contentInset.bottom = 0
@@ -221,7 +221,7 @@
let searchResultsDatasource = RxTableViewSectionedReloadDataSource<ConversationSection>(configureCell: configureCell)
//Allows to delete
- conversationsDataSource.canEditRowAtIndexPath = { _ in
+ conversationsDataSource.canEditRowAtIndexPath = { _, _ in
return true
}
@@ -336,7 +336,7 @@
}
-extension SmartlistViewController : UITableViewDelegate {
+extension SmartlistViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
index 5e642d8..92c16e8 100644
--- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
@@ -84,7 +84,7 @@
return lastMessage1.receivedDate > lastMessage2.receivedDate
})
.filter({ self.contactsService.contact(withRingId: $0.recipientRingId) != nil
- || (!$0.messages.isEmpty && (self.contactsService.contactRequest(withRingId:$0.recipientRingId) == nil))
+ || (!$0.messages.isEmpty && (self.contactsService.contactRequest(withRingId: $0.recipientRingId) == nil))
})
.flatMap({ conversationModel in
@@ -130,12 +130,12 @@
self.hideNoConversationsMessage = Observable
.combineLatest( self.conversations, self.searchBarText.asObservable(), resultSelector: { conversations, searchBarText in
- return !conversations.first!.items.isEmpty || !searchBarText.characters.isEmpty
+ return !conversations.first!.items.isEmpty || !searchBarText.isEmpty
}).observeOn(MainScheduler.instance)
//Observes if the user is searching
self.isSearching = searchBarText.asObservable().map({ text in
- return !text.characters.isEmpty
+ return !text.isEmpty
}).observeOn(MainScheduler.instance)
//Observes search bar text
diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewController.storyboard b/Ring/Ring/Features/Me/LinkNewDeviceViewController.storyboard
index f1e3cfc..f172d57 100644
--- a/Ring/Ring/Features/Me/LinkNewDeviceViewController.storyboard
+++ b/Ring/Ring/Features/Me/LinkNewDeviceViewController.storyboard
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2dj-eG-xeW">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="2dj-eG-xeW">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -25,7 +25,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<edgeInsets key="layoutMargins" top="0.0" left="0.0" bottom="0.0" right="0.0"/>
</imageView>
- <visualEffectView opaque="NO" alpha="0.59999999999999998" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tkx-Tz-Dro">
+ <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tkx-Tz-Dro">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="hhH-X0-zM1">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
index 5778a59..d290d56 100644
--- a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
+++ b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
@@ -46,21 +46,21 @@
// initial state
self.viewModel.isInitialState
.bind(to: self.titleLable.rx.isHidden)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
self.viewModel.isInitialState.bind(to: self.passwordField.rx.isHidden)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
self.viewModel.isInitialState.bind(to: self.cancelButton.rx.isHidden)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
// error state
self.viewModel.isErrorState.bind(to: self.errorMessage.rx.isVisible)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
// success state
self.viewModel.isSuccessState
.bind(to: self.explanationMessage.rx.isVisible)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
self.viewModel.isSuccessState
.bind(to: self.pinLabel.rx.isVisible)
- .addDisposableTo(self.disposeBag)
+ .disposed(by: self.disposeBag)
self.viewModel.observableState
.observeOn(MainScheduler.instance)
@@ -77,7 +77,7 @@
default:
break
}
- }).addDisposableTo(self.disposeBag)
+ }).disposed(by: self.disposeBag)
cancelButton.rx.tap.subscribe(onNext: { [unowned self] in
self.dismiss(animated: true, completion: nil)
@@ -109,4 +109,3 @@
self.explanationMessage.text = self.viewModel.explanationMessage
}
}
-
diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift b/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
index e8a5418..0dca2b5 100644
--- a/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
+++ b/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
@@ -152,17 +152,15 @@
default:
self.generatingState.value = GeneratingPinState.error(error: PinError.defaultError)
}
-
}
})
.disposed(by: self.disposeBag)
} else {
self.generatingState.value = GeneratingPinState.error(error: PinError.defaultError)
}
- })
- { error in
+ }, onError: { error in
self.generatingState.value = GeneratingPinState.error(error: PinError.passwordError)
- }.addDisposableTo(self.disposeBag)
+ }).disposed(by: self.disposeBag)
}
func refresh() {
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
index e008e16..927e33f 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
@@ -113,13 +113,10 @@
switch state {
case .started:
self?.showAccountCreationInProgress()
- break
case .success:
self?.hideAccountCreationHud()
- break
default:
self?.hideAccountCreationHud()
- break
}
}, onError: { [weak self] (error) in
self?.hideAccountCreationHud()
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
index 5709dc8..94cc381 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
@@ -280,4 +280,3 @@
password: self.password.value)
}
}
-
diff --git a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewModel.swift b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewModel.swift
index 753aa49..bc84677 100644
--- a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewModel.swift
+++ b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewModel.swift
@@ -72,4 +72,3 @@
password: self.password.value)
}
}
-
diff --git a/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift b/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift
index 09fcad4..82c341a 100644
--- a/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift
+++ b/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift
@@ -66,13 +66,10 @@
switch state {
case .welcomeDone(let walkthroughType):
self.showCreateProfile(with: walkthroughType)
- break
case .profileCreated(let walkthroughType):
self.showFinalStep(with: walkthroughType)
- break
case .accountCreated, .deviceLinked:
self.rootViewController.dismiss(animated: true, completion: nil)
- break
}
}).disposed(by: self.disposeBag)
diff --git a/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.storyboard b/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.storyboard
index 6b1db22..f494b7a 100644
--- a/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.storyboard
+++ b/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.storyboard
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ILs-xb-iKr">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ILs-xb-iKr">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
diff --git a/Ring/Ring/Models/AccountCredentialsModel.swift b/Ring/Ring/Models/AccountCredentialsModel.swift
index 4ddfddd..ad49edf 100644
--- a/Ring/Ring/Models/AccountCredentialsModel.swift
+++ b/Ring/Ring/Models/AccountCredentialsModel.swift
@@ -36,9 +36,9 @@
- keep the credentials of an account.
*/
class AccountCredentialsModel: Object {
- dynamic var username: String = ""
- dynamic var password: String = ""
- dynamic var accountRealm: String = ""
+ @objc dynamic var username: String = ""
+ @objc dynamic var password: String = ""
+ @objc dynamic var accountRealm: String = ""
/**
Constructor.
diff --git a/Ring/Ring/Models/ContactModel.swift b/Ring/Ring/Models/ContactModel.swift
index 266c1c9..fe0febd 100644
--- a/Ring/Ring/Models/ContactModel.swift
+++ b/Ring/Ring/Models/ContactModel.swift
@@ -29,7 +29,7 @@
self.ringId = ringId
}
- init(withDictionary dictionary: [String : String]) {
+ init(withDictionary dictionary: [String: String]) {
if let ringId = dictionary["id"] {
self.ringId = ringId
diff --git a/Ring/Ring/Models/ContactRequestModel.swift b/Ring/Ring/Models/ContactRequestModel.swift
index 22d3eb8..d5fe432 100644
--- a/Ring/Ring/Models/ContactRequestModel.swift
+++ b/Ring/Ring/Models/ContactRequestModel.swift
@@ -43,7 +43,7 @@
self.accountId = accountId
}
- init(withDictionary dictionary: [String : String], accountId: String) {
+ init(withDictionary dictionary: [String: String], accountId: String) {
if let ringId = dictionary[ContactRequestKey.from.rawValue] {
self.ringId = ringId
diff --git a/Ring/Ring/Models/ConversationModel.swift b/Ring/Ring/Models/ConversationModel.swift
index 020579b..7cee811 100644
--- a/Ring/Ring/Models/ConversationModel.swift
+++ b/Ring/Ring/Models/ConversationModel.swift
@@ -23,8 +23,8 @@
class ConversationModel: Object {
let messages = List<MessageModel>()
- dynamic var recipientRingId: String = ""
- dynamic var accountId: String = ""
+ @objc dynamic var recipientRingId: String = ""
+ @objc dynamic var accountId: String = ""
convenience init(withRecipientRingId recipientRingId: String, accountId: String) {
self.init()
diff --git a/Ring/Ring/Models/DeviceModel.swift b/Ring/Ring/Models/DeviceModel.swift
index 5a18407..0e32611 100644
--- a/Ring/Ring/Models/DeviceModel.swift
+++ b/Ring/Ring/Models/DeviceModel.swift
@@ -23,8 +23,8 @@
class DeviceModel: Object {
- dynamic var deviceId = ""
- dynamic var deviceName: String?
+ @objc dynamic var deviceId = ""
+ @objc dynamic var deviceName: String?
convenience init(withDeviceId deviceId: String, deviceName: String?) {
self.init()
diff --git a/Ring/Ring/Models/MessageModel.swift b/Ring/Ring/Models/MessageModel.swift
index 1ab7f40..de90b6b 100644
--- a/Ring/Ring/Models/MessageModel.swift
+++ b/Ring/Ring/Models/MessageModel.swift
@@ -22,12 +22,12 @@
class MessageModel: Object {
- dynamic var id: String = ""
- dynamic var receivedDate: Date = Date()
- dynamic var content: String = ""
- dynamic var author: String = ""
- dynamic var status: MessageStatus = .unknown
- dynamic var isGenerated: Bool = false
+ @objc dynamic var id: String = ""
+ @objc dynamic var receivedDate: Date = Date()
+ @objc dynamic var content: String = ""
+ @objc dynamic var author: String = ""
+ @objc dynamic var status: MessageStatus = .unknown
+ @objc dynamic var isGenerated: Bool = false
convenience init(withId id: String, receivedDate: Date, content: String, author: String) {
self.init()
diff --git a/Ring/Ring/Protocols/Coordinator.swift b/Ring/Ring/Protocols/Coordinator.swift
index f77dd97..7a3cea7 100644
--- a/Ring/Ring/Protocols/Coordinator.swift
+++ b/Ring/Ring/Protocols/Coordinator.swift
@@ -86,16 +86,14 @@
case .present: self.rootViewController.present(viewController,
animated: animation,
completion: nil)
- break
case .popup:
viewController.modalPresentationStyle = .overCurrentContext
viewController.modalTransitionStyle = .coverVertical
self.rootViewController.present(viewController,
animated: animation,
completion: nil)
- break
- case .show: self.rootViewController.show(viewController, sender: nil)
- break
+ case .show:
+ self.rootViewController.show(viewController, sender: nil)
case .appear:
viewController.modalPresentationStyle = .overFullScreen
viewController.modalTransitionStyle = .crossDissolve
diff --git a/Ring/Ring/Services/ConversationsService.swift b/Ring/Ring/Services/ConversationsService.swift
index 44bb35f..8957177 100644
--- a/Ring/Ring/Services/ConversationsService.swift
+++ b/Ring/Ring/Services/ConversationsService.swift
@@ -125,6 +125,7 @@
})
}
+ // swiftlint:disable function_parameter_count
func saveMessage(withId messageId: String,
withContent content: String,
byAuthor author: String,
@@ -170,6 +171,7 @@
})
}
+ // swiftlint:enable function_parameter_count
func findConversation(withRingId ringId: String,
withAccountId accountId: String) -> ConversationModel? {
@@ -309,23 +311,25 @@
}).first
//Find message
- if let message = conversation?.messages.filter({ messages in
+ if let messages: [MessageModel] = conversation?.messages.filter({ (messages) -> Bool in
return !messages.id.isEmpty && messages.id == String(messageId) &&
- ((status.rawValue > messages.status.rawValue && status != .failure) ||
+ ((status.rawValue > messages.status.rawValue && status != .failure) ||
(status == .failure && messages.status == .sending))
- }).first {
- self.setMessageStatus(withMessage: message,
- withStatus: status)
- .subscribe(onCompleted: { [unowned self] in
- self.log.info("Message status updated")
- var event = ServiceEvent(withEventType: .messageStateChanged)
- event.addEventInput(.messageStatus, value: status)
- event.addEventInput(.messageId, value: String(messageId))
- event.addEventInput(.id, value: accountId)
- event.addEventInput(.uri, value: uri)
- self.responseStream.onNext(event)
- })
- .disposed(by: disposeBag)
+ }) {
+ if let message = messages.first {
+ self.setMessageStatus(withMessage: message,
+ withStatus: status)
+ .subscribe(onCompleted: { [unowned self] in
+ self.log.info("Message status updated")
+ var event = ServiceEvent(withEventType: .messageStateChanged)
+ event.addEventInput(.messageStatus, value: status)
+ event.addEventInput(.messageId, value: String(messageId))
+ event.addEventInput(.id, value: accountId)
+ event.addEventInput(.uri, value: uri)
+ self.responseStream.onNext(event)
+ })
+ .disposed(by: disposeBag)
+ }
}
log.debug("messageStatusChanged: \(status.rawValue) for: \(messageId) from: \(accountId) to: \(uri)")