Commit 29385d27 authored by Thibault Wittemberg's avatar Thibault Wittemberg Committed by Andreas Traczyk

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's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 4eca6de4
......@@ -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;
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
......@@ -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 @@ struct ColorAsset {
// 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 accountIcon = ImageAsset(name: "account_icon")
static let icContactPicture = ImageAsset(name: "ic_contact_picture")
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 icContactPicture = ImageAsset(name: "ic_contact_picture")
static let logoRingBeta2Blanc = ImageAsset(name: "logo-ring-beta2-blanc")
static let settingsIcon = ImageAsset(name: "settings_icon")
// swiftlint:disable trailing_comma
static let allColors: [ColorAsset] = [
]
static let allImages: [ImageAsset] = [
accountIcon,
addPerson,
backgroundRing,
contactRequestIcon,
accountIcon,
icContactPicture,
settingsIcon,
conversationIcon,
contactRequestIcon,
device,
icContactPicture,
logoRingBeta2Blanc,
settingsIcon,
]
// swiftlint:enable trailing_comma
@available(*, deprecated, renamed: "allImages")
......
......@@ -4,7 +4,6 @@
import Foundation
import UIKit
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
protocol StoryboardType {
......
......@@ -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
......
......@@ -52,7 +52,6 @@ class AppCoordinator: Coordinator, StateableResponsive {
switch state {
case .needToOnboard:
self.showWalkthrough()
break
}
}).disposed(by: self.disposeBag)
......
......@@ -60,7 +60,7 @@ class EditProfileViewController: UIViewController, UITextFieldDelegate, UIImageP
}).disposed(by: disposeBag)
}
func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
let alert = UIAlertController.init(title: nil,
message: nil,
......
......@@ -34,7 +34,7 @@ extension String {
}
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
......
......@@ -23,39 +23,39 @@ import UIKit
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 ringSecondary = UIColor(red: 0.0/255.0,
green: 76.0/255.0,
blue: 96.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,
static let ringMsgCellSent = UIColor(red: 58.0/255.0,
green: 192.0/255.0,
blue: 210.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,
alpha: 1.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 ringMsgCellReceivedText = UIColor(colorLiteralRed: 48.0/255.0,
green: 48.0/255.0,
blue: 48.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 ringMsgCellTimeText = UIColor(colorLiteralRed: 128.0/255.0,
green: 128.0/255.0,
blue: 128.0/255.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)
}
......@@ -37,7 +37,7 @@ extension UIImage {
}
// 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()
......
......@@ -25,7 +25,7 @@ extension UILabel {
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
......
......@@ -68,7 +68,7 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo
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 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo
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 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo
}
// swiftlint:disable cyclomatic_complexity
func formatCell(withCell cell: MessageCell,
cellForRowAt indexPath: IndexPath,
withMessageVM messageVM: MessageViewModel) {
......@@ -486,6 +487,7 @@ class ConversationViewController: UIViewController, UITextFieldDelegate, Storybo
}
}
}
// swiftlint:enable cyclomatic_complexity
}
extension ConversationViewController: UITableViewDataSource {
......
......@@ -26,7 +26,7 @@ import Reusable
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 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased
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 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased
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 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased
let searchResultsDatasource = RxTableViewSectionedReloadDataSource<ConversationSection>(configureCell: configureCell)
//Allows to delete
conversationsDataSource.canEditRowAtIndexPath = { _ in
conversationsDataSource.canEditRowAtIndexPath = { _, _ in
return true
}
......@@ -336,7 +336,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased
}
extension SmartlistViewController : UITableViewDelegate {
extension SmartlistViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
......
......@@ -84,7 +84,7 @@ class SmartlistViewModel: Stateable, ViewModel {
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 @@ class SmartlistViewModel: Stateable, ViewModel {
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
......
<?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"/>
......
......@@ -46,21 +46,21 @@ class LinkNewDeviceViewController: UIViewController, StoryboardBased, ViewModelB
// 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 @@ class LinkNewDeviceViewController: UIViewController, StoryboardBased, ViewModelB
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 @@ class LinkNewDeviceViewController: UIViewController, StoryboardBased, ViewModelB
self.explanationMessage.text = self.viewModel.explanationMessage
}
}
......@@ -152,17 +152,15 @@ class LinkNewDeviceViewModel: ViewModel, Stateable {
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() {
......
......@@ -113,13 +113,10 @@ class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelB
switch state {
case .started:
self?.showAccountCreationInProgress()
break
case .success:
self?.hideAccountCreationHud()
break
default:
self?.hideAccountCreationHud()
break
}
}, onError: { [weak self] (error) in
self?.hideAccountCreationHud()
......
......@@ -280,4 +280,3 @@ class CreateAccountViewModel: Stateable, ViewModel {
password: self.password.value)
}
}
......@@ -72,4 +72,3 @@ class LinkDeviceViewModel: Stateable, ViewModel {
password: self.password.value)
}
}
......@@ -66,13 +66,10 @@ class WalkthroughCoordinator: Coordinator, StateableResponsive {
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)
......
<?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">