-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// LKDanceUIAttrMaker.h | ||
// LookinClient | ||
// | ||
// Created by likai.123 on 2023/12/21. | ||
// Copyright © 2023 hughkli. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface LKDanceUIAttrMaker : NSObject | ||
|
||
/// 给 item 的属性列表里填充上“跳转 DanceUI 文件”相关的信息 | ||
+ (void)makeDanceUIJumpAttribute:(LookinDisplayItem *)item danceSource:(NSString *)source; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// LKDanceUIAttrMaker.m | ||
// LookinClient | ||
// | ||
// Created by likai.123 on 2023/12/21. | ||
// Copyright © 2023 hughkli. All rights reserved. | ||
// | ||
|
||
#import "LKDanceUIAttrMaker.h" | ||
#import "LookinAttributesGroup.h" | ||
#import "LookinAttributesSection.h" | ||
#import "LookinAttribute.h" | ||
|
||
@implementation LKDanceUIAttrMaker | ||
|
||
+ (void)makeDanceUIJumpAttribute:(LookinDisplayItem *)item danceSource:(NSString *)source { | ||
NSString *className = [self getClassFromSource:source]; | ||
if (!className) { | ||
return; | ||
} | ||
|
||
__block BOOL alreadyHas = NO; | ||
[item.attributesGroupList enumerateObjectsUsingBlock:^(LookinAttributesGroup * _Nonnull group, NSUInteger idx, BOOL * _Nonnull stop) { | ||
if ([group.identifier isEqualToString:LookinAttrGroup_Class]) { | ||
alreadyHas = YES; | ||
*stop = YES; | ||
} | ||
}]; | ||
if (alreadyHas) { | ||
NSAssert(NO, @""); | ||
return; | ||
} | ||
LookinAttribute *attr = [LookinAttribute new]; | ||
attr.identifier = LookinAttr_Class_Class_Class; | ||
attr.attrType = LookinAttrTypeCustomObj; | ||
attr.value = @[@[className]]; | ||
|
||
LookinAttributesSection *sec = [LookinAttributesSection new]; | ||
sec.identifier = LookinAttrSec_Class_Class; | ||
sec.attributes = @[attr]; | ||
|
||
LookinAttributesGroup *group = [LookinAttributesGroup new]; | ||
group.identifier = LookinAttrGroup_Class; | ||
group.attrSections = @[sec]; | ||
|
||
if (item.attributesGroupList) { | ||
item.attributesGroupList = [item.attributesGroupList arrayByAddingObject:group]; | ||
} else { | ||
item.attributesGroupList = @[group]; | ||
} | ||
} | ||
|
||
+ (NSString *)getClassFromSource:(NSString *)json { | ||
NSData *jsonData = [json dataUsingEncoding:NSUTF8StringEncoding]; | ||
NSError *error; | ||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error]; | ||
if (error) { | ||
NSAssert(NO, @""); | ||
return nil; | ||
} | ||
if (![dict isKindOfClass:[NSDictionary class]]) { | ||
NSAssert(NO, @""); | ||
return nil; | ||
} | ||
NSString *type = dict[@"type"]; | ||
if (!type) { | ||
NSAssert(NO, @""); | ||
return nil; | ||
} | ||
return type; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters