Files
flipper/iOS/SonarKit/FlipperDiagnosticsViewController.m
John Knox e2575239f2 Add background color to iOS diagnostic screen
Summary:
Some apps have a default background color, for example black, making the diagnostic screen fully black.
Fix this by making sure the bg is always white so the text is readable.

Reviewed By: passy

Differential Revision: D9400682

fbshipit-source-id: a45744f833cb7fe5ca7db4dcdacc09f304670032
2018-08-21 12:43:02 -07:00

57 lines
1.8 KiB
Objective-C

#ifdef FB_SONARKIT_ENABLED
#import "FlipperDiagnosticsViewController.h"
#import "SonarClient.h"
@implementation FlipperDiagnosticsViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
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 - 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];
self.scrollView.contentSize = self.stateLabel.frame.size;
[self.view addSubview:self.scrollView];
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)onUpdate {
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 {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskPortrait;
}
@end
#endif