Add UINavigationController and settings bar button to AppRTCMobile.
The navigation controller is used to display the title of the app
and to feature the settings button.
This work is foundation for adding settings screen to the app (see webrtc:6473 for more info)
BUG=webrtc:6618, webrtc:6473
Review-Url: https://codereview.webrtc.org/2455363002
Cr-Commit-Position: refs/heads/master@{#14816}
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m
index 8f19262..3cdccd9 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m
@@ -31,7 +31,11 @@
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[_window makeKeyAndVisible];
ARDMainViewController *viewController = [[ARDMainViewController alloc] init];
- _window.rootViewController = viewController;
+
+ UINavigationController *root =
+ [[UINavigationController alloc] initWithRootViewController:viewController];
+ root.navigationBar.translucent = NO;
+ _window.rootViewController = root;
#if defined(NDEBUG)
// In debug builds the default level is LS_INFO and in non-debug builds it is
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
index 9ebee5c..2034036 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
@@ -114,7 +114,6 @@
@end
@implementation ARDMainView {
- UILabel *_appLabel;
ARDRoomTextField *_roomText;
UILabel *_callOptionsLabel;
UISwitch *_audioOnlySwitch;
@@ -136,13 +135,6 @@
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
- _appLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _appLabel.text = @"AppRTCMobile";
- _appLabel.font = [UIFont fontWithName:@"Roboto" size:34];
- _appLabel.textColor = [UIColor colorWithWhite:0 alpha:.2];
- [_appLabel sizeToFit];
- [self addSubview:_appLabel];
-
_roomText = [[ARDRoomTextField alloc] initWithFrame:CGRectZero];
[self addSubview:_roomText];
@@ -263,11 +255,8 @@
CGRect bounds = self.bounds;
CGFloat roomTextWidth = bounds.size.width - 2 * kRoomTextFieldMargin;
CGFloat roomTextHeight = [_roomText sizeThatFits:bounds.size].height;
- _roomText.frame = CGRectMake(kRoomTextFieldMargin,
- kStatusBarHeight + kRoomTextFieldMargin,
- roomTextWidth,
- roomTextHeight);
- _appLabel.center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
+ _roomText.frame =
+ CGRectMake(kRoomTextFieldMargin, kRoomTextFieldMargin, roomTextWidth, roomTextHeight);
CGFloat callOptionsLabelTop =
CGRectGetMaxY(_roomText.frame) + kCallControlMargin * 4;
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
index e392168..f7e03bc 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
@@ -21,6 +21,8 @@
#import "ARDMainView.h"
#import "ARDVideoCallViewController.h"
+static NSString *barButtonImageString = @"ic_settings_black_24dp.png";
+
@interface ARDMainViewController () <
ARDMainViewDelegate,
ARDVideoCallViewControllerDelegate,
@@ -34,9 +36,11 @@
}
- (void)loadView {
+ self.title = @"AppRTC Mobile";
_mainView = [[ARDMainView alloc] initWithFrame:CGRectZero];
_mainView.delegate = self;
self.view = _mainView;
+ [self addSettingsBarButton];
RTCAudioSessionConfiguration *webRTCConfig =
[RTCAudioSessionConfiguration webRTCConfiguration];
@@ -51,6 +55,15 @@
[self setupAudioPlayer];
}
+- (void)addSettingsBarButton {
+ UIBarButtonItem *settingsButton =
+ [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:barButtonImageString]
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(showSettings:)];
+ self.navigationItem.rightBarButtonItem = settingsButton;
+}
+
#pragma mark - ARDMainViewDelegate
- (void)mainView:(ARDMainView *)mainView
@@ -155,6 +168,8 @@
}
#pragma mark - Private
+- (void)showSettings:(id)sender {
+}
- (void)configureAudioSession {
RTCAudioSessionConfiguration *configuration =
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp.png b/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp.png
new file mode 100644
index 0000000..c59419c
--- /dev/null
+++ b/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp.png
Binary files differ
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp@2x.png b/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp@2x.png
new file mode 100644
index 0000000..e84e188
--- /dev/null
+++ b/webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp@2x.png
Binary files differ