From d4477ac2a356362fb9bb03cb1a989cdace5fceca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 14 Jul 2021 19:54:34 +0800 Subject: [PATCH] iOS: add show tree node action --- DoricDevkit.podspec | 2 + .../Devkit/Classes/DoricDevViewController.m | 17 +++ .../Classes/DoricShowNodeTreeViewCell.h | 31 +++++ .../Classes/DoricShowNodeTreeViewCell.m | 55 ++++++++ .../Classes/DoricShowNodeTreeViewController.h | 30 +++++ .../Classes/DoricShowNodeTreeViewController.m | 118 ++++++++++++++++++ doric-iOS/Example/Example/ViewController.m | 4 + 7 files changed, 257 insertions(+) create mode 100644 doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.h create mode 100644 doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.m create mode 100644 doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.h create mode 100644 doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.m diff --git a/DoricDevkit.podspec b/DoricDevkit.podspec index 51df6e06..0fdff791 100644 --- a/DoricDevkit.podspec +++ b/DoricDevkit.podspec @@ -24,4 +24,6 @@ Doric iOS Devkit for debugging & hotload. s.dependency 'DoricCore' s.dependency 'SocketRocket' + + s.dependency 'RATreeView' end diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 645a0ca0..9a9b4bd5 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -28,6 +28,7 @@ #import "QRScanViewController.h" #import "DoricDebugDriver.h" #import "DoricSnapshotView.h" +#import "DoricShowNodeTreeViewController.h" @interface DoricContextCell : UITableViewCell @property(nonatomic, strong) UILabel *tvId; @@ -106,6 +107,22 @@ - (void)onClick { }]; [alertController addAction:cancel]; [alertController addAction:viewSource]; + + UIAlertAction *showNodeTree = [UIAlertAction actionWithTitle:@"Show node tree" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) { + DoricShowNodeTreeViewController *doricShowNodeTreeViewController = [[DoricShowNodeTreeViewController alloc] init]; + doricShowNodeTreeViewController.contextId = self.doricContext.contextId; + + UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController; + UINavigationController *navigationController; + if ([viewController isKindOfClass:[UINavigationController class]]) { + navigationController = (UINavigationController *) viewController; + } else { + navigationController = viewController.navigationController; + } + [navigationController pushViewController:doricShowNodeTreeViewController animated:NO]; + }]; + [alertController addAction:showNodeTree]; + if (DoricDev.instance.isInDevMode) { if ([self.doricContext.driver isKindOfClass:DoricDebugDriver.class]) { UIAlertAction *stopDebugging = [UIAlertAction actionWithTitle:@"Stop debugging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) { diff --git a/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.h b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.h new file mode 100644 index 00000000..757530c4 --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.h @@ -0,0 +1,31 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// DoricShowNodeTreeViewController.h +// Doric +// +// Created by jingpeng.wang on 2021/7/14. +// + +#import + +@interface DoricShowNodeTreeViewCell : UITableViewCell + +@property(nonatomic,strong)UILabel *nodeNameLabel; +@property(nonatomic,strong)UIImageView *nodeIcon; + +@end + diff --git a/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.m b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.m new file mode 100644 index 00000000..3fba2886 --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewCell.m @@ -0,0 +1,55 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// DoricShowNodeTreeViewController.m +// Doric +// +// Created by jingpeng.wang on 2021/7/12. +// +#import "DoricShowNodeTreeViewCell.h" + +#import + +@implementation DoricShowNodeTreeViewCell + +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + + if (self) { + self.nodeIcon = [[UIImageView new] also:^(UIImageView *it) { + it.width = 20; + it.height = 20; + it.contentMode = UIViewContentModeScaleToFill; + [self.contentView addSubview:it]; + }]; + + self.nodeNameLabel = [[UILabel new] also:^(UIImageView *it) { + it.contentMode = UIViewContentModeScaleToFill; + it.left = 30; + [self.contentView addSubview:it]; + }]; + } + return self; +} + +- (void)layoutSubviews { + [super layoutSubviews]; + + self.nodeIcon.centerY = self.contentView.height / 2; + self.nodeNameLabel.centerY = self.contentView.height / 2; +} + +@end diff --git a/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.h b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.h new file mode 100644 index 00000000..652780ea --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.h @@ -0,0 +1,30 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// DoricShowNodeTreeViewController.h +// Doric +// +// Created by jingpeng.wang on 2021/7/8. +// + +#import + +@interface DoricShowNodeTreeViewController : UIViewController + +@property(nonatomic,strong)NSString *contextId; + +@end + diff --git a/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.m b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.m new file mode 100644 index 00000000..40222f0c --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricShowNodeTreeViewController.m @@ -0,0 +1,118 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// DoricShowNodeTreeViewController.m +// Doric +// +// Created by jingpeng.wang on 2021/7/8. +// +#import "DoricShowNodeTreeViewController.h" +#import "DoricShowNodeTreeViewCell.h" + +#import "RATreeView.h" +#import +#import +#import + +@interface DoricShowNodeTreeViewController () +@property(nonatomic, weak) DoricContext *doricContext; +@property(nonatomic, weak) NSString *collapse; +@property(nonatomic, weak) NSString *expand; +@end + +@implementation DoricShowNodeTreeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.collapse = @"iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAWIElEQVR4Xu2de5Tc9HXH79Wu7RpDAg3gBA4JIYEEOBAO0FAoCS55EEOA3ZW0tvFKYxuzo1ljwOFVnsa8Eh4xEOMdzWLsHck2eKUxHHMotDQFCjmkJDQPCpwSUk4hCaRAAi2pX7u6PRoT4oDtnfndmV1Jc+df/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fTdiN8TnJeQ6dC+Oq7DgjMgYGBnQ2NK8H2ICAGacIJkUwm5wRzD3ca8LvxaraEsKFcshc1IXXtpxCDNPEUiGet9UjQw5yy6Ds2d/9FZgr6yMUgTe51IpMrAKLSCU4AXyk7NmvfxSaX2/bTiUFmoIWJjHUnICyvb2q61XeKV9ankdFcAmIQLkFFfcK0vggAV9cov8F37BU1jpVhDSQgBmkgzHpDJbL5a4Hopql0SHCV59rczW/qTU3GTxAQg8zwqZDI5va/wSjhct8trJrhFLWeXgzSAu2PZ/JLEOnu3VMhhL5yyS60QHpapyAGaZH2x03rQgQYX1AB6UK/VFzfIqlpnYYYpIXaH8/musJ0yqXiSAulpXUqYhCt2y/FRxEQg0QRkuNaExCDaN1+KT6KgBgkipAc15qAGETr9kvxUQTEIFGE5LjWBMQgWrdfio8iIAaJIiTHtSYgBtG6/VJ8FAExSBQhOa41ATGI1u2X4qMIiEGiCMlxrQmIQbRuvxQfRUAMEkVIjmtNQAyidful+CgCYpAoQnJcawJiEK3bL8VHERCDRBGS41oTEINo3X4pPoqAGCSKkBzXmoAYROv2S/FRBMQgUYTkuNYExCBat1+KjyIgBokiJMe1JiAG0br9UnwUATFIFCE5rjUBMYjW7ZfiowiIQaIIyXGtCYhBtG6/FB9FQAwSRUiOa01ADKJ1+6X4KAJikChCclxrAmIQrdsvxUcREINEEZLjWhMQg2jdfik+ioAYJIqQHNeagBhE6/ZL8VEExCBRhOS41gTEIFq3X4qPIiAGiSIkx7UmIAbRuv1SfBQBMUgUITmuNQExiNbtl+KjCIhBogjJca0JiEG0br8UH0VADBJFSI5rTUAMonX7pfgoAv8P7isVI5gCJAIAAAAASUVORK5CYII="; + + self.doricContext = [[DoricContextManager instance] getContext:self.contextId]; + + RATreeView *treeView = [[RATreeView alloc] initWithFrame:self.view.bounds]; + [self.view addSubview:treeView]; + + treeView.delegate = self; + treeView.dataSource = self; + [treeView registerClass:DoricShowNodeTreeViewCell.self forCellReuseIdentifier:@"cell"]; + [treeView reloadData]; +} + + +#pragma mark ratreeview delegate + +- (nonnull UITableViewCell *)treeView:(nonnull RATreeView *)treeView cellForItem:(nullable id)item { + DoricShowNodeTreeViewCell *cell = [treeView dequeueReusableCellWithIdentifier:@"cell"]; + cell.nodeNameLabel.text = [item description]; + [cell.nodeNameLabel sizeToFit]; + + if ([item isKindOfClass:[DoricGroupNode class]]) { + NSData *imageData = [[NSData alloc] initWithBase64EncodedString:self.collapse + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + cell.nodeIcon.image = [UIImage imageWithData:imageData]; + } else { + cell.nodeIcon.image = nil; + } + + NSInteger indent = [treeView levelForCellForItem:item]; + cell.nodeIcon.left = indent * 30; + cell.nodeNameLabel.left = 30 + indent * 30; + return cell; +} + +- (nonnull id)treeView:(nonnull RATreeView *)treeView child:(NSInteger)index ofItem:(nullable id)item { + if (item == nil) { + return self.doricContext.rootNode; + } else { + DoricGroupNode *groupNode = item; + return groupNode.childNodes[index]; + } +} + +- (NSInteger)treeView:(nonnull RATreeView *)treeView numberOfChildrenOfItem:(nullable id)item { + if (item == nil) { + return 1; + } else if ([item isKindOfClass:[DoricGroupNode class]]) { + DoricGroupNode *groupNode = item; + return groupNode.childNodes.count; + } + return 0; +} + +- (CGFloat)treeView:(RATreeView *)treeView heightForRowForItem:(id)item { + return 50; +} + +- (void)treeView:(RATreeView *)treeView willExpandRowForItem:(id)item { + if ([item isKindOfClass:[DoricGroupNode class]]) { + DoricShowNodeTreeViewCell *cell = (DoricShowNodeTreeViewCell *)[treeView cellForItem:item]; + + NSData *imageData = [[NSData alloc] initWithBase64EncodedString:self.expand + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + cell.nodeIcon.image = [UIImage imageWithData:imageData]; + } +} + +- (void)treeView:(RATreeView *)treeView willCollapseRowForItem:(id)item { + if ([item isKindOfClass:[DoricGroupNode class]]) { + DoricShowNodeTreeViewCell *cell = (DoricShowNodeTreeViewCell *)[treeView cellForItem:item]; + NSData *imageData = [[NSData alloc] initWithBase64EncodedString:self.collapse + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + cell.nodeIcon.image = [UIImage imageWithData:imageData]; + } +} +@end diff --git a/doric-iOS/Example/Example/ViewController.m b/doric-iOS/Example/Example/ViewController.m index 70630233..2e0e1b4c 100644 --- a/doric-iOS/Example/Example/ViewController.m +++ b/doric-iOS/Example/Example/ViewController.m @@ -87,6 +87,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"Devkit" style:UIBarButtonItemStylePlain target:self action:@selector(onOpenDevkit)]; doricViewController.navigationItem.rightBarButtonItem = rightBarItem; [self.navigationController pushViewController:doricViewController animated:NO]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[DoricDev instance] openDevMode:self]; + }); } @end