CNLiveShowTips.h 6.28 KB
//
//  CNLiveTips.h
//  CNLiveNetAdd
//
//  Created by 殷巧娟 on 2018/12/25.
//  Copyright © 2018年 cnlive. All rights reserved.
//

#import "CNLiveToastView.h"

NS_ASSUME_NONNULL_BEGIN
// 自动计算秒数的标志符,在 delay 里面赋值 QMUITipsAutomaticallyHideToastSeconds 即可通过自动计算 tips 消失的秒数
extern const NSInteger QMUITipsAutomaticallyHideToastSeconds;

/// 默认的 parentView
#define DefaultTipsParentView [[[UIApplication sharedApplication] delegate] window]

/**
 * 简单封装了 QMUIToastView,支持弹出纯文本、loading、succeed、error、info 等五种 tips。如果这些接口还满足不了业务的需求,可以通过 QMUITips 的分类自行添加接口。
 * 注意用类方法显示 tips 的话,会导致父类的 willShowBlock 无法正常工作,具体请查看 willShowBlock 的注释。
 * @see [QMUIToastView willShowBlock]
 */
@interface CNLiveShowTips : CNLiveToastView
/// 实例方法:需要自己addSubview,hide之后不会自动removeFromSuperView

- (void)showLoading;
- (void)showLoading:(nullable NSString *)text;
- (void)showLoadingHideAfterDelay:(NSTimeInterval)delay;
- (void)showLoading:(nullable NSString *)text hideAfterDelay:(NSTimeInterval)delay;
- (void)showLoading:(nullable NSString *)text detailText:(nullable NSString *)detailText;
- (void)showLoading:(nullable NSString *)text detailText:(nullable NSString *)detailText hideAfterDelay:(NSTimeInterval)delay;

- (void)showWithText:(nullable NSString *)text;
- (void)showWithText:(nullable NSString *)text hideAfterDelay:(NSTimeInterval)delay;
- (void)showWithText:(nullable NSString *)text detailText:(nullable NSString *)detailText;
- (void)showWithText:(nullable NSString *)text detailText:(nullable NSString *)detailText hideAfterDelay:(NSTimeInterval)delay;

- (void)showSucceed:(nullable NSString *)text;
- (void)showSucceed:(nullable NSString *)text hideAfterDelay:(NSTimeInterval)delay;
- (void)showSucceed:(nullable NSString *)text detailText:(nullable NSString *)detailText;
- (void)showSucceed:(nullable NSString *)text detailText:(nullable NSString *)detailText hideAfterDelay:(NSTimeInterval)delay;

- (void)showError:(nullable NSString *)text;
- (void)showError:(nullable NSString *)text hideAfterDelay:(NSTimeInterval)delay;
- (void)showError:(nullable NSString *)text detailText:(nullable NSString *)detailText;
- (void)showError:(nullable NSString *)text detailText:(nullable NSString *)detailText hideAfterDelay:(NSTimeInterval)delay;

- (void)showInfo:(nullable NSString *)text;
- (void)showInfo:(nullable NSString *)text hideAfterDelay:(NSTimeInterval)delay;
- (void)showInfo:(nullable NSString *)text detailText:(nullable NSString *)detailText;
- (void)showInfo:(nullable NSString *)text detailText:(nullable NSString *)detailText hideAfterDelay:(NSTimeInterval)delay;

/// 类方法:主要用在局部一次性使用的场景,hide之后会自动removeFromSuperView

+ (CNLiveShowTips *)createTipsToView:(UIView *)view;

+ (CNLiveShowTips *)showLoadingInView:(UIView *)view;
+ (CNLiveShowTips *)showLoading:(nullable NSString *)text inView:(UIView *)view;
+ (CNLiveShowTips *)showLoadingInView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showLoading:(nullable NSString *)text inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showLoading:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view;
+ (CNLiveShowTips *)showLoading:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;

+ (CNLiveShowTips *)showWithText:(nullable NSString *)text;
+ (CNLiveShowTips *)showWithText:(nullable NSString *)text detailText:(nullable NSString *)detailText;
+ (CNLiveShowTips *)showWithText:(nullable NSString *)text inView:(UIView *)view;
+ (CNLiveShowTips *)showWithText:(nullable NSString *)text inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showWithText:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view;
+ (CNLiveShowTips *)showWithText:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;

+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text;
+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text detailText:(nullable NSString *)detailText;
+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text inView:(UIView *)view;
+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view;
+ (CNLiveShowTips *)showSucceed:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;

+ (CNLiveShowTips *)showError:(nullable NSString *)text;
+ (CNLiveShowTips *)showError:(nullable NSString *)text detailText:(nullable NSString *)detailText;
+ (CNLiveShowTips *)showError:(nullable NSString *)text inView:(UIView *)view;
+ (CNLiveShowTips *)showError:(nullable NSString *)text inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showError:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view;
+ (CNLiveShowTips *)showError:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;

+ (CNLiveShowTips *)showInfo:(nullable NSString *)text;
+ (CNLiveShowTips *)showInfo:(nullable NSString *)text detailText:(nullable NSString *)detailText;
+ (CNLiveShowTips *)showInfo:(nullable NSString *)text inView:(UIView *)view;
+ (CNLiveShowTips *)showInfo:(nullable NSString *)text inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;
+ (CNLiveShowTips *)showInfo:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view;
+ (CNLiveShowTips *)showInfo:(nullable NSString *)text detailText:(nullable NSString *)detailText inView:(UIView *)view hideAfterDelay:(NSTimeInterval)delay;

/// 隐藏 tips
+ (void)hideAllTipsInView:(UIView *)view;
+ (void)hideAllTips;

/// 自动隐藏 toast 可以使用这个方法自动计算秒数
+ (NSTimeInterval)smartDelaySecondsForTipsText:(NSString *)text;
@end

NS_ASSUME_NONNULL_END