diff --git a/ComponentSwift.podspec b/ComponentSwift.podspec index b9bfe8f..d41a9d9 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 @@ -28,7 +28,7 @@ ComponentSwift is an objc wrapper of ComponentKit and refined for swift. Compone 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO' } - s.dependency "ComponentKit", "~>0.15.0" - s.dependency "CKTableViewTransactionalDataSource", " ~> 0.1.0" + s.dependency "ComponentKit", " ~> 0.20" + s.dependency "CKTableViewTransactionalDataSource", " ~> 0.2.0" end diff --git a/Example/CKWrapperDemo/Component.swift b/Example/CKWrapperDemo/Component.swift index 26923e0..2738f92 100644 --- a/Example/CKWrapperDemo/Component.swift +++ b/Example/CKWrapperDemo/Component.swift @@ -56,8 +56,8 @@ class SwiftComponent: CompositeComponent { ) ).stackLayoutChild - .flexGrow(true) - .flexShrink(true) + .flexGrow(1) + .flexShrink(1) ) ) ) diff --git a/Example/CKWrapperDemo/components/DemoComponent.swift b/Example/CKWrapperDemo/components/DemoComponent.swift index 46c8e12..617a7e1 100644 --- a/Example/CKWrapperDemo/components/DemoComponent.swift +++ b/Example/CKWrapperDemo/components/DemoComponent.swift @@ -49,8 +49,8 @@ class DemoComponent: CompositeComponent, ComponentInitialStateProtocol { ) ).stackLayoutChild - .flexGrow(true) - .flexShrink(true) + .flexGrow(1) + .flexShrink(1) ) ) } diff --git a/Example/Podfile b/Example/Podfile index f7a5300..be4206a 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -8,8 +8,8 @@ target 'ComponentSwiftDemo' do # Pods for CKWrapperDemo pod 'ComponentSwift', :path => '../' pod 'WrapExisted', :path => './WrapExisted' - pod 'ComponentKit', :inhibit_warnings => true - + pod "ComponentKit", :git=> "https://github.com/leavez/componentkit", :branch => "pod", :inhibit_warnings => true + pod "CKTableViewTransactionalDataSource", :git=> "https://github.com/leavez/CKTableViewTransactionalDataSource.git", :tag => "0.2.1" end diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 51e4723..2fdd547 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,35 +1,45 @@ PODS: - - CKTableViewTransactionalDataSource (0.1.1): - - ComponentKit (~> 0.2) - - ComponentKit (0.15.1) + - CKTableViewTransactionalDataSource (0.2.1): + - ComponentKit (~> 0.20) + - ComponentKit (0.20) - ComponentSwift (0.3): - - CKTableViewTransactionalDataSource (~> 0.1.0) - - ComponentKit (~> 0.15.0) + - CKTableViewTransactionalDataSource (~> 0.2.0) + - ComponentKit (~> 0.20) - WrapExisted (0.0.1): - ComponentSwift DEPENDENCIES: - - ComponentKit + - CKTableViewTransactionalDataSource (from `https://github.com/leavez/CKTableViewTransactionalDataSource.git`, tag `0.2.1`) + - ComponentKit (from `https://github.com/leavez/componentkit`, branch `pod`) - ComponentSwift (from `../`) - WrapExisted (from `./WrapExisted`) -SPEC REPOS: - https://github.com/CocoaPods/Specs.git: - - CKTableViewTransactionalDataSource - - ComponentKit - EXTERNAL SOURCES: + CKTableViewTransactionalDataSource: + :git: https://github.com/leavez/CKTableViewTransactionalDataSource.git + :tag: 0.2.1 + ComponentKit: + :branch: pod + :git: https://github.com/leavez/componentkit ComponentSwift: :path: "../" WrapExisted: :path: "./WrapExisted" +CHECKOUT OPTIONS: + CKTableViewTransactionalDataSource: + :git: https://github.com/leavez/CKTableViewTransactionalDataSource.git + :tag: 0.2.1 + ComponentKit: + :commit: 3c33e17106e296e0fdd0b191a820a744b78a5e4f + :git: https://github.com/leavez/componentkit + SPEC CHECKSUMS: - CKTableViewTransactionalDataSource: 8ed793a62a7602e9be76c5a0ab1597f27bb435ab - ComponentKit: beef88630f344efb8344fe40fc6fc7c1732b68c8 - ComponentSwift: a3080c586fdb207aafd025f8cd71885c4ef41762 + CKTableViewTransactionalDataSource: a7ea39dd8a9630a64f1352e5b09f46078434d0ec + ComponentKit: 54a9e19e4072c4a11dae762e1846cc1e7496cf48 + ComponentSwift: 6b27914b7ac8f5fbcd66f45ba6b3dc77728f2884 WrapExisted: 3b9af64c8a2cd1193ae90349117bccfcc3eb4b85 -PODFILE CHECKSUM: 00b1b9bb8109730b3adc9f47a6cf90c92fd44213 +PODFILE CHECKSUM: c75b14aee523a3f1323596faa8d8809d171cf4bd COCOAPODS: 1.5.0.beta.1 diff --git a/Example/WrapExisted/private/CKFadeNetworkImageComponent.mm b/Example/WrapExisted/private/CKFadeNetworkImageComponent.mm index 7f57a33..41d658a 100644 --- a/Example/WrapExisted/private/CKFadeNetworkImageComponent.mm +++ b/Example/WrapExisted/private/CKFadeNetworkImageComponent.mm @@ -248,7 +248,6 @@ - (void)_startDownloadIfNotInReusePool auto start = CACurrentMediaTime(); __weak CKFadeNetworkImageComponentView *weakSelf = self; _download = [_specifier.imageDownloader downloadImageWithURL:_specifier.url - scenePath:_specifier.scenePath caller:self callbackQueue:dispatch_get_main_queue() downloadProgressBlock:nil diff --git a/Sources/Components/LayoutComponent/CSStackLayoutComponent.h b/Sources/Components/LayoutComponent/CSStackLayoutComponent.h index f6dfd97..6dc7767 100644 --- a/Sources/Components/LayoutComponent/CSStackLayoutComponent.h +++ b/Sources/Components/LayoutComponent/CSStackLayoutComponent.h @@ -81,10 +81,14 @@ NS_SWIFT_NAME(StackLayoutChild) @property (nonatomic) CGFloat spacingBefore; /** Additional space to place after the component in the stacking direction. */ @property (nonatomic) CGFloat spacingAfter; -/** If the sum of childrens' stack dimensions is less than the minimum size, should this component grow? */ -@property (nonatomic) BOOL flexGrow; +/** + If the sum of childrens' stack dimensions is less than the minimum size, how much should this component grow? + This value represents the "flex grow factor" and determines how much this component should grow in relation to any + other flexible children. + */ +@property (nonatomic) CGFloat flexGrow; /** If the sum of childrens' stack dimensions is greater than the maximum size, should this component shrink? */ -@property (nonatomic) BOOL flexShrink; +@property (nonatomic) CGFloat flexShrink; /** Specifies the initial size in the stack dimension for the child. */ @property (nonatomic, nullable) CSDimension *flexBasis; /** Orientation of the child along cross axis, overriding alignItems */ diff --git a/Sources/Components/ViewComponent/CSImageComponent.h b/Sources/Components/ViewComponent/CSImageComponent.h index f8484be..0b37931 100644 --- a/Sources/Components/ViewComponent/CSImageComponent.h +++ b/Sources/Components/ViewComponent/CSImageComponent.h @@ -20,8 +20,10 @@ NS_SWIFT_NAME(ImageComponent) /** Uses a static layout with the given image size. */ + - (nonnull instancetype)initWithImage:(nullable UIImage *)image contentMode:(UIViewContentMode)mode + attributes:(nullable CSViewAttributeMap *)attributes size:(nullable CSSize *)size; @end diff --git a/Sources/Components/ViewComponent/CSImageComponent.mm b/Sources/Components/ViewComponent/CSImageComponent.mm index bf12aae..05f398c 100644 --- a/Sources/Components/ViewComponent/CSImageComponent.mm +++ b/Sources/Components/ViewComponent/CSImageComponent.mm @@ -14,20 +14,26 @@ @implementation CSImageComponent - (instancetype)initWithImage:(UIImage *)image { - return [self initWithImage:image contentMode:UIViewContentModeScaleAspectFill size:[[CSSize alloc] initWithCGSize:image.size]]; + return [self initWithImage:image contentMode:UIViewContentModeScaleAspectFill attributes:nil size:[[CSSize alloc] initWithCGSize:image.size]]; } -- (instancetype)initWithImage:(UIImage *)image contentMode:(UIViewContentMode)mode size:(CSSize *)size { +- (instancetype)initWithImage:(UIImage *)image contentMode:(UIViewContentMode)mode attributes:(nullable CSViewAttributeMap *)attributes size:(CSSize *)size { + + CKViewComponentAttributeValueMap copied = ConvertWithDefault(attributes, CKViewComponentAttributeValueMap()); + copied.insert({ + {@selector(setImage:), image}, + {@selector(setContentMode:) , @(mode)}, + }); + var key = @selector(setClipsToBounds:); + if (copied[key] == nil) { + copied[key] = @YES; + } self = [super init]; if (self) { self.realComponent = [CKComponent newWithView:{ [UIImageView class], - { - {@selector(setImage:), image}, - {@selector(setContentMode:) , @(mode)}, - {@selector(setClipsToBounds:), @YES} - } + copied } size:ConvertWithDefault(size, CKComponentSize())]; } return self; diff --git a/Sources/Components/ViewComponent/CSNetworkImageComponent.h b/Sources/Components/ViewComponent/CSNetworkImageComponent.h index 61e0463..7757d78 100644 --- a/Sources/Components/ViewComponent/CSNetworkImageComponent.h +++ b/Sources/Components/ViewComponent/CSNetworkImageComponent.h @@ -18,7 +18,6 @@ NS_SWIFT_NAME(NetworkImageComponent) // @param cropRect Optional rectangle (in the unit coordinate space) that specifies the portion of contents that the receiver should draw. - (nonnull instancetype)initWithURL:(nullable NSURL *)url imageDownloader:(nonnull id)imageDownloader - scenePath:(nullable id)scenePath size:(nullable CSSize *)size placeholderImage:(nullable UIImage *)placeholderImage cropRect:(CGRect)cropRect @@ -46,7 +45,6 @@ NS_SWIFT_NAME(NetworkImageDownloading) @result An opaque identifier to be used in canceling the download, via `cancelImageDownload:`. You must retain the identifier if you wish to use it later. */ - (nonnull id)downloadImageWithURL:(nullable NSURL *)URL - scenePath:(_Nullable id)scenePath caller:(_Nullable id)caller callbackQueue:(nonnull dispatch_queue_t)callbackQueue downloadProgressBlock:(void (^_Nonnull)(CGFloat progress))downloadProgressBlock diff --git a/Sources/Components/ViewComponent/CSNetworkImageComponent.mm b/Sources/Components/ViewComponent/CSNetworkImageComponent.mm index 358c382..480cf6f 100644 --- a/Sources/Components/ViewComponent/CSNetworkImageComponent.mm +++ b/Sources/Components/ViewComponent/CSNetworkImageComponent.mm @@ -13,14 +13,14 @@ @implementation CSNetworkImageComponent -- (instancetype)initWithURL:(NSURL *)url imageDownloader:(id)imageDownloader scenePath:(id)scenePath size:(CSSize *)size placeholderImage:(UIImage *)placeholderImage cropRect:(CGRect)cropRect attributes:(CSViewAttributeMap *)attributes +- (instancetype)initWithURL:(NSURL *)url imageDownloader:(id)imageDownloader size:(CSSize *)size placeholderImage:(UIImage *)placeholderImage cropRect:(CGRect)cropRect attributes:(CSViewAttributeMap *)attributes { self = [super init]; if (self) { + self.realComponent = [CKNetworkImageComponent newWithURL:url imageDownloader:(id)imageDownloader - scenePath:scenePath size:ConvertWithDefault(size, CKComponentSize()) options:{ .defaultImage = placeholderImage, diff --git a/Sources/Swift/Components+Convenience.swift b/Sources/Swift/Components+Convenience.swift index 16a485b..bb9b872 100644 --- a/Sources/Swift/Components+Convenience.swift +++ b/Sources/Swift/Components+Convenience.swift @@ -50,7 +50,6 @@ extension TextAttributes { - extension UIControlState: Hashable { public var hashValue: Int { return Int(self.rawValue) @@ -130,12 +129,11 @@ extension NetworkImageComponent { public convenience init(url: URL?, imageDownloader: NetworkImageDownloading, - scenePath: Any?, size: LayoutSize?, placeholderImage: UIImage?, cropRect: CGRect?, attributes: ViewAttributeMap?) { - self.init(__url: url, imageDownloader: imageDownloader, scenePath: scenePath, size: size, placeholderImage: placeholderImage, cropRect: cropRect ?? .zero, attributes: attributes) + self.init(__url: url, imageDownloader: imageDownloader, size: size, placeholderImage: placeholderImage, cropRect: cropRect ?? .zero, attributes: attributes) } public convenience init(url: URL?, @@ -143,7 +141,7 @@ extension NetworkImageComponent { size: LayoutSize? = nil, placeholderImage: UIImage? = nil, attributes: ViewAttributeMap? = nil) { - self.init(__url: url, imageDownloader: imageDownloader, scenePath: nil, size: size, placeholderImage: placeholderImage, cropRect: .zero, attributes: attributes) + self.init(__url: url, imageDownloader: imageDownloader, size: size, placeholderImage: placeholderImage, cropRect: .zero, attributes: attributes) } } diff --git a/Sources/Swift/Datasource+Convenience.swift b/Sources/Swift/Datasource+Convenience.swift index 0b673a7..21c3869 100644 --- a/Sources/Swift/Datasource+Convenience.swift +++ b/Sources/Swift/Datasource+Convenience.swift @@ -112,7 +112,6 @@ extension TableViewCellConfiguration { config.animationsDisabled = true return config } - public static func animationConfig(style: UITableViewRowAnimation = .automatic) -> TableViewCellConfiguration { let config = TableViewCellConfiguration() config.animationRowDelete = style diff --git a/Sources/Swift/StackLayout+Convenience.swift b/Sources/Swift/StackLayout+Convenience.swift index d1ae0bb..cb42a36 100644 --- a/Sources/Swift/StackLayout+Convenience.swift +++ b/Sources/Swift/StackLayout+Convenience.swift @@ -120,11 +120,11 @@ extension StackLayoutChild { self.spacingAfter = v return self } - public func flexGrow(_ v: Bool) -> StackLayoutChild { + public func flexGrow(_ v: CGFloat) -> StackLayoutChild { self.flexGrow = v return self } - public func flexShrink(_ v: Bool) -> StackLayoutChild { + public func flexShrink(_ v: CGFloat) -> StackLayoutChild { self.flexShrink = v return self }