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

Side by Side Diff: ios/chrome/browser/ui/contextual_search/contextual_search_promo_view.mm

Issue 2912863005: Use MDCTypography instead of MDFRobotoFontLoader directly. (Closed)
Patch Set: Revert main_controller Created 3 years, 6 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/contextual_search/contextual_search_promo_view.h" 5 #import "ios/chrome/browser/ui/contextual_search/contextual_search_promo_view.h"
6 6
7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
8 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.h" 8 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.h"
9 #include "ios/chrome/browser/ui/uikit_ui_util.h" 9 #include "ios/chrome/browser/ui/uikit_ui_util.h"
10 #import "ios/chrome/browser/ui/util/label_link_controller.h" 10 #import "ios/chrome/browser/ui/util/label_link_controller.h"
11 #import "ios/chrome/common/material_timing.h" 11 #import "ios/chrome/common/material_timing.h"
12 #include "ios/chrome/common/string_util.h" 12 #include "ios/chrome/common/string_util.h"
13 #include "ios/chrome/grit/ios_strings.h" 13 #include "ios/chrome/grit/ios_strings.h"
14 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 14 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
15 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc) 19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support." 20 #error "This file requires ARC support."
21 #endif 21 #endif
22 22
23 namespace { 23 namespace {
24 const int kMargin = 16; 24 const int kMargin = 16;
25 const int kSpaceBelowText = 32; 25 const int kSpaceBelowText = 32;
26 const int kButtonSeparator = 8; 26 const int kButtonSeparator = 8;
27 const int kButtonHeight = 36; 27 const int kButtonHeight = 36;
28 const int kButtonMinWidth = 88; 28 const int kButtonMinWidth = 88;
29 const int kDividerHeight = 1; 29 const int kDividerHeight = 1;
30 30
31 const int kTextFontSize = 16;
32 const int kButtonFontSize = 14;
33 const CGFloat kTextColorGrayShade = 0.494; 31 const CGFloat kTextColorGrayShade = 0.494;
34 const int kLinkColorRGB = 0x5D9AFF; 32 const int kLinkColorRGB = 0x5D9AFF;
35 33
36 const CGFloat kLineSpace = 1.15; 34 const CGFloat kLineSpace = 1.15;
37 35
38 // Animation timings. 36 // Animation timings.
39 const CGFloat kCloseDuration = ios::material::kDuration1; 37 const CGFloat kCloseDuration = ios::material::kDuration1;
40 } 38 }
41 39
42 @interface ContextualSearchPromoView () 40 @interface ContextualSearchPromoView ()
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 NSRange linkRange; 85 NSRange linkRange;
88 textString = ParseStringWithLink(textString, &linkRange); 86 textString = ParseStringWithLink(textString, &linkRange);
89 87
90 // Build style attributes for the label. 88 // Build style attributes for the label.
91 NSMutableParagraphStyle* paragraphStyle = 89 NSMutableParagraphStyle* paragraphStyle =
92 [[NSMutableParagraphStyle alloc] init]; 90 [[NSMutableParagraphStyle alloc] init];
93 [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping]; 91 [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping];
94 [paragraphStyle setLineHeightMultiple:kLineSpace]; 92 [paragraphStyle setLineHeightMultiple:kLineSpace];
95 NSDictionary* attributes = @{ 93 NSDictionary* attributes = @{
96 NSParagraphStyleAttributeName : paragraphStyle, 94 NSParagraphStyleAttributeName : paragraphStyle,
97 NSFontAttributeName : 95 NSFontAttributeName : [MDCTypography subheadFont],
98 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:kTextFontSize],
99 NSForegroundColorAttributeName : 96 NSForegroundColorAttributeName :
100 [UIColor colorWithWhite:kTextColorGrayShade alpha:1] 97 [UIColor colorWithWhite:kTextColorGrayShade alpha:1]
101 }; 98 };
102 99
103 // Create and assign attributed text to label. 100 // Create and assign attributed text to label.
104 NSMutableAttributedString* attributedText = 101 NSMutableAttributedString* attributedText =
105 [[NSMutableAttributedString alloc] initWithString:textString]; 102 [[NSMutableAttributedString alloc] initWithString:textString];
106 [attributedText setAttributes:attributes 103 [attributedText setAttributes:attributes
107 range:NSMakeRange(0, textString.length)]; 104 range:NSMakeRange(0, textString.length)];
108 text.attributedText = attributedText; 105 text.attributedText = attributedText;
109 [_linkController addLinkWithRange:linkRange 106 [_linkController addLinkWithRange:linkRange
110 url:GURL("contextualSearch://settings")]; 107 url:GURL("contextualSearch://settings")];
111 text.numberOfLines = 0; 108 text.numberOfLines = 0;
112 109
113 UIFont* buttonFont = 110 UIFont* buttonFont = [MDCTypography buttonFont];
114 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:kButtonFontSize];
115 111
116 // Create accept and decline buttons with dimensions defined by the 112 // Create accept and decline buttons with dimensions defined by the
117 // minimum height and width constants. 113 // minimum height and width constants.
118 MDCFlatButton* acceptButton = [[MDCFlatButton alloc] init]; 114 MDCFlatButton* acceptButton = [[MDCFlatButton alloc] init];
119 acceptButton.hasOpaqueBackground = YES; 115 acceptButton.hasOpaqueBackground = YES;
120 acceptButton.inkColor = 116 acceptButton.inkColor =
121 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f]; 117 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f];
122 [acceptButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 118 [acceptButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
123 forState:UIControlStateNormal]; 119 forState:UIControlStateNormal];
124 [acceptButton setBackgroundColor:[UIColor colorWithWhite:0.6f alpha:1.0f] 120 [acceptButton setBackgroundColor:[UIColor colorWithWhite:0.6f alpha:1.0f]
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 self.hidden = NO; 247 self.hidden = NO;
252 } 248 }
253 } 249 }
254 250
255 - (void)panelWillPromote:(ContextualSearchPanelView*)panel { 251 - (void)panelWillPromote:(ContextualSearchPanelView*)panel {
256 _delegate = nil; 252 _delegate = nil;
257 [panel removeMotionObserver:self]; 253 [panel removeMotionObserver:self];
258 } 254 }
259 255
260 @end 256 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698