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/tab_switcher/tab_switcher_panel_overlay_view.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" |
6 | 6 |
7 #import "base/mac/scoped_nsobject.h" | |
8 #include "base/metrics/user_metrics.h" | 7 #include "base/metrics/user_metrics.h" |
9 #include "base/metrics/user_metrics_action.h" | 8 #include "base/metrics/user_metrics_action.h" |
10 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
11 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 10 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
12 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
13 #import "ios/chrome/browser/ui/commands/show_signin_command.h" | 12 #import "ios/chrome/browser/ui/commands/show_signin_command.h" |
14 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" | 13 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" |
15 #import "ios/chrome/browser/ui/sync/sync_util.h" | 14 #import "ios/chrome/browser/ui/sync/sync_util.h" |
16 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model.h" | 15 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model.h" |
17 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 16 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
18 #include "ios/chrome/grit/ios_chromium_strings.h" | 17 #include "ios/chrome/grit/ios_chromium_strings.h" |
19 #include "ios/chrome/grit/ios_strings.h" | 18 #include "ios/chrome/grit/ios_strings.h" |
20 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 19 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
21 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" | 20 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
22 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 21 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
23 #import "ios/third_party/material_components_ios/src/components/ShadowElevations
/src/MaterialShadowElevations.h" | 22 #import "ios/third_party/material_components_ios/src/components/ShadowElevations
/src/MaterialShadowElevations.h" |
24 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 23 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
25 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
26 | 25 |
| 26 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 27 #error "This file requires ARC support." |
| 28 #endif |
| 29 |
27 TabSwitcherPanelOverlayType PanelOverlayTypeFromSignInPanelsType( | 30 TabSwitcherPanelOverlayType PanelOverlayTypeFromSignInPanelsType( |
28 TabSwitcherSignInPanelsType signInPanelType) { | 31 TabSwitcherSignInPanelsType signInPanelType) { |
29 switch (signInPanelType) { | 32 switch (signInPanelType) { |
30 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_OUT: | 33 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_OUT: |
31 return TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_OUT; | 34 return TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_OUT; |
32 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_IN_SYNC_OFF: | 35 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_IN_SYNC_OFF: |
33 return TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_IN_SYNC_OFF; | 36 return TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_IN_SYNC_OFF; |
34 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS: | 37 case TabSwitcherSignInPanelsType::PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS: |
35 return TabSwitcherPanelOverlayType:: | 38 return TabSwitcherPanelOverlayType:: |
36 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS; | 39 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS; |
(...skipping 19 matching lines...) Expand all Loading... |
56 - (void)updateText; | 59 - (void)updateText; |
57 // Updates the button target and tag according to the current |overlayType|. | 60 // Updates the button target and tag according to the current |overlayType|. |
58 - (void)updateButtonTarget; | 61 - (void)updateButtonTarget; |
59 // Sends a SignIn chrome command. | 62 // Sends a SignIn chrome command. |
60 - (void)showSignIn; | 63 - (void)showSignIn; |
61 | 64 |
62 @end | 65 @end |
63 | 66 |
64 @implementation TabSwitcherPanelOverlayView { | 67 @implementation TabSwitcherPanelOverlayView { |
65 ios::ChromeBrowserState* _browserState; // Weak. | 68 ios::ChromeBrowserState* _browserState; // Weak. |
66 base::scoped_nsobject<UIView> _container; | 69 UIView* _container; |
67 base::scoped_nsobject<UILabel> _titleLabel; | 70 UILabel* _titleLabel; |
68 base::scoped_nsobject<UILabel> _subtitleLabel; | 71 UILabel* _subtitleLabel; |
69 base::scoped_nsobject<MDCButton> _textButton; | 72 MDCButton* _textButton; |
70 base::scoped_nsobject<MDCButton> _floatingButton; | 73 MDCButton* _floatingButton; |
71 base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; | 74 MDCActivityIndicator* _activityIndicator; |
72 std::string _recordedMetricString; | 75 std::string _recordedMetricString; |
73 } | 76 } |
74 | 77 |
75 @synthesize overlayType = _overlayType; | 78 @synthesize overlayType = _overlayType; |
76 | 79 |
77 - (instancetype)initWithFrame:(CGRect)frame | 80 - (instancetype)initWithFrame:(CGRect)frame |
78 browserState:(ios::ChromeBrowserState*)browserState { | 81 browserState:(ios::ChromeBrowserState*)browserState { |
79 self = [super initWithFrame:frame]; | 82 self = [super initWithFrame:frame]; |
80 if (self) { | 83 if (self) { |
81 _browserState = browserState; | 84 _browserState = browserState; |
82 // Create and add container. Will be vertically and horizontally centered. | 85 // Create and add container. Will be vertically and horizontally centered. |
83 _container.reset([[UIView alloc] initWithFrame:CGRectZero]); | 86 _container = [[UIView alloc] initWithFrame:CGRectZero]; |
84 [_container setTranslatesAutoresizingMaskIntoConstraints:NO]; | 87 [_container setTranslatesAutoresizingMaskIntoConstraints:NO]; |
85 [self addSubview:_container]; | 88 [self addSubview:_container]; |
86 | 89 |
87 // Create and add title label to the container. | 90 // Create and add title label to the container. |
88 _titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 91 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
89 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 92 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
90 [_titleLabel setFont:[MDCTypography headlineFont]]; | 93 [_titleLabel setFont:[MDCTypography headlineFont]]; |
91 [_titleLabel | 94 [_titleLabel |
92 setTextColor:[UIColor | 95 setTextColor:[UIColor |
93 colorWithWhite:1 | 96 colorWithWhite:1 |
94 alpha:[MDCTypography headlineFontOpacity]]]; | 97 alpha:[MDCTypography headlineFontOpacity]]]; |
95 [_titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; | 98 [_titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; |
96 [_titleLabel setNumberOfLines:0]; | 99 [_titleLabel setNumberOfLines:0]; |
97 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; | 100 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; |
98 [_container addSubview:_titleLabel]; | 101 [_container addSubview:_titleLabel]; |
99 | 102 |
100 // Create and add subtitle label to the container. | 103 // Create and add subtitle label to the container. |
101 _subtitleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 104 _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
102 [_subtitleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 105 [_subtitleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
103 [_subtitleLabel setFont:[MDCTypography subheadFont]]; | 106 [_subtitleLabel setFont:[MDCTypography subheadFont]]; |
104 [_subtitleLabel | 107 [_subtitleLabel |
105 setTextColor:[UIColor | 108 setTextColor:[UIColor |
106 colorWithWhite:1 | 109 colorWithWhite:1 |
107 alpha:[MDCTypography display1FontOpacity]]]; | 110 alpha:[MDCTypography display1FontOpacity]]]; |
108 [_subtitleLabel setNumberOfLines:0]; | 111 [_subtitleLabel setNumberOfLines:0]; |
109 [_container addSubview:_subtitleLabel]; | 112 [_container addSubview:_subtitleLabel]; |
110 | 113 |
111 // Create and add button to the container. | 114 // Create and add button to the container. |
112 _textButton.reset([[MDCRaisedButton alloc] init]); | 115 _textButton = [[MDCRaisedButton alloc] init]; |
113 [_textButton setElevation:MDCShadowElevationNone | 116 [_textButton setElevation:MDCShadowElevationNone |
114 forState:UIControlStateNormal]; | 117 forState:UIControlStateNormal]; |
115 MDCPalette* buttonPalette = [MDCPalette cr_bluePalette]; | 118 MDCPalette* buttonPalette = [MDCPalette cr_bluePalette]; |
116 [_textButton | 119 [_textButton |
117 setInkColor:[[buttonPalette tint300] colorWithAlphaComponent:0.5f]]; | 120 setInkColor:[[buttonPalette tint300] colorWithAlphaComponent:0.5f]]; |
118 [_textButton setBackgroundColor:[buttonPalette tint500] | 121 [_textButton setBackgroundColor:[buttonPalette tint500] |
119 forState:UIControlStateNormal]; | 122 forState:UIControlStateNormal]; |
120 [_textButton setBackgroundColor:[UIColor colorWithWhite:0.8f alpha:1.0f] | 123 [_textButton setBackgroundColor:[UIColor colorWithWhite:0.8f alpha:1.0f] |
121 forState:UIControlStateDisabled]; | 124 forState:UIControlStateDisabled]; |
122 [_textButton setTranslatesAutoresizingMaskIntoConstraints:NO]; | 125 [_textButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
123 [[_textButton imageView] setTintColor:[UIColor whiteColor]]; | 126 [[_textButton imageView] setTintColor:[UIColor whiteColor]]; |
124 [_textButton setCustomTitleColor:[UIColor whiteColor]]; | 127 [_textButton setCustomTitleColor:[UIColor whiteColor]]; |
125 [_container addSubview:_textButton]; | 128 [_container addSubview:_textButton]; |
126 | 129 |
127 // Create and add floatingButton to the container. | 130 // Create and add floatingButton to the container. |
128 _floatingButton.reset([[MDCFloatingButton alloc] init]); | 131 _floatingButton = [[MDCFloatingButton alloc] init]; |
129 [_floatingButton setTranslatesAutoresizingMaskIntoConstraints:NO]; | 132 [_floatingButton setTranslatesAutoresizingMaskIntoConstraints:NO]; |
130 [[_floatingButton imageView] setTintColor:[UIColor whiteColor]]; | 133 [[_floatingButton imageView] setTintColor:[UIColor whiteColor]]; |
131 [_container addSubview:_floatingButton]; | 134 [_container addSubview:_floatingButton]; |
132 | 135 |
133 // Create and add activity indicator to the container. | 136 // Create and add activity indicator to the container. |
134 _activityIndicator.reset( | 137 _activityIndicator = |
135 [[MDCActivityIndicator alloc] initWithFrame:CGRectZero]); | 138 [[MDCActivityIndicator alloc] initWithFrame:CGRectZero]; |
136 [_activityIndicator setCycleColors:ActivityIndicatorBrandedCycleColors()]; | 139 [_activityIndicator setCycleColors:ActivityIndicatorBrandedCycleColors()]; |
137 [_activityIndicator setTranslatesAutoresizingMaskIntoConstraints:NO]; | 140 [_activityIndicator setTranslatesAutoresizingMaskIntoConstraints:NO]; |
138 [_container addSubview:_activityIndicator]; | 141 [_container addSubview:_activityIndicator]; |
139 | 142 |
140 // Set constraints on all of the container's subviews. | 143 // Set constraints on all of the container's subviews. |
141 AddSameCenterXConstraint(_container, _titleLabel); | 144 AddSameCenterXConstraint(_container, _titleLabel); |
142 AddSameCenterXConstraint(_container, _subtitleLabel); | 145 AddSameCenterXConstraint(_container, _subtitleLabel); |
143 NSDictionary* viewsDictionary = @{ | 146 NSDictionary* viewsDictionary = @{ |
144 @"title" : _titleLabel.get(), | 147 @"title" : _titleLabel, |
145 @"subtitle" : _subtitleLabel.get(), | 148 @"subtitle" : _subtitleLabel, |
146 @"button" : _textButton.get(), | 149 @"button" : _textButton, |
147 @"floatingButton" : _floatingButton.get(), | 150 @"floatingButton" : _floatingButton, |
148 @"activityIndicator" : _activityIndicator.get(), | 151 @"activityIndicator" : _activityIndicator, |
149 }; | 152 }; |
150 AddSameCenterXConstraint(_container, _textButton); | 153 AddSameCenterXConstraint(_container, _textButton); |
151 AddSameCenterXConstraint(_container, _floatingButton); | 154 AddSameCenterXConstraint(_container, _floatingButton); |
152 AddSameCenterXConstraint(_container, _activityIndicator); | 155 AddSameCenterXConstraint(_container, _activityIndicator); |
153 NSArray* constraints = @[ | 156 NSArray* constraints = @[ |
154 @"V:|-0-[title]-12-[subtitle]-48-[button]-0-|", | 157 @"V:|-0-[title]-12-[subtitle]-48-[button]-0-|", |
155 @"V:[subtitle]-35-[floatingButton(==48)]-0-|", | 158 @"V:[subtitle]-35-[floatingButton(==48)]-0-|", |
156 @"V:[subtitle]-24-[activityIndicator]", @"H:|-[title]-|", | 159 @"V:[subtitle]-24-[activityIndicator]", @"H:|-[title]-|", |
157 @"H:|-[subtitle]-|", @"H:[button(>=180)]", @"H:[floatingButton(==48)]" | 160 @"H:|-[subtitle]-|", @"H:[button(>=180)]", @"H:[floatingButton(==48)]" |
158 ]; | 161 ]; |
159 ApplyVisualConstraints(constraints, viewsDictionary, _container); | 162 ApplyVisualConstraints(constraints, viewsDictionary, _container); |
160 | 163 |
161 // Sets the container's width relative to the parent. | 164 // Sets the container's width relative to the parent. |
162 ApplyVisualConstraintsWithMetrics( | 165 ApplyVisualConstraintsWithMetrics( |
163 @[ | 166 @[ |
164 @"H:|-(>=0)-[container(==containerWidth@999)]-(>=0)-|", | 167 @"H:|-(>=0)-[container(==containerWidth@999)]-(>=0)-|", |
165 ], | 168 ], |
166 @{ @"container" : _container.get() }, | 169 @{ @"container" : _container }, |
167 @{ @"containerWidth" : @(kContainerWidth) }, self); | 170 @{ @"containerWidth" : @(kContainerWidth) }, self); |
168 } | 171 } |
169 return self; | 172 return self; |
170 } | 173 } |
171 | 174 |
172 - (void)layoutSubviews { | 175 - (void)layoutSubviews { |
173 [super layoutSubviews]; | 176 [super layoutSubviews]; |
174 CGRect containerFrame = [_container frame]; | 177 CGRect containerFrame = [_container frame]; |
175 containerFrame.origin.x = | 178 containerFrame.origin.x = |
176 (self.frame.size.width - containerFrame.size.width) / 2; | 179 (self.frame.size.width - containerFrame.size.width) / 2; |
(...skipping 19 matching lines...) Expand all Loading... |
196 UIImage* buttonImage = nil; | 199 UIImage* buttonImage = nil; |
197 NSString* buttonAccessibilityLabel = nil; | 200 NSString* buttonAccessibilityLabel = nil; |
198 UIColor* floatingButtonNormalBackgroundColor = nil; | 201 UIColor* floatingButtonNormalBackgroundColor = nil; |
199 UIColor* floatingButtonDisabledBackgroundColor = nil; | 202 UIColor* floatingButtonDisabledBackgroundColor = nil; |
200 UIColor* floatingButtonInkColor = nil; | 203 UIColor* floatingButtonInkColor = nil; |
201 BOOL spinnerIsHidden = YES; | 204 BOOL spinnerIsHidden = YES; |
202 switch (self.overlayType) { | 205 switch (self.overlayType) { |
203 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_EMPTY: | 206 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_EMPTY: |
204 break; | 207 break; |
205 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_OUT: | 208 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_OUT: |
206 titleString = [[[NSMutableAttributedString alloc] | 209 titleString = [[NSMutableAttributedString alloc] |
207 initWithString:l10n_util::GetNSString( | 210 initWithString:l10n_util::GetNSString( |
208 IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_TITLE)] | 211 IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_TITLE)]; |
209 autorelease]; | 212 subtitleString = [[NSMutableAttributedString alloc] |
210 subtitleString = [[[NSMutableAttributedString alloc] | |
211 initWithString:l10n_util::GetNSString( | 213 initWithString:l10n_util::GetNSString( |
212 IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_PROMO)] | 214 IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_PROMO)]; |
213 autorelease]; | |
214 buttonTitle = | 215 buttonTitle = |
215 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_BUTTON); | 216 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_SIGN_IN_ACCOUNT_BUTTON); |
216 break; | 217 break; |
217 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_IN_SYNC_OFF: | 218 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_SIGNED_IN_SYNC_OFF: |
218 titleString = [[[NSMutableAttributedString alloc] | 219 titleString = [[NSMutableAttributedString alloc] |
219 initWithString:l10n_util::GetNSString( | 220 initWithString:l10n_util::GetNSString( |
220 IDS_IOS_TAB_SWITCHER_ENABLE_SYNC_TITLE)] | 221 IDS_IOS_TAB_SWITCHER_ENABLE_SYNC_TITLE)]; |
221 autorelease]; | 222 subtitleString = [[NSMutableAttributedString alloc] |
222 subtitleString = [[[NSMutableAttributedString alloc] | |
223 initWithString:l10n_util::GetNSString( | 223 initWithString:l10n_util::GetNSString( |
224 IDS_IOS_TAB_SWITCHER_SYNC_IS_OFF)] autorelease]; | 224 IDS_IOS_TAB_SWITCHER_SYNC_IS_OFF)]; |
225 buttonTitle = | 225 buttonTitle = |
226 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_ENABLE_SYNC_BUTTON); | 226 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_ENABLE_SYNC_BUTTON); |
227 break; | 227 break; |
228 case TabSwitcherPanelOverlayType:: | 228 case TabSwitcherPanelOverlayType:: |
229 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_ON_NO_SESSIONS: | 229 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_ON_NO_SESSIONS: |
230 titleString = [[[NSMutableAttributedString alloc] | 230 titleString = [[NSMutableAttributedString alloc] |
231 initWithString:l10n_util::GetNSString( | 231 initWithString:l10n_util::GetNSString( |
232 IDS_IOS_TAB_SWITCHER_NO_TABS_TO_SYNC_PROMO)] | 232 IDS_IOS_TAB_SWITCHER_NO_TABS_TO_SYNC_PROMO)]; |
233 autorelease]; | 233 subtitleString = [[NSMutableAttributedString alloc] |
234 subtitleString = [[[NSMutableAttributedString alloc] | |
235 initWithString:l10n_util::GetNSString( | 234 initWithString:l10n_util::GetNSString( |
236 IDS_IOS_OPEN_TABS_NO_SESSION_INSTRUCTIONS)] | 235 IDS_IOS_OPEN_TABS_NO_SESSION_INSTRUCTIONS)]; |
237 autorelease]; | |
238 break; | 236 break; |
239 case TabSwitcherPanelOverlayType:: | 237 case TabSwitcherPanelOverlayType:: |
240 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS: | 238 OVERLAY_PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS: |
241 titleString = [[[NSMutableAttributedString alloc] | 239 titleString = [[NSMutableAttributedString alloc] |
242 initWithString:l10n_util::GetNSString( | 240 initWithString:l10n_util::GetNSString( |
243 IDS_IOS_TAB_SWITCHER_SYNC_IN_PROGRESS_PROMO)] | 241 IDS_IOS_TAB_SWITCHER_SYNC_IN_PROGRESS_PROMO)]; |
244 autorelease]; | 242 subtitleString = [[NSMutableAttributedString alloc] |
245 subtitleString = [[[NSMutableAttributedString alloc] | |
246 initWithString:l10n_util::GetNSString( | 243 initWithString:l10n_util::GetNSString( |
247 IDS_IOS_TAB_SWITCHER_SYNC_IS_OFF)] autorelease]; | 244 IDS_IOS_TAB_SWITCHER_SYNC_IS_OFF)]; |
248 spinnerIsHidden = NO; | 245 spinnerIsHidden = NO; |
249 break; | 246 break; |
250 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_OPEN_TABS: | 247 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_OPEN_TABS: |
251 titleString = [[[NSMutableAttributedString alloc] | 248 titleString = [[NSMutableAttributedString alloc] |
252 initWithString: | 249 initWithString: |
253 l10n_util::GetNSString( | 250 l10n_util::GetNSString( |
254 IDS_IOS_TAB_SWITCHER_NO_LOCAL_NON_INCOGNITO_TABS_TITLE)] | 251 IDS_IOS_TAB_SWITCHER_NO_LOCAL_NON_INCOGNITO_TABS_TITLE)]; |
255 autorelease]; | 252 subtitleString = [[NSMutableAttributedString alloc] |
256 subtitleString = [[[NSMutableAttributedString alloc] | |
257 initWithString:l10n_util::GetNSString( | 253 initWithString:l10n_util::GetNSString( |
258 IDS_IOS_TAB_SWITCHER_NO_LOCAL_NON_INCOGNITO_TABS)] | 254 IDS_IOS_TAB_SWITCHER_NO_LOCAL_NON_INCOGNITO_TABS)]; |
259 autorelease]; | |
260 buttonImage = [UIImage imageNamed:@"tabswitcher_new_tab_fab"]; | 255 buttonImage = [UIImage imageNamed:@"tabswitcher_new_tab_fab"]; |
261 buttonImage = [buttonImage | 256 buttonImage = [buttonImage |
262 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 257 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
263 floatingButtonInkColor = | 258 floatingButtonInkColor = |
264 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f]; | 259 [[[MDCPalette cr_bluePalette] tint300] colorWithAlphaComponent:0.5f]; |
265 floatingButtonNormalBackgroundColor = | 260 floatingButtonNormalBackgroundColor = |
266 [[MDCPalette cr_bluePalette] tint500]; | 261 [[MDCPalette cr_bluePalette] tint500]; |
267 floatingButtonDisabledBackgroundColor = | 262 floatingButtonDisabledBackgroundColor = |
268 [UIColor colorWithWhite:0.8f alpha:1.0f]; | 263 [UIColor colorWithWhite:0.8f alpha:1.0f]; |
269 buttonAccessibilityLabel = | 264 buttonAccessibilityLabel = |
270 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CREATE_NEW_TAB); | 265 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CREATE_NEW_TAB); |
271 break; | 266 break; |
272 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_INCOGNITO_TABS: | 267 case TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_INCOGNITO_TABS: |
273 titleString = [[[NSMutableAttributedString alloc] | 268 titleString = [[NSMutableAttributedString alloc] |
274 initWithString: | 269 initWithString: |
275 l10n_util::GetNSString( | 270 l10n_util::GetNSString( |
276 IDS_IOS_TAB_SWITCHER_NO_LOCAL_INCOGNITO_TABS_PROMO)] | 271 IDS_IOS_TAB_SWITCHER_NO_LOCAL_INCOGNITO_TABS_PROMO)]; |
277 autorelease]; | 272 subtitleString = [[NSMutableAttributedString alloc] |
278 subtitleString = [[[NSMutableAttributedString alloc] | |
279 initWithString:l10n_util::GetNSString( | 273 initWithString:l10n_util::GetNSString( |
280 IDS_IOS_TAB_SWITCHER_NO_LOCAL_INCOGNITO_TABS)] | 274 IDS_IOS_TAB_SWITCHER_NO_LOCAL_INCOGNITO_TABS)]; |
281 autorelease]; | |
282 buttonImage = [UIImage imageNamed:@"tabswitcher_new_tab_fab"]; | 275 buttonImage = [UIImage imageNamed:@"tabswitcher_new_tab_fab"]; |
283 buttonImage = [buttonImage | 276 buttonImage = [buttonImage |
284 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 277 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
285 | 278 |
286 floatingButtonInkColor = | 279 floatingButtonInkColor = |
287 [[[MDCPalette greyPalette] tint300] colorWithAlphaComponent:0.25f]; | 280 [[[MDCPalette greyPalette] tint300] colorWithAlphaComponent:0.25f]; |
288 floatingButtonNormalBackgroundColor = [[MDCPalette greyPalette] tint500]; | 281 floatingButtonNormalBackgroundColor = [[MDCPalette greyPalette] tint500]; |
289 floatingButtonDisabledBackgroundColor = | 282 floatingButtonDisabledBackgroundColor = |
290 [UIColor colorWithWhite:0.8f alpha:1.0f]; | 283 [UIColor colorWithWhite:0.8f alpha:1.0f]; |
291 buttonAccessibilityLabel = | 284 buttonAccessibilityLabel = |
292 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CREATE_NEW_INCOGNITO_TAB); | 285 l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CREATE_NEW_INCOGNITO_TAB); |
293 break; | 286 break; |
294 }; | 287 }; |
295 | 288 |
296 base::scoped_nsobject<NSMutableParagraphStyle> titleStyle( | 289 NSMutableParagraphStyle* titleStyle = [[NSMutableParagraphStyle alloc] init]; |
297 [[NSMutableParagraphStyle alloc] init]); | |
298 [titleStyle setMinimumLineHeight:kTitleMinimumLineHeight]; | 290 [titleStyle setMinimumLineHeight:kTitleMinimumLineHeight]; |
299 [titleStyle setAlignment:NSTextAlignmentCenter]; | 291 [titleStyle setAlignment:NSTextAlignmentCenter]; |
300 [titleStyle setLineBreakMode:NSLineBreakByWordWrapping]; | 292 [titleStyle setLineBreakMode:NSLineBreakByWordWrapping]; |
301 [titleString addAttribute:NSParagraphStyleAttributeName | 293 [titleString addAttribute:NSParagraphStyleAttributeName |
302 value:titleStyle | 294 value:titleStyle |
303 range:NSMakeRange(0, [titleString length])]; | 295 range:NSMakeRange(0, [titleString length])]; |
304 [_titleLabel setAttributedText:titleString]; | 296 [_titleLabel setAttributedText:titleString]; |
305 | 297 |
306 base::scoped_nsobject<NSMutableParagraphStyle> subtitleStyle( | 298 NSMutableParagraphStyle* subtitleStyle = |
307 [[NSMutableParagraphStyle alloc] init]); | 299 [[NSMutableParagraphStyle alloc] init]; |
308 [subtitleStyle setMinimumLineHeight:kSubtitleMinimunLineHeight]; | 300 [subtitleStyle setMinimumLineHeight:kSubtitleMinimunLineHeight]; |
309 [subtitleStyle setAlignment:NSTextAlignmentCenter]; | 301 [subtitleStyle setAlignment:NSTextAlignmentCenter]; |
310 [subtitleStyle setLineBreakMode:NSLineBreakByWordWrapping]; | 302 [subtitleStyle setLineBreakMode:NSLineBreakByWordWrapping]; |
311 [subtitleString addAttribute:NSParagraphStyleAttributeName | 303 [subtitleString addAttribute:NSParagraphStyleAttributeName |
312 value:subtitleStyle | 304 value:subtitleStyle |
313 range:NSMakeRange(0, [subtitleString length])]; | 305 range:NSMakeRange(0, [subtitleString length])]; |
314 [_subtitleLabel setAttributedText:subtitleString]; | 306 [_subtitleLabel setAttributedText:subtitleString]; |
315 | 307 |
316 [_textButton setTitle:buttonTitle forState:UIControlStateNormal]; | 308 [_textButton setTitle:buttonTitle forState:UIControlStateNormal]; |
317 [_textButton setImage:buttonImage forState:UIControlStateNormal]; | 309 [_textButton setImage:buttonImage forState:UIControlStateNormal]; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 action:selector | 380 action:selector |
389 forControlEvents:UIControlEventTouchUpInside]; | 381 forControlEvents:UIControlEventTouchUpInside]; |
390 [_floatingButton addTarget:self | 382 [_floatingButton addTarget:self |
391 action:@selector(recordMetrics) | 383 action:@selector(recordMetrics) |
392 forControlEvents:UIControlEventTouchUpInside]; | 384 forControlEvents:UIControlEventTouchUpInside]; |
393 [_floatingButton setHidden:!shouldShowFloatingButton]; | 385 [_floatingButton setHidden:!shouldShowFloatingButton]; |
394 } | 386 } |
395 | 387 |
396 - (void)showSignIn { | 388 - (void)showSignIn { |
397 base::RecordAction(base::UserMetricsAction("Signin_Signin_FromTabSwitcher")); | 389 base::RecordAction(base::UserMetricsAction("Signin_Signin_FromTabSwitcher")); |
398 base::scoped_nsobject<ShowSigninCommand> command([[ShowSigninCommand alloc] | 390 ShowSigninCommand* command = [[ShowSigninCommand alloc] |
399 initWithOperation:AUTHENTICATION_OPERATION_SIGNIN | 391 initWithOperation:AUTHENTICATION_OPERATION_SIGNIN |
400 signInAccessPoint:signin_metrics::AccessPoint:: | 392 signInAccessPoint:signin_metrics::AccessPoint::ACCESS_POINT_TAB_SWITCHER]; |
401 ACCESS_POINT_TAB_SWITCHER]); | |
402 [self chromeExecuteCommand:command]; | 393 [self chromeExecuteCommand:command]; |
403 } | 394 } |
404 | 395 |
405 - (void)showSyncSettings { | 396 - (void)showSyncSettings { |
406 [self chromeExecuteCommand:ios_internal::sync::GetSyncCommandForBrowserState( | 397 [self chromeExecuteCommand:ios_internal::sync::GetSyncCommandForBrowserState( |
407 _browserState)]; | 398 _browserState)]; |
408 } | 399 } |
409 | 400 |
410 - (void)rootViewControllerChromeCommand:(id)command { | 401 - (void)rootViewControllerChromeCommand:(id)command { |
411 [self chromeExecuteCommand:command]; | 402 [self chromeExecuteCommand:command]; |
412 } | 403 } |
413 | 404 |
414 - (void)recordMetrics { | 405 - (void)recordMetrics { |
415 if (!_recordedMetricString.length()) | 406 if (!_recordedMetricString.length()) |
416 return; | 407 return; |
417 base::RecordAction(base::UserMetricsAction(_recordedMetricString.c_str())); | 408 base::RecordAction(base::UserMetricsAction(_recordedMetricString.c_str())); |
418 } | 409 } |
419 | 410 |
420 @end | 411 @end |
OLD | NEW |