| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/clean/chrome/browser/ui/tools/menu_view_controller.h" | 5 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #import "base/logging.h" | 8 #import "base/logging.h" |
| 9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
| 10 #import "base/macros.h" | 10 #import "base/macros.h" |
| 11 #import "ios/chrome/browser/ui/rtl_geometry.h" | 11 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 13 #include "ios/chrome/grit/ios_theme_resources.h" | 13 #include "ios/chrome/grit/ios_theme_resources.h" |
| 14 #import "ios/clean/chrome/browser/ui/commands/find_in_page_visibility_commands.h
" |
| 14 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" | 15 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" |
| 15 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" | 16 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" |
| 16 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" | 17 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" |
| 17 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" | 18 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" |
| 18 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h" | 19 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h" |
| 19 #import "ios/clean/chrome/browser/ui/tools/menu_overflow_controls_stackview.h" | 20 #import "ios/clean/chrome/browser/ui/tools/menu_overflow_controls_stackview.h" |
| 20 #import "ios/clean/chrome/browser/ui/tools/tools_actions.h" | |
| 21 #import "ios/clean/chrome/browser/ui/tools/tools_menu_item.h" | 21 #import "ios/clean/chrome/browser/ui/tools/tools_menu_item.h" |
| 22 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 22 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 23 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 const CGFloat kMenuWidth = 250.0; | 29 const CGFloat kMenuWidth = 250.0; |
| 30 const CGFloat kMenuItemHeight = 48.0; | 30 const CGFloat kMenuItemHeight = 48.0; |
| 31 const CGFloat kMenuItemLeadingEdgeInset = 12.0; | 31 const CGFloat kMenuItemLeadingEdgeInset = 12.0; |
| 32 const CGFloat kOverflowControlsMargin = 58.0; | 32 const CGFloat kOverflowControlsMargin = 58.0; |
| 33 const CGFloat kCloseButtonHeight = 44.0; | 33 const CGFloat kCloseButtonHeight = 44.0; |
| 34 } | 34 } |
| 35 | 35 |
| 36 @interface MenuViewController ()<ToolsActions> | 36 @interface MenuViewController () |
| 37 @property(nonatomic, strong) UIScrollView* menuScrollView; | 37 @property(nonatomic, strong) UIScrollView* menuScrollView; |
| 38 @property(nonatomic, strong) UIStackView* menuStackView; | 38 @property(nonatomic, strong) UIStackView* menuStackView; |
| 39 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems; | 39 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems; |
| 40 @property(nonatomic, strong) | 40 @property(nonatomic, strong) |
| 41 MenuOverflowControlsStackView* toolbarOverflowStackView; | 41 MenuOverflowControlsStackView* toolbarOverflowStackView; |
| 42 @property(nonatomic, assign) BOOL displayOverflowControls; | 42 @property(nonatomic, assign) BOOL displayOverflowControls; |
| 43 @property(nonatomic, strong) ToolbarButton* closeMenuButton; | 43 @property(nonatomic, strong) ToolbarButton* closeMenuButton; |
| 44 @property(nonatomic, assign) BOOL currentPageLoading; | 44 @property(nonatomic, assign) BOOL currentPageLoading; |
| 45 | 45 |
| 46 // Sets up the main StackView and creates a button for each Menu item. | 46 // Sets up the main StackView and creates a button for each Menu item. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 constraintEqualToAnchor:self.menuScrollView.bottomAnchor], | 230 constraintEqualToAnchor:self.menuScrollView.bottomAnchor], |
| 231 [self.menuStackView.topAnchor | 231 [self.menuStackView.topAnchor |
| 232 constraintEqualToAnchor:self.menuScrollView.topAnchor], | 232 constraintEqualToAnchor:self.menuScrollView.topAnchor], |
| 233 [self.menuStackView.widthAnchor | 233 [self.menuStackView.widthAnchor |
| 234 constraintEqualToAnchor:self.menuScrollView.widthAnchor], | 234 constraintEqualToAnchor:self.menuScrollView.widthAnchor], |
| 235 [self.menuStackView.heightAnchor | 235 [self.menuStackView.heightAnchor |
| 236 constraintEqualToConstant:kMenuItemHeight * self.menuItems.count], | 236 constraintEqualToConstant:kMenuItemHeight * self.menuItems.count], |
| 237 // CloseMenu Button Constraint. | 237 // CloseMenu Button Constraint. |
| 238 [self.closeMenuButton.trailingAnchor | 238 [self.closeMenuButton.trailingAnchor |
| 239 constraintEqualToAnchor:self.view.trailingAnchor], | 239 constraintEqualToAnchor:self.view.trailingAnchor], |
| 240 [self.closeMenuButton.topAnchor |
| 241 constraintEqualToAnchor:self.menuScrollView.topAnchor], |
| 240 ]]; | 242 ]]; |
| 241 } | 243 } |
| 242 | 244 |
| 243 #pragma mark - Tools Consumer | 245 #pragma mark - Tools Consumer |
| 244 | 246 |
| 245 - (void)setToolsMenuItems:(NSArray*)menuItems { | 247 - (void)setToolsMenuItems:(NSArray*)menuItems { |
| 246 _menuItems = menuItems; | 248 _menuItems = menuItems; |
| 247 } | 249 } |
| 248 | 250 |
| 249 - (void)displayOverflowControls:(BOOL)displayOverflowControls { | 251 - (void)displayOverflowControls:(BOOL)displayOverflowControls { |
| 250 self.displayOverflowControls = displayOverflowControls; | 252 self.displayOverflowControls = displayOverflowControls; |
| 251 } | 253 } |
| 252 | 254 |
| 253 - (void)setIsLoading:(BOOL)isLoading { | 255 - (void)setIsLoading:(BOOL)isLoading { |
| 254 self.currentPageLoading = isLoading; | 256 self.currentPageLoading = isLoading; |
| 255 } | 257 } |
| 256 | 258 |
| 257 - (void)setCurrentPageLoading:(BOOL)currentPageLoading { | 259 - (void)setCurrentPageLoading:(BOOL)currentPageLoading { |
| 258 _currentPageLoading = currentPageLoading; | 260 _currentPageLoading = currentPageLoading; |
| 259 // If the OverflowButtons have been initialized update their visibility. | 261 // If the OverflowButtons have been initialized update their visibility. |
| 260 if (self.toolbarOverflowStackView) { | 262 if (self.toolbarOverflowStackView) { |
| 261 self.toolbarOverflowStackView.reloadButton.hidden = currentPageLoading; | 263 self.toolbarOverflowStackView.reloadButton.hidden = currentPageLoading; |
| 262 self.toolbarOverflowStackView.stopButton.hidden = !currentPageLoading; | 264 self.toolbarOverflowStackView.stopButton.hidden = !currentPageLoading; |
| 263 } | 265 } |
| 264 } | 266 } |
| 265 | 267 |
| 266 @end | 268 @end |
| OLD | NEW |