| OLD | NEW |
| 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; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 textString = ParseStringWithLink(textString, &linkRange); | 88 textString = ParseStringWithLink(textString, &linkRange); |
| 89 | 89 |
| 90 // Build style attributes for the label. | 90 // Build style attributes for the label. |
| 91 NSMutableParagraphStyle* paragraphStyle = | 91 NSMutableParagraphStyle* paragraphStyle = |
| 92 [[NSMutableParagraphStyle alloc] init]; | 92 [[NSMutableParagraphStyle alloc] init]; |
| 93 [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping]; | 93 [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping]; |
| 94 [paragraphStyle setLineHeightMultiple:kLineSpace]; | 94 [paragraphStyle setLineHeightMultiple:kLineSpace]; |
| 95 NSDictionary* attributes = @{ | 95 NSDictionary* attributes = @{ |
| 96 NSParagraphStyleAttributeName : paragraphStyle, | 96 NSParagraphStyleAttributeName : paragraphStyle, |
| 97 NSFontAttributeName : | 97 NSFontAttributeName : |
| 98 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:kTextFontSize], | 98 [[MDCTypography fontLoader] regularFontOfSize:kTextFontSize], |
| 99 NSForegroundColorAttributeName : | 99 NSForegroundColorAttributeName : |
| 100 [UIColor colorWithWhite:kTextColorGrayShade alpha:1] | 100 [UIColor colorWithWhite:kTextColorGrayShade alpha:1] |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // Create and assign attributed text to label. | 103 // Create and assign attributed text to label. |
| 104 NSMutableAttributedString* attributedText = | 104 NSMutableAttributedString* attributedText = |
| 105 [[NSMutableAttributedString alloc] initWithString:textString]; | 105 [[NSMutableAttributedString alloc] initWithString:textString]; |
| 106 [attributedText setAttributes:attributes | 106 [attributedText setAttributes:attributes |
| 107 range:NSMakeRange(0, textString.length)]; | 107 range:NSMakeRange(0, textString.length)]; |
| 108 text.attributedText = attributedText; | 108 text.attributedText = attributedText; |
| 109 [_linkController addLinkWithRange:linkRange | 109 [_linkController addLinkWithRange:linkRange |
| 110 url:GURL("contextualSearch://settings")]; | 110 url:GURL("contextualSearch://settings")]; |
| 111 text.numberOfLines = 0; | 111 text.numberOfLines = 0; |
| 112 | 112 |
| 113 UIFont* buttonFont = | 113 UIFont* buttonFont = |
| 114 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:kButtonFontSize]; | 114 [[MDCTypography fontLoader] mediumFontOfSize:kButtonFontSize]; |
| 115 | 115 |
| 116 // Create accept and decline buttons with dimensions defined by the | 116 // Create accept and decline buttons with dimensions defined by the |
| 117 // minimum height and width constants. | 117 // minimum height and width constants. |
| 118 MDCFlatButton* acceptButton = [[MDCFlatButton alloc] init]; | 118 MDCFlatButton* acceptButton = [[MDCFlatButton alloc] init]; |
| 119 acceptButton.hasOpaqueBackground = YES; | 119 acceptButton.hasOpaqueBackground = YES; |
| 120 acceptButton.inkColor = | 120 acceptButton.inkColor = |
| 121 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f]; | 121 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f]; |
| 122 [acceptButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] | 122 [acceptButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] |
| 123 forState:UIControlStateNormal]; | 123 forState:UIControlStateNormal]; |
| 124 [acceptButton setBackgroundColor:[UIColor colorWithWhite:0.6f alpha:1.0f] | 124 [acceptButton setBackgroundColor:[UIColor colorWithWhite:0.6f alpha:1.0f] |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 self.hidden = NO; | 251 self.hidden = NO; |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 - (void)panelWillPromote:(ContextualSearchPanelView*)panel { | 255 - (void)panelWillPromote:(ContextualSearchPanelView*)panel { |
| 256 _delegate = nil; | 256 _delegate = nil; |
| 257 [panel removeMotionObserver:self]; | 257 [panel removeMotionObserver:self]; |
| 258 } | 258 } |
| 259 | 259 |
| 260 @end | 260 @end |
| OLD | NEW |