OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/side_swipe/card_side_swipe_view.h" | 5 #import "ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/ios/device_util.h" | 9 #include "base/ios/device_util.h" |
10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
11 #include "base/metrics/user_metrics_action.h" | 11 #include "base/metrics/user_metrics_action.h" |
12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
13 #include "ios/chrome/browser/chrome_url_constants.h" | 13 #include "ios/chrome/browser/chrome_url_constants.h" |
14 #import "ios/chrome/browser/tabs/tab.h" | 14 #import "ios/chrome/browser/tabs/tab.h" |
15 #import "ios/chrome/browser/tabs/tab_model.h" | 15 #import "ios/chrome/browser/tabs/tab_model.h" |
16 #import "ios/chrome/browser/ui/background_generator.h" | 16 #import "ios/chrome/browser/ui/background_generator.h" |
17 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h" | 17 #import "ios/chrome/browser/ui/ntp/new_tab_page_panel_protocol.h" |
18 #include "ios/chrome/browser/ui/rtl_geometry.h" | 18 #include "ios/chrome/browser/ui/rtl_geometry.h" |
19 #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h" | 19 #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h" |
20 #import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h" | 20 #import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h" |
21 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 21 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
22 #include "ios/chrome/browser/ui/ui_util.h" | 22 #include "ios/chrome/browser/ui/ui_util.h" |
23 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 23 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
24 #include "ios/chrome/grit/ios_theme_resources.h" | 24 #include "ios/chrome/grit/ios_theme_resources.h" |
25 #import "ios/web/web_state/ui/crw_web_controller.h" | 25 #import "ios/web/web_state/ui/crw_web_controller.h" |
26 #include "ui/base/resource/resource_bundle.h" | |
27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
28 | 27 |
29 using base::UserMetricsAction; | 28 using base::UserMetricsAction; |
30 | 29 |
31 namespace { | 30 namespace { |
32 // Spacing between cards. | 31 // Spacing between cards. |
33 const CGFloat kCardHorizontalSpacing = 30; | 32 const CGFloat kCardHorizontalSpacing = 30; |
34 | 33 |
35 // Portion of the screen an edge card can be dragged. | 34 // Portion of the screen an edge card can be dragged. |
36 const CGFloat kEdgeCardDragPercentage = 0.35; | 35 const CGFloat kEdgeCardDragPercentage = 0.35; |
(...skipping 12 matching lines...) Expand all Loading... |
49 if (self) { | 48 if (self) { |
50 image_.reset([[UIImageView alloc] initWithFrame:CGRectZero]); | 49 image_.reset([[UIImageView alloc] initWithFrame:CGRectZero]); |
51 [image_ setClipsToBounds:YES]; | 50 [image_ setClipsToBounds:YES]; |
52 [image_ setContentMode:UIViewContentModeScaleAspectFill]; | 51 [image_ setContentMode:UIViewContentModeScaleAspectFill]; |
53 [self addSubview:image_]; | 52 [self addSubview:image_]; |
54 | 53 |
55 toolbarHolder_.reset([[UIImageView alloc] initWithFrame:CGRectZero]); | 54 toolbarHolder_.reset([[UIImageView alloc] initWithFrame:CGRectZero]); |
56 [self addSubview:toolbarHolder_]; | 55 [self addSubview:toolbarHolder_]; |
57 | 56 |
58 shadowView_.reset([[UIImageView alloc] initWithFrame:self.bounds]); | 57 shadowView_.reset([[UIImageView alloc] initWithFrame:self.bounds]); |
59 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 58 [shadowView_ setImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW)]; |
60 gfx::Image shadow = rb.GetNativeImageNamed(IDR_IOS_TOOLBAR_SHADOW); | |
61 [shadowView_ setImage:shadow.ToUIImage()]; | |
62 [self addSubview:shadowView_]; | 59 [self addSubview:shadowView_]; |
63 | 60 |
64 // All subviews are as wide as the parent | 61 // All subviews are as wide as the parent |
65 NSMutableArray* constraints = [NSMutableArray array]; | 62 NSMutableArray* constraints = [NSMutableArray array]; |
66 for (UIView* view in self.subviews) { | 63 for (UIView* view in self.subviews) { |
67 [view setTranslatesAutoresizingMaskIntoConstraints:NO]; | 64 [view setTranslatesAutoresizingMaskIntoConstraints:NO]; |
68 [constraints addObject:[view.leadingAnchor | 65 [constraints addObject:[view.leadingAnchor |
69 constraintEqualToAnchor:self.leadingAnchor]]; | 66 constraintEqualToAnchor:self.leadingAnchor]]; |
70 [constraints addObject:[view.trailingAnchor | 67 [constraints addObject:[view.trailingAnchor |
71 constraintEqualToAnchor:self.trailingAnchor]]; | 68 constraintEqualToAnchor:self.trailingAnchor]]; |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 completion:^(BOOL finished) { | 389 completion:^(BOOL finished) { |
393 [leftCard_ setImage:nil]; | 390 [leftCard_ setImage:nil]; |
394 [rightCard_ setImage:nil]; | 391 [rightCard_ setImage:nil]; |
395 [leftCard_ setToolbarImage:nil isNewTabPage:NO]; | 392 [leftCard_ setToolbarImage:nil isNewTabPage:NO]; |
396 [rightCard_ setToolbarImage:nil isNewTabPage:NO]; | 393 [rightCard_ setToolbarImage:nil isNewTabPage:NO]; |
397 [delegate_ sideSwipeViewDismissAnimationDidEnd:self]; | 394 [delegate_ sideSwipeViewDismissAnimationDidEnd:self]; |
398 }]; | 395 }]; |
399 } | 396 } |
400 | 397 |
401 @end | 398 @end |
OLD | NEW |