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

229 lines
12 KiB
C
Raw Permalink 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.
*/
//
// QMUIDialogViewController.h
// WeRead
//
// Created by QMUI Team on 16/7/8.
//
#import <UIKit/UIKit.h>
#import "QMUICommonViewController.h"
#import "QMUIModalPresentationViewController.h"
#import "QMUITableView.h"
NS_ASSUME_NONNULL_BEGIN
@class QMUIButton;
@class QMUILabel;
@class QMUITextField;
@class QMUITableViewCell;
/**
* `headerView``contentView``footerView``addCancelButtonWithText:block:``addSubmitButtonWithText:block:`
* UIView设置给`contentView`contentView的sizeThatFits:
* `QMUICommonViewController`使self.titleView的功能来实现双行标题`QMUINavigationTitleView`
* `QMUIDialogViewController``UIAppearance`dialog样式`[QMUIDialogViewController appearance].headerViewHeight = 48;`
*
* @see QMUIDialogSelectionViewController
* @see QMUIDialogTextFieldViewController
*/
@interface QMUIDialogViewController : QMUICommonViewController<QMUIModalPresentationContentViewControllerProtocol, QMUIModalPresentationComponentProtocol>
@property(nonatomic, assign) CGFloat cornerRadius UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) UIEdgeInsets dialogViewMargins UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) CGFloat maximumContentViewWidth UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
/// 标题的 tintColor当没有设置 titleLabelTextColor 和 subTitleLabelTextColor 的情况下,标题和副标题的颜色均会使用 titleTintColor当 titleLabelTextColor 和 subTitleLabelTextColor 其中任何一个被设置了值时,则 titleTintColor 作为候选项使用(也即谁为 nil 才会用 titleTintColor 顶替,不为 nil 则不会用到 titleTintColor
/// 默认为 nil
@property(nullable, nonatomic, strong) UIColor *titleTintColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIFont *titleLabelFont UI_APPEARANCE_SELECTOR;
/// 主标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色
@property(nullable, nonatomic, strong) UIColor *titleLabelTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIFont *subTitleLabelFont UI_APPEARANCE_SELECTOR;
/// 副标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色
/// @note 副标题可通过 dialog.titleView.subtitle 来设置
@property(nullable, nonatomic, strong) UIColor *subTitleLabelTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *headerSeparatorColor UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) CGFloat headerViewHeight UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *headerViewBackgroundColor UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) UIEdgeInsets contentViewMargins UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *contentViewBackgroundColor UI_APPEARANCE_SELECTOR;// 对自定义 contentView 无效
@property(nullable, nonatomic, strong) UIColor *footerSeparatorColor UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) CGFloat footerViewHeight UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *footerViewBackgroundColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *buttonBackgroundColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *buttonHighlightedBackgroundColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, copy) NSDictionary<NSAttributedStringKey, id> *buttonTitleAttributes UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong, readonly) UIView *headerView;
@property(nullable, nonatomic, strong, readonly) CALayer *headerViewSeparatorLayer;
/// dialog的主体内容部分默认是一个空的白色UIView建议设置为自己的UIView
/// dialog会通过询问contentView的sizeThatFits得到当前内容的大小
@property(nullable, nonatomic, strong) UIView *contentView;
@property(nullable, nonatomic, strong, readonly) UIView *footerView;
@property(nullable, nonatomic, strong, readonly) CALayer *footerViewSeparatorLayer;
@property(nullable, nonatomic, strong, readonly) QMUIButton *cancelButton;
@property(nullable, nonatomic, strong, readonly) QMUIButton *submitButton;
@property(nullable, nonatomic, strong, readonly) CALayer *buttonSeparatorLayer;
/**
hide block hide
@param buttonText
@param block hide block hide
*/
- (void)addCancelButtonWithText:(NSString *)buttonText block:(void (^ _Nullable)(__kindof QMUIDialogViewController *aDialogViewController))block;
/**
*/
- (void)removeCancelButton;
/**
@param buttonText
@param block block hide
*/
- (void)addSubmitButtonWithText:(NSString *)buttonText block:(void (^ _Nullable)(__kindof QMUIDialogViewController *aDialogViewController))block;
/**
*/
- (void)removeSubmitButton;
/**
dialog modalPresentationViewController
*/
@property(nullable, nonatomic, strong) QMUIModalPresentationViewController *modalPresentationViewController;
/**
[self showWithAnimated:YES completion:nil]
*/
- (void)show;
/**
@param animated
@param completion
*/
- (void)showWithAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
/**
[self hideWithAnimated:YES completion:nil]
*/
- (void)hide;
/**
@param animated
@param completion
*/
- (void)hideWithAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL finished))completion;
@end
@interface QMUIDialogViewController (UIAppearance)
+ (instancetype)appearance;
@end
/// 表示没有选中的item
extern const NSInteger QMUIDialogSelectionViewControllerSelectedItemIndexNone;
/**
* `items` `NSString`使 `allowsMultipleSelection`
* `selectedItemIndex` dialog后设置这个属性来达到默认值的效果
* `selectedItemIndexes` dialog后设置这个属性来达到默认值的效果
*/
@interface QMUIDialogSelectionViewController : QMUIDialogViewController<QMUITableViewDelegate, QMUITableViewDataSource>
/// 每一行的高度,如果使用了 heightForItemBlock 则该属性不生效,默认值为配置表里的 TableViewCellNormalHeight
@property(nonatomic, assign) CGFloat rowHeight UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong, readonly) QMUITableView *tableView;
@property(nullable, nonatomic, copy) NSArray <NSString *> *items;
/// 表示单选模式下已选中的item序号默认为QMUIDialogSelectionViewControllerSelectedItemIndexNone。此属性与 `selectedItemIndexes` 互斥。
@property(nonatomic, assign) NSInteger selectedItemIndex;
/// 表示多选模式下已选中的item序号默认为nil。此属性与 `selectedItemIndex` 互斥。
@property(nullable, nonatomic, strong) NSMutableSet <NSNumber *> *selectedItemIndexes;
/// 控制是否允许多选默认为NO。
@property(nonatomic, assign) BOOL allowsMultipleSelection;
@property(nullable, nonatomic, copy) void (^cellForItemBlock)(__kindof QMUIDialogSelectionViewController *aDialogViewController, __kindof QMUITableViewCell *cell, NSUInteger itemIndex);
@property(nullable, nonatomic, copy) CGFloat (^heightForItemBlock)(__kindof QMUIDialogSelectionViewController *aDialogViewController, NSUInteger itemIndex);
@property(nullable, nonatomic, copy) BOOL (^canSelectItemBlock)(__kindof QMUIDialogSelectionViewController *aDialogViewController, NSUInteger itemIndex);
@property(nullable, nonatomic, copy) void (^didSelectItemBlock)(__kindof QMUIDialogSelectionViewController *aDialogViewController, NSUInteger itemIndex);
@property(nullable, nonatomic, copy) void (^didDeselectItemBlock)(__kindof QMUIDialogSelectionViewController *aDialogViewController, NSUInteger itemIndex);
@end
/**
* `textField.maximumLength`
* `enablesSubmitButtonAutomatically``submitButton.enabled`
*/
@interface QMUIDialogTextFieldViewController : QMUIDialogViewController
@property(nullable, nonatomic, strong) UIFont *textFieldLabelFont UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *textFieldLabelTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIFont *textFieldFont UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *textFieldTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *textFieldSeparatorColor UI_APPEARANCE_SELECTOR;
/// 输入框上方文字的间距,如果不存在文字则不使用这个间距
@property(nonatomic, assign) UIEdgeInsets textFieldLabelMargins UI_APPEARANCE_SELECTOR;
/// 输入框本身的间距,注意输入框内部自带 textInsets所以可能文字实际的显示位置会比这个间距更往内部一点
@property(nonatomic, assign) UIEdgeInsets textFieldMargins UI_APPEARANCE_SELECTOR;
/// 输入框的高度
@property(nonatomic, assign) CGFloat textFieldHeight UI_APPEARANCE_SELECTOR;
/// 输入框底部分隔线基于默认布局的偏移,注意分隔线默认的布局为:宽度是输入框宽度减去输入框左右的 textInsetsy 紧贴输入框底部。如果 textFieldSeparatorLayer.hidden = YES 则布局时不考虑这个间距
@property(nonatomic, assign) UIEdgeInsets textFieldSeparatorInsets UI_APPEARANCE_SELECTOR;
- (void)addTextFieldWithTitle:(nullable NSString *)textFieldTitle configurationHandler:(void (^ _Nullable)(QMUILabel *titleLabel, QMUITextField *textField, CALayer *separatorLayer))configurationHandler;
@property(nullable, nonatomic, copy, readonly) NSArray<QMUILabel *> *textFieldTitleLabels;
@property(nullable, nonatomic, copy, readonly) NSArray<QMUITextField *> *textFields;
@property(nullable, nonatomic, copy, readonly) NSArray<CALayer *> *textFieldSeparatorLayers;
/// 是否应该自动管理输入框的键盘 Return 事件,默认为 YESYES 表示当点击 Return 按钮时,视为点击了 dialog 的 submit 按钮。你也可以通过 UITextFieldDelegate 自己管理,此时请将此属性置为 NO。
@property(nonatomic, assign) BOOL shouldManageTextFieldsReturnEventAutomatically;
/// 是否自动控制提交按钮的enabled状态默认为YES则当任一输入框内容为空时禁用提交按钮
@property(nonatomic, assign) BOOL enablesSubmitButtonAutomatically;
@property(nullable, nonatomic, copy) BOOL (^shouldEnableSubmitButtonBlock)(__kindof QMUIDialogTextFieldViewController *aDialogViewController);
@end
NS_ASSUME_NONNULL_END