Skip to content

Commit

Permalink
Merge pull request #144 from tigerAndBull/develop
Browse files Browse the repository at this point in the history
feature: add penerate api
  • Loading branch information
tigerAndBull authored Apr 13, 2021
2 parents 599b025 + 2c21baa commit 1f1f07b
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ - (instancetype)init {
_cacheModelArray = @[].mutableCopy;
_cacheManagerDict = @{}.mutableCopy;
_maxMemeoryCount = kMemeoryModelMaxCount;
_currentSystemVersion = [TABAnimationMethod appVersion];
}
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ extern int const TABAnimatedIndexTag;

#pragma mark -

/// 骨架屏启动中,穿透骨架屏指定标记的组件,
/// 一般用于多段网络请求,局部显示指定组件
/// @param index 指定标记元素
- (void)tab_penperateSkeletonWithIndex:(NSInteger)index;

/// 骨架屏启动中,穿透骨架屏指定标记的组件, 用于多段网络请求
/// 一般用于多段网络请求,局部显示指定组件
/// @param indexArray 指定标记数组
- (void)tab_penperateSkeletonWithIndexArray:(NSArray <NSNumber *> *)indexArray;

#pragma mark -

- (void)tab_startAnimationWithSection:(NSInteger)section;
- (void)tab_startAnimationWithSection:(NSInteger)section completion:(void (^)(void))completion;
- (void)tab_startAnimationWithSection:(NSInteger)section delayTime:(CGFloat)delayTime completion:(void (^)(void))completion;
Expand Down
14 changes: 14 additions & 0 deletions TABAnimatedDemo/TABAnimated/Control/UIView+TABControlAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "TABAnimatedProduction.h"

#import "TABAnimatedPullLoadingComponent.h"
#import "TABAnimatedProductHelper.h"

#ifdef DEBUG
static const NSTimeInterval kDelayReloadDataTime = 4;
Expand Down Expand Up @@ -204,6 +205,19 @@ - (void)_endViewAnimation {

#pragma mark -

- (void)tab_penperateSkeletonWithIndex:(NSInteger)index {
[self tab_penperateSkeletonWithIndexArray:@[@(index)]];
}

- (void)tab_penperateSkeletonWithIndexArray:(NSArray <NSNumber *> *)indexArray {
if (!self.tabAnimated || !self.tabAnimatedProduction || self.tabAnimated.state != TABViewAnimationRunning) {
return;
}
[TABAnimatedProductHelper penerateIndexArray:indexArray production:self.tabAnimatedProduction];
}

#pragma mark -

- (void)tab_startAnimationWithSection:(NSInteger)section {
[self tab_startAnimationWithIndex:section];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ NS_ASSUME_NONNULL_BEGIN
@param frame 控制视图的frame
*/
+ (nullable NSString *)getKeyWithControllerName:(NSString *)controllerName targetClass:(Class)targetClass frame:(CGRect)frame;

+ (void)penerateIndexArray:(NSArray <NSNumber *> *)penerateIndexArray production:(TABAnimatedProduction *)production;

@end

Expand Down
15 changes: 14 additions & 1 deletion TABAnimatedDemo/TABAnimated/Product/TABAnimatedProductHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ + (void)bindView:(UIView *)view production:(TABAnimatedProduction *)production a
view.frame.size.height != 0 && production.backgroundLayer.frame.size.height != view.frame.size.height) {
production.backgroundLayer.frame = CGRectMake(production.backgroundLayer.frame.origin.x, production.backgroundLayer.frame.origin.y, view.frame.size.width, view.frame.size.height);
}


view.hidden = NO;
view.layer.cornerRadius = production.backgroundLayer.cornerRadius;
[view.layer addSublayer:production.backgroundLayer];

Expand Down Expand Up @@ -250,6 +251,18 @@ + (void)cutView:(UIView *)view rootView:(UIView *)rootView {
});
}

+ (void)penerateIndexArray:(NSArray <NSNumber *> *)penerateIndexArray production:(TABAnimatedProduction *)production {
UIBezierPath *penetratePath = [UIBezierPath bezierPathWithRect:production.backgroundLayer.bounds];
for (NSInteger i = 0; i < penerateIndexArray.count; i++) {
NSInteger index = [penerateIndexArray[i] integerValue];
TABComponentLayer *layer = production.layers[index];
layer.hidden = YES;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:layer.originFrame cornerRadius:layer.cornerRadius];
[penetratePath appendPath:path];
}
[self penetrateTargetLayer:production.backgroundLayer path:penetratePath];
}

+ (void)penetrateTargetLayer:(TABComponentLayer *)targetLayer path:(UIBezierPath *)path {
CAShapeLayer *fillLayer = [CAShapeLayer layer];
fillLayer.path = path.CGPath;
Expand Down
5 changes: 3 additions & 2 deletions TABAnimatedDemo/TABAnimated/Product/TABAnimatedProductImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ - (void)productWithView:(nonnull UIView *)view
if (production) {
TABAnimatedProduction *newProduction = production.copy;
[self _bindWithProduction:newProduction targetView:view];
_controlView.tabAnimated.state = TABViewAnimationRunning;
return;
}

Expand Down Expand Up @@ -297,8 +298,8 @@ - (void)_productBackgroundLayerWithView:(UIView *)view needReset:(BOOL)needReset
flagView = view.subviews[1];
isCard = YES;
}
}else if (view.subviews.count >= 1 && view.subviews[0].layer.shadowOpacity > 0.) {
flagView = view.subviews[0];
}else if (view.layer.shadowOpacity > 0.) {
flagView = view;
isCard = YES;
}

