From 6d6762cb0e236acd3231d1fba8ad590b43156d51 Mon Sep 17 00:00:00 2001 From: denicija Date: Fri, 28 Oct 2016 04:53:16 -0700 Subject: [PATCH] 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} --- webrtc/examples/BUILD.gn | 2 ++ .../objc/AppRTCMobile/ios/ARDAppDelegate.m | 6 +++++- .../examples/objc/AppRTCMobile/ios/ARDMainView.m | 15 ++------------- .../AppRTCMobile/ios/ARDMainViewController.m | 15 +++++++++++++++ .../ios/resources/ic_settings_black_24dp.png | Bin 0 -> 322 bytes .../ios/resources/ic_settings_black_24dp@2x.png | Bin 0 -> 557 bytes 6 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp.png create mode 100644 webrtc/examples/objc/AppRTCMobile/ios/resources/ic_settings_black_24dp@2x.png diff --git a/webrtc/examples/BUILD.gn b/webrtc/examples/BUILD.gn index a1f0231440..e812f9ea9d 100644 --- a/webrtc/examples/BUILD.gn +++ b/webrtc/examples/BUILD.gn @@ -269,6 +269,8 @@ if (is_ios || (is_mac && target_cpu != "x86")) { "objc/AppRTCMobile/ios/resources/ic_call_end_black_24dp@2x.png", "objc/AppRTCMobile/ios/resources/ic_clear_black_24dp.png", "objc/AppRTCMobile/ios/resources/ic_clear_black_24dp@2x.png", + "objc/AppRTCMobile/ios/resources/ic_settings_black_24dp.png", + "objc/AppRTCMobile/ios/resources/ic_settings_black_24dp@2x.png", "objc/AppRTCMobile/ios/resources/ic_surround_sound_black_24dp.png", "objc/AppRTCMobile/ios/resources/ic_surround_sound_black_24dp@2x.png", "objc/AppRTCMobile/ios/resources/ic_switch_video_black_24dp.png", diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m index 8f19262305..3cdccd9de0 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 9ebee5c099..20340366c5 100644 --- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m +++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m @@ -114,7 +114,6 @@ static CGFloat const kCallControlMargin = 8; @end @implementation ARDMainView { - UILabel *_appLabel; ARDRoomTextField *_roomText; UILabel *_callOptionsLabel; UISwitch *_audioOnlySwitch; @@ -136,13 +135,6 @@ static CGFloat const kCallControlMargin = 8; - (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 @@ static CGFloat const kCallControlMargin = 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 e392168dee..f7e03bc72f 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 0000000000000000000000000000000000000000..c59419c02b6273e09063a0529d2239784818207f GIT binary patch literal 322 zcmV-I0lof-P)J%}fHzV<>iUk{yCv=|P(yFM9CIKrv6;vdj!^e)OQ=oM~3L z3Hov zYMc*TMS6^4Y*s#v8YK}AT(ig&XB4{J=afm7xZ$2C{CQWp)PoCx)G7YcXPY7T1DnU) UWG_v5V*mgE07*qoM6N<$f<$+V!TNkla9V}f0{{|82kXi@9MRd@?$weK4A^ju7 zLRBcZi6~YV4Y?x0YCBk^ee93}@A5qN9`;=V`Fy9md5-r894+Q7Vwa zKGHbsTJ3CbB>k$}G!3du63TIxO+;yvI}8$@RV#hZwGsJa1 zG(UeLOQIW*%YP$A_S8JsifkZzY=a`Er-+B1U^vMR;-MW*pvdqV@zg66vq)lJDKSEJ zw`0sxb4<_B;v8FuS(#q`)kg&}+hPL6xOrb?GQ?%fExvFHL!Kq|$LU4WPhFXQ&M?@z zxR1mtVOeOIy~lo>;tz)rETgf>fK;}TNLegBvB^KiQ=u3Ot|-Y( z2Uu+mzU3;1m}L#YE?|a1uJMlWb*&qR^Q=+kG@*msHr|$gaEk##XL&}z6#u1a9Hidf vu2=2VHre2#z3N8+Q5wRd6(rV6I@-ivWBUX&LwAlh00000NkvXXu0mjfs0IG% literal 0 HcmV?d00001