iOS:add view source option

This commit is contained in:
pengfei.zhou 2021-03-01 18:45:16 +08:00 committed by osborn
parent dfbd46197c
commit a568a704fe

View File

@ -73,19 +73,21 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
} }
- (void)onClick { - (void)onClick {
if (DoricDev.instance.isInDevMode) { UIAlertController *alertController = [[UIAlertController alloc] init];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
UIAlertController *alertController = [[UIAlertController alloc] init]; UIAlertAction *viewSource = [UIAlertAction actionWithTitle:@"View source" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"View source: %@", self.doricContext.source]
UIAlertAction *viewSource = [UIAlertAction actionWithTitle:@"View source" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { message:self.doricContext.script
ShowToast(@"View source", DoricGravityBottom); preferredStyle:UIAlertControllerStyleAlert];
}]; UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
[alertController addAction:cancel]; style:UIAlertActionStyleDefault
[alertController addAction:viewSource]; handler:nil];
[self.vc presentViewController:alertController animated:true completion:nil]; [alert addAction:action];
} else { [self.vc presentViewController:alert animated:YES completion:nil];
ShowToast(@"Please connect to devkit first", DoricGravityBottom); }];
} [alertController addAction:cancel];
[alertController addAction:viewSource];
[self.vc presentViewController:alertController animated:true completion:nil];
} }
@end @end
@ -304,7 +306,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row]; DoricContext *context = [DoricContextManager.instance aliveContexts][(NSUInteger) indexPath.row];
NSString *contextId = context.contextId; NSString *contextId = context.contextId;
NSString *source = context.source; NSString *source = context.source;
cell.doricContext = nil; cell.doricContext = context;
cell.contentView.width = tableView.width; cell.contentView.width = tableView.width;
cell.contentView.height = 60; cell.contentView.height = 60;
cell.tvId.text = contextId; cell.tvId.text = contextId;