| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/toolbar/new_keyboard_accessory_view.h" | 5 #import "ios/chrome/browser/ui/toolbar/new_keyboard_accessory_view.h" |
| 6 | 6 |
| 7 #import <NotificationCenter/NotificationCenter.h> | 7 #import <NotificationCenter/NotificationCenter.h> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "ios/chrome/browser/experimental_flags.h" | 10 #include "ios/chrome/browser/experimental_flags.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 @implementation NewKeyboardAccessoryView | 36 @implementation NewKeyboardAccessoryView |
| 37 | 37 |
| 38 // Unused by this implementation of |KeyboardAccessoryViewProtocol|. | 38 // Unused by this implementation of |KeyboardAccessoryViewProtocol|. |
| 39 @synthesize mode = _mode; | 39 @synthesize mode = _mode; |
| 40 | 40 |
| 41 @synthesize buttonTitles = _buttonTitles; | 41 @synthesize buttonTitles = _buttonTitles; |
| 42 @synthesize delegate = _delegate; | 42 @synthesize delegate = _delegate; |
| 43 | 43 |
| 44 - (instancetype)initWithButtons:(NSArray<NSString*>*)buttonTitles | 44 - (instancetype)initWithButtons:(NSArray<NSString*>*)buttonTitles |
| 45 delegate:(id<KeyboardAccessoryViewDelegate>)delegate { | 45 delegate:(id<KeyboardAccessoryViewDelegate>)delegate { |
| 46 DCHECK(!IsIPadIdiom()); | |
| 47 | |
| 48 const CGFloat kViewHeight = 44.0; | 46 const CGFloat kViewHeight = 44.0; |
| 49 CGFloat width = [[UIScreen mainScreen] bounds].size.width; | 47 CGFloat width = [[UIScreen mainScreen] bounds].size.width; |
| 50 // TODO(734512): Have the creator of the view define the size. | 48 // TODO(734512): Have the creator of the view define the size. |
| 51 CGRect frame = CGRectMake(0.0, 0.0, width, kViewHeight); | 49 CGRect frame = CGRectMake(0.0, 0.0, width, kViewHeight); |
| 52 | 50 |
| 53 self = [super initWithFrame:frame inputViewStyle:UIInputViewStyleKeyboard]; | 51 self = [super initWithFrame:frame inputViewStyle:UIInputViewStyleKeyboard]; |
| 54 if (self) { | 52 if (self) { |
| 55 _buttonTitles = buttonTitles; | 53 _buttonTitles = buttonTitles; |
| 56 _delegate = delegate; | 54 _delegate = delegate; |
| 57 | 55 [self addSubviews]; |
| 58 } | 56 } |
| 59 return self; | 57 return self; |
| 60 } | 58 } |
| 61 | 59 |
| 62 - (void)willMoveToSuperview:(UIView*)newSuperview { | 60 - (void)addSubviews { |
| 63 if (!self.subviews.count) | 61 if (!self.subviews.count) |
| 64 return; | 62 return; |
| 65 | 63 |
| 66 const CGFloat kButtonMinWidth = 36.0; | 64 const CGFloat kButtonMinWidth = 36.0; |
| 67 const CGFloat kButtonHeight = 34.0; | 65 const CGFloat kButtonHeight = 34.0; |
| 68 const CGFloat kBetweenShortcutButtonSpacing = 5.0; | 66 const CGFloat kBetweenShortcutButtonSpacing = 5.0; |
| 69 const CGFloat kBetweenSearchButtonSpacing = 12.0; | 67 const CGFloat kBetweenSearchButtonSpacing = 12.0; |
| 70 const CGFloat kMarginFromBottom = 2.0; | 68 const CGFloat kMarginFromBottom = 2.0; |
| 71 const CGFloat kHorizontalMargin = 12.0; | 69 const CGFloat kHorizontalMargin = 12.0; |
| 72 | 70 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return YES; | 174 return YES; |
| 177 } | 175 } |
| 178 | 176 |
| 179 - (void)keyboardButtonPressed:(id)sender { | 177 - (void)keyboardButtonPressed:(id)sender { |
| 180 UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender); | 178 UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender); |
| 181 [[UIDevice currentDevice] playInputClick]; | 179 [[UIDevice currentDevice] playInputClick]; |
| 182 [_delegate keyPressed:[button currentTitle]]; | 180 [_delegate keyPressed:[button currentTitle]]; |
| 183 } | 181 } |
| 184 | 182 |
| 185 @end | 183 @end |
| OLD | NEW |