Expand Down
71 changes: 42 additions & 29 deletions TABAnimatedDemo/TABAnimated/Product/TABComponentLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
static NSString * const TABComponentLayerName = @"TABLayer";
static const CGFloat kDefaultHeight = 16.f;

@interface TABComponentLayer()

@end

@implementation TABComponentLayer

+ (NSString *)getLineKey:(NSInteger)index {
Expand Down Expand Up @@ -91,7 +87,13 @@ - (void)addLayer:(TABComponentLayer *)layer viewWidth:(CGFloat)viewWidth animate
}
#endif
}else {
[self _addLinesLayer:layer animatedHeight:animatedHeight];
if (layer.lineLayers.count != 0) {
for (TABComponentLayer *subLayer in layer.lineLayers) {
[self addSublayer:subLayer];
}
}else {
[self _addLinesLayer:layer animatedHeight:animatedHeight];
}
}
}

Expand Down Expand Up @@ -180,30 +182,6 @@ - (CGFloat)lineSpace {
return (_lineSpace == 0.) ? 8. : _lineSpace;
}

- (CGFloat)tab_maxY {
if (self.lineLayers.count == 0) {
return CGRectGetMaxY(self.frame);
}
CGFloat result = [self.lineLayers[0] tab_maxY];
for (NSInteger i = 1; i < self.lineLayers.count; i++) {
TABComponentLayer *layer = self.lineLayers[i];
result = MAX(result, [layer tab_maxY]);
}
return result;
}

- (CGFloat)tab_minY {
if (self.lineLayers.count == 0) {
return CGRectGetMinY(self.frame);
}
CGFloat result = [self.lineLayers[0] tab_minY];
for (NSInteger i = 1; i < self.lineLayers.count; i++) {
TABComponentLayer *layer = self.lineLayers[i];
result = MIN(result, [layer tab_minY]);
}
return result;
}

#pragma mark - NSSecureCoding

+ (BOOL)supportsSecureCoding {
Expand Down Expand Up @@ -244,6 +222,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {

[aCoder encodeBool:_isCard forKey:@"isCard"];
[aCoder encodeCGRect:_originFrame forKey:@"originFrame"];

[aCoder encodeObject:_widthDict forKey:@"widthDict"];
[aCoder encodeObject:_heightDict forKey:@"heightDict"];
[aCoder encodeObject:_spaceDict forKey:@"spaceDict"];
Expand Down Expand Up @@ -287,6 +266,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
self.colors = cgcolorArray;
self.masksToBounds = [aDecoder decodeBoolForKey:@"masksToBounds"];
self.isCard = [aDecoder decodeBoolForKey:@"isCard"];

self.widthDict = [aDecoder decodeObjectForKey:@"widthDict"];
self.heightDict = [aDecoder decodeObjectForKey:@"heightDict"];
self.spaceDict = [aDecoder decodeObjectForKey:@"spaceDict"];
Expand Down Expand Up @@ -345,9 +325,42 @@ - (id)copyWithZone:(NSZone *)zone {
layer.widthDict = self.widthDict;
layer.heightDict = self.heightDict;
layer.spaceDict = self.spaceDict;

if(self.lineLayers.count != 0) {
layer.lineLayers = @[].mutableCopy;
for (TABComponentLayer *subLayer in self.lineLayers) {
[layer.lineLayers addObject:subLayer.copy];
}
}

return layer;
}

- (CGFloat)tab_maxY {
if (self.lineLayers.count == 0) {
return CGRectGetMaxY(self.frame);
}
CGFloat result = [self.lineLayers[0] tab_maxY];
for (NSInteger i = 1; i < self.lineLayers.count; i++) {
TABComponentLayer *layer = self.lineLayers[i];
result = MAX(result, [layer tab_maxY]);
}
return result;
}

- (CGFloat)tab_minY {
if (self.lineLayers.count == 0) {
return CGRectGetMinY(self.frame);
}
CGFloat result = [self.lineLayers[0] tab_minY];
for (NSInteger i = 1; i < self.lineLayers.count; i++) {
TABComponentLayer *layer = self.lineLayers[i];
result = MIN(result, [layer tab_minY]);
}
return result;
}


- (NSMutableArray *)lineLayers {
if (!_lineLayers) {
_lineLayers = @[].mutableCopy;
Expand Down
8 changes: 4 additions & 4 deletions TABAnimatedDemo/TABAnimatedDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.5.1;
CURRENT_PROJECT_VERSION = 2.5.3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = JGZKPAYJ7R;
ENABLE_BITCODE = NO;
Expand All @@ -2033,7 +2033,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.3;
OTHER_LDFLAGS = (
"-Xlinker",
"-interposable",
Expand All @@ -2052,7 +2052,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.5.1;
CURRENT_PROJECT_VERSION = 2.5.3;
DEVELOPMENT_TEAM = JGZKPAYJ7R;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -2068,7 +2068,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.5.1;
MARKETING_VERSION = 2.5.3;
OTHER_LDFLAGS = (
"-Xlinker",
"-interposable",
Expand Down

0 comments on commit 1f1f07b

Please sign in to comment.