From 0e7f68a2c21bb080c66e145e41541ce43db91e61 Mon Sep 17 00:00:00 2001 From: pengfeizhou Date: Wed, 24 Feb 2021 17:53:26 +0800 Subject: [PATCH] iOS:optimize devkit context list ui --- .../pub/doric/devkit/ui/DoricDevActivity.java | 2 +- .../Devkit/Classes/DoricDevViewController.m | 149 +++++++++++++++--- 2 files changed, 131 insertions(+), 20 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java index f1837b6c..373cabae 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java @@ -268,7 +268,7 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat holder.layoutBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (true) { + if (DoricDev.getInstance().isInDevMode()) { final String items[] = {"View source",}; AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext(), R.style.Theme_Doric_Modal); builder.setTitle(String.format("%s %s", context.getContextId(), context.getSource())); diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 21394e36..f22b5266 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -25,6 +25,69 @@ #import "DoricDev.h" #import "DoricDevViewController.h" #import "QRScanViewController.h" +#import "DoricDebugDriver.h" + +@interface DoricContextCell : UITableViewCell +@property(nonatomic, strong) UILabel *tvId; +@property(nonatomic, strong) UILabel *tvSource; +@property(nonatomic, strong) UIView *vBtn; +@property(nonatomic, strong) UIImageView *ivDebug; +@property(nonatomic, weak) DoricContext *doricContext; +@property(nonatomic, weak) UIViewController *vc; +@end + +@implementation DoricContextCell +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { + if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { + self.tvId = [[UILabel new] also:^(UILabel *it) { + it.width = 50; + it.textAlignment = NSTextAlignmentCenter; + it.font = [UIFont systemFontOfSize:20]; + it.textColor = [UIColor blackColor]; + it.left = 0; + [self.contentView addSubview:it]; + }]; + self.tvSource = [[UILabel new] also:^(UILabel *it) { + it.textAlignment = NSTextAlignmentCenter; + it.font = [UIFont systemFontOfSize:20]; + it.textColor = [UIColor blackColor]; + [self.contentView addSubview:it]; + }]; + self.vBtn = [[UIView new] also:^(UIView *it) { + it.width = 60; + it.height = 60; + [self.contentView addSubview:it]; + UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClick)]; + [it addGestureRecognizer:tapGestureRecognizer]; + }]; + self.ivDebug = [[UIImageView new] also:^(UIImageView *it) { + it.width = 20; + it.height = 20; + it.centerX = self.vBtn.width / 2; + it.centerY = self.vBtn.height / 2; + it.contentMode = UIViewContentModeScaleToFill; + [self.vBtn addSubview:it]; + }]; + } + return self; +} + +- (void)onClick { + if (DoricDev.instance.isInDevMode) { + + UIAlertController *alertController = [[UIAlertController alloc] init]; + UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil]; + UIAlertAction *viewSource = [UIAlertAction actionWithTitle:@"View source" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + ShowToast(@"View source", DoricGravityBottom); + }]; + [alertController addAction:cancel]; + [alertController addAction:viewSource]; + [self.vc presentViewController:alertController animated:true completion:nil]; + } else { + ShowToast(@"Please connect to devkit first", DoricGravityBottom); + } +} +@end @interface DoricDevViewController () @property(nonatomic, strong) UIView *headerView; @@ -111,6 +174,7 @@ - (void)viewDidLoad { [it addGestureRecognizer:tapGestureRecognizer]; }]; [self initHeaders]; + [self initList]; [DoricDev.instance addStatusCallback:self]; } @@ -196,60 +260,107 @@ - (void)initHeaders { } } +- (void)initList { + self.listView = [[UITableView new] also:^(UITableView *it) { + it.width = self.view.width; + it.height = self.view.height - self.headerView.height; + it.top = self.headerView.height; + it.backgroundColor = DoricColor(@(0xffdfe6e9)); + [self.view addSubview:it]; + it.delegate = self; + it.dataSource = self; + [it setSeparatorStyle:UITableViewCellSeparatorStyleNone]; + }]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + self.listView.height = self.view.height - self.headerView.height; +} + +- (UIImage *)decodeImage:(BOOL)on { + NSString *debugOff = @"iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAANJElEQVR4Xu2dW4hdVxnHv7UnFwlI1KpgBa1FK5ZGNLFtohFa8qJSxbbWgFWQPgzShznrTKIJ0mamglimTvbak4h0fAioLSVqfagaS72hbUzSGrEqotQGFfQlDYaaG87ZS/bkjM1tZvZZl7O/vb7/gWGmzV5rfev3X7+z9jn7XBThBgIgsCgBBTYgAAKLE4AgWB0gsAQBCILlAQIQBGsABNwIYAdx44ZWQghAECFBY5puBCCIGze0EkIAgggJGtN0IwBB3LihlRACogXRWk9UORtjHhCS90DTBB8isYL0w5/sr5hJSHKxO+BznodIQS4Jf2FlQJI+CfB55c5CnCCLhA9JlpZDLB9Rgiwjh9hFsDBx8Ln8IZoYQWqGL1YSrXX1eGz+SYsaNzGnoyIEGVAOcZIMKIcoPskL4iiHmEXgKIcYPkkL4ilH8ovAU47k+ST9NG8gOZJdBIHkSJbPwsSS3EECy5HcIggsx/kLakpN5Hn+pRoP8Ft1SHKCRJIjGUliyPH/e9sEJUlKkMhytF6SmHIswLHWThRFkcxOkowgQ5KjtZIMQ44UJUlJkEEudIU4D27NxbJhytEH2xo2yy2EZASpJoqFcHncYLKcAkv/e1KCQJKLw4YcfnIkex0ECwO7qb8a53tIbgdZACNZEslzDyVG0hcKJUsCOcIqkuwOwlGSycnJ7OTJk+vLsnwrEb05y7KrrbVXV39Xv5VS1d/V7V/Vj1Lqn9Vva+387+q/V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yxp7VVb1ntBuiQHW/HXBPjWqlH1f6HXkmYaxM93QQjSu5NMxjdC8VP/927hHe5Jmunlha/iyALBCNL7mWSyfrWq/NYR9lUs49GkmQb1cp6gBOlJMl4f1pr8Doo1VdyhZdUsigemR9PtZa1f1rrBCdIFfeEzA5doRx9RxVBZ4Ku0rorc2/bkxYf9cg9SkC6kD7TO2NBB50EFtvYLLaTrfXz5SD/5BSvIEqRGq34nRO7ikett20bwTKS6w6cXHvYjxtK1wQvSeww8EW+OoHeryMfyQPRtTPeR+JlnpHf78pJ1k3woyHH0Gq34DgB3A/D+F2An2zQK7I0gO6abs7822VQ+jaUgb0tzcHJgI6B3ieKTPgW9Ui8ieECidEfV30O+Up/9/j8FOQWxxtTAtejoNgDX9Qu1Wtfrzs5CtHP/VbMvVqvu1amWgqzA2V9RKEYWxShIFkrdl6p4c0fRnZ0o2rl/C+8YWaKnIFkoHXfN0MTANQq9BsA1EFTjpd6C3aq6S6PolxSjv8ApSH+83nK147LsVuguWZDfJFeluw3aDHooBbEU/zFZRLcCcrGlafuZ5n8AXlDok5HIrumRdE8/g3ntyQlQkAJ2RmOqvh4duQLApQpcKoJLrf+mXvGaiu6JJHpBgT2yUNs9vfXI4QLaCXpKCrIa8SuiCybjK0RxhQjeq6pnRZGsVZW1gJ4FwVp0sPgven8oYEaBGQAzIjqjkBlAZ0RlpgNpayfavX/r0T+tRumhr0FBQt8B7H9ZAhSEG4QEliFAQbg9SICCcA+QQD4CvIPk48ZRgRCgIIEEzTbzEaAg+bhxVCAEKEggQbPNfAQoSD5uHBUIAQoSSNBsMx+B/wNQA1oj5tl0JAAAAABJRU5ErkJggg=="; + NSString *base64 = on ? debugOn : debugOff; + NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64 + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + return [UIImage imageWithData:imageData]; +} + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [DoricContextManager.instance aliveContexts].count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row]; - NSString *path = context.source; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; + DoricContextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellID"]; + cell = [[DoricContextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellID"]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } - cell.textLabel.text = [path stringByAppendingString:@" Debug"]; + DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row]; + NSString *contextId = context.contextId; + NSString *source = context.source; + cell.doricContext = nil; + cell.contentView.width = tableView.width; + cell.contentView.height = 60; + cell.tvId.text = contextId; + cell.tvSource.text = source; + cell.ivDebug.image = [self decodeImage:DoricDev.instance.isInDevMode]; + [cell.tvId sizeToFit]; + [cell.tvSource sizeToFit]; + cell.tvId.centerY = cell.contentView.height / 2; + cell.tvId.width = 50; + cell.tvSource.centerY = cell.contentView.height / 2; + cell.vBtn.centerY = cell.contentView.height / 2; + cell.tvSource.width = cell.contentView.width - cell.tvId.width - cell.vBtn.width; + cell.tvId.left = 0; + cell.tvSource.left = cell.tvId.right; + cell.vBtn.right = cell.contentView.width; + cell.vc = self; + cell.contentView.backgroundColor = indexPath.row % 2 == 0 ? DoricColor(@(0xffecf0f1)) : DoricColor(@(0xffbdc3c7)); + if ([DoricDev.instance isReloadingContext:context]) { + cell.contentView.backgroundColor = DoricColor(@(0xffffeaa7)); + } + if ([context.driver isKindOfClass:DoricDebugDriver.class]) { + cell.contentView.backgroundColor = DoricColor(@(0xfffab1a0)); + } return cell; } +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 60.f; +} + - (BOOL)isSimulator { return TARGET_OS_SIMULATOR == 1; } -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"StartDebugEvent" object:context.contextId]; - NSDictionary *jsonDic = @{ - @"cmd": @"DEBUG", - @"data": @{ - @"contextId": context.contextId, - @"source": [context.source stringByReplacingOccurrencesOfString:@".js" withString:@".ts"] - } - }; -} - (void)onOpen:(NSString *)url { [self initHeaders]; + [self.listView reloadData]; } - (void)onClose:(NSString *)url { [self initHeaders]; + [self.listView reloadData]; } - (void)onFailure:(NSError *)error { [self initHeaders]; + [self.listView reloadData]; } - (void)onReload:(DoricContext *)context script:(NSString *)script { - + [self.listView reloadData]; } - (void)onStartDebugging:(DoricContext *)context { - + [self.listView reloadData]; } - (void)onStopDebugging { - + [self.listView reloadData]; }