Skip to content

Commit

Permalink
danceui 跳转
Browse files Browse the repository at this point in the history
  • Loading branch information
hughkli committed Dec 20, 2023
1 parent 679b097 commit 34a66dc
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lookin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
A77AA17B2AEED1B8006A7BF4 /* LKMessageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AA17A2AEED1B8006A7BF4 /* LKMessageManager.m */; };
A77AA17E2AEED988006A7BF4 /* LKServerVersionRequestor.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AA17D2AEED988006A7BF4 /* LKServerVersionRequestor.m */; };
A77AA1822AEEE095006A7BF4 /* LKVersionComparer.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AA1812AEEE095006A7BF4 /* LKVersionComparer.m */; };
A78FCEB42B334D3300F1D307 /* LKDanceUIAttrMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = A78FCEB32B334D3300F1D307 /* LKDanceUIAttrMaker.m */; };
A7F8FC552AF289F000ABC7F4 /* LookinCustomDisplayItemInfo+LookinClient.m in Sources */ = {isa = PBXBuildFile; fileRef = A7F8FC542AF289F000ABC7F4 /* LookinCustomDisplayItemInfo+LookinClient.m */; };
AA01EF2722DD0D26002A2E06 /* LKHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = AA01EF2522DD0D26002A2E06 /* LKHelper.m */; };
AA049A1721E61B85008C6366 /* LKMenuPopoverSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = AA049A1621E61B85008C6366 /* LKMenuPopoverSettingController.m */; };
Expand Down Expand Up @@ -268,6 +269,8 @@
A77AA17D2AEED988006A7BF4 /* LKServerVersionRequestor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKServerVersionRequestor.m; sourceTree = "<group>"; };
A77AA1802AEEE095006A7BF4 /* LKVersionComparer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LKVersionComparer.h; sourceTree = "<group>"; };
A77AA1812AEEE095006A7BF4 /* LKVersionComparer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKVersionComparer.m; sourceTree = "<group>"; };
A78FCEB22B334D3300F1D307 /* LKDanceUIAttrMaker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LKDanceUIAttrMaker.h; sourceTree = "<group>"; };
A78FCEB32B334D3300F1D307 /* LKDanceUIAttrMaker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKDanceUIAttrMaker.m; sourceTree = "<group>"; };
A7F8FC532AF289F000ABC7F4 /* LookinCustomDisplayItemInfo+LookinClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LookinCustomDisplayItemInfo+LookinClient.h"; sourceTree = "<group>"; };
A7F8FC542AF289F000ABC7F4 /* LookinCustomDisplayItemInfo+LookinClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "LookinCustomDisplayItemInfo+LookinClient.m"; sourceTree = "<group>"; };
AA01EF2522DD0D26002A2E06 /* LKHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LKHelper.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -972,6 +975,8 @@
AAD387332288632100042229 /* LKHierarchyController.m */,
AAC5E2DC228034DC0081A810 /* LKHierarchyDataSource.h */,
AAC5E2DD228034DC0081A810 /* LKHierarchyDataSource.m */,
A78FCEB22B334D3300F1D307 /* LKDanceUIAttrMaker.h */,
A78FCEB32B334D3300F1D307 /* LKDanceUIAttrMaker.m */,
601AD5E32A64D6110013F490 /* LKHierarchyDataSource+KeyDown.h */,
601AD5E42A64D6110013F490 /* LKHierarchyDataSource+KeyDown.m */,
AA3A7D0223003D7A00997887 /* LKHierarchyHandlersPopoverController.h */,
Expand Down Expand Up @@ -1387,6 +1392,7 @@
AA50755722A3E76A00D2A5AC /* LKInputSearchView.m in Sources */,
AA65ED492341FE8300F0BF34 /* LKTwoColors.m in Sources */,
AA39055123694D5D00CA7646 /* LKAboutViewController.m in Sources */,
A78FCEB42B334D3300F1D307 /* LKDanceUIAttrMaker.m in Sources */,
AAB65C092320FC30001E4299 /* LKDashboardSearchCardView.m in Sources */,
AA290358229824A400073B65 /* LKPanelContentView.m in Sources */,
AAA8C15E21CC17680017A345 /* LKLaunchViewController.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ - (void)renderWithAttribute {
[self.danceButton setHidden:YES];
if ([self.attribute.identifier isEqualToString:LookinAttr_Class_Class_Class]) {
NSString *danceSource = self.attribute.targetDisplayItem.danceuiSource;
if (!danceSource) {
danceSource = self.attribute.targetDisplayItem.customInfo.danceuiSource;
}
if (danceSource) {
[self addDanceButtonIfNeeded];
self.danceButton.title = NSLocalizedString(@"Navigate…", nil);
Expand Down Expand Up @@ -141,6 +144,9 @@ - (void)addDanceButtonIfNeeded {

- (void)handleDanceButton {
NSString *json = self.attribute.targetDisplayItem.danceuiSource;
if (!json) {
json = self.attribute.targetDisplayItem.customInfo.danceuiSource;
}
[[DanceScriptManager shared] handleText:json];
}

Expand Down
16 changes: 16 additions & 0 deletions LookinClient/Hierarchy/LKDanceUIAttrMaker.h
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
73 changes: 73 additions & 0 deletions LookinClient/Hierarchy/LKDanceUIAttrMaker.m
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
5 changes: 5 additions & 0 deletions LookinClient/Hierarchy/LKHierarchyDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "LKColorIndicatorLayer.h"
#import "LKUserActionManager.h"
#import "LookinDisplayItem+LookinClient.h"
#import "LKDanceUIAttrMaker.h"
@import AppCenter;
@import AppCenterAnalytics;

Expand Down Expand Up @@ -188,6 +189,10 @@ - (void)reloadWithHierarchyInfo:(LookinHierarchyInfo *)info keepState:(BOOL)keep
}
}

if (obj.customInfo.danceuiSource.length > 0) {
[LKDanceUIAttrMaker makeDanceUIJumpAttribute:obj danceSource:obj.customInfo.danceuiSource];
}

if (obj.isUserCustom) {
hasCustomSubviews = YES;
}
Expand Down

0 comments on commit 34a66dc

Please sign in to comment.