Skip to content

Commit

Permalink
Merge pull request #4 from stefanrenne/feature/swift5
Browse files Browse the repository at this point in the history
Swift 5
  • Loading branch information
RuudPuts authored Jul 20, 2019
2 parents 69b449c + 3cd916b commit b55578c
Show file tree
Hide file tree
Showing 41 changed files with 653 additions and 534 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2
5.0
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: swift
os: osx
osx_image: xcode10.1
osx_image: xcode10.2
cache:
directories:
- Pods
Expand All @@ -12,15 +12,15 @@ env:
- SCHEME=Down
- CC_TEST_REPORTER_ID=4074485b984af5323f0806408b43441628bc6f72f523b89c5338f87ae807820a
matrix:
- DESTINATION="OS=12.1,name=iPhone XS"
- DESTINATION="platform=iOS Simulator,name=iPhone XS"
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- whoami
before_install:
- gem install activesupport -N
- gem install slather --no-rdoc
- gem install slather
- pod install --repo-update
script:
- fastlane test
Expand Down
311 changes: 176 additions & 135 deletions Down.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Down.xcodeproj/xcshareddata/xcschemes/Down.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Down.xcodeproj/xcshareddata/xcschemes/DownKit.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import Kingfisher

import RxSwift
import RxCocoa
import Result
import RxResult


