| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ntp/whats_new_header_view.h" | 5 #import "ios/chrome/browser/ui/ntp/whats_new_header_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 10 #include "ios/chrome/common/string_util.h" | 10 #include "ios/chrome/common/string_util.h" |
| 11 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 11 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 12 #include "ios/public/provider/chrome/browser/images/branded_image_provider.h" | 12 #include "ios/public/provider/chrome/browser/images/branded_image_provider.h" |
| 13 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 13 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const CGFloat kLabelTopMargin = 16; | 17 const CGFloat kLabelTopMargin = 16; |
| 18 const CGFloat kLabelBottomMargin = 24; | 18 const CGFloat kLabelBottomMargin = 24; |
| 19 const CGFloat kLabelLineSpacing = 4; | 19 const CGFloat kLabelLineSpacing = 4; |
| 20 const CGFloat kLabelLeftMargin = 8; | 20 const CGFloat kLabelLeftMargin = 8; |
| 21 const CGFloat kLabelFontSize = 14; | |
| 22 const CGFloat kInfoIconSize = 24; | 21 const CGFloat kInfoIconSize = 24; |
| 23 const CGFloat kInfoIconTopMargin = 12; | 22 const CGFloat kInfoIconTopMargin = 12; |
| 24 | 23 |
| 25 const int kTextColorRgb = 0x333333; | 24 const int kTextColorRgb = 0x333333; |
| 26 const int kLinkColorRgb = 0x5595FE; | 25 const int kLinkColorRgb = 0x5595FE; |
| 27 | 26 |
| 28 } // namespace | 27 } // namespace |
| 29 | 28 |
| 30 @interface WhatsNewHeaderView () { | 29 @interface WhatsNewHeaderView () { |
| 31 base::scoped_nsobject<UIImageView> _infoIconImageView; | 30 base::scoped_nsobject<UIImageView> _infoIconImageView; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 [attributedText addAttribute:NSParagraphStyleAttributeName | 175 [attributedText addAttribute:NSParagraphStyleAttributeName |
| 177 value:style | 176 value:style |
| 178 range:NSMakeRange(0, strLength)]; | 177 range:NSMakeRange(0, strLength)]; |
| 179 | 178 |
| 180 [promoLabel setAttributedText:attributedText]; | 179 [promoLabel setAttributedText:attributedText]; |
| 181 } | 180 } |
| 182 | 181 |
| 183 + (UILabel*)promoLabel { | 182 + (UILabel*)promoLabel { |
| 184 base::scoped_nsobject<UILabel> promoLabel( | 183 base::scoped_nsobject<UILabel> promoLabel( |
| 185 [[UILabel alloc] initWithFrame:CGRectZero]); | 184 [[UILabel alloc] initWithFrame:CGRectZero]); |
| 186 [promoLabel setFont:[[MDFRobotoFontLoader sharedInstance] | 185 [promoLabel setFont:[MDCTypography body1Font]]; |
| 187 regularFontOfSize:kLabelFontSize]]; | |
| 188 [promoLabel setTextColor:UIColorFromRGB(kTextColorRgb, 1.0)]; | 186 [promoLabel setTextColor:UIColorFromRGB(kTextColorRgb, 1.0)]; |
| 189 [promoLabel setNumberOfLines:0]; | 187 [promoLabel setNumberOfLines:0]; |
| 190 [promoLabel setTextAlignment:NSTextAlignmentNatural]; | 188 [promoLabel setTextAlignment:NSTextAlignmentNatural]; |
| 191 [promoLabel setLineBreakMode:NSLineBreakByWordWrapping]; | 189 [promoLabel setLineBreakMode:NSLineBreakByWordWrapping]; |
| 192 return promoLabel.autorelease(); | 190 return promoLabel.autorelease(); |
| 193 } | 191 } |
| 194 | 192 |
| 195 + (int)heightToFitText:(NSString*)text inWidth:(CGFloat)width { | 193 + (int)heightToFitText:(NSString*)text inWidth:(CGFloat)width { |
| 196 CGFloat maxWidthForLabel = width - kInfoIconSize - kLabelLeftMargin; | 194 CGFloat maxWidthForLabel = width - kInfoIconSize - kLabelLeftMargin; |
| 197 base::scoped_nsobject<UILabel> promoLabel([[self promoLabel] retain]); | 195 base::scoped_nsobject<UILabel> promoLabel([[self promoLabel] retain]); |
| 198 [[self class] setText:text inPromoLabel:promoLabel.get()]; | 196 [[self class] setText:text inPromoLabel:promoLabel.get()]; |
| 199 CGFloat promoLabelHeight = | 197 CGFloat promoLabelHeight = |
| 200 [promoLabel sizeThatFits:CGSizeMake(maxWidthForLabel, CGFLOAT_MAX)] | 198 [promoLabel sizeThatFits:CGSizeMake(maxWidthForLabel, CGFLOAT_MAX)] |
| 201 .height; | 199 .height; |
| 202 return promoLabelHeight + kLabelTopMargin + kLabelBottomMargin; | 200 return promoLabelHeight + kLabelTopMargin + kLabelBottomMargin; |
| 203 } | 201 } |
| 204 | 202 |
| 205 @end | 203 @end |
| OLD | NEW |