123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //
- // YMAlert.h
- // yuemoClient
- //
- // Created by YoMi on 2023/11/6.
- //
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- #import "YMPopupView.h"
- NS_ASSUME_NONNULL_BEGIN
- @class YMAlert;
- typedef YMAlert * _Nonnull (^YMAlertString)(NSString * string);
- typedef YMAlert * _Nonnull (^YMAlertView)(UIView * view);
- typedef YMAlert * _Nonnull (^YMAlertCustomView)(YmViewBlock block);
- typedef YMAlert * _Nonnull (^YMAlertColor)(UIColor * color);
- typedef YMAlert * _Nonnull (^YMAlertDelegate)(id<YMPopupViewProtocol> delegate);
- typedef YMAlert * _Nonnull (^YMAlertPositionStyle)(YMPositionStyle style);
- typedef YMAlert * _Nonnull (^YMAlertPopStyle)(YMPopupStyle style);
- typedef YMAlert * _Nonnull (^YMAlertDismissStyle)(YMDismissStyle style);
- typedef YMAlert * _Nonnull (^YMAlertDragStyle)(YMDragStyle style);
- typedef YMAlert * _Nonnull (^YMAlertSweepStyle)(YMSweepStyle style);
- typedef YMAlert * _Nonnull (^YMAlertSweepDismissStyle)(YMSweepDismissStyle style);
- typedef YMAlert * _Nonnull (^YMAlertInterval)(NSTimeInterval num);
- typedef YMAlert * _Nonnull (^YMAlertFloat)(CGFloat num);
- typedef YMAlert * _Nonnull (^YMAlertBOOL)(BOOL is);
- typedef YMAlert * _Nonnull (^YMAlertCorner)(UIRectCorner corner);
- typedef YMAlert * _Nonnull (^YMAlertBlock)(YmVoidBlock block);
- typedef YMAlert * _Nonnull (^YMAlertVoid)(void);
- typedef YMAlert * _Nonnull (^YMAlertPointBlock)(YmPointBlock block);
- typedef YMAlert * _Nonnull (^YMAlertKeyBoardChangeBlock)(YmKeyBoardChangeBlock block);
- typedef YMAlert * _Nonnull (^YMAlertAlertCountDownBlock)(YmAlertCountDownBlock block);
- @interface YMAlert : NSObject
- /// 初始化 alert
- + (instancetype)alert;
- #pragma mark - =================== 便利方法 ===================
- /// 获取全局(整个app内)所有popView
- + (NSArray <YMPopupView *>*)getAllPopView;
- /// 获取当前页面所有popView
- + (NSArray <YMPopupView *>*)getAllPopViewForParentView:(UIView *)parentView;
- /// 获取当前页面指定编队的所有popView
- + (NSArray <YMPopupView *>*)getAllPopViewForPopView:(UIView *)popView;
- /// 读取popView (有可能会跨编队读取弹窗)
- + (YMPopupView *)getPopViewForKey:(NSString *)key;
- /// 移除所有的 popview
- + (void)dismissAllAlert:(YmVoidBlock)complete;
- /// 移除最后添加的 popview
- + (void)dismissAlertComplete:(YmVoidBlock)complete;
- /// 移除指定 YMAlert 的 popview
- + (void)dismissAlertForAlert:(YMAlert *)alert complete:(YmVoidBlock)complete;
- /// 移除指定 key 的 popview
- + (void)dismissAlertForKey:(NSString *)key complete:(YmVoidBlock)complete;
- /// 移除指定 popview 的 popview
- + (void)dismissAlertForPopView:(YMPopupView *)popView complete:(YmVoidBlock)complete;
- #pragma mark - 基础属性
- /// 代理 支持多代理
- @property (nonatomic , copy , readonly ) YMAlertDelegate delegate;
- /// 标识 默认为空
- @property (nonatomic , copy , readonly ) YMAlertString identifier;
- /// 弹窗容器
- @property (nonatomic , copy , readonly ) YMAlertView parentView;
- /// 自定义view
- @property (nonatomic , copy , readonly ) YMAlertCustomView currCustomView;
- /// 弹窗位置 默认YMPositionStyleCenter
- @property (nonatomic , copy , readonly ) YMAlertPositionStyle positionStyle;
- /// 显示时动画弹窗样式 默认YMPopupStyleFade
- @property (nonatomic , copy , readonly ) YMAlertPopStyle popStyle;
- /// 移除时动画弹窗样式 默认YMDismissStyleFade
- @property (nonatomic , copy , readonly ) YMAlertDismissStyle dismissStyle;
- /// 显示时动画时长,> 0。不设置则使用默认的动画时长 设置成YMPopupStyleNO, 该属性无效
- @property (nonatomic , copy , readonly ) YMAlertInterval popDuration;
- /// 隐藏时动画时长,>0。不设置则使用默认的动画时长 设置成YMDismissStyleNO, 该属性无效
- @property (nonatomic , copy , readonly ) YMAlertInterval dismissDuration;
- /// 弹窗水平方向(X)偏移量校准 默认0
- @property (nonatomic , copy , readonly ) YMAlertFloat adjustX;
- /// 弹窗垂直方向(Y)偏移量校准 默认0
- @property (nonatomic , copy , readonly ) YMAlertFloat adjustY;
- /// 背景颜色 默认rgb(0,0,0) 透明度0.3
- @property (nonatomic , copy , readonly ) YMAlertColor bgColor;
- /// 显示时背景的透明度,取值(0.0~1.0),默认为0.3
- @property (nonatomic , copy , readonly ) YMAlertFloat bgAlpha;
- /// 是否隐藏背景 默认NO
- @property (nonatomic , copy , readonly ) YMAlertBOOL isHideBg;
- /// 显示时点击背景是否移除弹窗,默认为NO。
- @property (nonatomic , copy , readonly ) YMAlertBOOL isClickBgDismiss;
- /// 是否监听屏幕旋转,默认为YES
- @property (nonatomic , copy , readonly ) YMAlertBOOL isObserverScreenRotation;
- /// 是否支持点击回馈 默认NO (暂时关闭)
- @property (nonatomic , copy , readonly ) YMAlertBOOL isClickFeedback;
- /// 是否规避键盘 默认YES
- @property (nonatomic , copy , readonly ) YMAlertBOOL isAvoidKeyboard;
- /// 弹窗和键盘的距离 默认10
- @property (nonatomic , copy , readonly ) YMAlertFloat avoidKeyboardSpace;
- /// 显示多长时间 默认0 不会消失
- @property (nonatomic , copy , readonly ) YMAlertInterval showTime;
- /// 自定view圆角方向设置 默认UIRectCornerAllCorners 当cornerRadius>0时生效
- @property (nonatomic , copy , readonly ) YMAlertCorner rectCorners;
- /// 自定义view圆角大小, 默认 0
- @property (nonatomic , copy , readonly ) YMAlertFloat cornerRadius;
- /// 弹出震动反馈 默认NO iOS10+ 系统才有此效果
- @property (nonatomic , copy , readonly ) YMAlertBOOL isImpactFeedback;
- #pragma mark - 群组相关属性
- /// 群组标识 统一给弹窗编队 方便独立管理 默认为nil,统一全局处理
- @property (nonatomic , copy , readonly ) YMAlertString groupId;
- /// 是否堆叠 默认NO 如果是YES priority优先级不生效
- @property (nonatomic , copy , readonly ) YMAlertBOOL isStack;
- /// 单显示 默认NO 只会显示优先级最高的popView
- @property (nonatomic , copy , readonly ) YMAlertBOOL isSingle;
- /// 优先级 范围0~1000 (默认0,遵循先进先出) isStack和isSingle为NO的时候生效
- @property (nonatomic , copy , readonly ) YMAlertFloat priority;
- #pragma mark - 拖拽手势相关属性
- /// 拖拽方向 默认 不可拖拽
- @property (nonatomic , copy , readonly ) YMAlertDragStyle dragStyle;
- /// X轴或者Y轴拖拽移除临界距离 范围(0 ~ +∞) 默认0 不拖拽移除 基使用于dragStyle
- @property (nonatomic , copy , readonly ) YMAlertFloat dragDistance;
- /// 拖拽移除动画类型 默认同dismissStyle
- @property (nonatomic , copy , readonly ) YMAlertDismissStyle dragDismissStyle;
- /// 拖拽消失动画时间 默认同 dismissDuration
- @property (nonatomic , copy , readonly ) YMAlertInterval dragDismissDuration;
- /// 拖拽复原动画时间 默认0.25s
- @property (nonatomic , copy , readonly ) YMAlertInterval dragReboundTime;
- /// 轻扫方向 默认 不可轻扫 前提开启dragStyle
- @property (nonatomic , copy , readonly ) YMAlertSweepStyle sweepStyle;
- /// 轻扫速率 控制轻扫移除 默认1000 基于使用sweepStyle
- @property (nonatomic , copy , readonly ) YMAlertFloat swipeVelocity;
- /// 轻扫移除的动画 默认YMSweepDismissStyleVelocity
- @property (nonatomic , copy , readonly ) YMAlertSweepDismissStyle sweepDismissStyle;
- #pragma mark - 交互回调
- /// 点击背景
- @property (nonatomic , copy , readonly ) YMAlertBlock bgClickBlock;
- /// 长按背景
- @property (nonatomic , copy , readonly ) YMAlertBlock bgLongPressBlock;
- /// 弹窗pan手势偏移量
- @property (nonatomic , copy , readonly ) YMAlertPointBlock panOffsetBlock;
- #pragma mark - 以下键盘弹出/收起 第三方键盘会多次回调(百度,搜狗测试得出), 原生键盘回调一次
- /// 键盘将要弹出
- @property (nonatomic , copy , readonly ) YMAlertBlock keyboardWillShowBlock;
- /// 键盘弹出完毕
- @property (nonatomic , copy , readonly ) YMAlertBlock keyboardDidShowBlock;
- /// 键盘frame将要改变
- @property (nonatomic , copy , readonly ) YMAlertKeyBoardChangeBlock keyboardFrameWillChangeBlock;
- /// 键盘frame改变完毕
- @property (nonatomic , copy , readonly ) YMAlertKeyBoardChangeBlock keyboardFrameDidChangeBlock;
- /// 键盘将要收起
- @property (nonatomic , copy , readonly ) YMAlertBlock keyboardWillHideBlock;
- /// 键盘收起完毕
- @property (nonatomic , copy , readonly ) YMAlertBlock keyboardDidHideBlock;
- #pragma mark - 生命周期回调(Block)
- /// 将要显示 回调
- @property (nonatomic , copy , readonly ) YMAlertBlock popViewWillPopBlock;
- /// 已经显示完毕 回调
- @property (nonatomic , copy , readonly ) YMAlertBlock popViewDidPopBlock;
- /// 将要开始移除 回调
- @property (nonatomic , copy , readonly ) YMAlertBlock popViewWillDismissBlock;
- /// 已经移除完毕 回调
- @property (nonatomic , copy , readonly ) YMAlertBlock popViewDidDismissBlock;
- /// 倒计时 回调
- @property (nonatomic , copy , readonly ) YMAlertAlertCountDownBlock popViewCountDownBlock;
- /// 弹出
- @property (nonatomic , copy , readonly ) YMAlertVoid pop;
- /// 消失
- @property (nonatomic , copy , readonly ) YMAlertVoid dismiss;
- @property (nonatomic , weak , readonly ) YMPopupView * popView;
- @end
- NS_ASSUME_NONNULL_END
|