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

Side by Side Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.mm

Issue 2892113002: [ios clean] Fixes Toolbar constraints. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h"
6 6
7 #import "ios/chrome/browser/ui/rtl_geometry.h" 7 #import "ios/chrome/browser/ui/rtl_geometry.h"
8 #import "ios/chrome/browser/ui/uikit_ui_util.h" 8 #import "ios/chrome/browser/ui/uikit_ui_util.h"
9 #include "ios/chrome/grit/ios_theme_resources.h" 9 #include "ios/chrome/grit/ios_theme_resources.h"
10 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc) 11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support." 12 #error "This file requires ARC support."
13 #endif 13 #endif
14 14
15 namespace {
16 // ToolbarButton fixed width.
17 CGFloat kToolbarButtonWidth = 42.0f;
18 } // namespace
19
20 @implementation ToolbarButton (Factory) 15 @implementation ToolbarButton (Factory)
21 16
22 #pragma mark - ToolbarButton Setup 17 #pragma mark - ToolbarButton Setup
23 18
24 + (instancetype)backToolbarButton { 19 + (instancetype)backToolbarButton {
25 ToolbarButton* backButton = [self 20 ToolbarButton* backButton = [self
26 toolbarButtonWithImageForNormalState:NativeReversableImage( 21 toolbarButtonWithImageForNormalState:NativeReversableImage(
27 IDR_IOS_TOOLBAR_LIGHT_BACK, YES) 22 IDR_IOS_TOOLBAR_LIGHT_BACK, YES)
28 imageForHighlightedState: 23 imageForHighlightedState:
29 NativeReversableImage(IDR_IOS_TOOLBAR_LIGHT_BACK_PRESSED, 24 NativeReversableImage(IDR_IOS_TOOLBAR_LIGHT_BACK_PRESSED,
30 YES) 25 YES)
31 imageForDisabledState: 26 imageForDisabledState:
32 NativeReversableImage( 27 NativeReversableImage(
33 IDR_IOS_TOOLBAR_LIGHT_BACK_DISABLED, YES)]; 28 IDR_IOS_TOOLBAR_LIGHT_BACK_DISABLED, YES)];
34 [backButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
35 .active = YES;
36 return backButton; 29 return backButton;
37 } 30 }
38 31
39 + (instancetype)forwardToolbarButton { 32 + (instancetype)forwardToolbarButton {
40 ToolbarButton* forwardButton = [self 33 ToolbarButton* forwardButton = [self
41 toolbarButtonWithImageForNormalState:NativeReversableImage( 34 toolbarButtonWithImageForNormalState:NativeReversableImage(
42 IDR_IOS_TOOLBAR_LIGHT_FORWARD, 35 IDR_IOS_TOOLBAR_LIGHT_FORWARD,
43 YES) 36 YES)
44 imageForHighlightedState: 37 imageForHighlightedState:
45 NativeReversableImage( 38 NativeReversableImage(
46 IDR_IOS_TOOLBAR_LIGHT_FORWARD_PRESSED, YES) 39 IDR_IOS_TOOLBAR_LIGHT_FORWARD_PRESSED, YES)
47 imageForDisabledState: 40 imageForDisabledState:
48 NativeReversableImage( 41 NativeReversableImage(
49 IDR_IOS_TOOLBAR_LIGHT_FORWARD_DISABLED, YES)]; 42 IDR_IOS_TOOLBAR_LIGHT_FORWARD_DISABLED, YES)];
50 [forwardButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
51 .active = YES;
52 return forwardButton; 43 return forwardButton;
53 } 44 }
54 45
55 + (instancetype)tabSwitcherStripToolbarButton { 46 + (instancetype)tabSwitcherStripToolbarButton {
56 ToolbarButton* tabSwitcherStripButton = 47 ToolbarButton* tabSwitcherStripButton =
57 [self toolbarButtonWithImageForNormalState: 48 [self toolbarButtonWithImageForNormalState:
58 [UIImage imageNamed:@"tabswitcher_open_tabs"] 49 [UIImage imageNamed:@"tabswitcher_open_tabs"]
59 imageForHighlightedState:nil 50 imageForHighlightedState:nil
60 imageForDisabledState:nil]; 51 imageForDisabledState:nil];
61 [tabSwitcherStripButton.widthAnchor
62 constraintEqualToConstant:kToolbarButtonWidth]
63 .active = YES;
64 return tabSwitcherStripButton; 52 return tabSwitcherStripButton;
65 } 53 }
66 54
67 + (instancetype)tabSwitcherGridToolbarButton { 55 + (instancetype)tabSwitcherGridToolbarButton {
68 ToolbarButton* tabSwitcherGridButton = 56 ToolbarButton* tabSwitcherGridButton =
69 [self toolbarButtonWithImageForNormalState: 57 [self toolbarButtonWithImageForNormalState:
70 [UIImage imageNamed:@"tabswitcher_tab_switcher_button"] 58 [UIImage imageNamed:@"tabswitcher_tab_switcher_button"]
71 imageForHighlightedState:nil 59 imageForHighlightedState:nil
72 imageForDisabledState:nil]; 60 imageForDisabledState:nil];
73 [tabSwitcherGridButton.widthAnchor
74 constraintEqualToConstant:kToolbarButtonWidth]
75 .active = YES;
76 return tabSwitcherGridButton; 61 return tabSwitcherGridButton;
77 } 62 }
78 63
79 + (instancetype)toolsMenuToolbarButton { 64 + (instancetype)toolsMenuToolbarButton {
80 ToolbarButton* toolsMenuButton = [self 65 ToolbarButton* toolsMenuButton = [self
81 toolbarButtonWithImageForNormalState:[UIImage 66 toolbarButtonWithImageForNormalState:[UIImage
82 imageNamed:@"tabswitcher_menu"] 67 imageNamed:@"tabswitcher_menu"]
83 imageForHighlightedState:nil 68 imageForHighlightedState:nil
84 imageForDisabledState:nil]; 69 imageForDisabledState:nil];
85 [toolsMenuButton setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -3, 0, 0)]; 70 [toolsMenuButton setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -3, 0, 0)];
86 [toolsMenuButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
87 .active = YES;
88 return toolsMenuButton; 71 return toolsMenuButton;
89 } 72 }
90 73
91 + (instancetype)shareToolbarButton { 74 + (instancetype)shareToolbarButton {
92 ToolbarButton* shareButton = [self 75 ToolbarButton* shareButton = [self
93 toolbarButtonWithImageForNormalState:NativeImage( 76 toolbarButtonWithImageForNormalState:NativeImage(
94 IDR_IOS_TOOLBAR_LIGHT_SHARE) 77 IDR_IOS_TOOLBAR_LIGHT_SHARE)
95 imageForHighlightedState: 78 imageForHighlightedState:
96 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_PRESSED) 79 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_PRESSED)
97 imageForDisabledState: 80 imageForDisabledState:
98 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_DISABLED)]; 81 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_DISABLED)];
99 [shareButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
100 .active = YES;
101 return shareButton; 82 return shareButton;
102 } 83 }
103 84
104 + (instancetype)reloadToolbarButton { 85 + (instancetype)reloadToolbarButton {
105 ToolbarButton* reloadButton = [self 86 ToolbarButton* reloadButton = [self
106 toolbarButtonWithImageForNormalState:NativeReversableImage( 87 toolbarButtonWithImageForNormalState:NativeReversableImage(
107 IDR_IOS_TOOLBAR_LIGHT_RELOAD, 88 IDR_IOS_TOOLBAR_LIGHT_RELOAD,
108 YES) 89 YES)
109 imageForHighlightedState: 90 imageForHighlightedState:
110 NativeReversableImage( 91 NativeReversableImage(
111 IDR_IOS_TOOLBAR_LIGHT_RELOAD_PRESSED, YES) 92 IDR_IOS_TOOLBAR_LIGHT_RELOAD_PRESSED, YES)
112 imageForDisabledState: 93 imageForDisabledState:
113 NativeReversableImage( 94 NativeReversableImage(
114 IDR_IOS_TOOLBAR_LIGHT_RELOAD_DISABLED, YES)]; 95 IDR_IOS_TOOLBAR_LIGHT_RELOAD_DISABLED, YES)];
115 [reloadButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
116 .active = YES;
117 return reloadButton; 96 return reloadButton;
118 } 97 }
119 98
120 + (instancetype)stopToolbarButton { 99 + (instancetype)stopToolbarButton {
121 ToolbarButton* stopButton = [self 100 ToolbarButton* stopButton = [self
122 toolbarButtonWithImageForNormalState:NativeImage( 101 toolbarButtonWithImageForNormalState:NativeImage(
123 IDR_IOS_TOOLBAR_LIGHT_STOP) 102 IDR_IOS_TOOLBAR_LIGHT_STOP)
124 imageForHighlightedState: 103 imageForHighlightedState:
125 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_PRESSED) 104 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_PRESSED)
126 imageForDisabledState: 105 imageForDisabledState:
127 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_DISABLED)]; 106 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_DISABLED)];
128 [stopButton.widthAnchor constraintEqualToConstant:kToolbarButtonWidth]
129 .active = YES;
130 return stopButton; 107 return stopButton;
131 } 108 }
132 109
133 @end 110 @end
OLDNEW
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698