Skip to content

Commit

Permalink
fix: 修复几个回放问题。
Browse files Browse the repository at this point in the history
1. 优先比对目标cell的viewContent
2. highlightImageName的比对也要考虑前缀标识
3. 可交互view判断的逻辑完善
  • Loading branch information
Hulk committed Aug 2, 2021
1 parent 4f01b3b commit 7dbd779
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ - (void)highlightTheElement:(UIView*)element withCompletion:(void(^)(void))block
if (self.needExecute && block) {
block();
}
});

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[redLayer removeFromSuperlayer];
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ - (PrismInstructionParseResult)parseWithFormatter:(PrismInstructionFormatter *)f
if ([targetView isKindOfClass:[UITableViewCell class]]) {
UITableView *tableView = [targetView prism_UITableViewBelow];
UITableViewCell *targetCell = (UITableViewCell*)targetView;
for (UITableViewCell *cell in [tableView visibleCells]) {
NSString *viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:cell needRecursive:YES];
if ([viewContent containsString:representativeContent]) {
targetCell = cell;
break;
NSString *viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:targetCell needRecursive:YES];
if (![viewContent containsString:representativeContent]) {
for (UITableViewCell *cell in [tableView visibleCells]) {
viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:cell needRecursive:YES];
if ([viewContent containsString:representativeContent]) {
targetCell = cell;
break;
}
}
}
NSIndexPath *cellIndexPath = [tableView indexPathForCell:targetCell];
Expand All @@ -86,11 +89,14 @@ - (PrismInstructionParseResult)parseWithFormatter:(PrismInstructionFormatter *)f
else if ([targetView isKindOfClass:[UICollectionViewCell class]]) {
UICollectionView *collectionView = [targetView prism_UICollectionViewBelow];
UICollectionViewCell *targetCell = (UICollectionViewCell*)targetView;
for (UICollectionViewCell *cell in [collectionView visibleCells]) {
NSString *viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:cell needRecursive:YES];
if ([viewContent containsString:representativeContent]) {
targetCell = cell;
break;
NSString *viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:targetCell needRecursive:YES];
if (![viewContent containsString:representativeContent]) {
for (UICollectionViewCell *cell in [collectionView visibleCells]) {
viewContent = [PrismInstructionContentUtil getRepresentativeContentOfView:cell needRecursive:YES];
if ([viewContent containsString:representativeContent]) {
targetCell = cell;
break;
}
}
}
NSIndexPath *cellIndexPath = [collectionView indexPathForCell:targetCell];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ - (PrismInstructionParseResult)parseWithFormatter:(PrismInstructionFormatter *)f
}
}
}
if (!targetControl) {
targetControl = [self searchControlWithArea:areaInfo withTargetClass:targetClass withAction:targetAction fromSuperView:targetView];
}
}
// target + selector
else if (viewFunctionArray.count) {
Expand Down Expand Up @@ -184,7 +181,7 @@ - (UIControl*)searchControlWithArea:(NSString*)areaInfo
}
BOOL isAreaInfoEqual = [self isAreaInfoEqualBetween:controlAreaInfo withAnother:areaInfo allowCompatibleMode:NO];
if (isAreaInfoEqual
&& (!representativeContent.length || ([representativeContent isEqualToString:controlViewContent] || [representativeContent isEqualToString:highlightedImageName]))
&& (!representativeContent.length || ([representativeContent isEqualToString:controlViewContent] || [representativeContent isEqualToString:[NSString stringWithFormat:@"%@%@", kViewRepresentativeContentTypeLocalImage, highlightedImageName]] || [representativeContent isEqualToString:[NSString stringWithFormat:@"%@%@", kViewRepresentativeContentTypeNetworkImage, highlightedImageName]]))
&& (!targetClass || [target isKindOfClass:targetClass])
&& (!action.length || [controlActions containsObject:action])) {
return control;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ + (void)recursiveSubviewsWithViews:(NSArray<UIView*>*)views
break;
}
}

id wxComponent = [view prism_wxComponent];
if ([wxComponent isKindOfClass:NSClassFromString(@"WXTextComponent")] || [view isKindOfClass:[UILabel class]]) {
if ([view isKindOfClass:[UILabel class]] || [wxComponent isKindOfClass:NSClassFromString(@"WXTextComponent")]) {
if (!*firstTextView) {
*firstTextView = view;
}
Expand All @@ -140,10 +141,10 @@ + (void)recursiveSubviewsWithViews:(NSArray<UIView*>*)views
}
}
}
else if ([wxComponent isKindOfClass:NSClassFromString(@"WXImageComponent")] || [view isKindOfClass:[UIImageView class]]) {
else if ([view isKindOfClass:[UIImageView class]] || [wxComponent isKindOfClass:NSClassFromString(@"WXImageComponent")]) {
[imageViews prism_addObject:view];
}
else if ([view isKindOfClass:[UIButton class]] || viewHasTapGesture) {
else if (view.userInteractionEnabled && ([view isKindOfClass:[UIButton class]] || viewHasTapGesture)) {
// 不提取可交互view的信息,避免混淆。
continue;
}
Expand Down

0 comments on commit 7dbd779

Please sign in to comment.