Merge pull request #28 from TouchInstinct/new-swift

New swift
This commit is contained in:
Ivan Smolin 2017-10-23 14:54:49 +03:00 committed by GitHub
commit a66a06200a
19 changed files with 135 additions and 114 deletions

1
.swift-version Normal file
View File

@ -0,0 +1 @@
4.0

6
CHANGELOG.md Normal file
View File

@ -0,0 +1,6 @@
# Changelog
## 0.1.0
- **Add**: support for Swift 3.2 / 4

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKitAdditions"
s.version = "0.0.23"
s.version = "0.1.0"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKitAdditions"
s.license = "Apache License, Version 2.0"
@ -16,11 +16,11 @@ Pod::Spec.new do |s|
"LeadKitAdditions/Sources/Services/Network/DefaultNetworkService+ActivityIndicator+Extension.swift",
]
ss.dependency "LeadKit", '~> 0.5' # till 0.6
ss.dependency "KeychainAccess", '3.0.2'
ss.dependency "LeadKit", '0.6.0'
ss.dependency "KeychainAccess", '3.1.0'
ss.dependency "IDZSwiftCommonCrypto", '0.9.1'
ss.dependency "InputMask", '2.2.5'
ss.dependency "SwiftValidator", '4.0.0'
ss.dependency "InputMask", '3.0.0'
ss.dependency "SwiftValidator", '5.0.0'
end
s.subspec 'Core-iOS-Extension' do |ss|
@ -31,11 +31,11 @@ Pod::Spec.new do |s|
"LeadKitAdditions/Sources/Services/Network/DefaultNetworkService+ActivityIndicator.swift",
]
ss.dependency "LeadKit/Core-iOS-Extension", '~> 0.5'
ss.dependency "KeychainAccess", '3.0.2'
ss.dependency "LeadKit/Core-iOS-Extension", '0.6.0'
ss.dependency "KeychainAccess", '3.1.0'
ss.dependency "IDZSwiftCommonCrypto", '0.9.1'
ss.dependency "InputMask", '2.2.5'
ss.dependency "SwiftValidator", '4.0.0'
ss.dependency "InputMask", '3.0.0'
ss.dependency "SwiftValidator", '5.0.0'
end
s.default_subspec = 'Core'

View File

