// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_LENS_OVERLAY_MODEL_LENS_OVERLAY_PAN_TRACKER_H_
#define IOS_CHROME_BROWSER_LENS_OVERLAY_MODEL_LENS_OVERLAY_PAN_TRACKER_H_

#import <UIKit/UIKit.h>

@protocol LensOverlayPanTrackerDelegate;

// Utility class that tracks whether the user pans a given UIView.
//
// Does not strongly retain the view.
@interface LensOverlayPanTracker : NSObject <UIGestureRecognizerDelegate>

@property(nonatomic, weak) id<LensOverlayPanTrackerDelegate> delegate;
// Whether the user pans the view.
@property(nonatomic, assign, readonly) BOOL isPanning;

// Whether the gesture recognizer cancels touches in view.
// Default is `NO`.
@property(nonatomic) BOOL cancelsTouchesInView;

// Creates a new instance of the pan tracker for a given UIView.
- (instancetype)initWithView:(UIView*)view;

// Starts tracking pan gestures on the given view.
- (void)startTracking;

// Stops tracking pan gestures on the given view.
- (void)stopTracking;

@end

// Delegate for starting and stopping tracking pan gesture.
@protocol LensOverlayPanTrackerDelegate <NSObject>

@optional
// Called when the tracker started recognizing a pan gesture.
- (void)lensOverlayPanTrackerDidBeginPanGesture:
    (LensOverlayPanTracker*)panTracker;

// Called when the tracker ended recognizing a pan gesture.
- (void)lensOverlayPanTracker:(LensOverlayPanTracker*)panTracker
    didEndPanGestureWithVelocity:(CGPoint)velocity;

// Called once a pan gesture is registered.
- (void)lensOverlayPanTracker:(LensOverlayPanTracker*)panTracker
        didPanWithTranslation:(CGPoint)translation
                     velocity:(CGPoint)velocity;

// Asks if the given gesture recognizer should be allowed to recognize gestures
// simultaneously with the pan tracker.
- (BOOL)lensOverlayPanTracker:(LensOverlayPanTracker*)panTracker
    shouldRecognizeSimultaneouslyWithGestureRecognizer:
        (UIGestureRecognizer*)gestureRecognizer;

@end

#endif  // IOS_CHROME_BROWSER_LENS_OVERLAY_MODEL_LENS_OVERLAY_PAN_TRACKER_H_