class DownloadItemDetailViewController: UIViewController & Depending {
typealias Dependencies = RouterDependency
Expand Down Expand Up @@ -167,14 +166,14 @@ extension DownloadItemDetailViewController: ReactiveBinding {
.disposed(by: disposeBag)
}

private func bindItemDeleted(_ itemDeleted: Observable<Result<Void, DownError>>) {
private func bindItemDeleted(_ itemDeleted: Observable<Swift.Result<Void, DownError>>) {
itemDeleted
.do(
onSuccess: {
onSuccess: { _ in
self.dependencies.router.close(viewController: self)
},
onFailure: {
self.dependencies.errorHandler.handle(error: $0,
onFailure: { error in
self.dependencies.errorHandler.handle(error: error,
action: .download_deleteItem,
source: self)
}
Expand Down
3 changes: 1 addition & 2 deletions Down/Download/Item details/DownloadItemDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import UIKit
import DownKit
import RxSwift
import RxCocoa
import Result

struct DownloadItemDetailViewModel: Depending {
typealias Dependencies = DownloadInteractorFactoryDependency & DvrRequestBuilderDependency
Expand All @@ -34,7 +33,7 @@ extension DownloadItemDetailViewModel: ReactiveBindable {

struct Output {
let refinedItem: Driver<RefinedItem>
let itemDeleted: Observable<Result<Void, DownError>>
let itemDeleted: Observable<Swift.Result<Void, DownError>>
}
}

Expand Down
4 changes: 2 additions & 2 deletions Down/Download/Overview/DownloadStatusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import DownKit

import RxSwift
import RxCocoa
import RxResult


class DownloadStatusViewController: UIViewController & Depending {
typealias Dependencies = DownloadStatusTableController.Dependencies
Expand Down Expand Up @@ -210,7 +210,7 @@ extension DownloadStatusViewController: ReactiveBinding {

actions.forEach { data in
data.observable
.subscribeResult(onFailure: {
.subscribe(onFailure: {
self.dependencies.errorHandler.handle(error: $0, action: data.action, source: self)
})
.disposed(by: disposeBag)
Expand Down
17 changes: 8 additions & 9 deletions Down/Download/Overview/DownloadStatusViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import DownKit
import RxSwift
import RxCocoa
import Result
import RxResult


struct DownloadStatusViewModel: Depending {
typealias Dependencies = DownloadInteractorFactoryDependency & DownloadApplicationDependency
Expand All @@ -21,7 +20,7 @@ struct DownloadStatusViewModel: Depending {
var input = Input()
lazy var output = transform(input: input)

fileprivate let refreshInterval: TimeInterval = 2
fileprivate let refreshInterval: RxTimeInterval = .seconds(2)

init(dependencies: Dependencies) {
self.dependencies = dependencies
Expand All @@ -41,9 +40,9 @@ extension DownloadStatusViewModel: ReactiveBindable {
let sectionsData: Driver<[TableSectionData<DownloadItem>]>
let itemSelected: Observable<DownloadItem>

let queuePaused: Observable<Result<Bool, DownError>>
let queueResumed: Observable<Result<Bool, DownError>>
let historyPurged: Observable<Result<Bool, DownError>>
let queuePaused: Observable<Swift.Result<Bool, DownError>>
let queueResumed: Observable<Swift.Result<Bool, DownError>>
let historyPurged: Observable<Swift.Result<Bool, DownError>>
}
}

Expand Down Expand Up @@ -91,13 +90,13 @@ extension DownloadStatusViewModel {
.asDriver(onErrorJustReturn: DownloadQueue())
}

private func makePauseQueueInteractor() -> Observable<Result<Bool, DownError>> {
private func makePauseQueueInteractor() -> Observable<Swift.Result<Bool, DownError>> {
return dependencies.downloadInteractorFactory
.makePauseQueueInteractor(for: dependencies.downloadApplication)
.observeResult()
}

private func makeResumeQueueInteractor() -> Observable<Result<Bool, DownError>> {
private func makeResumeQueueInteractor() -> Observable<Swift.Result<Bool, DownError>> {
return dependencies.downloadInteractorFactory
.makeResumeQueueInteractor(for: dependencies.downloadApplication)
.observeResult()
Expand All @@ -112,7 +111,7 @@ extension DownloadStatusViewModel {
.asDriver(onErrorJustReturn: [])
}

private func makePurgeHistoryInteractor() -> Observable<Result<Bool, DownError>> {
private func makePurgeHistoryInteractor() -> Observable<Swift.Result<Bool, DownError>> {
return dependencies.downloadInteractorFactory
.makePurgeHistoryInteractor(for: dependencies.downloadApplication)
.observeResult()
Expand Down
2 changes: 1 addition & 1 deletion Down/Dvr/Add Show/DvrAddShowViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SkyFloatingLabelTextField
import DownKit
import RxSwift
import RxCocoa
import RxResult


class DvrAddShowViewController: UIViewController & Depending {
let dependencies: Dependencies
Expand Down
5 changes: 2 additions & 3 deletions Down/Dvr/Add Show/DvrAddShowViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import DownKit
import RxSwift
import RxCocoa
import Result
import RxResult


struct DvrAddShowViewModel: Depending {
typealias Dependencies = DvrApplicationDependency & DvrInteractorFactoryDependency
Expand All @@ -37,7 +36,7 @@ extension DvrAddShowViewModel: ReactiveBindable {
struct Output {
let searchResults: Observable<[DvrShow]>
let addingShow: Observable<DvrShow>
let showAdded: Observable<Result<DvrShow, DownError>>
let showAdded: Observable<Swift.Result<DvrShow, DownError>>
}
}

Expand Down
4 changes: 2 additions & 2 deletions Down/Dvr/Show details/DvrEpisodeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ extension DvrEpisodeCell: ReactiveBinding {
.disposed(by: disposeBag)

output.plotFetched
.delay(0.1, scheduler: MainScheduler.instance)
.delay(.milliseconds(100), scheduler: MainScheduler.instance)
.do(onNext: { _ in
DispatchQueue.main.async {
self.setNeedsLayout()
Expand All @@ -160,7 +160,7 @@ extension DvrEpisodeCell: ReactiveBinding {

private func bindStatusChanged(_ output: DvrEpisodeCellModel.Output) {
output.statusChanged
.subscribeResult(onFailure: {
.subscribe(onFailure: {
guard let context = self.context else {
return
}
Expand Down
3 changes: 1 addition & 2 deletions Down/Dvr/Show details/DvrEpisodeCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DownKit
import RxSwift
import RxCocoa
import RxRealm
import Result

struct DvrEpisodeCellModel: Depending {
typealias Dependencies = DvrInteractorFactoryDependency
Expand Down Expand Up @@ -43,7 +42,7 @@ extension DvrEpisodeCellModel: ReactiveBindable {
struct Output {
let episode: Observable<RefinedEpisode>
let plotFetched: Observable<Void>
let statusChanged: Observable<Result<Void, DownError>>
let statusChanged: Observable<Swift.Result<Void, DownError>>
}
}

Expand Down
3 changes: 1 addition & 2 deletions Down/Dvr/Show details/DvrSeasonHeaderViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DownKit
import RxSwift
import RxCocoa
import RxRealm
import Result

struct DvrSeasonTableHeaderViewModel: Depending {
typealias Dependencies = DvrInteractorFactoryDependency
Expand Down Expand Up @@ -41,7 +40,7 @@ extension DvrSeasonTableHeaderViewModel: ReactiveBindable {

struct Output {
let season: Observable<RefinedSeason>
let statusChanged: Observable<Result<Void, DownError>>
let statusChanged: Observable<Swift.Result<Void, DownError>>
}
}

Expand Down
2 changes: 1 addition & 1 deletion Down/Dvr/Show details/DvrSeasonTableHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension DvrSeasonTableHeaderView: ReactiveBinding {
.disposed(by: disposeBag)

output.statusChanged
.subscribeResult(onFailure: {
.subscribe(onFailure: {
guard let context = self.context else {
return
}
Expand Down
1 change: 0 additions & 1 deletion Down/Dvr/Show details/DvrShowDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import DownKit
import RxSwift
import UIKit
import RxResult

class DvrShowDetailViewController: UIViewController, Depending {
typealias Dependencies = DvrShowDetailsViewModel.Dependencies
Expand Down
5 changes: 2 additions & 3 deletions Down/Dvr/Show details/DvrShowDetailsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import DownKit
import RxSwift
import RxCocoa
import Result
import RxResult


struct DvrShowDetailsViewModel: Depending {
typealias Dependencies = DvrInteractorFactoryDependency & DvrRequestBuilderDependency
Expand Down Expand Up @@ -42,7 +41,7 @@ extension DvrShowDetailsViewModel: ReactiveBindable {

struct Output {
let refinedShow: Driver<RefinedShow>
let showDeleted: Observable<Result<Void, DownError>>
let showDeleted: Observable<Swift.Result<Void, DownError>>
}
}

Expand Down
2 changes: 1 addition & 1 deletion Down/Dvr/Shows overview/DvrShowsCollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ extension DvrShowsCollectionViewModel: UICollectionViewDelegate, UICollectionVie

extension DvrShowsCollectionViewModel {
func indexPath(for show: DvrShow) -> IndexPath {
return IndexPath(item: shows?.index(of: show) ?? NSNotFound, section: 0)
return IndexPath(item: shows?.firstIndex(of: show) ?? NSNotFound, section: 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import RxSwift
import RxCocoa
import RxSwiftExt
import RxRealm
import Result

class ApplicationSettingsViewController: UIViewController & Depending {
typealias Dependencies = ApplicationSettingsViewModel.Dependencies
Expand Down
12 changes: 5 additions & 7 deletions Down/Settings/Application/ApplicationSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import DownKit
import RxSwift
import RxCocoa
import Result
import RxResult


struct ApplicationSettingsViewModel: Depending {
typealias Dependencies = ApiApplicationInteractorFactoryDependency
Expand Down Expand Up @@ -172,17 +171,16 @@ extension ApplicationSettingsViewModel {
.makeApiKeyInteractor(for: application, credentials: credentials)
.observeResult()
.do(
onSuccess: {
guard let apiKey = $0 else {
onSuccess: { optionalApiKey in
guard let apiKey = optionalApiKey else {
NSLog("⚠️ -> Api key fetch was succesful, but no data was returend!")
return
}

NSLog("Api key -> \(apiKey)")
},
onFailure: { error in
}, onFailure: { error in
NSLog("ApiKey error -> \(error)")
}
}
)
.map { $0.value ?? nil }
.asSingle()
Expand Down
2 changes: 1 addition & 1 deletion Down/Shared/ErrorHandling/DownError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation
import DownKit
import RxResult


enum DownError: Error {
case request(Error)
Expand Down
5 changes: 2 additions & 3 deletions Down/Shared/Extensions/DownKitExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import DownKit
import RxSwift
import Result
import RxResult


extension Quality {
var displayString: String {
Expand Down Expand Up @@ -117,7 +116,7 @@ extension DvrEpisodeStatus {
}

extension ObservableInteractor {
func observeResult() -> Observable<Result<Element, DownError>> {
func observeResult() -> Observable<Swift.Result<Element, DownError>> {
return observe()
.asObservable()
.mapResult(DownError.self)
Expand Down
2 changes: 1 addition & 1 deletion Down/Shared/Extensions/UITextFieldExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension Reactive where Base: UITextField {
var debouncedText: Driver<String> {
return text.orEmpty
.asObservable()
.debounce(0.3, scheduler: MainScheduler.instance)
.debounce(.milliseconds(300), scheduler: MainScheduler.instance)
.asDriver(onErrorJustReturn: String())
}
}
4 changes: 2 additions & 2 deletions Down/Shared/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extension Router {

childRouter(ofType: type)?.stop()

if let index = ApiApplicationType.allCases.index(of: type) {
if let index = ApiApplicationType.allCases.firstIndex(of: type) {
tabBarController?.viewControllers?.remove(at: index)
}
}
Expand All @@ -127,7 +127,7 @@ extension Router {
}

guard let viewController = vc,
let typeIndex = ApiApplicationType.allCases.index(of: type) else {
let typeIndex = ApiApplicationType.allCases.firstIndex(of: type) else {
return nil
}

Expand Down
Loading

0 comments on commit b55578c

Please sign in to comment.