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]; UIAlertController *alertController = [[UIAlertController alloc] init];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *viewSource = [UIAlertAction actionWithTitle:@"View source" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UIAlertAction *viewSource = [UIAlertAction actionWithTitle:@"View source" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) {
ShowToast(@"View source", DoricGravityBottom); UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"View source: %@", self.doricContext.source]
message:self.doricContext.script
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:nil];
[alert addAction:action];
[self.vc presentViewController:alert animated:YES completion:nil];
}]; }];
[alertController addAction:cancel]; [alertController addAction:cancel];
[alertController addAction:viewSource]; [alertController addAction:viewSource];
[self.vc presentViewController:alertController animated:true completion:nil]; [self.vc presentViewController:alertController animated:true completion:nil];
} else {
ShowToast(@"Please connect to devkit first", DoricGravityBottom);
}
} }
@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;