cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/QMUIModalPresentationViewController.h

326 lines
18 KiB
C
Raw Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// QMUIModalPresentationViewController.h
// qmui
//
// Created by QMUI Team on 16/7/6.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class QMUIModalPresentationViewController;
@class QMUIModalPresentationWindow;
typedef NS_ENUM(NSUInteger, QMUIModalPresentationAnimationStyle) {
QMUIModalPresentationAnimationStyleFade, // 渐现渐隐,默认
QMUIModalPresentationAnimationStylePopup, // 从中心点弹出
QMUIModalPresentationAnimationStyleSlide // 从下往上升起
};
@protocol QMUIModalPresentationContentViewControllerProtocol <NSObject>
@optional
/**
* UIViewController UIView使 modalController modalController modalController layoutBlock layoutBlock
* @param controller modalController
* @param keyboardHeight 0
* @param limitSize modalController `contentViewMargins``maximumContentViewWidth`
* @return `limitSize` / width/height `CGFLOAT_MAX`
*/
- (CGSize)preferredContentSizeInModalPresentationViewController:(QMUIModalPresentationViewController *)controller keyboardHeight:(CGFloat)keyboardHeight limitSize:(CGSize)limitSize;
@end
@protocol QMUIModalPresentationViewControllerDelegate <NSObject>
@optional
/**
* YES
* @param controller modalController
* @return YES NO
*/
- (BOOL)shouldHideModalPresentationViewController:(QMUIModalPresentationViewController *)controller;
/**
* modalController window dimmed
* @param controller modalController
*/
- (void)willHideModalPresentationViewController:(QMUIModalPresentationViewController *)controller;
/**
* modalController隐藏后的回调方法`hideWithAnimated:completion:`
* 使hideWithAnimated方法的completion参数`didHideByDimmingViewTappedBlock`
* @param controller modalController
*/
- (void)didHideModalPresentationViewController:(QMUIModalPresentationViewController *)controller;
@end
/**
* `UIView``UIViewController`
*
* 3
*
* 1. **** `UIWindow` `QMUIModalPresentationViewController` `rootViewController` `supportedOrientationMask` window controller
* shownInWindowMode
* @code
* [modalPresentationViewController showWithAnimated:YES completion:nil];
* @endcode
*
* 2. 使**** 使 `animated` `NO` `supportedOrientationMask`
* shownInPresentedMode
* @code
* [self presentViewController:modalPresentationViewController animated:NO completion:nil];
* @endcode
*
* 3. subview `superview` `superview` `QMUIModalPresentationViewController` retain
* shownInSubviewMode
* @code
* self.modalPresentationViewController.view.frame = CGRectMake(50, 50, 100, 100);
* [self.view addSubview:self.modalPresentationViewController.view];
* @endcode
*
*
* 1. `contentViewController` `preferredContentSizeInModalPresentationViewController:keyboardHeight:limitSize:`
* 2. 使 `contentView`使 `contentViewController` `preferredContentSizeInModalPresentationViewController:keyboardHeight:limitSize:``contentView``sizeThatFits:`
* 3. `maximumContentViewWidth` `contentViewMargins`
*
* `layoutBlock``showingAnimation``hidingAnimation`
*
* `dimmingView`使 view
*
* `animationStyle`
*
* @warning 使retain了modalPresentationViewController`hideWithAnimated:completion:`release
*
* @see QMUIAlertController
* @see QMUIDialogViewController
* @see QMUIMoreOperationController
*/
@interface QMUIModalPresentationViewController : UIViewController
@property(nullable, nonatomic, weak) IBOutlet id<QMUIModalPresentationViewControllerDelegate> delegate;
/**
*
* @warning `contentView``contentViewController`
*/
@property(nullable, nonatomic, strong) IBOutlet UIView *contentView;
/**
* UIViewController的形式来管理的情况
* @warning `contentViewController``contentViewController.view``contentView`使`contentView`
* @warning `contentViewController`使
*/
@property(nullable, nonatomic, strong) IBOutlet UIViewController<QMUIModalPresentationContentViewControllerProtocol> *contentViewController;
/**
* `contentView`(20, 20, 20, 20)
* @warning `layoutBlock`
*/
@property(nonatomic, assign) UIEdgeInsets contentViewMargins UI_APPEARANCE_SELECTOR;
/**
* `contentView` CGFLOAT_MAX
* @warning `layoutBlock`
*/
@property(nonatomic, assign) CGFloat maximumContentViewWidth UI_APPEARANCE_SELECTOR;
/**
modal window window
*/
@property(nullable, nonatomic, strong, readonly) UIWindow *window;
/**
modal window modal App
YES
window
*/
@property(nonatomic, assign) BOOL shouldDimmedAppAutomatically;
/**
* `UIView``UIColorMask`view`dimmingView`
*
* `QMUIModalPresentationViewController``dimmingView`
*/
@property(nullable, nonatomic, strong) IBOutlet UIView *dimmingView;
/**
*
*/
@property(nullable, nonatomic, copy) void (^willHideByDimmingViewTappedBlock)(void);
/**
* `hideWithAnimated:completion:`completion
*/
@property(nullable, nonatomic, copy) void (^didHideByDimmingViewTappedBlock)(void);
/**
*
*
* NO
*/
@property(nonatomic, assign, getter=isModal) BOOL modal;
/**
* /NO
*/
@property(nonatomic, assign, readonly, getter=isVisible) BOOL visible;
/**
* SupportedOrientationMask
*/
@property(nonatomic, assign) UIInterfaceOrientationMask supportedOrientationMask;
/**
* 使/`QMUIModalPresentationAnimationStyleFade`
* @warning 使`showingAnimation``hidingAnimation`
*/
@property(nonatomic, assign) QMUIModalPresentationAnimationStyle animationStyle UI_APPEARANCE_SELECTOR;
/// 是否以 UIWindow 的方式显示,建议在显示之后才使用,否则可能不准确。
@property(nonatomic, assign, readonly, getter=isShownInWindowMode) BOOL shownInWindowMode;
/// 是否以系统 present 的方式显示,建议在显示之后才使用,否则可能不准确。
@property(nonatomic, assign, readonly, getter=isShownInPresentedMode) BOOL shownInPresentedMode;
/// 是否以 addSubview 的方式显示,建议在显示之后才使用,否则可能不准确。
@property(nonatomic, assign, readonly, getter=isShownInSubviewMode) BOOL shownInSubviewMode;
/// 只响应 modal.view 上的 view 所产生的键盘事件,当为 NO 时,只要有键盘事件产生,浮层都会重新计算布局。
/// 默认为 YES也即只响应浮层上的 view 引起的键盘位置变化。
@property(nonatomic, assign) BOOL onlyRespondsToKeyboardEventFromDescendantViews;
/**
* block view frame qmui_frameApplyTransform setFrame:
* @arg containerBounds `self.view.bounds`
* @arg keyboardHeight 0
* @arg contentViewDefaultFrame 使`contentViewMargins``maximumContentViewWidth``contentView sizeThatFits:`
*
* @see contentViewMargins
* @see maximumContentViewWidth
*/
@property(nullable, nonatomic, copy) void (^layoutBlock)(CGRect containerBounds, CGFloat keyboardHeight, CGRect contentViewDefaultFrame);
/**
* `contentView``dimmingView``showingAnimation``contentView`使`layoutBlock``layoutBlock``showingAnimation``completion` block
* @arg dimmingView View
* @arg containerBounds `self.view.bounds`
* @arg keyboardHeight 0
* @arg contentViewFrame `contentView`frame使`layoutBlock``layoutBlock`frame
* @arg completion modalController的回调modalController会在这个回调里做一些状态设置
*/
@property(nullable, nonatomic, copy) void (^showingAnimation)(UIView * _Nullable dimmingView, CGRect containerBounds, CGFloat keyboardHeight, CGRect contentViewFrame, void(^completion)(BOOL finished));
/**
* `contentView``dimmingView``completion` block
* @arg dimmingView View
* @arg containerBounds `self.view.bounds`
* @arg keyboardHeight 0
* @arg completion modalController的回调modalController会在这个回调里做一些清理工作
*/
@property(nullable, nonatomic, copy) void (^hidingAnimation)(UIView * _Nullable dimmingView, CGRect containerBounds, CGFloat keyboardHeight, void(^completion)(BOOL finished));
/**
*
*/
- (void)updateLayout;
/**
* UIWindow
* @param animated
* @param completion
*/
- (void)showWithAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
/**
*
* @param animated
* @param completion
* @warning `completion``hideWithAnimated:completion:``dimmingView``hideWithAnimated:completion:`completion是不会被调用的使`delegate``didHideModalPresentationViewController:`
*/
- (void)hideWithAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
/**
* addSubview
*
* @param view view
* @param animated
* @param completion
*/
- (void)showInView:(UIView *)view animated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
/**
* view
* @param view view
* @param animated
* @param completion
* @warning `completion``hideInView:animated:completion:``dimmingView``hideInView:animated:completion:`completion是不会被调用的使`delegate``didHideModalPresentationViewController:`
*/
- (void)hideInView:(UIView *)view animated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
@end
/**
* QMUIModalPresentationViewController + [QMUIModalPresentationViewController hideAllVisibleModalPresentationViewControllerIfCan] hideModalPresentationComponent QMUIModalPresentationViewController hide
*/
@protocol QMUIModalPresentationComponentProtocol <NSObject>
@required
- (void)hideModalPresentationComponent;
@end
@interface QMUIModalPresentationViewController (Manager)
/**
* App里是否有modalViewController正在显示modalViewController但不可见的时候
* @return YESNO
*/
+ (BOOL)isAnyModalPresentationViewControllerVisible;
/**
* modalViewController都隐藏掉
* @return NOYES
* @see shouldHideModalPresentationViewController:
* @see QMUIModalPresentationComponentProtocol
* @warning modalPresentationViewController modal QMUIModalPresentationComponentProtocol hideModalPresentationComponent QMUIModalPresentationViewController hideWithAnimated:completion:
*/
+ (BOOL)hideAllVisibleModalPresentationViewControllerIfCan;
@end
@interface QMUIModalPresentationViewController (UIAppearance)
+ (instancetype)appearance;
@end
/// 专用于QMUIModalPresentationViewController的UIWindow这样才能在`UIApplication.sharedApplication.windows`里方便地区分出来
@interface QMUIModalPresentationWindow : UIWindow
@end
@interface UIViewController (QMUIModalPresentationViewController)
/**
* vieController QMUIModalPresentationViewController
*/
@property(nullable, nonatomic, weak, readonly) QMUIModalPresentationViewController *qmui_modalPresentationViewController;
@end
NS_ASSUME_NONNULL_END