HWPanModalPresentableHandler.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // HWPanModalPresentableHandler.h
  3. // HWPanModal
  4. //
  5. // Created by heath wang on 2019/10/15.
  6. // Copyright © 2019 Heath Wang. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <HWPanModal/HWPanModalPresentable.h>
  10. #import <HWPanModal/HWPanModalPanGestureDelegate.h>
  11. #import "HWPanModalPresentationDelegate.h"
  12. typedef NS_ENUM(NSUInteger, HWPanModalPresentableHandlerMode) {
  13. HWPanModalPresentableHandlerModeViewController, // used for UIViewController
  14. HWPanModalPresentableHandlerModeView, // used for view
  15. };
  16. NS_ASSUME_NONNULL_BEGIN
  17. @protocol HWPanModalPresentableHandlerDelegate <NSObject>
  18. /**
  19. * tell the delegate the presentable is about to update origin y
  20. */
  21. - (void)adjustPresentableYPos:(CGFloat)yPos;
  22. /**
  23. * tell the delegate presentable is about to change the form state
  24. * @param state short,medium, long
  25. */
  26. - (void)presentableTransitionToState:(PresentationState)state;
  27. /**
  28. * get current CurrentPresentationState of the delegate
  29. */
  30. - (PresentationState)getCurrentPresentationState;
  31. /**
  32. * dismiss Controller/UIView
  33. * @param isInteractive only for UIViewController, pop view will ignore it.
  34. * @param mode only for UIViewController, pop view will ignore it.
  35. */
  36. - (void)dismiss:(BOOL)isInteractive mode:(PanModalInteractiveMode)mode;
  37. @optional
  38. - (void)cancelInteractiveTransition;
  39. - (void)finishInteractiveTransition;
  40. @end
  41. @protocol HWPanModalPresentableHandlerDataSource <NSObject>
  42. - (CGSize)containerSize;
  43. - (BOOL)isBeingDismissed;
  44. - (BOOL)isBeingPresented;
  45. - (BOOL)isFormPositionAnimating;
  46. @optional
  47. - (BOOL)isPresentedViewAnchored;
  48. - (BOOL)isPresentedControllerInteractive;
  49. @end
  50. @interface HWPanModalPresentableHandler : NSObject <UIGestureRecognizerDelegate>
  51. @property (nonatomic, assign, readonly) CGFloat shortFormYPosition;
  52. @property (nonatomic, assign, readonly) CGFloat mediumFormYPosition;
  53. @property (nonatomic, assign, readonly) CGFloat longFormYPosition;
  54. @property (nonatomic, assign, readonly) BOOL extendsPanScrolling;
  55. @property (nonatomic, assign, readonly) BOOL anchorModalToLongForm;
  56. @property (nonatomic, assign, readonly) CGFloat anchoredYPosition;
  57. @property (nonatomic, strong, readonly) UIPanGestureRecognizer *panGestureRecognizer;
  58. // make controller or view to deal with the gesture action
  59. @property (nonatomic, strong, readonly) UIPanGestureRecognizer *screenEdgeGestureRecognizer;
  60. @property (nonatomic, assign) HWPanModalPresentableHandlerMode mode;
  61. @property (nonatomic, weak) UIView<HWPanModalIndicatorProtocol> *dragIndicatorView;
  62. @property (nonatomic, weak) UIView *presentedView; // which used to present.
  63. @property(nonatomic, weak) id <HWPanModalPresentableHandlerDelegate> delegate;
  64. @property(nonatomic, weak) id <HWPanModalPresentableHandlerDataSource> dataSource;
  65. - (instancetype)initWithPresentable:(id <HWPanModalPresentable>)presentable;
  66. + (instancetype)handlerWithPresentable:(id <HWPanModalPresentable>)presentable;
  67. + (instancetype)new NS_UNAVAILABLE;
  68. - (instancetype)init NS_UNAVAILABLE;
  69. - (void)observeScrollable;
  70. - (void)configureScrollViewInsets;
  71. - (void)setScrollableContentOffset:(CGPoint)offset animated:(BOOL)animated;
  72. - (void)configureViewLayout;
  73. @end
  74. NS_ASSUME_NONNULL_END