iOS: Update diagnostic screen on state update
Summary: Update the diagnostic screen whenever the sonar state changes. Reviewed By: priteshrnandgaonkar Differential Revision: D9218765 fbshipit-source-id: 654a35e309cb43df18bc8c8a645d469eddc1031d
This commit is contained in:
committed by
Facebook Github Bot
parent
21888157df
commit
d8e5e31c9a
@@ -12,8 +12,9 @@
|
||||
text.text = @"Flipper Diagnostics";
|
||||
[self.view addSubview:text];
|
||||
|
||||
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height - 50)];
|
||||
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height - 100)];
|
||||
self.stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1000)];
|
||||
|
||||
self.stateLabel.numberOfLines = 0;
|
||||
self.stateLabel.text = [[SonarClient sharedClient] getState];
|
||||
[self.scrollView addSubview:self.stateLabel];
|
||||
@@ -22,8 +23,23 @@
|
||||
}
|
||||
|
||||
- (void)onUpdate {
|
||||
self.stateLabel.text = [[SonarClient sharedClient] getState];
|
||||
self.scrollView.contentSize = self.stateLabel.frame.size;
|
||||
FlipperDiagnosticsViewController __weak *weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
FlipperDiagnosticsViewController *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
NSString *state = [[SonarClient sharedClient] getState];
|
||||
strongSelf.stateLabel.text = state;
|
||||
[strongSelf.stateLabel sizeToFit];
|
||||
strongSelf.scrollView.contentSize = strongSelf.stateLabel.frame.size;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
id<FlipperStateUpdateListener> weakSelf = self;
|
||||
[[SonarClient sharedClient] subscribeForUpdates:weakSelf];
|
||||
}
|
||||
|
||||
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
|
||||
|
||||
Reference in New Issue
Block a user