Skip to content

Commit

Permalink
Merge pull request #3 from leavez/4.1
Browse files Browse the repository at this point in the history
update for swift 4.1
  • Loading branch information
leavez authored Apr 1, 2018
2 parents 328a9fb + 7ff10c3 commit 1fc2d04
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode9.2
osx_image: xcode9.3beta
language: objective-c
cache: cocoapods
# podfile: Example/Podfile
Expand Down
2 changes: 1 addition & 1 deletion ComponentSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'ComponentSwift'
s.version = '0.3'
s.version = '0.4.1'
s.summary = 'ComponentSwift brings ComponentKit to swift'

s.description = <<-DESC
Expand Down
34 changes: 17 additions & 17 deletions Example/ComponentSwiftDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
41D7C9491EABA789004B2DE7 /* Frameworks */,
41D7C94A1EABA789004B2DE7 /* Resources */,
5EF6991BA070A0F1FF298175 /* [CP] Embed Pods Frameworks */,
3A0B2F8658A971042F261558 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -187,7 +186,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = leave;
TargetAttributes = {
41D7C94B1EABA789004B2DE7 = {
Expand Down Expand Up @@ -248,21 +247,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3A0B2F8658A971042F261558 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ComponentSwiftDemo/Pods-ComponentSwiftDemo-resources.sh\"\n";
showEnvVarsInLog = 0;
};
5EF6991BA070A0F1FF298175 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -340,15 +324,23 @@
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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = 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;
Expand Down Expand Up @@ -390,15 +382,23 @@
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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
15 changes: 10 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ DEPENDENCIES:
- ComponentSwift (from `../`)
- WrapExisted (from `./WrapExisted`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- CKTableViewTransactionalDataSource
- ComponentKit

EXTERNAL SOURCES:
ComponentSwift:
:path: ../
:path: "../"
WrapExisted:
:path: ./WrapExisted
:path: "./WrapExisted"

SPEC CHECKSUMS:
CKTableViewTransactionalDataSource: 8ed793a62a7602e9be76c5a0ab1597f27bb435ab
ComponentKit: beef88630f344efb8344fe40fc6fc7c1732b68c8
ComponentSwift: ebd44405ac0c9b9bb51280d433f17c5d98e44474
WrapExisted: 314e296d1445a284c31d6d75aabdb7b4c62c41bd
ComponentSwift: a3080c586fdb207aafd025f8cd71885c4ef41762
WrapExisted: 3b9af64c8a2cd1193ae90349117bccfcc3eb4b85

PODFILE CHECKSUM: 00b1b9bb8109730b3adc9f47a6cf90c92fd44213

COCOAPODS: 1.4.0.beta.2
COCOAPODS: 1.5.0.beta.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p align="center"><img src="/etc/logo.png" width="512"></p>

[![Platform](https://img.shields.io/cocoapods/p/ComponentSwift.svg?style=flat)](http://cocoapods.org/pods/ComponentSwift)
[![Swift](https://img.shields.io/badge/swift-4-orange.svg?style=flat)](#)
[![Swift](https://img.shields.io/badge/swift-4.1-orange.svg?style=flat)](#)
[![Build Status](https://travis-ci.org/leavez/ComponentSwift.svg?branch=master)](https://travis-ci.org/leavez/ComponentSwift)


Expand Down
2 changes: 1 addition & 1 deletion Sources/Swift/Components+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ extension ButtonComponent {
viewAttributes: ViewAttributeMap? = nil) {

let list: [[UIControlState: Any?]?] = [attributes.titles, attributes.titleColors, attributes.images, attributes.backgroundImages]
let states: [UIControlState] = list.flatMap{ $0 }.map{ Array($0.keys) }.reduce([], { $0 + $1 })
let states: [UIControlState] = list.compactMap{ $0 }.map{ Array($0.keys) }.reduce([], { $0 + $1 })
let buttonAttrs = Set(states).map{ (state) -> __ButtonAttributes in
let a = __ButtonAttributes()
a.state = state
Expand Down
59 changes: 34 additions & 25 deletions Sources/Swift/StackLayout+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,57 @@ extension StackLayoutChild: StackLayoutChildType {


// MARK:- convenient initialier for stack layout component
public class StackLayoutComponent: __StackLayoutComponent, StackComponentInitialierProtocol {
public class func modifyStyle(_ v: StackLayoutStyle) {
public class StackLayoutComponent: __StackLayoutComponent {

public init(view: ViewConfiguration? = nil,
style: StackLayoutStyle?,
size:LayoutSize? = nil,
children:[StackLayoutChildType?])
{
let s = style ?? StackLayoutStyle()
type(of:self).modifyStyle(s)
super.init(
__view:view, size:size, style:s,
children: children.compactMap{ $0?.toChild }
)
}

public convenience init(_ children:StackLayoutChildType?...) {
self.init(style: nil, children: children)
}

public convenience init(view: ViewConfiguration? = nil,
style: StackLayoutStyle?,
size:LayoutSize? = nil,
children:StackLayoutChildType?...)
{
self.init(view: view, style: style, size: size, children: children)
}


// MARK:- private

class func modifyStyle(_ v: StackLayoutStyle) {
// do nothing
}

}


/// subclass of StackLayoutComponent, with preset layoutDirction
public class VerticalStackComponent: StackLayoutComponent {
public override class func modifyStyle(_ v: StackLayoutStyle) {
override class func modifyStyle(_ v: StackLayoutStyle) {
v.direction = .vertical
}
}
/// subclass of StackLayoutComponent, with preset layoutDirction
public class HorizontalStackComponent: StackLayoutComponent {
public override class func modifyStyle(_ v: StackLayoutStyle) {
override class func modifyStyle(_ v: StackLayoutStyle) {
v.direction = .horizontal
}
}

public protocol StackComponentInitialierProtocol: class {
static func modifyStyle(_ v: StackLayoutStyle)
}

extension StackComponentInitialierProtocol where Self: StackLayoutComponent {

public init(_ children:StackLayoutChildType?...) {
self.init(style: nil, children: children)
}
public init(view: ViewConfiguration? = nil, style: StackLayoutStyle?, size:LayoutSize? = nil, children:StackLayoutChildType?...) {
self.init(view: view, style: style, size: size, children: children)
}
public init(view: ViewConfiguration? = nil, style: StackLayoutStyle?, size:LayoutSize? = nil, children:[StackLayoutChildType?]) {

let s = style ?? StackLayoutStyle()
Self.modifyStyle(s)
self.init(
__view:view, size:size, style:s,
children: children.flatMap{ $0?.toChild }
)
}
}



Expand Down

0 comments on commit 1fc2d04

Please sign in to comment.