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 "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." |
| 30 #endif |
| 31 |
28 using base::UserMetricsAction; | 32 using base::UserMetricsAction; |
29 | 33 |
30 namespace { | 34 namespace { |
31 // Spacing between cards. | 35 // Spacing between cards. |
32 const CGFloat kCardHorizontalSpacing = 30; | 36 const CGFloat kCardHorizontalSpacing = 30; |
33 | 37 |
34 // Portion of the screen an edge card can be dragged. | 38 // Portion of the screen an edge card can be dragged. |
35 const CGFloat kEdgeCardDragPercentage = 0.35; | 39 const CGFloat kEdgeCardDragPercentage = 0.35; |
36 | 40 |
37 // Card animation times. | 41 // Card animation times. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 141 |
138 - (id)initWithFrame:(CGRect)frame | 142 - (id)initWithFrame:(CGRect)frame |
139 topMargin:(CGFloat)topMargin | 143 topMargin:(CGFloat)topMargin |
140 model:(TabModel*)model { | 144 model:(TabModel*)model { |
141 self = [super initWithFrame:frame]; | 145 self = [super initWithFrame:frame]; |
142 if (self) { | 146 if (self) { |
143 model_ = model; | 147 model_ = model; |
144 currentPoint_ = CGPointZero; | 148 currentPoint_ = CGPointZero; |
145 topMargin_ = topMargin; | 149 topMargin_ = topMargin; |
146 | 150 |
147 base::scoped_nsobject<UIView> background( | 151 UIView* background = [[UIView alloc] initWithFrame:CGRectZero]; |
148 [[UIView alloc] initWithFrame:CGRectZero]); | |
149 [self addSubview:background]; | 152 [self addSubview:background]; |
150 | 153 |
151 [background setTranslatesAutoresizingMaskIntoConstraints:NO]; | 154 [background setTranslatesAutoresizingMaskIntoConstraints:NO]; |
152 [NSLayoutConstraint activateConstraints:@[ | 155 [NSLayoutConstraint activateConstraints:@[ |
153 [[background rightAnchor] constraintEqualToAnchor:self.rightAnchor], | 156 [[background rightAnchor] constraintEqualToAnchor:self.rightAnchor], |
154 [[background leftAnchor] constraintEqualToAnchor:self.leftAnchor], | 157 [[background leftAnchor] constraintEqualToAnchor:self.leftAnchor], |
155 [[background topAnchor] constraintEqualToAnchor:self.topAnchor | 158 [[background topAnchor] constraintEqualToAnchor:self.topAnchor |
156 constant:-StatusBarHeight()], | 159 constant:-StatusBarHeight()], |
157 [[background bottomAnchor] constraintEqualToAnchor:self.bottomAnchor] | 160 [[background bottomAnchor] constraintEqualToAnchor:self.bottomAnchor] |
158 ]]; | 161 ]]; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 completion:^(BOOL finished) { | 392 completion:^(BOOL finished) { |
390 [leftCard_ setImage:nil]; | 393 [leftCard_ setImage:nil]; |
391 [rightCard_ setImage:nil]; | 394 [rightCard_ setImage:nil]; |
392 [leftCard_ setToolbarImage:nil isNewTabPage:NO]; | 395 [leftCard_ setToolbarImage:nil isNewTabPage:NO]; |
393 [rightCard_ setToolbarImage:nil isNewTabPage:NO]; | 396 [rightCard_ setToolbarImage:nil isNewTabPage:NO]; |
394 [delegate_ sideSwipeViewDismissAnimationDidEnd:self]; | 397 [delegate_ sideSwipeViewDismissAnimationDidEnd:self]; |
395 }]; | 398 }]; |
396 } | 399 } |
397 | 400 |
398 @end | 401 @end |
OLD | NEW |