| 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/tools_menu/tools_menu_view_controller.h" | 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" | 28 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" |
| 29 #include "ios/chrome/browser/ui/ui_util.h" | 29 #include "ios/chrome/browser/ui/ui_util.h" |
| 30 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 30 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 31 #import "ios/chrome/common/material_timing.h" | 31 #import "ios/chrome/common/material_timing.h" |
| 32 #include "ios/chrome/grit/ios_strings.h" | 32 #include "ios/chrome/grit/ios_strings.h" |
| 33 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 33 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 34 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider
.h" | 34 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider
.h" |
| 35 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material
Ink.h" | 35 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material
Ink.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/l10n/l10n_util_mac.h" | 37 #include "ui/base/l10n/l10n_util_mac.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | |
| 39 | 38 |
| 40 using ios::material::TimingFunction; | 39 using ios::material::TimingFunction; |
| 41 | 40 |
| 42 NSString* const kToolsMenuNewTabId = @"kToolsMenuNewTabId"; | 41 NSString* const kToolsMenuNewTabId = @"kToolsMenuNewTabId"; |
| 43 NSString* const kToolsMenuNewIncognitoTabId = @"kToolsMenuNewIncognitoTabId"; | 42 NSString* const kToolsMenuNewIncognitoTabId = @"kToolsMenuNewIncognitoTabId"; |
| 44 NSString* const kToolsMenuCloseAllTabsId = @"kToolsMenuCloseAllTabsId"; | 43 NSString* const kToolsMenuCloseAllTabsId = @"kToolsMenuCloseAllTabsId"; |
| 45 NSString* const kToolsMenuCloseAllIncognitoTabsId = | 44 NSString* const kToolsMenuCloseAllIncognitoTabsId = |
| 46 @"kToolsMenuCloseAllIncognitoTabsId"; | 45 @"kToolsMenuCloseAllIncognitoTabsId"; |
| 47 NSString* const kToolsMenuBookmarksId = @"kToolsMenuBookmarksId"; | 46 NSString* const kToolsMenuBookmarksId = @"kToolsMenuBookmarksId"; |
| 48 NSString* const kToolsMenuReadingListId = @"kToolsMenuReadingListId"; | 47 NSString* const kToolsMenuReadingListId = @"kToolsMenuReadingListId"; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 333 |
| 335 [contentView addSubview:_starredButton]; | 334 [contentView addSubview:_starredButton]; |
| 336 [contentView addSubview:_starButton]; | 335 [contentView addSubview:_starButton]; |
| 337 [contentView addSubview:_stopButton]; | 336 [contentView addSubview:_stopButton]; |
| 338 [contentView addSubview:_reloadButton]; | 337 [contentView addSubview:_reloadButton]; |
| 339 [contentView addSubview:_shareButton]; | 338 [contentView addSubview:_shareButton]; |
| 340 | 339 |
| 341 [self addConstraints]; | 340 [self addConstraints]; |
| 342 } | 341 } |
| 343 | 342 |
| 344 - (UIImage*)imageForImageId:(int)imageId reversed:(BOOL)reversed { | |
| 345 if (imageId == 0) { | |
| 346 return nil; | |
| 347 } | |
| 348 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 349 gfx::Image image = rb.GetNativeImageNamed(imageId); | |
| 350 if (reversed) { | |
| 351 return [image.ToUIImage() imageFlippedForRightToLeftLayoutDirection]; | |
| 352 } else { | |
| 353 return image.ToUIImage(); | |
| 354 } | |
| 355 } | |
| 356 | |
| 357 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds | 343 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds |
| 358 commandID:(int)commandID | 344 commandID:(int)commandID |
| 359 accessibilityLabelID:(int)labelID | 345 accessibilityLabelID:(int)labelID |
| 360 automationName:(NSString*)name { | 346 automationName:(NSString*)name { |
| 361 return [self newButtonForImageIds:imageIds | 347 return [self newButtonForImageIds:imageIds |
| 362 commandID:commandID | 348 commandID:commandID |
| 363 accessibilityLabelID:labelID | 349 accessibilityLabelID:labelID |
| 364 automationName:name | 350 automationName:name |
| 365 reverseForRTL:NO]; | 351 reverseForRTL:NO]; |
| 366 } | 352 } |
| 367 | 353 |
| 368 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds | 354 - (ToolsMenuButton*)newButtonForImageIds:(int[2][3])imageIds |
| 369 commandID:(int)commandID | 355 commandID:(int)commandID |
| 370 accessibilityLabelID:(int)labelID | 356 accessibilityLabelID:(int)labelID |
| 371 automationName:(NSString*)name | 357 automationName:(NSString*)name |
| 372 reverseForRTL:(BOOL)reverseForRTL { | 358 reverseForRTL:(BOOL)reverseForRTL { |
| 373 ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero]; | 359 ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero]; |
| 374 [button setTranslatesAutoresizingMaskIntoConstraints:NO]; | 360 [button setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 375 BOOL reverseImage = reverseForRTL && UseRTLLayout(); | |
| 376 | 361 |
| 377 [button setImage:[self imageForImageId:imageIds[0][0] reversed:reverseImage] | 362 [button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL) |
| 378 forState:UIControlStateNormal]; | 363 forState:UIControlStateNormal]; |
| 379 [[button imageView] setContentMode:UIViewContentModeCenter]; | 364 [[button imageView] setContentMode:UIViewContentModeCenter]; |
| 380 [button setBackgroundColor:[self backgroundColor]]; | 365 [button setBackgroundColor:[self backgroundColor]]; |
| 381 [button setTag:commandID]; | 366 [button setTag:commandID]; |
| 382 [button setOpaque:YES]; | 367 [button setOpaque:YES]; |
| 383 | 368 |
| 384 SetA11yLabelAndUiAutomationName(button, labelID, name); | 369 SetA11yLabelAndUiAutomationName(button, labelID, name); |
| 385 | 370 |
| 386 UIImage* pressedImage = | 371 UIImage* pressedImage = NativeReversableImage(imageIds[0][1], reverseForRTL); |
| 387 [self imageForImageId:imageIds[0][1] reversed:reverseImage]; | |
| 388 if (pressedImage) { | 372 if (pressedImage) { |
| 389 [button setImage:pressedImage forState:UIControlStateHighlighted]; | 373 [button setImage:pressedImage forState:UIControlStateHighlighted]; |
| 390 } | 374 } |
| 391 | 375 |
| 392 UIImage* disabledImage = | 376 UIImage* disabledImage = NativeReversableImage(imageIds[0][2], reverseForRTL); |
| 393 [self imageForImageId:imageIds[0][2] reversed:reverseImage]; | |
| 394 if (disabledImage) { | 377 if (disabledImage) { |
| 395 [button setImage:disabledImage forState:UIControlStateDisabled]; | 378 [button setImage:disabledImage forState:UIControlStateDisabled]; |
| 396 } | 379 } |
| 397 | 380 |
| 398 return button; | 381 return button; |
| 399 } | 382 } |
| 400 | 383 |
| 401 - (void)addConstraints { | 384 - (void)addConstraints { |
| 402 UIView* contentView = [self contentView]; | 385 UIView* contentView = [self contentView]; |
| 403 | 386 |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 | 932 |
| 950 - (void)unreadCountChanged:(NSInteger)unreadCount { | 933 - (void)unreadCountChanged:(NSInteger)unreadCount { |
| 951 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; | 934 [[self readingListCell] updateBadgeCount:unreadCount animated:YES]; |
| 952 } | 935 } |
| 953 | 936 |
| 954 - (void)unseenStateChanged:(BOOL)unseenItemsExist { | 937 - (void)unseenStateChanged:(BOOL)unseenItemsExist { |
| 955 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; | 938 [[self readingListCell] updateSeenState:unseenItemsExist animated:YES]; |
| 956 } | 939 } |
| 957 | 940 |
| 958 @end | 941 @end |
| OLD | NEW |