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

Side by Side Diff: ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.mm

Issue 2626073003: [ObjC ARC] Converts ios/chrome/browser/ui/contextual_search:contextual_search to ARC. (Closed)
Patch Set: Some fixes Created 3 years, 11 months 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
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/contextual_search/contextual_search_panel_view.h" 5 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_view.h"
6 6
7 #import "base/ios/crb_protocol_observers.h" 7 #import "base/ios/crb_protocol_observers.h"
8 #include "base/ios/weak_nsobject.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "base/mac/scoped_block.h" 9 #include "base/mac/scoped_block.h"
11 #include "base/mac/scoped_nsobject.h"
12 #import "ios/chrome/browser/procedural_block_types.h" 10 #import "ios/chrome/browser/procedural_block_types.h"
13 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_protoco ls.h" 11 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_protoco ls.h"
14 #import "ios/chrome/browser/ui/uikit_ui_util.h" 12 #import "ios/chrome/browser/ui/uikit_ui_util.h"
15 #import "ios/chrome/common/material_timing.h" 13 #import "ios/chrome/common/material_timing.h"
16 #import "ios/third_party/material_components_ios/src/components/ShadowElevations /src/MaterialShadowElevations.h" 14 #import "ios/third_party/material_components_ios/src/components/ShadowElevations /src/MaterialShadowElevations.h"
17 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/ MaterialShadowLayer.h" 15 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/ MaterialShadowLayer.h"
18 16
17 #if !defined(__has_feature) || !__has_feature(objc_arc)
18 #error "This file requires ARC support."
19 #endif
20
19 namespace { 21 namespace {
20 22
21 // Animation timings. 23 // Animation timings.
22 const NSTimeInterval kPanelAnimationDuration = ios::material::kDuration3; 24 const NSTimeInterval kPanelAnimationDuration = ios::material::kDuration3;
23 const NSTimeInterval kDismissAnimationDuration = ios::material::kDuration1; 25 const NSTimeInterval kDismissAnimationDuration = ios::material::kDuration1;
24 26
25 // Elevation (in MD vertical space) of the panel when dismissed and peeking. 27 // Elevation (in MD vertical space) of the panel when dismissed and peeking.
26 const CGFloat kShadowElevation = MDCShadowElevationMenu; 28 const CGFloat kShadowElevation = MDCShadowElevationMenu;
27 29
28 } // namespace 30 } // namespace
29 31
30 @interface ContextualSearchPanelObservers 32 @interface ContextualSearchPanelObservers
31 : CRBProtocolObservers<ContextualSearchPanelMotionObserver> 33 : CRBProtocolObservers<ContextualSearchPanelMotionObserver>
32 @end 34 @end
33 @implementation ContextualSearchPanelObservers 35 @implementation ContextualSearchPanelObservers
34 36
35 @end 37 @end
36 38
37 @interface ContextualSearchPanelView ()<UIGestureRecognizerDelegate, 39 @interface ContextualSearchPanelView ()<UIGestureRecognizerDelegate,
38 ContextualSearchPanelMotionObserver> 40 ContextualSearchPanelMotionObserver>
39 41
40 // A subview whose content scrolls and whose scrolling is synchronized with 42 // A subview whose content scrolls and whose scrolling is synchronized with
41 // panel dragging. This means that if the scrolling subview is being scrolled, 43 // panel dragging. This means that if the scrolling subview is being scrolled,
42 // that motion will not cause the panel to move, but if the scrolling reaches 44 // that motion will not cause the panel to move, but if the scrolling reaches
43 // the end of its possible range, the gesture will then start dragging the 45 // the end of its possible range, the gesture will then start dragging the
44 // panel. 46 // panel.
45 @property(nonatomic, assign) 47 @property(nonatomic, weak)
46 UIView<ContextualSearchPanelScrollSynchronizer>* scrollSynchronizer; 48 UIView<ContextualSearchPanelScrollSynchronizer>* scrollSynchronizer;
47 49
48 // Private readonly property to be used by weak pointers to |self| for non- 50 // Private readonly property to be used by weak pointers to |self| for non-
49 // retaining access to the underlying ivar in blocks. 51 // retaining access to the underlying ivar in blocks.
50 @property(nonatomic, readonly) ContextualSearchPanelObservers* observers; 52 @property(weak, nonatomic, readonly) ContextualSearchPanelObservers* observers;
marq (ping after 24h) 2017/01/13 10:38:17 nonatomic, weak, readonly
stkhapugin 2017/01/17 15:57:44 Done, and actually changed to strong.
51 53
52 // Utility to generate a PanelMotion struct for the panel's current position. 54 // Utility to generate a PanelMotion struct for the panel's current position.
53 - (ContextualSearch::PanelMotion)motion; 55 - (ContextualSearch::PanelMotion)motion;
54 @end 56 @end
55 57
56 @implementation ContextualSearchPanelView { 58 @implementation ContextualSearchPanelView {
57 UIStackView* _contents; 59 UIStackView* _contents;
58 60
59 // Constraints that define the size of this view. These will be cleared and 61 // Constraints that define the size of this view. These will be cleared and
60 // regenerated when the horizontal size class changes. 62 // regenerated when the horizontal size class changes.
61 base::scoped_nsobject<NSArray> _sizingConstraints; 63 NSArray* _sizingConstraints;
62 64
63 CGPoint _draggingStartPosition; 65 CGPoint _draggingStartPosition;
64 CGPoint _scrolledOffset; 66 CGPoint _scrolledOffset;
65 base::scoped_nsobject<UIPanGestureRecognizer> _dragRecognizer; 67 UIPanGestureRecognizer* _dragRecognizer;
66 68
67 base::scoped_nsobject<ContextualSearchPanelObservers> _observers; 69 ContextualSearchPanelObservers* _observers;
68 70
69 base::scoped_nsobject<PanelConfiguration> _configuration; 71 PanelConfiguration* _configuration;
70 72
71 base::WeakNSProtocol<id<ContextualSearchPanelScrollSynchronizer>> 73 __weak id<ContextualSearchPanelScrollSynchronizer> _scrollSynchronizer;
72 _scrollSynchronizer;
73 74
74 // Guide that's used to position this view. 75 // Guide that's used to position this view.
75 base::WeakNSObject<UILayoutGuide> _positioningGuide; 76 __weak UILayoutGuide* _positioningGuide;
76 // Constraint that sets the size of |_positioningView| so this view is 77 // Constraint that sets the size of |_positioningView| so this view is
77 // positioned correctly for its state. 78 // positioned correctly for its state.
78 base::WeakNSObject<NSLayoutConstraint> _positioningViewConstraint; 79 __weak NSLayoutConstraint* _positioningViewConstraint;
79 // Other constraints that determine the position of this view. 80 // Other constraints that determine the position of this view.
80 base::scoped_nsobject<NSArray> _positioningConstraints; 81 NSArray* _positioningConstraints;
81 82
82 // Promotion state variables. 83 // Promotion state variables.
83 BOOL _resizingForPromotion; 84 BOOL _resizingForPromotion;
84 CGFloat _promotionVerticalOffset; 85 CGFloat _promotionVerticalOffset;
85 86
86 // YES if dragging started inside the content view and scrolling is possible. 87 // YES if dragging started inside the content view and scrolling is possible.
87 BOOL _maybeScrollContent; 88 BOOL _maybeScrollContent;
88 // YES if the drag is happening along with scrolling the content view. 89 // YES if the drag is happening along with scrolling the content view.
89 BOOL _isScrollingContent; 90 BOOL _isScrollingContent;
90 91
91 // YES if dragging upwards has occurred. 92 // YES if dragging upwards has occurred.
92 BOOL _hasDraggedUp; 93 BOOL _hasDraggedUp;
93 } 94 }
94 95
95 @synthesize state = _state; 96 @synthesize state = _state;
96 97
97 + (BOOL)requiresConstraintBasedLayout { 98 + (BOOL)requiresConstraintBasedLayout {
98 return YES; 99 return YES;
99 } 100 }
100 101
101 #pragma mark - Initializers 102 #pragma mark - Initializers
102 103
103 - (instancetype)initWithConfiguration:(PanelConfiguration*)configuration { 104 - (instancetype)initWithConfiguration:(PanelConfiguration*)configuration {
104 if ((self = [super initWithFrame:CGRectZero])) { 105 if ((self = [super initWithFrame:CGRectZero])) {
105 _configuration.reset([configuration retain]); 106 _configuration = configuration;
106 _state = ContextualSearch::DISMISSED; 107 _state = ContextualSearch::DISMISSED;
107 108
108 self.translatesAutoresizingMaskIntoConstraints = NO; 109 self.translatesAutoresizingMaskIntoConstraints = NO;
109 self.backgroundColor = [UIColor whiteColor]; 110 self.backgroundColor = [UIColor whiteColor];
110 self.accessibilityIdentifier = @"contextualSearchPanel"; 111 self.accessibilityIdentifier = @"contextualSearchPanel";
111 112
112 _observers.reset([[ContextualSearchPanelObservers 113 _observers = [ContextualSearchPanelObservers
113 observersWithProtocol:@protocol(ContextualSearchPanelMotionObserver)] 114 observersWithProtocol:@protocol(ContextualSearchPanelMotionObserver)];
114 retain]);
115 [self addMotionObserver:self]; 115 [self addMotionObserver:self];
116 116
117 // Add gesture recognizer. 117 // Add gesture recognizer.
118 _dragRecognizer.reset([[UIPanGestureRecognizer alloc] 118 _dragRecognizer = [[UIPanGestureRecognizer alloc]
119 initWithTarget:self 119 initWithTarget:self
120 action:@selector(handleDragFrom:)]); 120 action:@selector(handleDragFrom:)];
121 [self addGestureRecognizer:_dragRecognizer]; 121 [self addGestureRecognizer:_dragRecognizer];
122 [_dragRecognizer setDelegate:self]; 122 [_dragRecognizer setDelegate:self];
123 123
124 // Set up the stack view that holds the panel content 124 // Set up the stack view that holds the panel content
125 _contents = [[[UIStackView alloc] initWithFrame:self.bounds] autorelease]; 125 _contents = [[UIStackView alloc] initWithFrame:self.bounds];
126 [self addSubview:_contents]; 126 [self addSubview:_contents];
127 _contents.translatesAutoresizingMaskIntoConstraints = NO; 127 _contents.translatesAutoresizingMaskIntoConstraints = NO;
128 _contents.accessibilityIdentifier = @"panelContents"; 128 _contents.accessibilityIdentifier = @"panelContents";
129 [NSLayoutConstraint activateConstraints:@[ 129 [NSLayoutConstraint activateConstraints:@[
130 [_contents.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], 130 [_contents.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
131 [_contents.centerYAnchor constraintEqualToAnchor:self.centerYAnchor], 131 [_contents.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
132 [_contents.widthAnchor constraintEqualToAnchor:self.widthAnchor], 132 [_contents.widthAnchor constraintEqualToAnchor:self.widthAnchor],
133 [_contents.heightAnchor constraintEqualToAnchor:self.heightAnchor] 133 [_contents.heightAnchor constraintEqualToAnchor:self.heightAnchor]
134 ]]; 134 ]];
135 _contents.axis = UILayoutConstraintAxisVertical; 135 _contents.axis = UILayoutConstraintAxisVertical;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 [[_positioningGuide owningView] removeLayoutGuide:_positioningGuide]; 190 [[_positioningGuide owningView] removeLayoutGuide:_positioningGuide];
191 [_observers panelIsPromoting:self]; 191 [_observers panelIsPromoting:self];
192 [self setNeedsUpdateConstraints]; 192 [self setNeedsUpdateConstraints];
193 [self updateConstraintsIfNeeded]; 193 [self updateConstraintsIfNeeded];
194 [self layoutIfNeeded]; 194 [self layoutIfNeeded];
195 } 195 }
196 196
197 #pragma mark - Public property getters/setters 197 #pragma mark - Public property getters/setters
198 198
199 - (PanelConfiguration*)configuration { 199 - (PanelConfiguration*)configuration {
200 return _configuration.get(); 200 return _configuration;
201 } 201 }
202 202
203 - (void)setScrollSynchronizer: 203 - (void)setScrollSynchronizer:
204 (id<ContextualSearchPanelScrollSynchronizer>)scrollSynchronizer { 204 (id<ContextualSearchPanelScrollSynchronizer>)scrollSynchronizer {
205 _scrollSynchronizer.reset(scrollSynchronizer); 205 _scrollSynchronizer = scrollSynchronizer;
206 } 206 }
207 207
208 - (id<ContextualSearchPanelScrollSynchronizer>)scrollSynchronizer { 208 - (id<ContextualSearchPanelScrollSynchronizer>)scrollSynchronizer {
209 return _scrollSynchronizer; 209 return _scrollSynchronizer;
210 } 210 }
211 211
212 - (ContextualSearchPanelObservers*)observers { 212 - (ContextualSearchPanelObservers*)observers {
213 return _observers; 213 return _observers;
214 } 214 }
215 215
216 - (void)setState:(ContextualSearch::PanelState)state { 216 - (void)setState:(ContextualSearch::PanelState)state {
217 if (state == _state) 217 if (state == _state)
218 return; 218 return;
219 219
220 [_positioningViewConstraint setActive:NO]; 220 [_positioningViewConstraint setActive:NO];
221 _positioningViewConstraint.reset(); 221 _positioningViewConstraint = nil;
222 base::WeakNSObject<ContextualSearchPanelView> weakSelf(self); 222 __weak ContextualSearchPanelView* weakSelf = self;
223 void (^transform)(void) = ^{ 223 void (^transform)(void) = ^{
224 base::scoped_nsobject<ContextualSearchPanelView> strongSelf( 224 ContextualSearchPanelView* strongSelf = weakSelf;
225 [weakSelf retain]);
226 if (strongSelf) { 225 if (strongSelf) {
227 [strongSelf setNeedsUpdateConstraints]; 226 [strongSelf setNeedsUpdateConstraints];
228 [[strongSelf superview] layoutIfNeeded]; 227 [[strongSelf superview] layoutIfNeeded];
229 [[strongSelf observers] panel:strongSelf 228 [[strongSelf observers] panel:strongSelf
230 didMoveWithMotion:[strongSelf motion]]; 229 didMoveWithMotion:[strongSelf motion]];
231 } 230 }
232 }; 231 };
233 232
234 base::mac::ScopedBlock<ProceduralBlockWithBool> completion; 233 base::mac::ScopedBlock<ProceduralBlockWithBool> completion;
marq (ping after 24h) 2017/01/13 10:38:17 Do we still need a scoped block under ARC?
stkhapugin 2017/01/17 15:57:44 Done.
235 NSTimeInterval animationDuration; 234 NSTimeInterval animationDuration;
236 if (state == ContextualSearch::DISMISSED) { 235 if (state == ContextualSearch::DISMISSED) {
237 animationDuration = kDismissAnimationDuration; 236 animationDuration = kDismissAnimationDuration;
238 completion.reset( 237 completion.reset([^(BOOL) {
239 ^(BOOL) { 238 [weakSelf setHidden:YES];
240 [weakSelf setHidden:YES]; 239 } copy]);
241 },
242 base::scoped_policy::RETAIN);
243 } else { 240 } else {
244 self.hidden = NO; 241 self.hidden = NO;
245 animationDuration = kPanelAnimationDuration; 242 animationDuration = kPanelAnimationDuration;
246 } 243 }
247 244
248 // Animations from a dismissed state are EaseOut, others are EaseInOut. 245 // Animations from a dismissed state are EaseOut, others are EaseInOut.
249 ios::material::Curve curve = _state == ContextualSearch::DISMISSED 246 ios::material::Curve curve = _state == ContextualSearch::DISMISSED
250 ? ios::material::CurveEaseOut 247 ? ios::material::CurveEaseOut
251 : ios::material::CurveEaseInOut; 248 : ios::material::CurveEaseInOut;
252 249
(...skipping 22 matching lines...) Expand all
275 .active = YES; 272 .active = YES;
276 [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor 273 [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor
277 constant:_promotionVerticalOffset] 274 constant:_promotionVerticalOffset]
278 .active = YES; 275 .active = YES;
279 } else { 276 } else {
280 // Don't update sizing constraints if there isn't a defined horizontal size 277 // Don't update sizing constraints if there isn't a defined horizontal size
281 // yet. 278 // yet.
282 if (self.traitCollection.horizontalSizeClass != 279 if (self.traitCollection.horizontalSizeClass !=
283 UIUserInterfaceSizeClassUnspecified && 280 UIUserInterfaceSizeClassUnspecified &&
284 !_sizingConstraints) { 281 !_sizingConstraints) {
285 _sizingConstraints.reset( 282 _sizingConstraints = [_configuration constraintsForSizingPanel:self];
286 [[_configuration constraintsForSizingPanel:self] retain]);
287 [NSLayoutConstraint activateConstraints:_sizingConstraints]; 283 [NSLayoutConstraint activateConstraints:_sizingConstraints];
288 } 284 }
289 // Update positioning constraints if they don't exist. 285 // Update positioning constraints if they don't exist.
290 if (!_positioningConstraints) { 286 if (!_positioningConstraints) {
291 NSArray* positioningConstraints = @[ 287 NSArray* positioningConstraints = @[
292 [[_positioningGuide topAnchor] 288 [[_positioningGuide topAnchor]
293 constraintEqualToAnchor:self.superview.topAnchor], 289 constraintEqualToAnchor:self.superview.topAnchor],
294 [[_positioningGuide bottomAnchor] 290 [[_positioningGuide bottomAnchor]
295 constraintEqualToAnchor:self.topAnchor] 291 constraintEqualToAnchor:self.topAnchor]
296 ]; 292 ];
297 [NSLayoutConstraint activateConstraints:positioningConstraints]; 293 [NSLayoutConstraint activateConstraints:positioningConstraints];
298 294
299 _positioningConstraints.reset([positioningConstraints retain]); 295 _positioningConstraints = positioningConstraints;
300 } 296 }
301 // Always update the positioning view constraint. 297 // Always update the positioning view constraint.
302 _positioningViewConstraint.reset([self.configuration 298 _positioningViewConstraint =
303 constraintForPositioningGuide:_positioningGuide 299 [self.configuration constraintForPositioningGuide:_positioningGuide
304 atState:self.state]); 300 atState:self.state];
305 [_positioningViewConstraint setActive:YES]; 301 [_positioningViewConstraint setActive:YES];
306 } 302 }
307 [super updateConstraints]; 303 [super updateConstraints];
308 } 304 }
309 305
310 - (void)didMoveToSuperview { 306 - (void)didMoveToSuperview {
311 if (!self.superview) 307 if (!self.superview)
312 return; 308 return;
313 // Set up the invisible positioning view used to constrain this view's 309 // Set up the invisible positioning view used to constrain this view's
314 // position. 310 // position.
315 UILayoutGuide* positioningGuide = [[[UILayoutGuide alloc] init] autorelease]; 311 UILayoutGuide* positioningGuide = [[UILayoutGuide alloc] init];
316 positioningGuide.identifier = @"contextualSearchPosition"; 312 positioningGuide.identifier = @"contextualSearchPosition";
317 [self.superview addLayoutGuide:positioningGuide]; 313 [self.superview addLayoutGuide:positioningGuide];
318 _positioningGuide.reset(positioningGuide); 314 _positioningGuide = positioningGuide;
319 [self setNeedsUpdateConstraints]; 315 [self setNeedsUpdateConstraints];
320 } 316 }
321 317
322 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { 318 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
323 if (previousTraitCollection.horizontalSizeClass == 319 if (previousTraitCollection.horizontalSizeClass ==
324 self.traitCollection.horizontalSizeClass) { 320 self.traitCollection.horizontalSizeClass) {
325 return; 321 return;
326 } 322 }
327 323
328 [self dismissPanel]; 324 [self dismissPanel];
329 325
330 [_configuration 326 [_configuration
331 setHorizontalSizeClass:self.traitCollection.horizontalSizeClass]; 327 setHorizontalSizeClass:self.traitCollection.horizontalSizeClass];
332 [NSLayoutConstraint deactivateConstraints:_sizingConstraints]; 328 [NSLayoutConstraint deactivateConstraints:_sizingConstraints];
333 _sizingConstraints.reset(); 329 _sizingConstraints = nil;
334 [self setNeedsUpdateConstraints]; 330 [self setNeedsUpdateConstraints];
335 } 331 }
336 332
337 - (void)layoutSubviews { 333 - (void)layoutSubviews {
338 [super layoutSubviews]; 334 [super layoutSubviews];
339 self.configuration.containerSize = self.superview.bounds.size; 335 self.configuration.containerSize = self.superview.bounds.size;
340 // Update the shadow path for this view. 336 // Update the shadow path for this view.
341 // Consider switching to "full" MDCShadowLayer. 337 // Consider switching to "full" MDCShadowLayer.
342 MDCShadowMetrics* metrics = 338 MDCShadowMetrics* metrics =
343 [MDCShadowMetrics metricsWithElevation:kShadowElevation]; 339 [MDCShadowMetrics metricsWithElevation:kShadowElevation];
344 UIBezierPath* shadowPath = [UIBezierPath bezierPathWithRect:self.bounds]; 340 UIBezierPath* shadowPath = [UIBezierPath bezierPathWithRect:self.bounds];
345 self.layer.shadowPath = shadowPath.CGPath; 341 self.layer.shadowPath = shadowPath.CGPath;
346 self.layer.shadowOpacity = metrics.topShadowOpacity; 342 self.layer.shadowOpacity = metrics.topShadowOpacity;
347 self.layer.shadowRadius = metrics.topShadowRadius; 343 self.layer.shadowRadius = metrics.topShadowRadius;
348 } 344 }
349 345
350 - (void)dismissPanel { 346 - (void)dismissPanel {
351 ContextualSearch::PanelMotion motion; 347 ContextualSearch::PanelMotion motion;
352 motion.state = ContextualSearch::DISMISSED; 348 motion.state = ContextualSearch::DISMISSED;
353 motion.nextState = ContextualSearch::DISMISSED; 349 motion.nextState = ContextualSearch::DISMISSED;
354 motion.gradation = 0; 350 motion.gradation = 0;
355 motion.position = 0; 351 motion.position = 0;
356 [_observers panel:self didStopMovingWithMotion:motion]; 352 [_observers panel:self didStopMovingWithMotion:motion];
357 } 353 }
358 354
359 - (void)dealloc { 355 - (void)dealloc {
360 [self removeMotionObserver:self]; 356 [self removeMotionObserver:self];
361 [self removeGestureRecognizer:_dragRecognizer]; 357 [self removeGestureRecognizer:_dragRecognizer];
362 [[_positioningGuide owningView] removeLayoutGuide:_positioningGuide]; 358 [[_positioningGuide owningView] removeLayoutGuide:_positioningGuide];
363 [super dealloc];
364 } 359 }
365 360
366 #pragma mark - Gesture recognizer callbacks 361 #pragma mark - Gesture recognizer callbacks
367 362
368 - (void)handleDragFrom:(UIGestureRecognizer*)gestureRecognizer { 363 - (void)handleDragFrom:(UIGestureRecognizer*)gestureRecognizer {
369 UIPanGestureRecognizer* recognizer = 364 UIPanGestureRecognizer* recognizer =
370 static_cast<UIPanGestureRecognizer*>(gestureRecognizer); 365 static_cast<UIPanGestureRecognizer*>(gestureRecognizer);
371 if ([recognizer state] == UIGestureRecognizerStateCancelled) { 366 if ([recognizer state] == UIGestureRecognizerStateCancelled) {
372 recognizer.enabled = YES; 367 recognizer.enabled = YES;
373 [self dismissPanel]; 368 [self dismissPanel];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 453 }
459 } 454 }
460 455
461 #pragma mark - UIGestureRecognizerDelegate methods 456 #pragma mark - UIGestureRecognizerDelegate methods
462 457
463 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer 458 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
464 shouldRecognizeSimultaneouslyWithGestureRecognizer: 459 shouldRecognizeSimultaneouslyWithGestureRecognizer:
465 (UIGestureRecognizer*)otherGestureRecognizer { 460 (UIGestureRecognizer*)otherGestureRecognizer {
466 // Allow the drag recognizer and the panel content scroll recognizer to 461 // Allow the drag recognizer and the panel content scroll recognizer to
467 // co-recognize. 462 // co-recognize.
468 if (gestureRecognizer == _dragRecognizer.get() && 463 if (gestureRecognizer == _dragRecognizer &&
469 otherGestureRecognizer == self.scrollSynchronizer.scrollRecognizer) { 464 otherGestureRecognizer == self.scrollSynchronizer.scrollRecognizer) {
470 return YES; 465 return YES;
471 } 466 }
472 467
473 if (gestureRecognizer == _dragRecognizer.get() && 468 if (gestureRecognizer == _dragRecognizer &&
474 [_dragRecognizer state] == UIGestureRecognizerStateChanged) { 469 [_dragRecognizer state] == UIGestureRecognizerStateChanged) {
475 [gestureRecognizer setEnabled:NO]; 470 [gestureRecognizer setEnabled:NO];
476 } 471 }
477 return NO; 472 return NO;
478 } 473 }
479 474
480 @end 475 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698