Merge pull request #185 from TouchInstinct/feature/carthage
Feature/carthage
This commit is contained in:
commit
d9a4cf03c9
|
|
@ -1,5 +1,8 @@
|
|||
# Changelog
|
||||
|
||||
### 0.9.7
|
||||
- **Add**: Carthage support.
|
||||
|
||||
### 0.9.6
|
||||
- **Add**: Add new `configureSeparators` method to `SeparatorRowBox` array.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
binary "https://raw.github.com/petropavel13/CarthageBinaries/master/SwiftDate/SwiftDate.json"
|
||||
github "ReactiveX/RxSwift"
|
||||
binary "https://raw.github.com/petropavel13/CarthageBinaries/master/RxAlamofire/RxAlamofire.json"
|
||||
github "maxsokolov/TableKit"
|
||||
github "pronebird/UIScrollView-InfiniteScroll"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
github "Alamofire/Alamofire" "4.8.1"
|
||||
github "ReactiveX/RxSwift" "4.4.0"
|
||||
github "RxSwiftCommunity/RxAlamofire" "4.3.0"
|
||||
github "malcommac/SwiftDate" "5.1.0"
|
||||
github "maxsokolov/TableKit" "2.8.1"
|
||||
github "pronebird/UIScrollView-InfiniteScroll" "1.1.0"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "LeadKit"
|
||||
s.version = "0.9.6"
|
||||
s.version = "0.9.7"
|
||||
s.summary = "iOS framework with a bunch of tools for rapid development"
|
||||
s.homepage = "https://github.com/TouchInstinct/LeadKit"
|
||||
s.license = "Apache License, Version 2.0"
|
||||
|
|
@ -22,9 +22,6 @@ Pod::Spec.new do |s|
|
|||
ss.watchos.deployment_target = '2.0'
|
||||
|
||||
ss.source_files = "Sources/**/*.swift"
|
||||
ss.ios.exclude_files = [
|
||||
"Sources/Extensions/NetworkService/NetworkService+ActivityIndicator.swift",
|
||||
]
|
||||
ss.watchos.exclude_files = [
|
||||
"Sources/Classes/Controllers/**/*",
|
||||
"Sources/Classes/Views/SeparatorRowBox/*",
|
||||
|
|
@ -39,7 +36,6 @@ Pod::Spec.new do |s|
|
|||
"Sources/Classes/Views/BasePlaceholderView/*",
|
||||
"Sources/Extensions/CABasicAnimation/*",
|
||||
"Sources/Extensions/CGFloat/CGFloat+Pixels.swift",
|
||||
"Sources/Extensions/NetworkService/NetworkService+ActivityIndicator-UIApplication.swift",
|
||||
"Sources/Extensions/NetworkService/NetworkService+RxLoadImage.swift",
|
||||
"Sources/Extensions/DataLoading/GeneralDataLoading/GeneralDataLoadingController+DefaultImplementation.swift",
|
||||
"Sources/Extensions/DataLoading/PaginationDataLoading/*",
|
||||
|
|
@ -74,13 +70,10 @@ Pod::Spec.new do |s|
|
|||
"Sources/Classes/Views/EmptyCell/*",
|
||||
"Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift",
|
||||
"Sources/Structures/Drawing/CALayerDrawingOperation.swift",
|
||||
"Sources/Extensions/NetworkService/NetworkService+ActivityIndicator-UIApplication.swift",
|
||||
"Sources/Extensions/DataLoading/PaginationDataLoading/*",
|
||||
"Sources/Extensions/Support/UIScrollView+Support.swift",
|
||||
"Sources/Extensions/Support/UINavigationItem+Support.swift",
|
||||
"Sources/Extensions/TableKit/**/*.swift",
|
||||
"Sources/Extensions/UIKit/UIApplication/UIApplication+OpenUrlSupport.swift",
|
||||
"Sources/Extensions/UIKit/UIApplication/UIApplication+Cellular.swift",
|
||||
"Sources/Extensions/Array/Array+SeparatorRowBoxExtensions.swift",
|
||||
"Sources/Extensions/Array/Array+RowExtensions.swift",
|
||||
"Sources/Extensions/Views/SeparatorCell/*",
|
||||
|
|
@ -90,39 +83,15 @@ Pod::Spec.new do |s|
|
|||
"Sources/Structures/DataLoading/PaginationDataLoading/*"
|
||||
]
|
||||
|
||||
ss.dependency "RxSwift", '~> 4.3'
|
||||
ss.dependency "RxCocoa", '~> 4.3'
|
||||
ss.dependency "RxAlamofire", '~> 4.3'
|
||||
ss.dependency "SwiftDate", '~> 5.0'
|
||||
ss.dependency "RxSwift", '~> 4'
|
||||
ss.dependency "RxCocoa", '~> 4'
|
||||
ss.dependency "RxAlamofire", '~> 4'
|
||||
ss.dependency "SwiftDate", '~> 5.1'
|
||||
|
||||
ss.ios.dependency "TableKit", '~> 2.8'
|
||||
ss.ios.dependency "UIScrollView-InfiniteScroll", '~> 1.1.0'
|
||||
end
|
||||
|
||||
s.subspec 'Core-iOS-Extension' do |ss|
|
||||
ss.platform = :ios, '9.0'
|
||||
|
||||
ss.source_files = "Sources/**/*.swift"
|
||||
|
||||
ss.exclude_files = [
|
||||
"Sources/Classes/Views/EmptyCell/*",
|
||||
"Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift",
|
||||
"Sources/Extensions/NetworkService/NetworkService+ActivityIndicator-UIApplication.swift",
|
||||
"Sources/Extensions/DataLoading/PaginationDataLoading/*",
|
||||
"Sources/Extensions/UIKit/UIApplication/UIApplication+OpenUrlSupport.swift",
|
||||
"Sources/Extensions/UIKit/UIApplication/UIApplication+Cellular.swift",
|
||||
"Sources/Extensions/Array/Array+SeparatorRowBoxExtensions.swift"
|
||||
]
|
||||
|
||||
ss.dependency "RxSwift", '~> 4.3'
|
||||
ss.dependency "RxCocoa", '~> 4.3'
|
||||
ss.dependency "RxAlamofire", '~> 4.3'
|
||||
ss.dependency "SwiftDate", '~> 5.0'
|
||||
|
||||
ss.ios.dependency "TableKit", '~> 2.8'
|
||||
|
||||
end
|
||||
|
||||
s.default_subspec = 'Core'
|
||||
|
||||
end
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,80 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6782BB901EB31CFE0086E0B8"
|
||||
BuildableName = "LeadKit.framework"
|
||||
BlueprintName = "LeadKit watchOS"
|
||||
ReferencedContainer = "container:LeadKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6782BB901EB31CFE0086E0B8"
|
||||
BuildableName = "LeadKit.framework"
|
||||
BlueprintName = "LeadKit watchOS"
|
||||
ReferencedContainer = "container:LeadKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6782BB901EB31CFE0086E0B8"
|
||||
BuildableName = "LeadKit.framework"
|
||||
BlueprintName = "LeadKit watchOS"
|
||||
ReferencedContainer = "container:LeadKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
10
Podfile
10
Podfile
|
|
@ -37,7 +37,7 @@ abstract_target 'LeadKit' do
|
|||
end
|
||||
|
||||
target 'LeadKit watchOS' do
|
||||
platform :watchos, '2.0'
|
||||
platform :watchos, '3.0'
|
||||
|
||||
use_frameworks!
|
||||
|
||||
|
|
@ -57,13 +57,5 @@ abstract_target 'LeadKit' do
|
|||
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
# 1.5+
|
||||
installer.pods_project.build_configurations.each do |config|
|
||||
config.build_settings.delete('CODE_SIGNING_ALLOWED')
|
||||
config.build_settings.delete('CODE_SIGNING_REQUIRED')
|
||||
end
|
||||
end
|
||||
|
||||
# If you have slow HDD
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = "true"
|
||||
|
|
|
|||
32
Podfile.lock
32
Podfile.lock
|
|
@ -1,16 +1,18 @@
|
|||
PODS:
|
||||
- Alamofire (4.7.3)
|
||||
- Alamofire (4.8.1)
|
||||
- RxAlamofire (4.3.0):
|
||||
- RxAlamofire/Core (= 4.3.0)
|
||||
- RxAlamofire/Core (4.3.0):
|
||||
- Alamofire (~> 4.5)
|
||||
- RxSwift (~> 4)
|
||||
- RxCocoa (4.3.1):
|
||||
- RxAtomic (4.4.0)
|
||||
- RxCocoa (4.4.0):
|
||||
- RxSwift (~> 4.0)
|
||||
- RxSwift (4.3.1)
|
||||
- SwiftDate (5.0.9)
|
||||
- SwiftLint (0.27.0)
|
||||
- TableKit (2.8.0)
|
||||
- RxSwift (4.4.0):
|
||||
- RxAtomic (~> 4.4)
|
||||
- SwiftDate (5.1.0)
|
||||
- SwiftLint (0.30.1)
|
||||
- TableKit (2.8.1)
|
||||
- UIScrollView-InfiniteScroll (1.1.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
|
|
@ -26,6 +28,7 @@ SPEC REPOS:
|
|||
https://github.com/cocoapods/specs.git:
|
||||
- Alamofire
|
||||
- RxAlamofire
|
||||
- RxAtomic
|
||||
- RxCocoa
|
||||
- RxSwift
|
||||
- SwiftDate
|
||||
|
|
@ -34,15 +37,16 @@ SPEC REPOS:
|
|||
- UIScrollView-InfiniteScroll
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
|
||||
Alamofire: 16ce2c353fb72865124ddae8a57c5942388f4f11
|
||||
RxAlamofire: 09624d0f2d48ed8b686e4eb4cf68e28cbd2df556
|
||||
RxCocoa: 78763c7b07d02455598d9fc3c1ad091a28b73635
|
||||
RxSwift: fe0fd770a43acdb7d0a53da411c9b892e69bb6e4
|
||||
SwiftDate: 52b718d32ec006861a2be2756cbfa482d438e781
|
||||
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073
|
||||
TableKit: d635663343d00e209f258e35d4ee0072ad1beb1a
|
||||
RxAtomic: eacf60db868c96bfd63320e28619fe29c179656f
|
||||
RxCocoa: df63ebf7b9a70d6b4eeea407ed5dd4efc8979749
|
||||
RxSwift: 5976ecd04fc2fefd648827c23de5e11157faa973
|
||||
SwiftDate: 6329e58969a2de31cea7f1ee1143b247693196e7
|
||||
SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7
|
||||
TableKit: 18a0049dea981c1106409bdeebc763ef74d36f02
|
||||
UIScrollView-InfiniteScroll: 3ef456bcbe759c19f510a383cff96e6647c98c98
|
||||
|
||||
PODFILE CHECKSUM: fd9789ede36fcba83a5b12f15edf8b32183698ba
|
||||
PODFILE CHECKSUM: abec65fc699c906f3429fd91a31217e4263a7e88
|
||||
|
||||
COCOAPODS: 1.6.0.beta.2
|
||||
COCOAPODS: 1.6.0.rc.1
|
||||
|
|
|
|||
|
|
@ -33,5 +33,4 @@ open class BaseCollectionContentController<ViewModel>: BaseScrollContentControll
|
|||
public var collectionView: UICollectionView {
|
||||
return customView.collectionView
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,5 +66,4 @@ open class BaseConfigurableController<ViewModel>: UIViewController, Configurable
|
|||
open func configureBarButtons() {
|
||||
// override in subclass
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,5 +51,4 @@ open class BaseCustomViewController<ViewModel, View: UIView>: BaseConfigurableCo
|
|||
open func createView() -> View {
|
||||
return View()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ open class BaseScrollContentController<ViewModel, View: ScrollViewHolderView>: B
|
|||
public var scrollView: UIScrollView {
|
||||
return customView.scrollView
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension BaseScrollContentController {
|
||||
|
|
@ -67,5 +66,4 @@ public extension BaseScrollContentController {
|
|||
automaticallyAdjustsScrollViewInsets = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,5 +49,4 @@ open class BaseTableContentController<ViewModel>: BaseScrollContentController<Vi
|
|||
public var tableView: UITableView {
|
||||
return customView.tableView
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ public class FixedPageCursor<Cursor: CursorType>: CursorType, RxDataSource {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// FixedPageCursor subclass with implementation of ResettableType
|
||||
|
|
@ -87,5 +86,4 @@ public class ResettableFixedPageCursor<Cursor: ResettableCursorType>: FixedPageC
|
|||
public required init(resetFrom other: ResettableFixedPageCursor) {
|
||||
super.init(cursor: other.cursor.reset(), pageSize: other.pageSize)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public extension CursorType {
|
|||
|
||||
return ResettableMapCursor(cursor: self, transform: transform)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Map cursor implementation with enclosed cursor for fetching results
|
||||
|
|
@ -87,7 +86,6 @@ public class MapCursor<Cursor: CursorType, T>: CursorType, RxDataSource {
|
|||
return transformedNewItems
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// MapCursor subclass with implementation of ResettableType
|
||||
|
|
@ -102,5 +100,4 @@ public class ResettableMapCursor<Cursor: ResettableCursorType, T>: MapCursor<Cur
|
|||
public required init(resetFrom other: ResettableMapCursor) {
|
||||
super.init(cursor: other.cursor.reset(), transform: other.transform)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public final class SingleLoadCursorConfiguration<Element>: TotalCountCursorConfi
|
|||
public init(resetFrom other: SingleLoadCursorConfiguration) {
|
||||
self.loadingSingle = other.loadingSingle
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Cursor implementation for single load operation
|
||||
|
|
@ -91,5 +90,4 @@ public class SingleLoadCursor<Element>: ResettableCursorType {
|
|||
content = result
|
||||
exhausted = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,5 +61,4 @@ public class StaticCursor<Element>: ResettableRxDataSourceCursor {
|
|||
return .just(self.content)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,5 +64,4 @@ public final class TotalCountCursor<CursorConfiguration: TotalCountCursorConfigu
|
|||
$0.results
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,5 +128,4 @@ open class GeneralDataLoadingViewModel<ResultType>: BaseViewModel, GeneralDataLo
|
|||
open func onErrorState(error: Error) {
|
||||
// override in subclass
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
case reload
|
||||
case retry
|
||||
case next
|
||||
|
||||
}
|
||||
|
||||
override public func reload() {
|
||||
|
|
@ -59,6 +58,7 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
}
|
||||
|
||||
state = .initialLoading(after: state)
|
||||
|
||||
case .next:
|
||||
if case .exhausted = state {
|
||||
fatalError("You shouldn't call load(.next) after got .exhausted state!")
|
||||
|
|
@ -75,6 +75,7 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
switch after {
|
||||
case .initial, .empty: // cursor exhausted after creation
|
||||
state = .empty
|
||||
|
||||
default:
|
||||
super.onGot(error: error)
|
||||
}
|
||||
|
|
@ -88,5 +89,4 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
state = .exhausted
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,10 +245,12 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
|
|||
let topConstraint = placeholderView.topAnchor.constraint(equalTo: placeholderWrapperView.topAnchor)
|
||||
let bottomConstraint = placeholderView.bottomAnchor.constraint(equalTo: placeholderWrapperView.bottomAnchor)
|
||||
|
||||
NSLayoutConstraint.activate([leadingConstraint,
|
||||
trailingConstraint,
|
||||
topConstraint,
|
||||
bottomConstraint])
|
||||
NSLayoutConstraint.activate([
|
||||
leadingConstraint,
|
||||
trailingConstraint,
|
||||
topConstraint,
|
||||
bottomConstraint
|
||||
])
|
||||
|
||||
currentPlaceholderViewTopConstraint = topConstraint
|
||||
|
||||
|
|
@ -311,7 +313,7 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
|
|||
.filter { $0 }
|
||||
.delay(0.5, scheduler: MainScheduler.instance)
|
||||
.asDriver(onErrorJustReturn: true)
|
||||
.map { _ in state }
|
||||
.replace(with: state)
|
||||
}
|
||||
}
|
||||
.drive(stateChanged)
|
||||
|
|
@ -326,18 +328,17 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
|
|||
let notificationCenter = NotificationCenter.default.rx
|
||||
|
||||
notificationCenter.notification(UIApplication.willResignActiveNotification)
|
||||
.map { _ in false }
|
||||
.replace(with: false)
|
||||
.asDriver(onErrorJustReturn: false)
|
||||
.drive(applicationCurrentyActive)
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
notificationCenter.notification(UIApplication.didBecomeActiveNotification)
|
||||
.map { _ in true }
|
||||
.replace(with: true)
|
||||
.asDriver(onErrorJustReturn: true)
|
||||
.drive(applicationCurrentyActive)
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension PaginationWrapper {
|
||||
|
|
@ -347,16 +348,22 @@ private extension PaginationWrapper {
|
|||
switch value {
|
||||
case .initial:
|
||||
base.onInitialState()
|
||||
|
||||
case .initialLoading(let after):
|
||||
base.onLoadingState(afterState: after)
|
||||
|
||||
case .loadingMore(let after):
|
||||
base.onLoadingMoreState(afterState: after)
|
||||
case .results(let newItems, let from, let after):
|
||||
|
||||
case let .results(newItems, from, after):
|
||||
base.onResultsState(newItems: newItems, from: from, afterState: after)
|
||||
case .error(let error, let after):
|
||||
|
||||
case let .error(error, after):
|
||||
base.onErrorState(error: error, afterState: after)
|
||||
|
||||
case .empty:
|
||||
base.onEmptyState()
|
||||
|
||||
case .exhausted:
|
||||
base.onExhaustedState()
|
||||
}
|
||||
|
|
@ -380,5 +387,4 @@ private extension PaginationWrapper {
|
|||
base.currentPlaceholderViewTopConstraint?.constant = -value.y
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,5 +62,4 @@ open class RxDataLoadingModel<LoadingStateType: DataLoadingState>: RxNetworkOper
|
|||
func updateStateAfterResult(from dataSource: DataSourceType) {
|
||||
// override in subcass if needed
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,5 +96,4 @@ open class RxNetworkOperationModel<LoadingStateType: NetworkOperationState>: Net
|
|||
stateRelay.accept(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ open class NetworkService {
|
|||
private let lock = NSRecursiveLock()
|
||||
|
||||
private let requestCountRelay = BehaviorRelay(value: 0)
|
||||
private var disposeBag = DisposeBag()
|
||||
|
||||
public let configuration: NetworkServiceConfiguration
|
||||
public let sessionManager: SessionManager
|
||||
|
||||
var requestCount: Driver<Int> {
|
||||
return requestCountRelay.asDriver()
|
||||
/// Driver that emits true when active requests count != 0 and false otherwise.
|
||||
public var isActivityIndicatorVisibleDriver: Driver<Bool> {
|
||||
return requestCountRelay.asDriver().map { $0 != 0 }.distinctUntilChanged()
|
||||
}
|
||||
|
||||
/// - Parameter sessionManager: Alamofire.SessionManager to use for requests
|
||||
|
|
@ -51,7 +51,6 @@ open class NetworkService {
|
|||
|
||||
self.configuration = configuration
|
||||
self.sessionManager = configuration.sessionManager
|
||||
bindToApplicationActivityIndicator()
|
||||
}
|
||||
|
||||
/// Perform reactive request to get mapped ObservableMappable model and http response
|
||||
|
|
@ -80,20 +79,6 @@ open class NetworkService {
|
|||
decoder: decoder)
|
||||
.counterTracking(for: self)
|
||||
}
|
||||
|
||||
/// Shows network activity indicator when requests in executed. Works only on iOS.
|
||||
public func bindToApplicationActivityIndicator() {
|
||||
// Fatal error: `drive*` family of methods can be only called from `MainThread`
|
||||
DispatchQueue.main.async {
|
||||
self.bindActivityIndicator()?.disposed(by: self.disposeBag)
|
||||
}
|
||||
}
|
||||
|
||||
/// Disable showing network activity indicator.
|
||||
public func unbindToApplicationActivityIndicator() {
|
||||
disposeBag = DisposeBag()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension NetworkService {
|
||||
|
|
@ -109,7 +94,6 @@ private extension NetworkService {
|
|||
requestCountRelay.accept(requestCountRelay.value - 1)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension Observable {
|
||||
|
|
@ -126,5 +110,4 @@ public extension Observable {
|
|||
networkService.decreaseRequestCounter()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ open class BasePlaceholderViewModel {
|
|||
self.buttonTitle = buttonTitle
|
||||
self.background = background
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension BasePlaceholderViewModel {
|
||||
|
|
@ -75,5 +74,4 @@ public extension BasePlaceholderViewModel {
|
|||
var hasCenterImage: Bool {
|
||||
return centerImage != nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ open class BasePlaceholderView: UIView, InitializableView {
|
|||
open func localize() {
|
||||
// override in subclass
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension BasePlaceholderView {
|
||||
|
|
@ -98,5 +97,4 @@ public extension BasePlaceholderView {
|
|||
button.isHidden = !viewModel.hasButton
|
||||
viewModel.buttonTitle?.configure(view: button)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,5 +44,4 @@ open class CollectionViewWrapperView: ScrollViewHolderView, CollectionViewHolder
|
|||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ internal final class TextPlaceholderView: UIView {
|
|||
case loading = "Loading..."
|
||||
case retry = "Retry"
|
||||
case retryLoadMore = "Retry load more"
|
||||
|
||||
}
|
||||
|
||||
init(title: PlaceholderText) {
|
||||
|
|
@ -52,5 +51,4 @@ internal final class TextPlaceholderView: UIView {
|
|||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,5 +58,4 @@ internal final class TextWithButtonPlaceholder: UIView {
|
|||
@objc private func buttonDidTapped(_ button: UIButton) {
|
||||
tapHandler()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,5 +61,4 @@ public final class EmptyCell: SeparatorCell, AppearanceConfigurable, Configurabl
|
|||
private func resetAppearance() {
|
||||
configure(appearance: Appearance())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,5 +50,4 @@ public final class EmptyCellRow: TableRow<EmptyCell> {
|
|||
override public var defaultHeight: CGFloat? {
|
||||
return rowHeight
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,13 +45,16 @@ open class SeparatorCell: UITableViewCell {
|
|||
switch separatorType {
|
||||
case .none:
|
||||
break
|
||||
|
||||
case .bottom(let configuration):
|
||||
updateBottomSeparator(with: configuration)
|
||||
setNeedsUpdateConstraints()
|
||||
|
||||
case .top(let configuration):
|
||||
updateTopSeparator(with: configuration)
|
||||
setNeedsUpdateConstraints()
|
||||
case .full(let topConfiguration, let bottomConfiguration):
|
||||
|
||||
case let .full(topConfiguration, bottomConfiguration):
|
||||
updateTopSeparator(with: topConfiguration)
|
||||
updateBottomSeparator(with: bottomConfiguration)
|
||||
setNeedsUpdateConstraints()
|
||||
|
|
@ -72,6 +75,8 @@ open class SeparatorCell: UITableViewCell {
|
|||
|
||||
// MARK: - Private
|
||||
|
||||
// swiftlint:disable implicitly_unwrapped_optional
|
||||
|
||||
private var topView: UIView!
|
||||
private var bottomView: UIView!
|
||||
|
||||
|
|
@ -87,10 +92,12 @@ open class SeparatorCell: UITableViewCell {
|
|||
private var bottomViewBottomConstraint: NSLayoutConstraint!
|
||||
private var bottomViewHeightConstraint: NSLayoutConstraint!
|
||||
|
||||
private var topSeparatorInsets = UIEdgeInsets.zero
|
||||
// swiftlint:enable implicitly_unwrapped_optional
|
||||
|
||||
private var topSeparatorInsets = UIEdgeInsets.zero
|
||||
private var bottomSeparatorInsets = UIEdgeInsets.zero
|
||||
|
||||
private var topSeparatorHeight = Constants.defaultSeparatorHeight
|
||||
private var topSeparatorHeight = Constants.defaultSeparatorHeight
|
||||
private var bottomSeparatorHeight = Constants.defaultSeparatorHeight
|
||||
|
||||
// MARK: - Initialization
|
||||
|
|
@ -108,13 +115,13 @@ open class SeparatorCell: UITableViewCell {
|
|||
}
|
||||
|
||||
override open func updateConstraints() {
|
||||
topViewTopConstraint.constant = topSeparatorInsets.top
|
||||
topViewLeftConstraint.constant = topSeparatorInsets.left
|
||||
topViewRightConstraint.constant = topSeparatorInsets.right
|
||||
topViewHeightConstraint.constant = topSeparatorHeight
|
||||
topViewTopConstraint.constant = topSeparatorInsets.top
|
||||
topViewLeftConstraint.constant = topSeparatorInsets.left
|
||||
topViewRightConstraint.constant = topSeparatorInsets.right
|
||||
topViewHeightConstraint.constant = topSeparatorHeight
|
||||
|
||||
bottomViewLeftConstraint.constant = bottomSeparatorInsets.left
|
||||
bottomViewRightConstraint.constant = bottomSeparatorInsets.right
|
||||
bottomViewLeftConstraint.constant = bottomSeparatorInsets.left
|
||||
bottomViewRightConstraint.constant = bottomSeparatorInsets.right
|
||||
bottomViewBottomConstraint.constant = bottomSeparatorInsets.bottom
|
||||
bottomViewHeightConstraint.constant = bottomSeparatorHeight
|
||||
|
||||
|
|
@ -147,8 +154,8 @@ open class SeparatorCell: UITableViewCell {
|
|||
|
||||
private func updateBottomSeparator(with configuration: SeparatorConfiguration) {
|
||||
bottomView.backgroundColor = configuration.color
|
||||
bottomSeparatorHeight = configuration.height
|
||||
bottomSeparatorInsets = configuration.insets
|
||||
bottomSeparatorHeight = configuration.height
|
||||
bottomSeparatorInsets = configuration.insets
|
||||
}
|
||||
|
||||
private func createConstraints() {
|
||||
|
|
@ -184,5 +191,4 @@ open class SeparatorCell: UITableViewCell {
|
|||
super.prepareForReuse()
|
||||
configureSeparator(with: .none)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ public struct SeparatorConfiguration {
|
|||
/// - parameter height: Height for separator. Default is 1 pixel
|
||||
/// - returns: Ready to use separator configuration
|
||||
public init(color: UIColor, insets: UIEdgeInsets = .zero, height: CGFloat = CGFloat(pixels: 1)) {
|
||||
self.color = color
|
||||
self.color = color
|
||||
self.insets = insets
|
||||
self.height = height
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,5 +39,4 @@ public final class SeparatorRowBox {
|
|||
self.row = row
|
||||
setSeparatorHandler = row.set
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,5 +153,4 @@ public final class SpinnerView: UIView, Animatable, LoadingIndicator {
|
|||
addAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,5 +44,4 @@ open class TableViewWrapperView: ScrollViewHolderView, TableViewHolder {
|
|||
required public init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ public final class DataModelFieldBinding<T> {
|
|||
public var fieldDriver: Driver<String?> {
|
||||
return modelDriver.map(getFieldClosure)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension DataModelFieldBinding {
|
||||
|
|
@ -87,7 +86,6 @@ public extension DataModelFieldBinding {
|
|||
getFieldClosure: getFieldClosure,
|
||||
mergeFieldClosure: mergeFieldClosure)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension DataModelFieldBinding where T == String? {
|
||||
|
|
@ -101,7 +99,6 @@ public extension DataModelFieldBinding where T == String? {
|
|||
getFieldClosure: { $0 },
|
||||
mergeFieldClosure: { $1 })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension BehaviorRelay {
|
||||
|
|
@ -119,7 +116,6 @@ public extension BehaviorRelay {
|
|||
getFieldClosure: getFieldClosure,
|
||||
mergeFieldClosure: mergeFieldClosure)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension BehaviorRelay where Element == String? {
|
||||
|
|
@ -130,5 +126,4 @@ public extension BehaviorRelay where Element == String? {
|
|||
func fieldBinding() -> DataModelFieldBinding<E> {
|
||||
return DataModelFieldBinding(modelRelay: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import RxSwift
|
|||
import RxCocoa
|
||||
|
||||
/// Class that used for binding text field with upper level view model.
|
||||
open class TextFieldViewModel<ViewEvents: TextFieldViewEvents,
|
||||
open class TextFieldViewModel < ViewEvents: TextFieldViewEvents,
|
||||
ViewModelEvents: TextFieldViewModelEvents> {
|
||||
|
||||
/// Events that can be emitted by view model.
|
||||
|
|
@ -66,7 +66,6 @@ open class TextFieldViewModel<ViewEvents: TextFieldViewEvents,
|
|||
public func unbindView() {
|
||||
disposeBag = DisposeBag()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension TextFieldViewModel {
|
||||
|
|
@ -97,5 +96,4 @@ public extension TextFieldViewModel {
|
|||
}
|
||||
.drive()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,5 +44,4 @@ open class BaseTextAttributes {
|
|||
self.color = color
|
||||
self.alignment = alignment
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,5 @@ open class XibView: UIView {
|
|||
|
||||
/// Provide initial configuration. Called once
|
||||
open func configure() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,4 @@ import Foundation
|
|||
public enum CursorError: Error {
|
||||
|
||||
case exhausted
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public enum GeneralDataLoadingState<DS: DataSource> {
|
|||
case result(newResult: DS.ResultType, from: DS)
|
||||
case error(error: Error)
|
||||
case empty
|
||||
|
||||
}
|
||||
|
||||
extension GeneralDataLoadingState: DataLoadingState {
|
||||
|
|
@ -70,6 +69,7 @@ extension GeneralDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .initial:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
|
@ -79,6 +79,7 @@ extension GeneralDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .result(let newResult, _):
|
||||
return newResult
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
@ -88,9 +89,9 @@ extension GeneralDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .error(let error):
|
||||
return error
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public indirect enum PaginationDataLoadingState<DS: DataSource> {
|
|||
case error(error: Error, after: PaginationDataLoadingState)
|
||||
case empty
|
||||
case exhausted
|
||||
|
||||
}
|
||||
|
||||
extension PaginationDataLoadingState: DataLoadingState {
|
||||
|
|
@ -74,6 +73,7 @@ extension PaginationDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .initial:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
|
@ -83,6 +83,7 @@ extension PaginationDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .results(let newItems, _, _):
|
||||
return newItems
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
@ -92,9 +93,9 @@ extension PaginationDataLoadingState: DataLoadingState {
|
|||
switch self {
|
||||
case .error(let error, _):
|
||||
return error
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,5 +35,4 @@ public enum RequestError: Error {
|
|||
case network(error: Error, response: Data?)
|
||||
case invalidResponse(error: AFError, response: Data?)
|
||||
case mapping(error: Error, response: Data)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,4 @@ public enum ContentLoadingViewModel<ContentType, PlaceholderType> {
|
|||
|
||||
case placeholder(PlaceholderType)
|
||||
case content(ContentType)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,5 +30,4 @@ public enum ViewBackground {
|
|||
|
||||
case color(UIColor)
|
||||
case image(UIImage)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,5 +30,4 @@ public enum ViewText {
|
|||
|
||||
case string(String, textAttributes: BaseTextAttributes)
|
||||
case attributedString(NSAttributedString)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ public extension Reactive where Base: DataRequest {
|
|||
private func response(onQueue queue: DispatchQueue) -> Observable<(HTTPURLResponse, Data)> {
|
||||
return responseResult(queue: queue, responseSerializer: DataRequest.dataResponseSerializer())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension ObservableType where E == ServerResponse {
|
||||
|
|
@ -87,5 +86,4 @@ private extension ObservableType where E == ServerResponse {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ enum RequestUsageError: Error {
|
|||
|
||||
case getMethodForbidden
|
||||
case urlEncodingForbidden
|
||||
|
||||
}
|
||||
|
||||
public extension Reactive where Base: SessionManager {
|
||||
|
|
@ -83,6 +82,7 @@ public extension Reactive where Base: SessionManager {
|
|||
parameters: parameters,
|
||||
encoding: requestParameters.encoding,
|
||||
headers: requestParameters.headers)
|
||||
|
||||
case .array(let parameters)?:
|
||||
guard let encoding = requestParameters.encoding as? JSONEncoding else {
|
||||
assertionFailure("Invalid encoding type with array parameter")
|
||||
|
|
@ -94,6 +94,7 @@ public extension Reactive where Base: SessionManager {
|
|||
parameters: parameters,
|
||||
encoding: encoding,
|
||||
headers: requestParameters.headers)
|
||||
|
||||
case .none:
|
||||
requestObservable = request(requestParameters.method,
|
||||
requestParameters.url,
|
||||
|
|
@ -139,7 +140,6 @@ public extension Reactive where Base: SessionManager {
|
|||
}
|
||||
.catchAsRequestError()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension ObservableType {
|
||||
|
|
@ -151,20 +151,25 @@ private extension ObservableType {
|
|||
switch error {
|
||||
case let requestError as RequestError:
|
||||
resultError = requestError
|
||||
|
||||
case let urlError as URLError:
|
||||
switch urlError.code {
|
||||
case .notConnectedToInternet:
|
||||
resultError = .noConnection
|
||||
|
||||
default:
|
||||
resultError = .network(error: urlError, response: response)
|
||||
}
|
||||
|
||||
case let afError as AFError:
|
||||
switch afError {
|
||||
case .responseSerializationFailed, .responseValidationFailed:
|
||||
resultError = .invalidResponse(error: afError, response: response)
|
||||
|
||||
default:
|
||||
resultError = .network(error: afError, response: response)
|
||||
}
|
||||
|
||||
default:
|
||||
resultError = .network(error: error, response: response)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ public extension Array where Element: Equatable {
|
|||
let allValues = values.flatMap { $0 }
|
||||
return filter { !allValues.contains($0) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension Array {
|
||||
|
|
@ -72,5 +71,4 @@ public extension Array {
|
|||
subscript(safe index: Index) -> Element? {
|
||||
return (index < count && index >= 0) ? self[index] : nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,5 +33,4 @@ public extension Array where Element: TableKitViewModel {
|
|||
var onlyRowsSection: TableSection {
|
||||
return TableSection(onlyRows: tableRows)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,5 +62,4 @@ public extension Array where Element == SeparatorRowBox {
|
|||
last?.set(separatorType: .bottom(lastSeparatorConfiguration))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,5 +31,4 @@ extension Array: TotalCountCursorListingResult {
|
|||
public var totalCount: Int {
|
||||
return count
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,5 +39,4 @@ extension CABasicAnimation {
|
|||
|
||||
return animation
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,5 +30,4 @@ public extension CGFloat {
|
|||
init(pixels: CGFloat) {
|
||||
self.init(pixels / UIScreen.main.nativeScale)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,5 +30,4 @@ public extension Comparable {
|
|||
func `in`(bounds: (lower: Self, upper: Self)) -> Self {
|
||||
return min(max(bounds.lower, self), bounds.upper)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ public extension RxDataSource where Self: CursorType {
|
|||
func resultSingle() -> Single<[Element]> {
|
||||
return loadNextBatch()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,5 +35,4 @@ public extension CursorType {
|
|||
var loadedElements: [Self.Element] {
|
||||
return self[0..<count]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,5 +40,4 @@ public extension TotalCountCursorListingResult {
|
|||
return DefaultTotalCountCursorListingResult(results: results,
|
||||
totalCount: totalCount)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ public extension GeneralDataLoadingController {
|
|||
func reload() {
|
||||
viewModel.reload()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension GeneralDataLoadingController where Self: DisposeBagHolder {
|
||||
|
|
@ -69,5 +68,4 @@ public extension GeneralDataLoadingController where Self: DisposeBagHolder {
|
|||
func bindLoadingState() {
|
||||
bindLoadingState(from: viewModel.loadingStateDriver)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,18 +31,21 @@ internal extension GeneralDataLoadingHandler where Self: AnyObject {
|
|||
switch value {
|
||||
case .loading:
|
||||
base.onLoadingState()
|
||||
|
||||
case .result(let newResult, _):
|
||||
base.onResultsState(result: newResult)
|
||||
|
||||
case .empty:
|
||||
base.onEmptyState()
|
||||
|
||||
case .error(let error):
|
||||
base.onErrorState(error: error)
|
||||
|
||||
case .initial:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension GeneralDataLoadingHandler where Self: AnyObject & DisposeBagHolder {
|
||||
|
|
@ -55,5 +58,4 @@ public extension GeneralDataLoadingHandler where Self: AnyObject & DisposeBagHol
|
|||
.drive(stateChangeBinder)
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ public extension GeneralDataLoadingState {
|
|||
switch self {
|
||||
case .result:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public extension GeneralDataLoadingViewModel {
|
|||
switch state {
|
||||
case .result(let newResult, _):
|
||||
return .just(newResult)
|
||||
|
||||
default:
|
||||
return .empty()
|
||||
}
|
||||
|
|
@ -50,10 +51,10 @@ public extension GeneralDataLoadingViewModel {
|
|||
switch state {
|
||||
case .result(let newResult, _):
|
||||
return .just(newResult)
|
||||
|
||||
default:
|
||||
return .empty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,5 @@
|
|||
|
||||
import UIKit.UICollectionView
|
||||
|
||||
extension UICollectionView: PaginationWrappable {
|
||||
|
||||
public var footerView: UIView? {
|
||||
get {
|
||||
return nil
|
||||
}
|
||||
set {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
extension UICollectionView: BackgroundViewHolder {
|
||||
}
|
||||
|
|
@ -32,5 +32,4 @@ extension UITableView: PaginationWrappable {
|
|||
tableFooterView = newValue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ extension Observable: RxDataSource {
|
|||
public func resultSingle() -> Single<ResultType> {
|
||||
return asSingle()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// waiting for Swift 4.2 release...
|
||||
|
|
@ -44,5 +43,4 @@ extension Single: RxDataSource {
|
|||
public func resultSingle() -> Single<ResultType> {
|
||||
return asObservable().asSingle()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ public extension DateFormattingService {
|
|||
|
||||
return format.dateToStringFormat.toString(dateInFormatterRegion)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension DateFormattingService where Self: Singleton {
|
||||
|
|
@ -102,5 +101,4 @@ public extension DateFormattingService where Self: Singleton {
|
|||
static func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String {
|
||||
return shared.string(from: date, format: format, formattedIn: formattedIn)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ public extension Double {
|
|||
switch roundType {
|
||||
case .normal:
|
||||
return (self * divider).rounded(.toNearestOrEven) / divider
|
||||
|
||||
case .down:
|
||||
return (self * divider).rounded(.down) / divider
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ public extension CGBitmapInfo {
|
|||
|
||||
static let alphaBitmapInfo = CGBitmapInfo(rawValue: CGBitmapInfo().rawValue | CGImageAlphaInfo.premultipliedFirst.rawValue)
|
||||
static let opaqueBitmapInfo = CGBitmapInfo(rawValue: CGBitmapInfo().rawValue | CGImageAlphaInfo.none.rawValue)
|
||||
|
||||
}
|
||||
|
||||
public extension CGContext {
|
||||
|
|
@ -74,5 +73,4 @@ public extension CGContext {
|
|||
space: colorSpace,
|
||||
bitmapInfo: bitmapInfo.rawValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public extension CGImage {
|
|||
switch alphaInfo {
|
||||
case .first, .last, .premultipliedFirst, .premultipliedLast:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,5 +64,4 @@ public extension CGImage {
|
|||
|
||||
return cropping(to: rect)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ public extension CGSize {
|
|||
var ceiledContextSize: CGContextSize {
|
||||
return (width: Int(ceil(width)), height: Int(ceil(height)))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ public extension CGSize {
|
|||
switch resizeMode {
|
||||
case .scaleToFill:
|
||||
ratio = 1
|
||||
|
||||
case .scaleAspectFill:
|
||||
ratio = max(horizontalRatio, verticalRatio)
|
||||
|
||||
case .scaleAspectFit:
|
||||
ratio = min(horizontalRatio, verticalRatio)
|
||||
}
|
||||
|
|
@ -70,5 +72,4 @@ public extension CGSize {
|
|||
return CGRect(origin: CGPoint(x: originX, y: originY),
|
||||
size: CGSize(width: newWidth, height: newHeight))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,6 @@ public extension UIImage {
|
|||
|
||||
return actionClosure(image)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@available(iOS 10.0, tvOS 10.0, *)
|
||||
|
|
@ -250,5 +249,4 @@ private extension DrawingOperation {
|
|||
self.apply(in: $0.cgContext)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,6 @@ public extension Support where Base: UIImage {
|
|||
|
||||
return actionClosure(image)?.support
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension CGImage {
|
||||
|
|
@ -250,7 +249,6 @@ private extension CGImage {
|
|||
opaque: false,
|
||||
flipY: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension DrawingOperation {
|
||||
|
|
@ -282,5 +280,4 @@ private extension DrawingOperation {
|
|||
|
||||
return UIImage(cgImage: image, scale: scale, orientation: .up)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,5 +35,4 @@ public extension FloatingPoint {
|
|||
func radiansToDegrees() -> Self {
|
||||
return self * 180 / .pi
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ public enum UserDefaultsError: Error {
|
|||
|
||||
case noSuchValue(key: String)
|
||||
case unableToDecode(decodingError: Error)
|
||||
|
||||
}
|
||||
|
||||
public extension UserDefaults {
|
||||
|
|
@ -65,7 +64,6 @@ public extension UserDefaults {
|
|||
try? set(object: newValue, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension Reactive where Base: UserDefaults {
|
||||
|
|
@ -104,5 +102,4 @@ public extension Reactive where Base: UserDefaults {
|
|||
try self.base.set(object: object, forKey: key, encoder: encoder)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public extension NSAttributedString {
|
|||
var mutable: NSMutableAttributedString {
|
||||
return NSMutableAttributedString(attributedString: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension NSMutableAttributedString {
|
||||
|
|
@ -54,5 +53,4 @@ public extension NSMutableAttributedString {
|
|||
var immutable: NSAttributedString {
|
||||
return NSAttributedString(attributedString: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2017 Touch Instinct
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the Software), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import RxSwift
|
||||
|
||||
public extension NetworkService {
|
||||
|
||||
/// Let netwrok service automatically show / hide activity indicator
|
||||
func bindActivityIndicator() -> Disposable? {
|
||||
return requestCount
|
||||
.map { $0 != 0 }
|
||||
.drive(UIApplication.shared.rx.isNetworkActivityIndicatorVisible)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2018 Touch Instinct
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the Software), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import RxSwift
|
||||
|
||||
public extension NetworkService {
|
||||
|
||||
/// Let netwrok service automatically show / hide activity indicator
|
||||
func bindActivityIndicator() -> Disposable? {
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@ extension NSNumber: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return self
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Decimal: NSNumberConvertible {
|
||||
|
|
@ -35,7 +34,6 @@ extension Decimal: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return NSDecimalNumber(decimal: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Int: NSNumberConvertible {
|
||||
|
|
@ -43,7 +41,6 @@ extension Int: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return NSNumber(value: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Int64: NSNumberConvertible {
|
||||
|
|
@ -51,7 +48,6 @@ extension Int64: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return NSNumber(value: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Double: NSNumberConvertible {
|
||||
|
|
@ -59,7 +55,6 @@ extension Double: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return NSNumber(value: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Float: NSNumberConvertible {
|
||||
|
|
@ -67,5 +62,4 @@ extension Float: NSNumberConvertible {
|
|||
public func asNSNumber() -> NSNumber {
|
||||
return NSNumber(value: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public extension NumberFormattingService {
|
|||
func number(from string: String, format: NumberFormatType) -> NSNumber? {
|
||||
return numberFormatter(for: format).number(from: string)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension NumberFormattingService where Self: Singleton {
|
||||
|
|
@ -56,5 +55,4 @@ public extension NumberFormattingService where Self: Singleton {
|
|||
static func number(from string: String, format: NumberFormatType) -> NSNumber? {
|
||||
return shared.number(from: string, format: format)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,5 +41,4 @@ public extension ObservableType {
|
|||
return Disposables.create()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public extension ObservableType {
|
|||
/// - Parameter value: A new element.
|
||||
/// - Returns: An observable sequence whose elements are equals to passed value.
|
||||
func replace<T>(with value: T) -> Observable<T> {
|
||||
return map { _ in value }
|
||||
return map { _ in value } // swiftlint:disable:this unused_map_parameter
|
||||
}
|
||||
|
||||
/// Replaces all emitted elements with Void.
|
||||
|
|
@ -45,5 +45,4 @@ public extension ObservableType {
|
|||
func asOptional() -> Observable<E?> {
|
||||
return map { $0 }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,5 +41,4 @@ public extension PrimitiveSequence where Trait == CompletableTrait {
|
|||
return Disposables.create()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public extension PrimitiveSequence where Trait == SingleTrait {
|
|||
/// - Parameter value: A new element.
|
||||
/// - Returns: An primitive sequence whose element is equal to passed value.
|
||||
func replace<T>(with value: T) -> PrimitiveSequence<Trait, T> {
|
||||
return map { _ in value }
|
||||
return map { _ in value } // swiftlint:disable:this unused_map_parameter
|
||||
}
|
||||
|
||||
/// Replaces emitted element with Void.
|
||||
|
|
@ -45,5 +45,4 @@ public extension PrimitiveSequence where Trait == SingleTrait {
|
|||
func asOptional() -> PrimitiveSequence<Trait, Element?> {
|
||||
return map { $0 }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public extension SharedSequence {
|
|||
/// - Parameter value: A new element.
|
||||
/// - Returns: An observable sequence whose elements are equals to passed value.
|
||||
func replace<T>(with value: T) -> SharedSequence<SharingStrategy, T> {
|
||||
return map { _ in value }
|
||||
return map { _ in value } // swiftlint:disable:this unused_map_parameter
|
||||
}
|
||||
|
||||
/// Replaces all emitted elements with Void.
|
||||
|
|
@ -45,5 +45,4 @@ public extension SharedSequence {
|
|||
func asOptional() -> SharedSequence<SharingStrategy, Element?> {
|
||||
return map { $0 }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,5 +64,4 @@ public extension Sequence {
|
|||
.flatMap { $0.results }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,5 +32,4 @@ public extension String {
|
|||
var nilIfEmpty: String? {
|
||||
return isEmpty ? nil : self
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,5 +32,4 @@ public extension String {
|
|||
func localized() -> String {
|
||||
return NSLocalizedString(self, comment: "")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,16 @@ public extension String {
|
|||
switch lastDigit {
|
||||
case 1:
|
||||
return stringOne
|
||||
|
||||
case 2...4:
|
||||
return stringTwo
|
||||
|
||||
case 5...9, 0:
|
||||
return stringMany
|
||||
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,22 +20,20 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import UIKit.UIApplication
|
||||
import Foundation
|
||||
|
||||
public extension UIApplication {
|
||||
|
||||
/// Attempt to open telprompt with given phone number.
|
||||
///
|
||||
/// - Parameter phoneNumber: Phone number to use in URL.
|
||||
func attemptPhoneCallWithPrompt(to phoneNumber: String) {
|
||||
public extension String {
|
||||
/// Telprompt url of arbitrary phone number. Can be nil if processed final string is not a valid URL.
|
||||
var telpromptURL: URL? {
|
||||
let characterSet = CharacterSet(charactersIn: "+0123456789")
|
||||
let cleanPhoneNumber = phoneNumber.components(separatedBy: characterSet.inverted).joined(separator: "")
|
||||
let cleanPhoneNumber = components(separatedBy: characterSet.inverted).joined()
|
||||
|
||||
if let escapedPhoneNumber = cleanPhoneNumber.addingPercentEncoding(withAllowedCharacters: characterSet),
|
||||
let phonePrompt = URL(string: "telprompt://\(escapedPhoneNumber)"),
|
||||
canOpenURL(phonePrompt) {
|
||||
let phonePrompt = URL(string: "telprompt://" + escapedPhoneNumber) {
|
||||
|
||||
support.open(phonePrompt)
|
||||
return phonePrompt
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -44,5 +44,4 @@ public extension Support where Base: UIScrollView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,5 +238,4 @@ public extension TableDirector {
|
|||
remove(at: index, with: animation, manualBeginEndUpdates: manualBeginEndUpdates)
|
||||
return insert(section: section, at: index, with: animation, manualBeginEndUpdates: manualBeginEndUpdates)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,5 +41,4 @@ public extension TableRow where CellType: AppearanceConfigurable {
|
|||
action.id = updateAppearanceActionId
|
||||
on(action)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public extension TableRow where CellType: SeparatorCell {
|
|||
action.id = configureSeparatorActionId
|
||||
on(action)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension TableRow where CellType: SeparatorCell {
|
||||
|
|
@ -50,5 +49,4 @@ public extension TableRow where CellType: SeparatorCell {
|
|||
var separatorRowBox: SeparatorRowBox {
|
||||
return SeparatorRowBox(row: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,5 +31,4 @@ public extension TableKitViewModel {
|
|||
var tableRow: RowType {
|
||||
return RowType(item: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ public extension TableSection {
|
|||
self.headerHeight = .leastNonzeroMagnitude
|
||||
self.footerHeight = .leastNonzeroMagnitude
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import Foundation
|
|||
extension TimeInterval {
|
||||
|
||||
private static let secondsInMinute = 60
|
||||
private static let minutesInHour = 60
|
||||
private static let hoursInDay = 24
|
||||
private static let secondsInHour = secondsInMinute * minutesInHour
|
||||
private static let secondsInDay = secondsInHour * hoursInDay
|
||||
private static let minutesInHour = 60
|
||||
private static let hoursInDay = 24
|
||||
private static let secondsInHour = secondsInMinute * minutesInHour
|
||||
private static let secondsInDay = secondsInHour * hoursInDay
|
||||
|
||||
public typealias TimeComponents = (days: Int, hours: Int, minutes: Int, seconds: Int)
|
||||
|
||||
|
|
@ -77,5 +77,4 @@ extension TimeInterval {
|
|||
timeInterval % TimeInterval.secondsInMinute
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ public extension UIColor {
|
|||
- parameter alpha: 0.0 - 1.0. The default is 1.0.
|
||||
*/
|
||||
convenience init(hex3: UInt16, alpha: CGFloat = 1) {
|
||||
let red = CGFloat((hex3 & 0xF00) >> 8) / 0xF
|
||||
let green = CGFloat((hex3 & 0x0F0) >> 4) / 0xF
|
||||
let blue = CGFloat((hex3 & 0x00F) >> 0) / 0xF
|
||||
let red = CGFloat((hex3 & 0xF00) >> 8) / 0xF
|
||||
let green = CGFloat((hex3 & 0x0F0) >> 4) / 0xF
|
||||
let blue = CGFloat((hex3 & 0x00F) >> 0) / 0xF
|
||||
self.init(red: red, green: green, blue: blue, alpha: alpha)
|
||||
}
|
||||
|
||||
|
|
@ -45,10 +45,10 @@ public extension UIColor {
|
|||
- parameter hex4: Four-digit hexadecimal value.
|
||||
*/
|
||||
convenience init(hex4: UInt16) {
|
||||
let red = CGFloat((hex4 & 0xF000) >> 12) / 0xF
|
||||
let green = CGFloat((hex4 & 0x0F00) >> 8) / 0xF
|
||||
let blue = CGFloat((hex4 & 0x00F0) >> 4) / 0xF
|
||||
let alpha = CGFloat((hex4 & 0x000F) >> 0) / 0xF
|
||||
let red = CGFloat((hex4 & 0xF000) >> 12) / 0xF
|
||||
let green = CGFloat((hex4 & 0x0F00) >> 8) / 0xF
|
||||
let blue = CGFloat((hex4 & 0x00F0) >> 4) / 0xF
|
||||
let alpha = CGFloat((hex4 & 0x000F) >> 0) / 0xF
|
||||
|
||||
self.init(red: red, green: green, blue: blue, alpha: alpha)
|
||||
}
|
||||
|
|
@ -60,9 +60,9 @@ public extension UIColor {
|
|||
- parameter alpha: alpha: 0.0 - 1.0. The default is 1.0.
|
||||
*/
|
||||
convenience init(hex6: UInt32, alpha: CGFloat = 1) {
|
||||
let red = CGFloat((hex6 & 0xFF0000) >> 16) / 0xFF
|
||||
let green = CGFloat((hex6 & 0x00FF00) >> 8) / 0xFF
|
||||
let blue = CGFloat((hex6 & 0x0000FF) >> 0) / 0xFF
|
||||
let red = CGFloat((hex6 & 0xFF0000) >> 16) / 0xFF
|
||||
let green = CGFloat((hex6 & 0x00FF00) >> 8) / 0xFF
|
||||
let blue = CGFloat((hex6 & 0x0000FF) >> 0) / 0xFF
|
||||
|
||||
self.init(red: red, green: green, blue: blue, alpha: alpha)
|
||||
}
|
||||
|
|
@ -73,10 +73,10 @@ public extension UIColor {
|
|||
- parameter hex8: Eight-digit hexadecimal value.
|
||||
*/
|
||||
convenience init(hex8: UInt32) {
|
||||
let red = CGFloat((hex8 & 0xFF000000) >> 24) / 0xFF
|
||||
let green = CGFloat((hex8 & 0x00FF0000) >> 16) / 0xFF
|
||||
let blue = CGFloat((hex8 & 0x0000FF00) >> 8) / 0xFF
|
||||
let alpha = CGFloat((hex8 & 0x000000FF) >> 0) / 0xFF
|
||||
let red = CGFloat((hex8 & 0xFF000000) >> 24) / 0xFF
|
||||
let green = CGFloat((hex8 & 0x00FF0000) >> 16) / 0xFF
|
||||
let blue = CGFloat((hex8 & 0x0000FF00) >> 8) / 0xFF
|
||||
let alpha = CGFloat((hex8 & 0x000000FF) >> 0) / 0xFF
|
||||
|
||||
self.init(red: red, green: green, blue: blue, alpha: alpha)
|
||||
}
|
||||
|
|
@ -109,6 +109,7 @@ public extension UIColor {
|
|||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
case 6, 8:
|
||||
if let hex = UInt32(hexStr, radix: 16) {
|
||||
if charactersCount == 6 {
|
||||
|
|
@ -119,9 +120,9 @@ public extension UIColor {
|
|||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue