diff --git a/.travis.yml b/.travis.yml index d24224e..122730a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/ComponentSwift.podspec b/ComponentSwift.podspec index b9bfe8f..a934da9 100644 --- a/ComponentSwift.podspec +++ b/ComponentSwift.podspec @@ -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 diff --git a/Example/ComponentSwiftDemo.xcodeproj/project.pbxproj b/Example/ComponentSwiftDemo.xcodeproj/project.pbxproj index 54f2951..7ef9130 100644 --- a/Example/ComponentSwiftDemo.xcodeproj/project.pbxproj +++ b/Example/ComponentSwiftDemo.xcodeproj/project.pbxproj @@ -169,7 +169,6 @@ 41D7C9491EABA789004B2DE7 /* Frameworks */, 41D7C94A1EABA789004B2DE7 /* Resources */, 5EF6991BA070A0F1FF298175 /* [CP] Embed Pods Frameworks */, - 3A0B2F8658A971042F261558 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -187,7 +186,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = leave; TargetAttributes = { 41D7C94B1EABA789004B2DE7 = { @@ -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; @@ -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; @@ -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; diff --git a/Example/ComponentSwiftDemo.xcodeproj/xcshareddata/xcschemes/ComponentSwiftDemo.xcscheme b/Example/ComponentSwiftDemo.xcodeproj/xcshareddata/xcschemes/ComponentSwiftDemo.xcscheme index 2973252..2027fab 100644 --- a/Example/ComponentSwiftDemo.xcodeproj/xcshareddata/xcschemes/ComponentSwiftDemo.xcscheme +++ b/Example/ComponentSwiftDemo.xcodeproj/xcshareddata/xcschemes/ComponentSwiftDemo.xcscheme @@ -1,6 +1,6 @@

[![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) diff --git a/Sources/Swift/Components+Convenience.swift b/Sources/Swift/Components+Convenience.swift index 55ee062..16a485b 100644 --- a/Sources/Swift/Components+Convenience.swift +++ b/Sources/Swift/Components+Convenience.swift @@ -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 diff --git a/Sources/Swift/StackLayout+Convenience.swift b/Sources/Swift/StackLayout+Convenience.swift index dfd12a1..d1ae0bb 100644 --- a/Sources/Swift/StackLayout+Convenience.swift +++ b/Sources/Swift/StackLayout+Convenience.swift @@ -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 } - ) - } -}