iOS update devkit ui,add snapshot switch and performance switch

This commit is contained in:
pengfei.zhou 2021-07-14 11:41:50 +08:00 committed by osborn
parent cf116dbb31
commit 47022fe715
8 changed files with 77 additions and 17 deletions

View File

@ -16,6 +16,9 @@ Doric iOS Devkit for debugging & hotload.
s.source_files = 'doric-iOS/Devkit/Classes/**/*' s.source_files = 'doric-iOS/Devkit/Classes/**/*'
s.resource_bundles = {
'DoricDevkit' => ['doric-iOS/Devkit/Assets/**/*']
}
s.public_header_files = 'doric-iOS/Devkit/Classes/**/*.h' s.public_header_files = 'doric-iOS/Devkit/Classes/**/*.h'
s.dependency 'DoricCore' s.dependency 'DoricCore'

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -27,6 +27,7 @@
#import "DoricDevViewController.h" #import "DoricDevViewController.h"
#import "QRScanViewController.h" #import "QRScanViewController.h"
#import "DoricDebugDriver.h" #import "DoricDebugDriver.h"
#import "DoricRegistry.h"
@interface DoricContextCell : UITableViewCell @interface DoricContextCell : UITableViewCell
@property(nonatomic, strong) UILabel *tvId; @property(nonatomic, strong) UILabel *tvId;
@ -130,7 +131,10 @@ @interface DoricDevViewController () <UITableViewDelegate, UITableViewDataSource
@property(nonatomic, strong) UILabel *tvInput; @property(nonatomic, strong) UILabel *tvInput;
@property(nonatomic, strong) UILabel *tvScan; @property(nonatomic, strong) UILabel *tvScan;
@property(nonatomic, strong) UILabel *tvDisconnect; @property(nonatomic, strong) UILabel *tvDisconnect;
@property(nonatomic, strong) UILabel *tvSnapshot;
@property(nonatomic, strong) UILabel *tvPerformance;
@property(nonatomic, strong) UISwitch *switchSnapshot;
@property(nonatomic, strong) UISwitch *switchPerformance;
@property(nonatomic, strong) UITableView *listView; @property(nonatomic, strong) UITableView *listView;
@end @end
@ -144,7 +148,7 @@ - (void)viewDidLoad {
self.view.backgroundColor = UIColor.whiteColor; self.view.backgroundColor = UIColor.whiteColor;
self.headerView = [[UIView new] also:^(UIView *it) { self.headerView = [[UIView new] also:^(UIView *it) {
it.width = self.view.width; it.width = self.view.width;
it.height = 60; it.height = 140;
it.backgroundColor = DoricColor(@(0xff70a1ff)); it.backgroundColor = DoricColor(@(0xff70a1ff));
[self.view addSubview:it]; [self.view addSubview:it];
}]; }];
@ -208,11 +212,43 @@ - (void)viewDidLoad {
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disconnect)]; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disconnect)];
[it addGestureRecognizer:tapGestureRecognizer]; [it addGestureRecognizer:tapGestureRecognizer];
}]; }];
self.tvSnapshot = [[UILabel new] also:^(UILabel *it) {
it.text = @"Record Snapshot";
it.textColor = [UIColor whiteColor];
it.font = [UIFont systemFontOfSize:15];
it.textAlignment = NSTextAlignmentCenter;
[it sizeToFit];
[self.headerView addSubview:it];
}];
self.tvPerformance = [[UILabel new] also:^(UILabel *it) {
it.text = @"Performance";
it.textColor = [UIColor whiteColor];
it.font = [UIFont systemFontOfSize:15];
it.textAlignment = NSTextAlignmentCenter;
[it sizeToFit];
[self.headerView addSubview:it];
}];
self.switchSnapshot = [[UISwitch new] also:^(UISwitch *it) {
[it addTarget:self action:@selector(onSnapshotSwitch) forControlEvents:UIControlEventValueChanged];
[self.headerView addSubview:it];
}];
self.switchPerformance = [[UISwitch new] also:^(UISwitch *it) {
[it addTarget:self action:@selector(onPerformanceSwitch) forControlEvents:UIControlEventValueChanged];
[self.headerView addSubview:it];
}];
[self initHeaders]; [self initHeaders];
[self initList]; [self initList];
[DoricDev.instance addStatusCallback:self]; [DoricDev.instance addStatusCallback:self];
} }
- (void)onSnapshotSwitch {
[DoricRegistry enableRenderSnapshot:self.switchSnapshot.isOn];
}
- (void)onPerformanceSwitch {
[DoricRegistry enablePerformance:self.switchPerformance.isOn];
}
- (void)disconnect { - (void)disconnect {
[DoricDev.instance closeDevMode]; [DoricDev.instance closeDevMode];
} }
@ -276,8 +312,8 @@ - (void)initHeaders {
self.tvConnection.left = self.tvLabel.right + 20; self.tvConnection.left = self.tvLabel.right + 20;
self.tvDisconnect.right = self.view.width - 15; self.tvDisconnect.right = self.view.width - 15;
self.tvConnection.centerY = self.headerView.centerY; self.tvConnection.top = 15;
self.tvDisconnect.centerY = self.headerView.centerY; self.tvDisconnect.top = 15;
} else { } else {
self.tvConnection.text = @"Disconnected"; self.tvConnection.text = @"Disconnected";
self.tvInput.hidden = NO; self.tvInput.hidden = NO;
@ -292,10 +328,22 @@ - (void)initHeaders {
self.tvConnection.left = self.tvLabel.right + 20; self.tvConnection.left = self.tvLabel.right + 20;
self.tvScan.right = self.view.width - 15; self.tvScan.right = self.view.width - 15;
self.tvInput.right = self.tvScan.left - 10; self.tvInput.right = self.tvScan.left - 10;
self.tvConnection.centerY = self.headerView.centerY;
self.tvScan.centerY = self.headerView.centerY; self.tvConnection.top = 15;
self.tvInput.centerY = self.headerView.centerY; self.tvScan.top = 15;
self.tvInput.top = 15;
} }
self.tvSnapshot.left = self.tvLabel.right + 20;
self.switchSnapshot.left = self.tvSnapshot.right + 20;
self.switchSnapshot.top = self.tvConnection.bottom + 15;
self.tvSnapshot.centerY = self.switchSnapshot.centerY;
self.switchSnapshot.on = [DoricRegistry isEnableRenderSnapshot];
self.tvPerformance.left = self.tvLabel.right + 20;
self.switchPerformance.left = self.tvPerformance.right + 20;
self.switchPerformance.top = self.switchSnapshot.bottom + 15;
self.tvPerformance.centerY = self.switchPerformance.centerY;
self.switchPerformance.on = [DoricRegistry isEnablePerformance];
} }
- (void)initList { - (void)initList {
@ -325,15 +373,12 @@ - (UIImage *)decodeImage:(BOOL)on {
return [UIImage imageWithData:imageData]; return [UIImage imageWithData:imageData];
} }
- (NSInteger)tableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
numberOfRowsInSection:
(NSInteger)section { (NSInteger)section {
return [DoricContextManager.instance aliveContexts].count; return [DoricContextManager.instance aliveContexts].count;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cellForRowAtIndexPath:
(NSIndexPath *)indexPath {
DoricContextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; DoricContextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) { if (cell == nil) {
cell = [[DoricContextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; cell = [[DoricContextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
@ -369,9 +414,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView
return cell; return cell;
} }
- (CGFloat) tableView:(UITableView *)tableView - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
heightForRowAtIndexPath:
(NSIndexPath *)indexPath {
return 60.f; return 60.f;
} }

View File

@ -56,6 +56,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)enablePerformance:(BOOL)enable; + (void)enablePerformance:(BOOL)enable;
+ (BOOL)isEnablePerformance; + (BOOL)isEnablePerformance;
+ (void)enableRenderSnapshot:(BOOL)enable;
+ (BOOL)isEnableRenderSnapshot;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -60,6 +60,7 @@ @interface DoricLibraries : NSObject
@property(nonatomic, strong) NSHashTable<DoricRegistry *> *registries; @property(nonatomic, strong) NSHashTable<DoricRegistry *> *registries;
@property(nonatomic, strong) NSMutableDictionary *envDic; @property(nonatomic, strong) NSMutableDictionary *envDic;
@property(nonatomic, assign) BOOL enablePerformance; @property(nonatomic, assign) BOOL enablePerformance;
@property(nonatomic, assign) BOOL enableRecordSnapshot;
+ (instancetype)instance; + (instancetype)instance;
@end @end
@ -71,6 +72,7 @@ - (instancetype)init {
_registries = [NSHashTable new]; _registries = [NSHashTable new];
_envDic = [NSMutableDictionary new]; _envDic = [NSMutableDictionary new];
_enablePerformance = NO; _enablePerformance = NO;
_enableRecordSnapshot = NO;
} }
return self; return self;
} }
@ -140,6 +142,14 @@ + (BOOL)isEnablePerformance {
return DoricLibraries.instance.enablePerformance; return DoricLibraries.instance.enablePerformance;
} }
+ (void)enableRenderSnapshot:(BOOL)enable {
DoricLibraries.instance.enableRecordSnapshot = enable;
}
+ (BOOL)isEnableRenderSnapshot {
return DoricLibraries.instance.enableRecordSnapshot;
}
- (void)innerRegister { - (void)innerRegister {
[self registerNativePlugin:DoricShaderPlugin.class withName:@"shader"]; [self registerNativePlugin:DoricShaderPlugin.class withName:@"shader"];
[self registerNativePlugin:DoricModalPlugin.class withName:@"modal"]; [self registerNativePlugin:DoricModalPlugin.class withName:@"modal"];