@ -425,12 +425,12 @@
CAE698DA1E968820000394B0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = TouchInstinct;
TargetAttributes = {
CAE698E21E968820000394B0 = {
CreatedOnToolsVersion = 8.3;
LastSwiftMigration = 0830;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
};
EFBD556F1EBB87100062AA63 = {
@ -670,7 +670,9 @@
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_DOCUMENTATION_COMMENTS = YES;
@ -678,7 +680,11 @@
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;
@ -724,7 +730,9 @@
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_DOCUMENTATION_COMMENTS = YES;
@ -732,7 +740,11 @@
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;
@ -782,7 +794,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@ -806,7 +818,7 @@
PRODUCT_NAME = LeadKitAdditions;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
@ -830,7 +842,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@ -854,7 +866,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};

View File

@ -2,10 +2,10 @@ source "https://github.com/CocoaPods/Specs.git"
source "https://github.com/TouchInstinct/Podspecs.git"
abstract_target 'LeadKitAdditions' do
pod 'KeychainAccess', '3.0.2'
pod 'IDZSwiftCommonCrypto', '0.9.1'
pod 'SwiftValidator', '4.0.0'
pod 'InputMask', '2.2.5'
pod 'KeychainAccess', '3.1.0'
pod 'IDZSwiftCommonCrypto'
pod "InputMask", '3.0.0'
pod "SwiftValidator", '5.0.0'
inhibit_all_warnings!
@ -14,7 +14,7 @@ abstract_target 'LeadKitAdditions' do
use_frameworks!
pod "LeadKit", '0.5.1'
pod "LeadKit", '0.6.0'
end
target 'LeadKitAdditions iOS Extensions' do
@ -22,7 +22,7 @@ abstract_target 'LeadKitAdditions' do
use_frameworks!
pod "LeadKit/Core-iOS-Extension", '0.5.1'
pod "LeadKit/Core-iOS-Extension", '0.6.0'
end
end

View File

@ -1,63 +1,63 @@
PODS:
- Alamofire (4.4.0)
- CocoaLumberjack/Default (3.1.0)
- CocoaLumberjack/Swift (3.1.0):
- Alamofire (4.5.1)
- CocoaLumberjack/Default (3.3.0)
- CocoaLumberjack/Swift (3.3.0):
- CocoaLumberjack/Default
- IDZSwiftCommonCrypto (0.9.1)
- InputMask (2.2.5)
- KeychainAccess (3.0.2)
- LeadKit (0.5.1):
- LeadKit/Core (= 0.5.1)
- LeadKit/Core (0.5.1):
- CocoaLumberjack/Swift (~> 3.1.0)
- ObjectMapper (~> 2.2)
- RxAlamofire (= 3.0.2)
- RxCocoa (= 3.4.0)
- RxSwift (= 3.4.0)
- TableKit (~> 2.3.1)
- IDZSwiftCommonCrypto (0.10.0)
- InputMask (3.0.0)
- KeychainAccess (3.1.0)
- LeadKit (0.6.0):
- LeadKit/Core (= 0.6.0)
- LeadKit/Core (0.6.0):
- CocoaLumberjack/Swift (~> 3.3.0)
- ObjectMapper (~> 3.0.0)
- RxAlamofire (= 4.0.0)
- RxCocoa (= 4.0.0)
- RxSwift (= 4.0.0)
- TableKit (~> 2.5.0)
- UIScrollView-InfiniteScroll (~> 1.0.0)
- LeadKit/Core-iOS-Extension (0.5.1):
- CocoaLumberjack/Swift (~> 3.1.0)
- ObjectMapper (~> 2.2)
- RxAlamofire (= 3.0.2)
- RxCocoa (= 3.4.0)
- RxSwift (= 3.4.0)
- ObjectMapper (2.2.6)
- RxAlamofire (3.0.2):
- RxAlamofire/Core (= 3.0.2)
- RxAlamofire/Core (3.0.2):
- Alamofire (~> 4.0)
- RxSwift (~> 3.0)
- RxCocoa (3.4.0):
- RxSwift (~> 3.4)
- RxSwift (3.4.0)
- SwiftValidator (4.0.0)
- TableKit (2.3.1)
- UIScrollView-InfiniteScroll (1.0.1)
- LeadKit/Core-iOS-Extension (0.6.0):
- CocoaLumberjack/Swift (~> 3.3.0)
- ObjectMapper (~> 3.0.0)
- RxAlamofire (= 4.0.0)
- RxCocoa (= 4.0.0)
- RxSwift (= 4.0.0)
- ObjectMapper (3.0.0)
- RxAlamofire (4.0.0):
- RxAlamofire/Core (= 4.0.0)
- RxAlamofire/Core (4.0.0):
- Alamofire (~> 4.5)
- RxSwift (~> 4.0)
- RxCocoa (4.0.0):
- RxSwift (~> 4.0)
- RxSwift (4.0.0)
- SwiftValidator (5.0.0)
- TableKit (2.5.0)
- UIScrollView-InfiniteScroll (1.0.2)
DEPENDENCIES:
- IDZSwiftCommonCrypto (= 0.9.1)
- InputMask (= 2.2.5)
- KeychainAccess (= 3.0.2)
- LeadKit (= 0.5.1)
- LeadKit/Core-iOS-Extension (= 0.5.1)
- SwiftValidator (= 4.0.0)
- IDZSwiftCommonCrypto
- InputMask (= 3.0.0)
- KeychainAccess (= 3.1.0)
- LeadKit (= 0.6.0)
- LeadKit/Core-iOS-Extension (= 0.6.0)
- SwiftValidator (= 5.0.0)
SPEC CHECKSUMS:
Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d
CocoaLumberjack: 8311463ddf9ee86a06ef92a071dd656c89244500
IDZSwiftCommonCrypto: c44fe5c0219a219846b56b4c148615dd06e58591
InputMask: fe1da1c6bf39133d88c1f79c507bcb0bf7728d51
KeychainAccess: a986406022dfc7c634c691ad3bec670cc6a32002
LeadKit: a66ca7c85b3e33deb11b6544fa80f45c9f0044e4
ObjectMapper: 042708195cc46c20871cbcbec0453826398273fd
RxAlamofire: bc53604b29fd2d220cfaa490c736cc4500819f34
RxCocoa: d14ef6b6029e1ddc6e966508c09289090de68ff9
RxSwift: 3789a1af753002a14edecdb698a2424624296a9c
SwiftValidator: 2aa43104ac8baaaeaa297f1dc18371c063543fd9
TableKit: 02e041b443f75fa3e9f1ee6024d4b256305bd904
UIScrollView-InfiniteScroll: a90df4ba4a7ca1926128ade34a850ddbdf74c564
Alamofire: 2d95912bf4c34f164fdfc335872e8c312acaea4a
CocoaLumberjack: 3c8c74683302f9012bb168e1c4b7ae3c0b558431
IDZSwiftCommonCrypto: 4eef2c46e262dfbcbc1fd76365e066336680ad7d
InputMask: 37c273bde6705187d80cf0b4240cb42ea92096c3
KeychainAccess: 94c5540b32eabf7bc32bfb976a268e8ea05fd6da
LeadKit: a8b51716890f6d19e2b4e6e5217883d7834d4185
ObjectMapper: 92230db59bf8f341a5c3a3cf0b9fbdde3cf0d87f
RxAlamofire: 6ea579ac53bf14cb4bc7049a3866e5a769989b1d
RxCocoa: d62846ca96495d862fa4c59ea7d87e5031d7340e
RxSwift: fd680d75283beb5e2559486f3c0ff852f0d35334
SwiftValidator: 46cdd2061962df3ee8bab3c536dea9b34191d459
TableKit: 42d4dff2944f273cdeec2ef6352064eb6a9a355b
UIScrollView-InfiniteScroll: c132d6d5851daff229ab4a1060ccf70a05a051c9
PODFILE CHECKSUM: 6f750f6723897b213ed701c061a4f70baaeb4d54
PODFILE CHECKSUM: 96dea11fb103a275758c4ef3e731c4cce206746d
COCOAPODS: 1.3.1

View File

@ -92,7 +92,7 @@ open class BasePassCodeViewController: UIViewController {
.subscribe(onNext: { [weak self] _ in
self?.resetUI()
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
private func enebleKeyboard() {
@ -217,7 +217,7 @@ extension BasePassCodeViewController: ConfigurableController {
self?.hideError()
self?.viewModel.setPassCodeText(text)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
viewModel.validationResult
.drive(onNext: { [weak self] validationResult in
@ -231,13 +231,13 @@ extension BasePassCodeViewController: ConfigurableController {
self?.showError(for: pasCodeError)
}
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
viewModel.passCodeControllerState
.drive(onNext: { [weak self] controllerState in
self?.configureUI(for: controllerState)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
open func addViews() {}

View File

@ -80,7 +80,7 @@ open class BasePassCodeViewModel: BaseViewModel {
self?.set(passCode: passCode)
}
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
validationResultHolder.asDriver()
.drive(onNext: { [weak self] validationResult in
@ -105,7 +105,7 @@ open class BasePassCodeViewModel: BaseViewModel {
}
}
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
// MARK: - Public

View File

@ -61,15 +61,15 @@ public extension Observable {
- retryLimit: how many times request can restarts
*/
func retryWithinErrors(_ errorTypes: [Error.Type] = [ConnectionError.self],
retryLimit: Int = DefaultNetworkService.retryLimit)
retryLimit: UInt = DefaultNetworkService.retryLimit)
-> Observable<Observable.E> {
return observeOn(CurrentThreadScheduler.instance)
.retryWhen { errors -> Observable<Observable.E> in
return errors.flatMapWithIndex { e, a -> Observable<Observable.E> in
let canRetry = errorTypes.contains { type(of: e) == $0 }
return errors.enumerated().flatMap { attempt, error -> Observable<Observable.E> in
let canRetry = errorTypes.contains { type(of: error) == $0 }
return (canRetry && a < retryLimit - 1) ? self : .error(e)
return (canRetry && attempt < retryLimit - 1) ? self : .error(error)
}
}
}
@ -82,7 +82,7 @@ public extension Observable {
- handler: block, that executes, when error occured
*/
func handleApiError<T: ApiErrorProtocol>(_ apiErrorType: T,
handler: @escaping () -> Void) -> Observable<Observable.E>
handler: @escaping () -> Void) -> Observable<Observable.E>
where T.RawValue == Int {
return observeOn(CurrentThreadScheduler.instance)
@ -104,7 +104,7 @@ public extension Observable {
isLoading.onNext(false)
}, onError: { _ in
isLoading.onNext(false)
}, onSubscribe: { _ in
}, onSubscribe: {
isLoading.onNext(true)
})
}

View File

@ -25,14 +25,14 @@ extension CellFieldJumpingProtocol {
.subscribe(onNext: { [weak textField] _ in
textField?.resignFirstResponder()
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
shouldBecomeFirstResponder.asObservable()
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak textField] _ in
textField?.becomeFirstResponder()
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
}

View File

@ -43,7 +43,7 @@ open class BasePassCodeService {
// MARK: - Private stuff
fileprivate lazy var keychain: Keychain = {
return Keychain(service: keychainService)
return Keychain(service: BasePassCodeService.keychainService)
.synchronizable(false)
}()

View File

@ -70,7 +70,7 @@ class CellFieldsJumpingService {
.subscribe(onNext: { [weak self] in
self?.shouldGoForwardAction(from: offset)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
cellFields.lastActive?.returnButtonType = .done
@ -87,30 +87,30 @@ class CellFieldsJumpingService {
.subscribe(onNext: { [weak self] in
self?.shouldGoForwardAction(from: index)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
toolBar.shouldGoBackward.asObservable()
toolBar.shouldGoBackward
.subscribe(onNext: { [weak self] in
if let previousActive = self?.cellFields.previousActive(from: index) {
previousActive.shouldBecomeFirstResponder.onNext()
previousActive.shouldBecomeFirstResponder.onNext(Void())
}
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
toolBar.shouldEndEditing.asObservable()
.subscribe(onNext: {
field.shouldResignFirstResponder.onNext()
toolBar.shouldEndEditing
.subscribe(onNext: { [field] in
field.shouldResignFirstResponder.onNext(Void())
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
return toolBar
}
private func shouldGoForwardAction(from index: Int) {
if let nextActive = cellFields.nextActive(from: index) {
nextActive.shouldBecomeFirstResponder.onNext()
nextActive.shouldBecomeFirstResponder.onNext(Void())
} else {
didDone.onNext()
didDone.onNext(Void())
}
}

View File

@ -45,7 +45,7 @@ class MaskFieldTextProxy: NSObject {
self?.maskedProxy.put(text: value, into: textField)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
}

View File

@ -22,13 +22,14 @@
import Alamofire
import LeadKit
import ObjectMapper
import RxSwift
/// Default implementation of network service, which trust any server and use default timeout interval
open class DefaultNetworkService: NetworkService {
static let retryLimit = 3
open class var retryLimit: UInt {
return 3
}
private let disposeBag = DisposeBag()
@ -45,7 +46,7 @@ open class DefaultNetworkService: NetworkService {
public override init(sessionManager: SessionManager) {
super.init(sessionManager: sessionManager)
activityIndicatorBinding()?.addDisposableTo(disposeBag)
activityIndicatorBinding()?.disposed(by: disposeBag)
}
// MARK: - Default Values

View File

@ -58,7 +58,7 @@ class ValidationItem {
.subscribe(onNext: { [weak self] value in
self?.validate(text: value)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
@discardableResult

View File

@ -97,7 +97,7 @@ class ValidationService {
}
.map { $0 ? ValidationServiceState.valid : .invalid }
.bind(to: stateHolder)
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
}

View File

@ -34,13 +34,13 @@ class CellTextField: UITextField {
.drive(onNext: {
viewModel.setTextValue($0)
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
rx.controlEvent(.editingDidEndOnExit).asObservable()
.subscribe(onNext: {
viewModel.shouldGoForward.onNext()
rx.controlEvent(.editingDidEndOnExit)
.subscribe(onNext: { [viewModel] in
viewModel.shouldGoForward.onNext(Void())
})
.addDisposableTo(disposeBag)
.disposed(by: disposeBag)
}
}

View File

@ -93,15 +93,15 @@ class CellTextFieldToolBar: UIToolbar, CellFieldsToolBarProtocol {
// MARK: - Actions
@objc private func backAction() {
shouldGoBackward.onNext()
shouldGoBackward.onNext(Void())
}
@objc private func forwardAction() {
shouldGoForward.onNext()
shouldGoForward.onNext(Void())
}
@objc private func doneAction() {
shouldEndEditing.onNext()
shouldEndEditing.onNext(Void())
}
}

1
README.md Normal file
View File

@ -0,0 +1 @@
# LeadKitAdditions