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

Side by Side Diff: ios/chrome/browser/ui/open_in_toolbar.mm

Issue 2804703002: [ObjC ARC] Converts ios/chrome/browser/ui:ui_internal_arc to ARC. (Closed)
Patch Set: comments Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/open_in_toolbar.h" 5 #import "ios/chrome/browser/ui/open_in_toolbar.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h"
9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
10 #include "ios/chrome/browser/ui/rtl_geometry.h" 9 #include "ios/chrome/browser/ui/rtl_geometry.h"
11 #import "ios/chrome/browser/ui/uikit_ui_util.h" 10 #import "ios/chrome/browser/ui/uikit_ui_util.h"
12 #include "ios/chrome/grit/ios_strings.h" 11 #include "ios/chrome/grit/ios_strings.h"
13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 12 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
14 #include "ui/base/l10n/l10n_util_mac.h" 13 #include "ui/base/l10n/l10n_util_mac.h"
15 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
16 namespace { 19 namespace {
17 20
18 // The toolbar's open button constants. 21 // The toolbar's open button constants.
19 const CGFloat kOpenButtonVerticalPadding = 8.0f; 22 const CGFloat kOpenButtonVerticalPadding = 8.0f;
20 const CGFloat kOpenButtonTrailingPadding = 16.0f; 23 const CGFloat kOpenButtonTrailingPadding = 16.0f;
21 24
22 // The toolbar's border related constants. 25 // The toolbar's border related constants.
23 const CGFloat kTopBorderHeight = 0.5f; 26 const CGFloat kTopBorderHeight = 0.5f;
24 const CGFloat kTopBorderTransparency = 0.13f; 27 const CGFloat kTopBorderTransparency = 0.13f;
25 const int kTopBorderColor = 0x000000; 28 const int kTopBorderColor = 0x000000;
26 29
27 // The toolbar's background related constants. 30 // The toolbar's background related constants.
28 const int kToolbarBackgroundColor = 0xFFFFFF; 31 const int kToolbarBackgroundColor = 0xFFFFFF;
29 const CGFloat kToolbarBackgroundTransparency = 0.97f; 32 const CGFloat kToolbarBackgroundTransparency = 0.97f;
30 33
31 } // anonymous namespace 34 } // anonymous namespace
32 35
33 @interface OpenInToolbar () { 36 @interface OpenInToolbar () {
34 // Backing object for |self.openButton|. 37 // Backing object for |self.openButton|.
35 base::scoped_nsobject<MDCButton> _openButton; 38 MDCButton* _openButton;
36 // Backing object for |self.topBorder|. 39 // Backing object for |self.topBorder|.
37 base::scoped_nsobject<UIView> _topBorder; 40 UIView* _topBorder;
38 } 41 }
39 42
40 // The "Open in..." button that's hooked up with the target and action passed 43 // The "Open in..." button that's hooked up with the target and action passed
41 // on initialization. 44 // on initialization.
42 @property(nonatomic, retain, readonly) MDCButton* openButton; 45 @property(nonatomic, retain, readonly) MDCButton* openButton;
43 46
44 // The line used as the border at the top of the toolbar. 47 // The line used as the border at the top of the toolbar.
45 @property(nonatomic, retain, readonly) UIView* topBorder; 48 @property(nonatomic, retain, readonly) UIView* topBorder;
46 49
47 @end 50 @end
(...skipping 17 matching lines...) Expand all
65 forControlEvents:UIControlEventTouchUpInside]; 68 forControlEvents:UIControlEventTouchUpInside];
66 [self addSubview:self.topBorder]; 69 [self addSubview:self.topBorder];
67 } 70 }
68 return self; 71 return self;
69 } 72 }
70 73
71 #pragma mark Accessors 74 #pragma mark Accessors
72 75
73 - (MDCButton*)openButton { 76 - (MDCButton*)openButton {
74 if (!_openButton) { 77 if (!_openButton) {
75 _openButton.reset([[MDCFlatButton alloc] init]); 78 _openButton = [[MDCFlatButton alloc] init];
76 [_openButton setCustomTitleColor:[[MDCPalette cr_bluePalette] tint500]]; 79 [_openButton setCustomTitleColor:[[MDCPalette cr_bluePalette] tint500]];
77 [_openButton setTitle:l10n_util::GetNSStringWithFixup(IDS_IOS_OPEN_IN) 80 [_openButton setTitle:l10n_util::GetNSStringWithFixup(IDS_IOS_OPEN_IN)
78 forState:UIControlStateNormal]; 81 forState:UIControlStateNormal];
79 [_openButton sizeToFit]; 82 [_openButton sizeToFit];
80 } 83 }
81 return _openButton.get(); 84 return _openButton;
82 } 85 }
83 86
84 - (UIView*)topBorder { 87 - (UIView*)topBorder {
85 if (!_topBorder) { 88 if (!_topBorder) {
86 _topBorder.reset([[UIView alloc] initWithFrame:CGRectZero]); 89 _topBorder = [[UIView alloc] initWithFrame:CGRectZero];
87 [_topBorder setBackgroundColor:UIColorFromRGB(kTopBorderColor, 90 [_topBorder setBackgroundColor:UIColorFromRGB(kTopBorderColor,
88 kTopBorderTransparency)]; 91 kTopBorderTransparency)];
89 } 92 }
90 return _topBorder.get(); 93 return _topBorder;
91 } 94 }
92 95
93 #pragma mark Layout 96 #pragma mark Layout
94 97
95 - (void)layoutSubviews { 98 - (void)layoutSubviews {
96 [super layoutSubviews]; 99 [super layoutSubviews];
97 100
98 // openButton layout. 101 // openButton layout.
99 CGFloat buttonWidth = CGRectGetWidth(self.openButton.bounds); 102 CGFloat buttonWidth = CGRectGetWidth(self.openButton.bounds);
100 CGFloat buttonHeight = CGRectGetHeight(self.openButton.bounds); 103 CGFloat buttonHeight = CGRectGetHeight(self.openButton.bounds);
(...skipping 12 matching lines...) Expand all
113 } 116 }
114 117
115 - (CGSize)sizeThatFits:(CGSize)size { 118 - (CGSize)sizeThatFits:(CGSize)size {
116 CGSize openButtonSize = [self.openButton sizeThatFits:size]; 119 CGSize openButtonSize = [self.openButton sizeThatFits:size];
117 CGFloat requiredHeight = 120 CGFloat requiredHeight =
118 openButtonSize.height + 2.0 * kOpenButtonVerticalPadding; 121 openButtonSize.height + 2.0 * kOpenButtonVerticalPadding;
119 return CGSizeMake(size.width, requiredHeight); 122 return CGSizeMake(size.width, requiredHeight);
120 } 123 }
121 124
122 @end 125 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/open_in_controller.mm ('k') | ios/chrome/browser/ui/page_not_available_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698