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

Side by Side Diff: ios/chrome/today_extension/footer_label.mm

Issue 2586713002: Upstream code and resources for Chrome on iOS extensions. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/today_extension/footer_label.h"
6
7 #import "base/mac/scoped_block.h"
8 #import "base/mac/scoped_nsobject.h"
9 #import "ios/chrome/common/string_util.h"
10 #include "ios/chrome/today_extension/interactive_label.h"
11 #include "ios/chrome/today_extension/transparent_button.h"
12 #include "ios/chrome/today_extension/ui_util.h"
13 #include "ios/today_extension/grit/ios_today_extension_strings.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 // Font size of a footer.
17 const CGFloat kFooterFontSize = 11;
18
19 @implementation SimpleFooterLabel {
20 base::scoped_nsobject<InteractiveLabel> _label;
21 }
22
23 - (instancetype)initWithLabelString:(NSString*)labelString
24 buttonString:(NSString*)buttonString
25 linkBlock:(ProceduralBlock)linkBlock
26 buttonBlock:(ProceduralBlock)buttonBlock {
27 self = [super init];
28 UIEdgeInsets insets = UIEdgeInsetsMake(
29 ui_util::kFooterVerticalMargin, ui_util::kFooterHorizontalMargin,
30 ui_util::kFooterVerticalMargin, ui_util::kFooterHorizontalMargin);
31 _label.reset([[InteractiveLabel alloc] initWithFrame:CGRectZero
32 labelString:labelString
33 fontSize:kFooterFontSize
34 labelAlignment:NSTextAlignmentCenter
35 insets:insets
36 buttonString:buttonString
37 linkBlock:linkBlock
38 buttonBlock:buttonBlock]);
39
40 return self;
41 }
42
43 - (CGFloat)heightForWidth:(CGFloat)width {
44 CGSize size = [_label sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)];
45 return size.height;
46 }
47
48 - (void)setFrame:(CGRect)frame {
49 [_label setFrame:frame];
50 }
51
52 - (UIView*)view {
53 return _label;
54 }
55
56 @end
57
58 @implementation PWIsOnFooterLabel
59
60 - (instancetype)initWithLearnMoreBlock:(LearnMoreBlock)learnMore
61 turnOffBlock:(EnableDisableBlock)turnOffBlock {
62 self = [super
63 initWithLabelString:
64 l10n_util::GetNSString(
65 IDS_IOS_PYSICAL_WEB_ON_TODAY_EXTENSION_FOOTER_LABEL)
66 buttonString:
67 l10n_util::GetNSString(
68 IDS_IOS_PYSICAL_WEB_TURN_OFF_TODAY_EXTENSION_FOOTER_LABEL)
69 linkBlock:learnMore
70 buttonBlock:turnOffBlock];
71 return self;
72 }
73
74 @end
75
76 @implementation PWIsOffFooterLabel
77
78 - (instancetype)initWithLearnMoreBlock:(LearnMoreBlock)learnMore
79 turnOnBlock:(EnableDisableBlock)turnOnBlock {
80 self = [super
81 initWithLabelString:
82 l10n_util::GetNSString(
83 IDS_IOS_PYSICAL_WEB_OFF_TODAY_EXTENSION_FOOTER_LABEL)
84 buttonString:
85 l10n_util::GetNSString(
86 IDS_IOS_PYSICAL_WEB_TURN_ON_TODAY_EXTENSION_FOOTER_LABEL)
87 linkBlock:learnMore
88 buttonBlock:turnOnBlock];
89 return self;
90 }
91
92 @end
93
94 @implementation PWScanningFooterLabel
95
96 - (instancetype)initWithLearnMoreBlock:(LearnMoreBlock)learnMore
97 turnOffBlock:(EnableDisableBlock)turnOffBlock {
98 self = [super
99 initWithLabelString:
100 l10n_util::GetNSString(
101 IDS_IOS_PYSICAL_WEB_SCANNING_TODAY_EXTENSION_FOOTER_LABEL)
102 buttonString:
103 l10n_util::GetNSString(
104 IDS_IOS_PYSICAL_WEB_TURN_OFF_TODAY_EXTENSION_FOOTER_LABEL)
105 linkBlock:learnMore
106 buttonBlock:turnOffBlock];
107 return self;
108 }
109
110 @end
111
112 @implementation PWBTOffFooterLabel
113
114 - (instancetype)initWithLearnMoreBlock:(LearnMoreBlock)learnMore {
115 self =
116 [super initWithLabelString:
117 l10n_util::GetNSString(
118 IDS_IOS_PYSICAL_WEB_BLUETOOTH_TODAY_EXTENSION_FOOTER_LABEL)
119 buttonString:nil
120 linkBlock:learnMore
121 buttonBlock:nil];
122 return self;
123 }
124
125 @end
OLDNEW
« no previous file with comments | « ios/chrome/today_extension/footer_label.h ('k') | ios/chrome/today_extension/interactive_label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698