Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Side by Side Diff: ios/clean/chrome/browser/ui/tools/menu_view_controller.mm

Issue 2685823002: [ios clean] ToolsMenu UI changes (Closed)
Patch Set: Use NSTextAlignmentNatural for RTL Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/clean/chrome/browser/ui/tools/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // ====== New Architecture ===== 5 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. = 6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================ 7 // ============================================================================
8 8
9 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" 9 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h"
10 10
11 #include "base/i18n/rtl.h"
11 #import "base/logging.h" 12 #import "base/logging.h"
12 #import "base/macros.h" 13 #import "base/macros.h"
13 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" 14 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h"
14 #import "ios/clean/chrome/browser/ui/actions/tools_menu_actions.h" 15 #import "ios/clean/chrome/browser/ui/actions/tools_menu_actions.h"
16 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
15 17
16 #if !defined(__has_feature) || !__has_feature(objc_arc) 18 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support." 19 #error "This file requires ARC support."
18 #endif 20 #endif
19 21
20 namespace { 22 namespace {
21 const CGFloat kMenuWidth = 250; 23 const CGFloat kMenuWidth = 250;
22 const CGFloat kMenuItemHeight = 44; 24 const CGFloat kMenuItemHeight = 48;
23 } 25 }
24 26
25 // Placeholder model for menu item configuration. 27 // Placeholder model for menu item configuration.
26 @interface MenuItem : NSObject 28 @interface MenuItem : NSObject
27 @property(nonatomic, copy) NSString* title; 29 @property(nonatomic, copy) NSString* title;
28 @property(nonatomic) SEL action; 30 @property(nonatomic) SEL action;
29 @end 31 @end
30 32
31 @implementation MenuItem 33 @implementation MenuItem
32 @synthesize title = _title; 34 @synthesize title = _title;
33 @synthesize action = _action; 35 @synthesize action = _action;
34 @end 36 @end
35 37
36 @interface MenuViewController () 38 @interface MenuViewController ()
37 @property(nonatomic, readonly) NSArray<MenuItem*>* menuItems; 39 @property(nonatomic, readonly) NSArray<MenuItem*>* menuItems;
38 @end 40 @end
39 41
40 @implementation MenuViewController 42 @implementation MenuViewController
41 @synthesize menuItems = _menuItems; 43 @synthesize menuItems = _menuItems;
42 44
43 - (instancetype)init { 45 - (instancetype)init {
44 if ((self = [super init])) { 46 if ((self = [super init])) {
45 _menuItems = @[ 47 _menuItems = @[
46 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], 48 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init],
47 [[MenuItem alloc] init] 49 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init],
50 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init],
51 [[MenuItem alloc] init], [[MenuItem alloc] init]
48 ]; 52 ];
49 53
50 _menuItems[0].title = @"New Tab"; 54 _menuItems[0].title = @"New Tab";
51 55
52 _menuItems[1].title = @"Find in Page…"; 56 _menuItems[1].title = @"New Incognito Tab";
53 57
54 _menuItems[2].title = @"Request Desktop Site"; 58 _menuItems[2].title = @"Bookmarks";
55 59
56 _menuItems[3].title = @"Settings"; 60 _menuItems[3].title = @"Reading List";
57 _menuItems[3].action = @selector(showSettings:); 61
62 _menuItems[4].title = @"Recent Tabs";
63
64 _menuItems[5].title = @"History";
65
66 _menuItems[6].title = @"Report an Issue";
67
68 _menuItems[7].title = @"Find in Page…";
69
70 _menuItems[8].title = @"Request Desktop Site";
71
72 _menuItems[9].title = @"Settings";
73 _menuItems[9].action = @selector(showSettings:);
74
75 _menuItems[10].title = @"Help";
58 } 76 }
59 return self; 77 return self;
60 } 78 }
61 79
62 - (void)loadView { 80 - (void)loadView {
63 CGRect frame; 81 CGRect frame;
64 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count); 82 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count);
65 frame.origin = CGPointZero; 83 frame.origin = CGPointZero;
66 self.view = [[UIView alloc] initWithFrame:frame]; 84 self.view = [[UIView alloc] initWithFrame:frame];
67 self.view.backgroundColor = [UIColor whiteColor]; 85 self.view.backgroundColor = [UIColor whiteColor];
68 self.view.autoresizingMask = UIViewAutoresizingNone; 86 self.view.autoresizingMask = UIViewAutoresizingNone;
87 self.view.layer.borderColor = [UIColor clearColor].CGColor;
69 } 88 }
70 89
71 - (void)viewDidLoad { 90 - (void)viewDidLoad {
72 NSMutableArray<UIButton*>* buttons = 91 NSMutableArray<UIButton*>* buttons =
73 [[NSMutableArray alloc] initWithCapacity:_menuItems.count]; 92 [[NSMutableArray alloc] initWithCapacity:_menuItems.count];
74 93
75 for (MenuItem* item in _menuItems) { 94 for (MenuItem* item in _menuItems) {
76 UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem]; 95 UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem];
77 menuButton.translatesAutoresizingMaskIntoConstraints = NO; 96 menuButton.translatesAutoresizingMaskIntoConstraints = NO;
97 menuButton.tintColor = [UIColor blackColor];
78 [menuButton setTitle:item.title forState:UIControlStateNormal]; 98 [menuButton setTitle:item.title forState:UIControlStateNormal];
99 [menuButton.titleLabel
100 setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]];
101 [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural];
79 [menuButton addTarget:nil 102 [menuButton addTarget:nil
80 action:@selector(closeToolsMenu:) 103 action:@selector(closeToolsMenu:)
81 forControlEvents:UIControlEventTouchUpInside]; 104 forControlEvents:UIControlEventTouchUpInside];
82 if (item.action) { 105 if (item.action) {
83 [menuButton addTarget:nil 106 [menuButton addTarget:nil
84 action:item.action 107 action:item.action
85 forControlEvents:UIControlEventTouchUpInside]; 108 forControlEvents:UIControlEventTouchUpInside];
86 } 109 }
87 [buttons addObject:menuButton]; 110 [buttons addObject:menuButton];
88 } 111 }
(...skipping 12 matching lines...) Expand all
101 [menu.trailingAnchor 124 [menu.trailingAnchor
102 constraintEqualToAnchor:self.view.layoutMarginsGuide.trailingAnchor], 125 constraintEqualToAnchor:self.view.layoutMarginsGuide.trailingAnchor],
103 [menu.bottomAnchor 126 [menu.bottomAnchor
104 constraintEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor], 127 constraintEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor],
105 [menu.topAnchor 128 [menu.topAnchor
106 constraintEqualToAnchor:self.view.layoutMarginsGuide.topAnchor], 129 constraintEqualToAnchor:self.view.layoutMarginsGuide.topAnchor],
107 ]]; 130 ]];
108 } 131 }
109 132
110 @end 133 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tools/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698