Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
update for Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
DianQK committed Mar 31, 2019
1 parent e11ce18 commit 0734313
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 121 deletions.
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,13 +1,13 @@
language: objective-c
sudo: required
osx_image: xcode9.3
osx_image: xcode10.2

env:
global:
- IOS_SDK="iphonesimulator11.3"
- IOS_SDK="iphonesimulator12.2"
- FRAMEWORK="Flix"
matrix:
- SDK="$IOS_SDK" TEST=0 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.3"
- SDK="$IOS_SDK" TEST=0 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=12.2"

notifications:
email: false
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

---

## [3.0.0](https://github.com/DianQK/Flix/releases/tag/3.0.0)

- Support Swift 5

## [1.1.0](https://github.com/DianQK/Flix/releases/tag/1.1.0)

- Add CollectionViewMoveable
Expand Down
Expand Up @@ -179,7 +179,7 @@ class SelectLocationViewController: UIViewController {
.subscribe(onNext: { [weak self] (placemark) in
_ = self?.navigationController?.popViewController(animated: true)
var recentSelectedPlacemarks = Storage.recentSelectedPlacemarks.value
if let index = recentSelectedPlacemarks.index(where: { $0.identity == placemark.identity }) {
if let index = recentSelectedPlacemarks.firstIndex(where: { $0.identity == placemark.identity }) {
recentSelectedPlacemarks.remove(at: index)
}
recentSelectedPlacemarks.append(placemark)
Expand Down
60 changes: 30 additions & 30 deletions Example/Example/DoNotDisturbSettingsViewController.swift
Expand Up @@ -66,36 +66,36 @@ class DoNotDisturbSettingsViewController: CollectionViewController {
}
}

let radioProvider = RadioProvider(options: [SlienceMode.always, SlienceMode.whileLocked])
radioProvider.checkedOption.accept(SlienceMode.always)
providers.append(radioProvider)

let slienceCommentProvider = UniqueCommentTextProvider(
text: ""
)
radioProvider.checkedOption.asObservable()
.map { (option) -> String in
return option?.comment ?? ""
}
.bind(to: slienceCommentProvider.text)
.disposed(by: disposeBag)
providers.append(slienceCommentProvider)

let allowCallsFromTitleProvider = UniqueCommentTextProvider(
text: "PHONE"
)
providers.append(allowCallsFromTitleProvider)
let allowCallsFromProvider = UniqueTextProvider(
title: "Allow Calls From",
desc: "Everyone"
)
providers.append(allowCallsFromProvider)
let allowCallsFromCommentProvider = UniqueCommentTextProvider(
text: "When in Do Not Disturb, allow incoming calls from everyone."
)
providers.append(allowCallsFromCommentProvider)

self.collectionView.flix.animatable.build(providers)
// let radioProvider = RadioProvider(options: [SlienceMode.always, SlienceMode.whileLocked])
// radioProvider.checkedOption.accept(SlienceMode.always)
// providers.append(radioProvider)
//
// let slienceCommentProvider = UniqueCommentTextProvider(
// text: ""
// )
// radioProvider.checkedOption.asObservable()
// .map { (option) -> String in
// return option?.comment ?? ""
// }
// .bind(to: slienceCommentProvider.text)
// .disposed(by: disposeBag)
// providers.append(slienceCommentProvider)
//
// let allowCallsFromTitleProvider = UniqueCommentTextProvider(
// text: "PHONE"
// )
// providers.append(allowCallsFromTitleProvider)
// let allowCallsFromProvider = UniqueTextProvider(
// title: "Allow Calls From",
// desc: "Everyone"
// )
// providers.append(allowCallsFromProvider)
// let allowCallsFromCommentProvider = UniqueCommentTextProvider(
// text: "When in Do Not Disturb, allow incoming calls from everyone."
// )
// providers.append(allowCallsFromCommentProvider)
//
// self.collectionView.flix.animatable.build(providers)
}

}
2 changes: 2 additions & 0 deletions Example/Example/MoveCollectionViewController.swift
Expand Up @@ -72,6 +72,8 @@ class MoveCollectionViewController: CollectionViewController {
collectionView.endInteractiveMovement()
case .cancelled, .failed, .possible:
collectionView.cancelInteractiveMovement()
@unknown default:
break;
}
})
.disposed(by: disposeBag)
Expand Down
25 changes: 16 additions & 9 deletions Example/Providers/RadioProvider.swift
Expand Up @@ -58,32 +58,39 @@ class RadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableColle
let options: [Option]
let checkedOption = BehaviorRelay<Option?>(value: nil)
let disposeBag = DisposeBag()
//
typealias Cell = RadioCollectionViewCell
typealias Value = Option

init(options: [Option]) {
self.options = options
}

func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Option) {
cell.titleLabel.text = String(describing: value)
checkedOption.asObservable()
.map { $0 == value }
.bind(to: cell.isChecked)
.disposed(by: cell.reuseBag)
}
func itemSelected(_ collectionView: UICollectionView, indexPath: IndexPath, value: Value) {

func itemSelected(_ collectionView: UICollectionView, indexPath: IndexPath, value: Option) {
collectionView.deselectItem(at: indexPath, animated: true)
checkedOption.accept(value)
}
func createValues() -> Observable<[Value]> {

func createValues() -> Observable<[Option]> {
return Observable.just(options)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath, value: Value) -> CGSize? {

// workaround: Segmentation fault: 11 While emitting IR SIL function "@$s7Example13RadioProviderCyqd__G4Flix033AnimatableCollectionViewMultiNodeC0AaeFP06createE5Nodes7RxSwift10ObservableCySayAE012IdentifiableI0VGGyFTW". for 'createAnimatableNodes()' (in module 'Flix')
func createAnimatableNodes() -> Observable<[IdentifiableNode]> {
let providerIdentity = self._flix_identity
return createValues()
.map { $0.map { IdentifiableNode(providerIdentity: providerIdentity, valueNode: $0) } }
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath, value: Option) -> CGSize? {
return CGSize(width: collectionView.bounds.width, height: 44)
}

Expand Down
8 changes: 4 additions & 4 deletions Flix.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Flix'
s.version = '2.0.0'
s.version = '3.0.0'
s.summary = 'iOS form builder in Swift'
s.homepage = 'https://github.com/DianQK/Flix'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand All @@ -11,11 +11,11 @@ Pod::Spec.new do |s|
s.frameworks = 'UIKit', 'Foundation'
s.requires_arc = true

s.dependency 'RxSwift', '~> 4.3'
s.dependency 'RxCocoa', '~> 4.3'
s.dependency 'RxSwift', '~> 4.4'
s.dependency 'RxCocoa', '~> 4.4'
s.dependency 'RxDataSources', '~> 3.1'

s.ios.deployment_target = '9.0'

s.swift_version = '4.2'
s.swift_version = '5.0'
end
45 changes: 12 additions & 33 deletions Flix.xcodeproj/project.pbxproj
Expand Up @@ -700,7 +700,6 @@
9157D7B62080536F008E22D8 /* Sources */,
9157D7B72080536F008E22D8 /* Frameworks */,
9157D7B82080536F008E22D8 /* Resources */,
2D6F2563A5C5FBCC2D8CF630 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -786,30 +785,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2D6F2563A5C5FBCC2D8CF630 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-FlixTests/Pods-FlixTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FlixTests/Pods-FlixTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
71E0C36382680B661BDAA87F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -834,8 +809,9 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/RxAtomic/RxAtomic.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
Expand All @@ -844,14 +820,15 @@
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxAtomic.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxKeyboard.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
E53098C1DFCC24D09F9B7948 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -1107,6 +1084,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1161,6 +1139,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1187,7 +1166,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1211,7 +1190,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -1231,7 +1210,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.dianqk.FlixExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1251,7 +1230,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.dianqk.FlixExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -1268,7 +1247,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.dianqk.FlixTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1285,7 +1264,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.dianqk.FlixTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions Flix.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.7">
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down
2 changes: 1 addition & 1 deletion Flix.xcodeproj/xcshareddata/xcschemes/Flix.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Expand Up @@ -63,7 +63,7 @@ open class SingleCollectionViewProvider<Cell: UICollectionViewCell>: CustomProvi
self.customIdentity = ""
}

open func onCreate(_ collectionView: UICollectionView, cell: Cell, indexPath: IndexPath) {
open func onCreate(_ collectionView: UICollectionView, cell: UICollectionViewCell, indexPath: IndexPath) {
self.onGetCell(cell)
cell.selectedBackgroundView = self.selectedBackgroundView
cell.backgroundView = self.backgroundView
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "cocoapods", '~> 1.7.0.beta'

0 comments on commit 0734313

Please sign in to comment.