chore: Initial clean commit

- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
This commit is contained in:
edwinQQQ
2025-10-09 16:19:14 +08:00
commit a35a711be6
5582 changed files with 408913 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
//
// TTActionSheetConfig.h
// AFNetworking
//
// Created by lee on 2019/5/23.
// action sheet item 配置
#import <UIKit/UIKit.h>
typedef enum : NSUInteger {
TTItemSelectNormal,
TTItemSelectHighLight,
} TTItemSelectType;
NS_ASSUME_NONNULL_BEGIN
typedef void(^TTActionSheetClickAction)(void);
@interface TTActionSheetConfig : NSObject
/** 标题 */
@property (nonatomic, copy) NSString *title;
/**
标题颜色
*/
@property (nonatomic, strong) UIColor *titleColor;
/** 是否选中 */
@property (nonatomic, assign) TTItemSelectType type;
/** 点击事件 */
@property (nonatomic, copy) TTActionSheetClickAction clickAction;
@property(nonatomic, assign) BOOL displayMoliCoin;
/**
构建 actionSheet item 实例
@param title 标题
@param clickAction 点击事件
@return item 实例
*/
+ (TTActionSheetConfig *)normalTitle:(NSString *)title
clickAction:(TTActionSheetClickAction)clickAction;
+ (TTActionSheetConfig *)normalTitle:(NSString *)title
selectColorType:(TTItemSelectType)type clickAction:(TTActionSheetClickAction)clickAction;
/// 构建实例
/// @param title 标题
/// @param textColor 颜色
/// @param handler 事件处理
+ (TTActionSheetConfig *)actionWithTitle:(NSString *)title
color:(UIColor *)textColor
handler:(TTActionSheetClickAction)handler;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,49 @@
//
// TTActionSheetConfig.m
// AFNetworking
//
// Created by lee on 2019/5/23.
//
#import "TTActionSheetConfig.h"
#import "DJDKMIMOMColor.h"
@implementation TTActionSheetConfig
/**
actionSheet item
@param title
@param clickAction
@return item
*/
+ (TTActionSheetConfig *)normalTitle:(NSString *)title clickAction:(TTActionSheetClickAction)clickAction {
return [self normalTitle:title selectColorType:TTItemSelectNormal clickAction:clickAction];
}
+ (TTActionSheetConfig *)normalTitle:(NSString *)title selectColorType:(TTItemSelectType)type clickAction:(TTActionSheetClickAction)clickAction {
UIColor *color = type == TTItemSelectHighLight ? [DJDKMIMOMColor alertTitleColor] : [DJDKMIMOMColor alertTitleColor];
TTActionSheetConfig *config = [self actionWithTitle:title color:color handler:clickAction];
config.type = type;
return config;
}
+ (TTActionSheetConfig *)actionWithTitle:(NSString *)title
color:(UIColor *)textColor
handler:(TTActionSheetClickAction)handler {
TTActionSheetConfig *config = [[TTActionSheetConfig alloc] init];
config.type = TTItemSelectNormal;
config.title = title;
config.titleColor = textColor;
config.clickAction = handler;
return config;
}
@end

View File

@@ -0,0 +1,30 @@
//
// TTAlertButtonConfig.h
// YM_TTChatViewKit
//
// Created by lee on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
// alert 按钮配置
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TTAlertButtonConfig : NSObject
/** 按钮标题 */
@property (nonatomic, copy) NSString *title;
/** 按钮字体 */
@property (nonatomic, strong) UIFont *font;
/** 按钮字体颜色 */
@property (nonatomic, strong) UIColor *titleColor;
/** 背景色 */
@property (nonatomic, strong) UIColor *backgroundColor;
/** 背景图 */
@property (nonatomic, strong) UIImage *backgroundImage;
/** 圆角 */
@property (nonatomic, assign) CGFloat cornerRadius;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,13 @@
//
// TTAlertButtonConfig.m
// YM_TTChatViewKit
//
// Created by lee on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTAlertButtonConfig.h"
@implementation TTAlertButtonConfig
@end

View File

@@ -0,0 +1,86 @@
//
// TTAlertConfig.h
// YM_TTChatViewKit
//
// Created by lee on 2019/5/20.
// Copyright © 2023 YUMI. All rights reserved.
// alert 配置
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "TTAlertButtonConfig.h"
#import "TTAlertMessageAttributedConfig.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, TTAlertActionStyle) {
TTAlertActionConfirmStyle = 0, // 只有确定按钮
TTAlertActionCancelStyle = 1, // 只有取消按钮
TTAlertActionBothStyle = 2, // 全部按钮
};
@interface TTAlertConfig : NSObject
// 按钮显示风格
@property (nonatomic, assign) TTAlertActionStyle actionStyle;
// 容器背景设置
@property (nonatomic, strong) UIColor *backgroundColor;
// 标题设置
@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) UIFont *titleFont;
@property (nonatomic, strong) UIColor *titleColor;
// 内容设置
@property (nonatomic, copy) NSString *message;
@property (nonatomic, strong) UIFont *messageFont;
@property (nonatomic, strong) UIColor *messageColor;
/** 内容的行间距,默认不设置,当值为 0 或负数时无效 */
@property (nonatomic, assign) CGFloat messageLineSpacing;
@property(nonatomic, assign) NSTextAlignment messageTextAlignment;
/** 内容富文本配置 */
@property (nonatomic, strong) NSArray<TTAlertMessageAttributedConfig *> *messageAttributedConfig;
///配置内容的富文本
@property (nonatomic,strong) NSMutableAttributedString *messageAttributed;
// 取消按钮配置
@property (nonatomic, strong) TTAlertButtonConfig *cancelButtonConfig;
// 确定按钮配置
@property (nonatomic, strong) TTAlertButtonConfig *confirmButtonConfig;
/**
背景蒙层的透明度
@Description 默认是 000000 黑色 0.3 alpha
*/
@property (nonatomic, assign) CGFloat maskBackgroundAlpha;
// 圆角
@property (nonatomic, assign) CGFloat cornerRadius;
// 点击蒙层是否消失默认YES
@property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch;
/**
点击确定取消按钮时禁止弹窗自动消失默认NO
@discussion 若值为 YES需要主动调用 [TTPopup dismiss] 消除弹窗
*/
@property (nonatomic, assign) BOOL disableAutoDismissWhenClickButton;
/**
重复弹窗过滤默认NO
@discussion 设置过滤时,队列中将不会出现相同过滤标识的弹窗
过滤标识通过 #<filterIdentifier> 设置
*/
@property (nonatomic, assign) BOOL shouldFilterPopup;
/**
过滤标识默认nil
*/
@property (nonatomic, copy) NSString *filterIdentifier;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,90 @@
//
// TTAlertConfig.m
// YM_TTChatViewKit
//
// Created by lee on 2019/5/20.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTAlertConfig.h"
#import "UIImage+Utils.h"
#import "DJDKMIMOMColor.h"
static CGFloat kAlertTitleFont = 18.f;
static CGFloat kAlertButtonFont = 15.f;
static CGFloat kAlertMessageFont = 15.f;
static CGFloat kAlertCornerRadius = 12.f;
static CGFloat kAlertBackgroundColorAlpha = 0.3;
static CGFloat kAlertMessageFontLineSpace = -1;
static CGFloat kAlertButtonCornerRadius = 8.f;
@implementation TTAlertConfig
- (instancetype)init {
self = [super init];
if (self) {
_backgroundColor = [DJDKMIMOMColor alertBackgroundColor];
//
kAlertTitleFont = 16.f;
kAlertCornerRadius = 14.f;
kAlertButtonCornerRadius = 19.f;
_actionStyle = TTAlertActionBothStyle;
// title
_title = @"";//
_titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:kAlertTitleFont];//
_titleColor = [DJDKMIMOMColor alertTitleColor];//
// message
_message = @"";
_messageFont = [UIFont systemFontOfSize:kAlertMessageFont];//
_messageColor = [DJDKMIMOMColor alertMessageColor];//
_messageLineSpacing = kAlertMessageFontLineSpace;//
_messageAttributedConfig = @[];//
_messageTextAlignment = NSTextAlignmentCenter;
// cancel button
_cancelButtonConfig = [[TTAlertButtonConfig alloc] init];
_cancelButtonConfig.title = YMLocalizedString(@"XPRoomSettingInputView4");//
_cancelButtonConfig.font = [UIFont systemFontOfSize:kAlertButtonFont];//
_cancelButtonConfig.titleColor = [DJDKMIMOMColor cancelButtonTextColor];//
_cancelButtonConfig.backgroundImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor cancelButtonGradientStartColor], [DJDKMIMOMColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_cancelButtonConfig.cornerRadius = kAlertButtonCornerRadius;//
// confirm button
_confirmButtonConfig = [[TTAlertButtonConfig alloc] init];
_confirmButtonConfig.title = YMLocalizedString(@"TTAlertConfig0");
_confirmButtonConfig.font = [UIFont systemFontOfSize:kAlertButtonFont];
_confirmButtonConfig.titleColor = [DJDKMIMOMColor confirmButtonTextColor];
_confirmButtonConfig.backgroundImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xE29030), UIColorFromRGB(0xFCC074)]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(10, 10)];
_confirmButtonConfig.cornerRadius = kAlertButtonCornerRadius;
// //
// CAGradientLayer *gradientLayer = [CAGradientLayer layer];
// gradientLayer.colors = @[(__bridge id)UIColorFromRGB(0xE29030).CGColor,
// (__bridge id)UIColorFromRGB(0xFCC074).CGColor];
// gradientLayer.startPoint = CGPointMake(0.0, 0.0); //
// gradientLayer.endPoint = CGPointMake(0.0, 1.0); //
// gradientLayer.frame = CGRectMake(0, 0, 120, 38); //
//
// //
// [_previewActionButton.layer insertSublayer:gradientLayer atIndex:0];
_cornerRadius = kAlertCornerRadius;//
_shouldDismissOnBackgroundTouch = YES;//
// mask default 0.3 black
_maskBackgroundAlpha = kAlertBackgroundColorAlpha; // alert
_disableAutoDismissWhenClickButton = NO;
}
return self;
}
@end

View File

@@ -0,0 +1,34 @@
//
// TTAlertContentAttributedConfig.h
// YM_TTChatViewKit
//
// Created by lee on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
// alert 提示内容富文本配置
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TTAlertMessageAttributedConfig : NSObject
/** 富文本字段需要特殊显示的文本 */
@property (nonatomic, copy) NSString *text;
/** 颜色 */
@property (nonatomic, strong) UIColor *color;
/** 字体 */
@property (nonatomic, strong) UIFont *font;
/**
目标文本指定位置,一旦设置则无视 text 的值
@discussion 内容文本中出现相同的目标文本时,可通过设置 range 精确指定位置
*/
@property (nonatomic, assign) NSRange range;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,13 @@
//
// TTAlertContentAttributedConfig.m
// YM_TTChatViewKit
//
// Created by lee on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTAlertMessageAttributedConfig.h"
@implementation TTAlertMessageAttributedConfig
@end

View File

@@ -0,0 +1,38 @@
//
// TTPopupConstants.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import <UIKit/UIKit.h>
/**
Popup 组件通用回调
*/
typedef void(^TTPopupCompletionHandler)(void);
/**
弹窗类型
- TTPopupStyleAlert: Alert
- TTPopupStyleActionSheet: ActionSheet
*/
typedef NS_ENUM(NSUInteger, TTPopupStyle) {
TTPopupStyleAlert = 0,
TTPopupStyleActionSheet
};
/**
弹窗优先级
- TTPopupPriorityNormal: 普通
- TTPopupPriorityHigh: 高
- TTPopupPriorityRequired: 必须
*/
typedef NS_ENUM(NSUInteger, TTPopupPriority) {
TTPopupPriorityNormal = 0,
TTPopupPriorityHigh,
TTPopupPriorityRequired
};

View File

@@ -0,0 +1,24 @@
//
// TTPopupManagerService.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TTPopupManagerServiceProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface TTPopupManagerService : NSObject<TTPopupManagerServiceProtocol>
/**
当前显示的弹窗服务
*/
@property (nonatomic, strong) id<TTPopupServiceProtocol> currentPopupService;
+ (instancetype)sharedInstance;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,200 @@
//
// TTPopupManagerService.m
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTPopupManagerService.h"
#import <FFPopup/FFPopup.h>
@interface TTPopupManagerService ()
@property (nonatomic, strong) NSMutableArray< id<TTPopupServiceProtocol> > *queue;
/**
*/
@property (nonatomic, assign, getter=isShowingPopup) BOOL showingPopup;
@end
@implementation TTPopupManagerService
#pragma mark - Life Cycle
+ (instancetype)sharedInstance {
static TTPopupManagerService *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}
- (instancetype)init {
if (self = [super init]) {
_queue = [NSMutableArray array];
}
return self;
}
#pragma mark - TTPopupManagerServiceProtocol
- (void)addPopupService:(id<TTPopupServiceProtocol>)service {
if (![service conformsToProtocol:@protocol(TTPopupServiceProtocol)]) {
return;
}
if ([_queue containsObject:service]) {
return;
}
NSInteger insertPosition = [self insertPositionForPopupService:service];
if (insertPosition == NSNotFound) {
return;
}
[_queue insertObject:service atIndex:insertPosition];
//
if (_currentPopupService == nil && _queue.count == 1) {
[self showPopup];
}
}
- (void)removePopupService {
// dismiss
//使 _currentPopupService
if (!self.isShowingPopup) {
return;
}
if (_currentPopupService == nil) {
return;
}
if (_queue.count > 0) {
[_queue removeObjectAtIndex:0];
}
[FFPopup dismissPopupForView:_currentPopupService.contentView animated:YES];
_currentPopupService = nil;
}
/**
@discussion dismissPopupForView
*/
- (void)removeSourceWhenTouchMaskView {
if (_currentPopupService == nil) {
return;
}
if (_queue.count > 0) {
[_queue removeObjectAtIndex:0];
}
_currentPopupService = nil;
}
#pragma mark - Private Methods
/**
*/
- (void)showPopup {
if (self.isShowingPopup) {
return;
}
if (_currentPopupService) {
return;
}
if (_queue.count == 0) {
return;
}
id<TTPopupServiceProtocol> popupService = _queue.firstObject;
if (![popupService conformsToProtocol:@protocol(TTPopupServiceProtocol)]) {
return;
}
_currentPopupService = popupService;
FFPopupHorizontalLayout horizontalLayout = FFPopupHorizontalLayout_Center;
FFPopupVerticalLayout verticalLayout = FFPopupVerticalLayout_Center;
FFPopupShowType showType = (FFPopupShowType)popupService.showType;
FFPopupDismissType dismissType = FFPopupDismissType_GrowOut;
if (popupService.style == TTPopupStyleActionSheet) {
verticalLayout = FFPopupVerticalLayout_Bottom;
showType = FFPopupShowType_SlideInFromBottom;
dismissType = FFPopupDismissType_SlideOutToBottom;
}
FFPopup *popup = [FFPopup popupWithContentView:popupService.contentView];
popup.showType = showType;
popup.dismissType = dismissType;
popup.maskType = FFPopupMaskType_Dimmed;
popup.dimmedMaskAlpha = popupService.maskBackgroundAlpha;
popup.shouldDismissOnBackgroundTouch = popupService.shouldDismissOnBackgroundTouch;
[popup showWithLayout:FFPopupLayoutMake(horizontalLayout, verticalLayout) duration:0.0];
__weak typeof(self) weakSelf = self;
// dismissPopupForView:animated:
//
// _currentPopupService
popup.didFinishDismissingBlock = ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
BOOL isDismissOnBackgroundTouch = strongSelf.currentPopupService != nil;
if (isDismissOnBackgroundTouch) {
//
[self removeSourceWhenTouchMaskView];
}
if (popupService.didFinishDismissHandler) {
popupService.didFinishDismissHandler(isDismissOnBackgroundTouch);
}
//
strongSelf.showingPopup = NO;
//
[strongSelf showPopup];
};
popup.didFinishShowingBlock = ^{
//
self.showingPopup = YES;
if (popupService.didFinishShowingHandler) {
popupService.didFinishShowingHandler();
}
};
}
/**
@param service
@return
*/
- (NSInteger)insertPositionForPopupService:(id<TTPopupServiceProtocol>)service {
__block NSInteger result = NSNotFound;
if (service == nil) {
return result;
}
if (_queue.count == 0) {
return 0;
}
//
if (service.shouldFilterPopup && service.filterIdentifier.length > 0) {
BOOL filterFlag = NO;
for (id<TTPopupServiceProtocol> serv in _queue) {
if ([serv.filterIdentifier isEqualToString:service.filterIdentifier]) {
filterFlag = YES;
break;
}
}
if (filterFlag) {
return result;
}
}
[_queue enumerateObjectsUsingBlock:^(id<TTPopupServiceProtocol> _Nonnull model, NSUInteger idx, BOOL * _Nonnull stop) {
//
if (service.priority > model.priority) {
result = idx;
*stop = YES;
}
}];
//
result = MIN(result, _queue.count);
return result;
}
@end

View File

@@ -0,0 +1,25 @@
//
// TTPopupManagerServiceProtocol.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTPopupServiceProtocol.h"
@protocol TTPopupManagerServiceProtocol <NSObject>
/**
添加一个弹窗
@param service 服从弹窗服务的实例
*/
- (void)addPopupService:(id<TTPopupServiceProtocol>)service;
/**
移除一个弹窗
*/
- (void)removePopupService;
@end

View File

@@ -0,0 +1,22 @@
//
// TTPopupService.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TTPopupServiceProtocol.h"
// TTPopupConfig 是 TTPopupService 的别称
// 具体信息见 TTPopupService
#define TTPopupConfig TTPopupService
NS_ASSUME_NONNULL_BEGIN
@interface TTPopupService : NSObject<TTPopupServiceProtocol>
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,36 @@
//
// TTPopupService.m
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTPopupService.h"
@implementation TTPopupService
@synthesize style = _style;
@synthesize priority = _priority;
@synthesize contentView = _contentView;
@synthesize maskBackgroundAlpha = _maskBackgroundAlpha;
@synthesize shouldDismissOnBackgroundTouch = _shouldDismissOnBackgroundTouch;
@synthesize didFinishDismissHandler = _didFinishDismissHandler;
@synthesize didFinishShowingHandler = _didFinishShowingHandler;
@synthesize shouldFilterPopup = _shouldFilterPopup;
@synthesize filterIdentifier = _filterIdentifier;
@synthesize showType = _showType;
- (instancetype)init {
self = [super init];
if (self) {
_style = TTPopupStyleAlert;
_priority = TTPopupPriorityNormal;
_maskBackgroundAlpha = 0.5;
_shouldDismissOnBackgroundTouch = YES;
_shouldFilterPopup = NO;
_showType = TTPopupShowTypeDefault;
}
return self;
}
@end

View File

@@ -0,0 +1,78 @@
//
// TTPopupServiceProtocol.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/21.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTPopupConstants.h"
typedef NS_ENUM(NSUInteger, TTPopupShowType) {
TTPopupShowType_FadeIn = 1,
TTPopupShowTypeDefault = 8,
};
@class UIView;
@protocol TTPopupServiceProtocol <NSObject>
/**
弹窗样式默认TTPopupStyleAlert
*/
@property (nonatomic, assign) TTPopupStyle style;
/**
弹窗优先级权重默认TTPopupPriorityNormal
@discussion 权重越高在弹窗队列的优先级越高,即优先弹出;相同权重按先来后到原则
*/
@property (nonatomic, assign) TTPopupPriority priority;
/**
自定义视图内容默认nil
@discussion 如果未配置,或 contentView 未继承自 UIView 及其子类,将忽略该弹窗
*/
@property (nonatomic, strong) UIView *contentView;
/**
背景蒙层透明度默认0x000000 0.3 alpha
@discussion 由于第三方原因,暂不支持蒙层颜色修改
*/
@property (nonatomic, assign) CGFloat maskBackgroundAlpha;
/**
点击蒙层是否消除弹窗默认YES
*/
@property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch;
/**
弹窗消失回调isDismissOnBackgroundTouch 区分是否点击蒙层触发
*/
@property (nonatomic, copy) void (^didFinishDismissHandler)(BOOL isDismissOnBackgroundTouch);
/**
弹窗显示成功回调
*/
@property (nonatomic, copy) void (^didFinishShowingHandler)(void);
/**
重复弹窗过滤默认NO
@discussion 设置过滤时,队列中将不会出现相同过滤标识的弹窗
过滤标识通过 #<filterIdentifier> 设置
*/
@property (nonatomic, assign) BOOL shouldFilterPopup;
/**
过滤标识默认nil
*/
@property (nonatomic, copy) NSString *filterIdentifier;
/**
显示动画类型, 默认是 default
*/
@property (nonatomic, assign) TTPopupShowType showType;
@end

View File

@@ -0,0 +1,126 @@
//
// TTPopup.h
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/22.
// Copyright © 2023 YUMI. All rights reserved.
// 弹窗工具类
#import <Foundation/Foundation.h>
#import "TTPopupConstants.h"
#import "TTAlertConfig.h"
#import "TTActionSheetConfig.h"
#import "TTPopupService.h"
NS_ASSUME_NONNULL_BEGIN
@class UIView;
@interface TTPopup : NSObject
#pragma mark Alert
/**
显示 alert 弹窗
@discussion 显示四个内容:默认标题‘提示’,提示内容,取消按钮,确认按钮
@param message 提示内容,不能为空(⊙o⊙)哦
@param confirmHandler 确认操作
@param cancelHandler 取消操作
*/
+ (void)alertWithMessage:(NSString *)message
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler;
/**
显示 alert 弹窗
@discussion 显示四个内容:默认标题‘提示’,提示内容,取消按钮,确认按钮
@param config 完善的视图配置,为您变态的需求保驾护航
@param isShowBorder 是否显示边框
@param confirmHandler 确认操作
@param cancelHandler 取消操作
*/
+ (void)alertWithConfig:(TTAlertConfig *)config
showBorder:(BOOL)isShowBorder
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler;
+ (void)alertWithMessage:(NSString *)message
config:(TTAlertConfig *)config
showBorder:(BOOL)isShowBorder
cancelHandler:(TTPopupCompletionHandler)cancelHandler
confirmHandler:(TTPopupCompletionHandler)confirmHandler;
/**
显示 alert 弹窗
@discussion 显示四个内容:标题,提示内容,取消按钮,确认按钮
@param config 完善的视图配置,为您变态的需求保驾护航
@param cancelHandler 取消操作
@param confirmHandler 确认操作
*/
+ (void)alertWithConfig:(TTAlertConfig *)config
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler;
#pragma mark Action Sheet
/**
显示 action sheet 弹窗,自带贴心的取消按钮😊
@param items 配置列表
*/
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items;
/**
显示 action sheet 弹窗
@param items 配置列表
@param showCancelItem 是否显示取消按钮
*/
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items
showCancelItem:(BOOL)showCancelItem;
/**
显示 action sheet 弹窗
@param items 配置列表
@param cancelHandler 取消按钮回调
*/
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items
cancelHandler:(TTActionSheetClickAction)cancelHandler;
#pragma mark Popup
/**
显示自定义弹窗
@param customView 自定义 view
@param style 弹窗样式
*/
+ (void)popupView:(UIView *)customView
style:(TTPopupStyle)style;
/**
显示自定义弹窗
@param config 自定义弹窗配置
*/
+ (void)popupWithConfig:(TTPopupService *)config;
#pragma mark Dismiss
/**
消除当前弹窗
*/
+ (void)dismiss;
#pragma mark Query
/**
当前是否有显示弹窗
*/
+ (BOOL)hasShowPopup;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,243 @@
//
// TTPopup.m
// YM_TTChatViewKit
//
// Created by lvjunhang on 2019/5/22.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTPopup.h"
#import "TTAlertView.h"
#import "TTActionSheetView.h"
#import "TTPopupService.h"
#import "TTPopupManagerService.h"
static CGFloat const kActionSheetViewPadding = 15.f;
static CGFloat const kActionSheetViewCellHeight = 52.f;
static CGFloat const kActionSheetViewCancelViewHeight = 67.f;
static CGFloat const kActionSheetViewBottomPadding = 15.f;
static CGFloat const kMixHeight = 200.f;
static CGFloat const kMaxHeight = 450.f;
@implementation TTPopup
#pragma mark - Public Methods
#pragma mark Alert
+ (void)alertWithMessage:(NSString *)message
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler {
[self alertWithMessage:message
config:nil
cancelHandler:cancelHandler
confirmHandler:confirmHandler];
}
+ (void)alertWithConfig:(TTAlertConfig *)config
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler {
[self alertWithMessage:nil
config:config
cancelHandler:cancelHandler
confirmHandler:confirmHandler];
}
+ (void)alertWithMessage:(NSString *)message
config:(TTAlertConfig *)config
cancelHandler:(TTPopupCompletionHandler)cancelHandler
confirmHandler:(TTPopupCompletionHandler)confirmHandler {
if (!config) {
config = [[TTAlertConfig alloc] init];
config.title = YMLocalizedString(@"UserDetail_CP_Toast_0");
config.message = message;
}
if (config.message.length <= 0 && config.messageAttributed.length <=0 && config.messageAttributedConfig.count <=0) {
#if DEBUG
NSAssert(NO, @" message can not be nil, 弹窗文案不可以为空");
return;
#else
// crash
config.message = @" ";
#endif
}
CGFloat width = [UIScreen mainScreen].bounds.size.width - 40 * 2;
CGFloat height = ([self messageSize:config.message width:width].height + 160);
// 200 450
if (height < kMixHeight) {
height = kMixHeight;
} else if (height > KScreenHeight - kSafeAreaTopHeight - kSafeAreaBottomHeight) {
height = KScreenHeight - kSafeAreaTopHeight - kSafeAreaBottomHeight;
}
TTAlertView *contentView = [[TTAlertView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
contentView.config = config;
contentView.isConfigBoard = NO;
contentView.cancelAction = cancelHandler;
contentView.confirmAction = confirmHandler;
if (!contentView.config.disableAutoDismissWhenClickButton) {
//
contentView.dismissAction = ^{
[TTPopup dismiss];
};
}
[self popupView:contentView style:TTPopupStyleAlert config:config];
}
+ (void)alertWithConfig:(TTAlertConfig *)config
showBorder:(BOOL)isShowBorder
confirmHandler:(TTPopupCompletionHandler)confirmHandler
cancelHandler:(TTPopupCompletionHandler)cancelHandler {
[self alertWithMessage:@""
config:config
showBorder:isShowBorder
cancelHandler:cancelHandler
confirmHandler:confirmHandler];
}
+ (void)alertWithMessage:(NSString *)message
config:(TTAlertConfig *)config
showBorder:(BOOL)isShowBorder
cancelHandler:(TTPopupCompletionHandler)cancelHandler
confirmHandler:(TTPopupCompletionHandler)confirmHandler {
if (!config) {
config = [[TTAlertConfig alloc] init];
config.message = message;
}
if (config.message.length <= 0) {
NSAssert(NO, @" message can not be nil, 弹窗文案不可以为空");
return;
}
CGFloat width = [UIScreen mainScreen].bounds.size.width - 40 * 2;
CGFloat height = ([self messageSize:config.message width:width].height + 160);
// 200 450
if (height < kMixHeight) {
height = kMixHeight;
} else if (height > kMaxHeight) {
height = kMaxHeight;
}
TTAlertView *contentView = [[TTAlertView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
contentView.config = config;
contentView.cancelAction = cancelHandler;
contentView.confirmAction = confirmHandler;
contentView.isConfigBoard = isShowBorder;
if (!contentView.config.disableAutoDismissWhenClickButton) {
//
contentView.dismissAction = ^{
[TTPopup dismiss];
};
}
[self popupView:contentView style:TTPopupStyleAlert config:config];
}
#pragma mark Action Sheet
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items {
[TTPopup actionSheetWithItems:items showCancelItem:YES cancelHandler:nil];
}
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items
showCancelItem:(BOOL)showCancelItem {
[TTPopup actionSheetWithItems:items showCancelItem:showCancelItem cancelHandler:nil];
}
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items cancelHandler:(TTActionSheetClickAction)cancelHandler {
[TTPopup actionSheetWithItems:items showCancelItem:YES cancelHandler:cancelHandler];
}
+ (void)actionSheetWithItems:(NSArray<TTActionSheetConfig *> *)items
showCancelItem:(BOOL)showCancelItem
cancelHandler:(TTActionSheetClickAction)cancelHandler {
CGFloat width = [UIScreen mainScreen].bounds.size.width - kActionSheetViewPadding * 2;
CGFloat height = kActionSheetViewCellHeight * items.count + kActionSheetViewBottomPadding;
//
if (showCancelItem) {
//
height += kActionSheetViewCancelViewHeight;
}
if (@available(iOS 11.0, *)) {
// iPhone X () 34
height += [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom;
}
CGRect rect = CGRectMake(0, 0, width, height);
TTActionSheetView *sheetView = [[TTActionSheetView alloc] initWithFrame:rect
needCancel:showCancelItem
items:items];
sheetView.cancelAction = cancelHandler;
//
sheetView.dismissAction = ^{
[TTPopup dismiss];
};
[self popupView:sheetView style:TTPopupStyleActionSheet];
}
#pragma mark Popup
+ (void)popupView:(UIView *)customView
style:(TTPopupStyle)style {
TTPopupService *service = [[TTPopupService alloc] init];
service.style = style;
service.contentView = customView;
[self popupWithConfig:service];
}
+ (void)popupView:(UIView *)customView
style:(TTPopupStyle)style
config:(TTAlertConfig *)config {
TTPopupService *service = [[TTPopupService alloc] init];
service.style = style;
service.contentView = customView;
service.shouldDismissOnBackgroundTouch = config.shouldDismissOnBackgroundTouch;
service.maskBackgroundAlpha = config.maskBackgroundAlpha;
[self popupWithConfig:service];
}
+ (void)popupWithConfig:(TTPopupService *)config {
if (![config.contentView isKindOfClass:UIView.class]) {
NSAssert(NO, @"TTPopup customView should inherit from UIView.");
return;
}
[[TTPopupManagerService sharedInstance] addPopupService:config];
}
#pragma mark Dismiss
+ (void)dismiss {
[[TTPopupManagerService sharedInstance] removePopupService];
}
#pragma mark Query
/**
*/
+ (BOOL)hasShowPopup {
return [TTPopupManagerService sharedInstance].currentPopupService != nil;
}
#pragma mark - Privite
+ (CGSize)messageSize:(NSString *)text width:(CGFloat)width {
CGRect stringRect = [text boundingRectWithSize:CGSizeMake(width - 2 * 20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.f]} context:nil];
return stringRect.size;
}
@end

View File

@@ -0,0 +1,26 @@
//
// TTActionSheetView.h
// YM_TTChatViewKit
//
// Created by lee on 2019/5/22.
// Copyright © 2023 YUMI. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TTPopupConstants.h"
NS_ASSUME_NONNULL_BEGIN
@class TTActionSheetConfig;
@interface TTActionSheetView : UIView
@property (nonatomic, copy) TTPopupCompletionHandler cancelAction;
@property (nonatomic, copy) TTPopupCompletionHandler dismissAction;
- (instancetype)initWithFrame:(CGRect)frame
needCancel:(BOOL)needCancel
items:(NSArray<TTActionSheetConfig *> *)items;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,159 @@
//
// TTActionSheetView.m
// YM_TTChatViewKit
//
// Created by lee on 2019/5/22.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTActionSheetView.h"
#import "TTActionSheetConfig.h"
#import "DJDKMIMOMColor.h"
#import <Masonry/Masonry.h>
static CGFloat const kSheetViewCellHeight = 51.f;
static CGFloat const kSheetViewCornerRadius = 14.f;
static NSString *const kSheetViewCellConst = @"kSheetViewCellConst";
@interface TTActionSheetView ()<UITableViewDelegate, UITableViewDataSource>
/** sheetView */
@property (nonatomic, strong) UITableView *tableView;
/** */
@property (nonatomic, strong) NSArray<TTActionSheetConfig *> *items;
/** */
@property (nonatomic, assign) BOOL needCancel;
/** */
@property (nonatomic, strong) UIButton *cancelButton;
@end
@implementation TTActionSheetView
#pragma mark -
#pragma mark lifeCycle
- (instancetype)initWithFrame:(CGRect)frame needCancel:(BOOL)needCancel items:(NSArray<TTActionSheetConfig *> *)items {
self = [super initWithFrame:frame];
if (self) {
_items = items;
_needCancel = needCancel;
[self initViews];
[self initConstraints];
}
return self;
}
- (void)initViews {
[self addSubview:self.tableView];
[self addSubview:self.cancelButton];
}
- (void)initConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.mas_equalTo(self);
make.height.mas_equalTo(self.items.count * kSheetViewCellHeight);
}];
if (_needCancel) {
// cancel view
self.cancelButton.hidden = NO;
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self);
make.height.mas_equalTo(kSheetViewCellHeight);
make.top.mas_equalTo(self.tableView.mas_bottom).offset(15);
}];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.items.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kSheetViewCellConst];
cell.backgroundColor = UIColor.clearColor;
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.text = _items[indexPath.row].title;
cell.textLabel.textColor = _items[indexPath.row].titleColor;
if ([_items[indexPath.row] displayMoliCoin]) {
NSTextAttachment *coinAttachment = [[NSTextAttachment alloc] init];
coinAttachment.image = kImage(@"moli_money_icon");
coinAttachment.bounds = CGRectMake(0, -3.5, 20, 20);
NSAttributedString *coinAttributedString = [NSAttributedString attributedStringWithAttachment:coinAttachment];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:coinAttributedString];
NSAttributedString *titleAttributedString = [[NSAttributedString alloc] initWithString:_items[indexPath.row].title
attributes:@{
NSForegroundColorAttributeName: _items[indexPath.row].titleColor,
NSFontAttributeName: cell.textLabel.font
}];
[string insertAttributedString:titleAttributedString atIndex:0];
cell.textLabel.attributedText = string.copy;
UIImageView *questionMark = [[UIImageView alloc] initWithImage:kImage(@"question_mark")];
[cell.contentView addSubview:questionMark];
[questionMark mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(cell.textLabel);
make.trailing.mas_equalTo(-20);
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//
TTActionSheetConfig *config = _items[indexPath.row];
!config.clickAction ?: config.clickAction();
!_dismissAction ?: _dismissAction();
}
- (void)onClickCancelButtonAction:(UIButton *)cancelButton {
!_cancelAction ?: _cancelAction();
!_dismissAction ?: _dismissAction();
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorColor = [DJDKMIMOMColor actionSeparatorColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
_tableView.rowHeight = kSheetViewCellHeight;
_tableView.tableFooterView = [[UIView alloc] init];
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.layer.cornerRadius = kSheetViewCornerRadius;
_tableView.layer.masksToBounds = YES;
_tableView.bounces = NO;
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kSheetViewCellConst];
}
return _tableView;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setTitle:YMLocalizedString(@"TTActionSheetView0") forState:UIControlStateNormal];
[_cancelButton setBackgroundColor:UIColor.whiteColor];
[_cancelButton setTitleColor:[DJDKMIMOMColor alertMessageColor] forState:UIControlStateNormal];
[_cancelButton.titleLabel setFont:[UIFont systemFontOfSize:16]];
_cancelButton.layer.cornerRadius = kSheetViewCornerRadius;
_cancelButton.layer.masksToBounds = YES;
[_cancelButton addTarget:self action:@selector(onClickCancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_cancelButton.hidden = YES;
}
return _cancelButton;
}
@end

View File

@@ -0,0 +1,25 @@
//
// TTAlertView.h
// YM_TTChatViewKit
//
// Created by lee on 2019/5/20.
// Copyright © 2023 YUMI. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TTPopupConstants.h"
@class TTAlertConfig;
NS_ASSUME_NONNULL_BEGIN
@interface TTAlertView : UIView
@property (nonatomic, strong) TTAlertConfig *config;// 配置
@property (nonatomic, assign) BOOL isConfigBoard;// 是否配置边框
@property (nonatomic, copy) TTPopupCompletionHandler cancelAction;
@property (nonatomic, copy) TTPopupCompletionHandler confirmAction;
@property (nonatomic, copy) TTPopupCompletionHandler dismissAction;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,255 @@
//
// TTAlertView.m
// YM_TTChatViewKit
//
// Created by lee on 2019/5/20.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "TTAlertView.h"
#import "TTAlertConfig.h"
#import "DJDKMIMOMColor.h"
#import <Masonry/Masonry.h>
static CGFloat const kMargin = 25.f;
static CGFloat const kPadding = 20.f;
static CGFloat const kBtnHeight = 38.f;
@interface TTAlertView ()
@property (nonatomic, strong) UILabel *titleLabel; //
@property (nonatomic, strong) UILabel *messageLabel; //
@property (nonatomic, strong) UIButton *cancelButton; //
@property (nonatomic, strong) UIButton *confirmButton; //
@property (nonatomic, strong) UIStackView *stackView;
@end
@implementation TTAlertView
#pragma mark - lifeCyle
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initViews];
[self initConstraints];
}
return self;
}
- (void)initViews {
[self addSubview:self.titleLabel];
[self addSubview:self.messageLabel];
[self addSubview:self.stackView];
[self.stackView addSubview:self.cancelButton];
[self.stackView addSubview:self.confirmButton];
}
- (void)initConstraints {
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(kPadding);
make.leading.trailing.mas_equalTo(self).inset(kPadding);
}];
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(kMargin);
make.leading.trailing.mas_equalTo(self).inset(kPadding);
make.bottom.mas_equalTo(self).offset(-kBtnHeight * 2);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-kPadding);
make.centerX.mas_equalTo(self);
}];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(kBtnHeight);
make.width.mas_equalTo(self.mas_width).multipliedBy(0.4);
}];
[self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(kBtnHeight);
make.width.mas_equalTo(self.mas_width).multipliedBy(0.4);
}];
}
#pragma mark - Button Events
- (void)onClickConfirmButtonAction:(UIButton *)confirmButton {
!_confirmAction ?: _confirmAction();
!_dismissAction ?: _dismissAction();
}
- (void)onClickCancelButtonAction:(UIButton *)cancelButton {
!_cancelAction ?: _cancelAction();
!_dismissAction ?: _dismissAction();
}
#pragma mark - private method
/**
messageLabel
@param config
@return
*/
- (NSMutableAttributedString *)messageAttributeString:(TTAlertConfig *)config {
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:config.message];
if (config.messageLineSpacing > 0) { //
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = config.messageLineSpacing;
paragraphStyle.alignment = config.messageTextAlignment;
[attString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, config.message.length)];
}
//
[config.messageAttributedConfig enumerateObjectsUsingBlock:^(TTAlertMessageAttributedConfig * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//
if ([obj isKindOfClass:[TTAlertMessageAttributedConfig class]]) {
if (obj.text && obj.text.length > 0) {
NSRange range = [config.message rangeOfString:obj.text];
// range range
if (obj.range.length != 0) {
if (obj.range.location + obj.range.length > config.message.length) {
NSAssert(NO, @"obj.range out of bounds");
return;
}
range = obj.range;
}
if (obj.font) { //
[attString addAttribute:NSFontAttributeName value:obj.font range:range];
}
if (obj.color) { //
[attString addAttribute:NSForegroundColorAttributeName value:obj.color range:range];
}
}
}
}];
return attString;
}
#pragma mark - getter && setter
- (void)setConfig:(TTAlertConfig *)config {
_config = config;
// cornerRadius
if (config.cornerRadius > 0) {
self.layer.cornerRadius = config.cornerRadius;
self.layer.masksToBounds = YES;
}
//
self.backgroundColor = config.backgroundColor;
// title
_titleLabel.text = config.title;
_titleLabel.textColor = config.titleColor;
_titleLabel.font = config.titleFont;
_cancelButton.hidden = config.actionStyle == TTAlertActionConfirmStyle;
_confirmButton.hidden = config.actionStyle == TTAlertActionCancelStyle;
// cancel button
[_cancelButton setTitle:config.cancelButtonConfig.title forState:UIControlStateNormal];
[_cancelButton setTitleColor:config.cancelButtonConfig.titleColor forState:UIControlStateNormal];
[_cancelButton.titleLabel setFont:config.cancelButtonConfig.font];
[_cancelButton setBackgroundColor:config.cancelButtonConfig.backgroundColor];
[_cancelButton setBackgroundImage:config.cancelButtonConfig.backgroundImage forState:UIControlStateNormal];
if (config.cancelButtonConfig.cornerRadius > 0) {
_cancelButton.layer.cornerRadius = config.cancelButtonConfig.cornerRadius;
_cancelButton.layer.masksToBounds = YES;
}
// confirm button
[_confirmButton setTitle:config.confirmButtonConfig.title forState:UIControlStateNormal];
[_confirmButton setTitleColor:config.confirmButtonConfig.titleColor forState:UIControlStateNormal];
[_confirmButton.titleLabel setFont:config.confirmButtonConfig.font];
[_confirmButton setBackgroundColor:config.confirmButtonConfig.backgroundColor];
[_confirmButton setBackgroundImage:config.confirmButtonConfig.backgroundImage forState:UIControlStateNormal];
if (config.confirmButtonConfig.cornerRadius > 0) {
_confirmButton.layer.cornerRadius = config.confirmButtonConfig.cornerRadius;
_confirmButton.layer.masksToBounds = YES;
}
// message
_messageLabel.font = config.messageFont;
_messageLabel.textColor = config.messageColor;
if (config.messageAttributedConfig.count > 0) {
_messageLabel.attributedText = [self messageAttributeString:config];
_messageLabel.textAlignment = NSTextAlignmentCenter;
} else if(config.messageAttributed.length > 0) {
_messageLabel.attributedText = config.messageAttributed;
_messageLabel.textAlignment = NSTextAlignmentCenter;
} else {
_messageLabel.text = config.message;
_messageLabel.textAlignment = config.messageTextAlignment;
}
_cancelButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_cancelButton.layer.borderWidth = 2.f;
_confirmButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_confirmButton.layer.borderWidth = 2.f;
}
- (void)setIsConfigBoard:(BOOL)isConfigBoard {
_isConfigBoard = isConfigBoard;
if (isConfigBoard) {
//
_cancelButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_cancelButton.layer.borderWidth = 2.f;
_confirmButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_confirmButton.layer.borderWidth = 2.f;
}else {
//
_cancelButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_cancelButton.layer.borderWidth = 0;
_confirmButton.layer.borderColor = [DJDKMIMOMColor dividerColor].CGColor;
_confirmButton.layer.borderWidth = 0;
}
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.numberOfLines = 0;
}
return _titleLabel ;
}
- (UILabel *)messageLabel {
if (!_messageLabel) {
_messageLabel = [[UILabel alloc] init];
_messageLabel.numberOfLines = 0;
_messageLabel.textAlignment = NSTextAlignmentCenter;
_messageLabel.minimumScaleFactor = 0.7;
_messageLabel.adjustsFontSizeToFitWidth = YES;
}
return _messageLabel;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton addTarget:self action:@selector(onClickCancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
}
- (UIButton *)confirmButton {
if (!_confirmButton) {
_confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_confirmButton addTarget:self action:@selector(onClickConfirmButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _confirmButton;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] initWithArrangedSubviews:@[self.cancelButton, self.confirmButton]];
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 16;
}
return _stackView;
}
@end

View File

@@ -0,0 +1,20 @@
//
// TTNewAlertView.h
// xplan-ios
//
// Created by duoban on 2023/1/9.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TTNewAlertView : UIView
@property (nonatomic,copy) NSString *message;
@property (nonatomic, copy) TTPopupCompletionHandler confirmHandle;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,118 @@
//
// TTNewAlertView.m
// xplan-ios
//
// Created by duoban on 2023/1/9.
//
#import "TTNewAlertView.h"
@interface TTNewAlertView()
@property (nonatomic,strong) UIView *bgView;
@property (nonatomic,strong) UILabel *messageView;
@property (nonatomic,strong) UIButton *confirmBtn;
@property (nonatomic,strong) UIButton *cancelBtn;
@end
@implementation TTNewAlertView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self addSubview:self.bgView];
[self.bgView addSubview:self.messageView];
[self.bgView addSubview:self.confirmBtn];
[self.bgView addSubview:self.cancelBtn];
}
- (void)initSubViewConstraints {
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(310));
make.height.mas_equalTo(kGetScaleWidth(149));
make.center.equalTo(self);
}];
[self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(110));
make.height.mas_equalTo(kGetScaleWidth(37));
make.leading.mas_equalTo(kGetScaleWidth(31));
make.bottom.mas_equalTo(-kGetScaleWidth(31));
}];
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.centerY.equalTo(self.confirmBtn);
make.trailing.mas_equalTo(-kGetScaleWidth(31));
}];
[self.messageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(25));
make.centerX.equalTo(self);
make.leading.trailing.equalTo(self).inset(kGetScaleWidth(10));
}];
}
-(void)setMessage:(NSString *)message{
_message = message;
_messageView.text = message;
}
-(void)confirmAction{
[TTPopup dismiss];
if(self.confirmHandle){
self.confirmHandle();
}
}
-(void)cancelAction{
[TTPopup dismiss];
}
#pragma mark -
- (UIView *)bgView{
if (!_bgView){
_bgView = [UIView new];
_bgView.backgroundColor = [UIColor whiteColor];
[_bgView setCornerWithLeftTopCorner:kGetScaleWidth(12) rightTopCorner:kGetScaleWidth(12) bottomLeftCorner:kGetScaleWidth(12) bottomRightCorner:kGetScaleWidth(12) size:CGSizeMake(kGetScaleWidth(310), kGetScaleWidth(149))];
}
return _bgView;
}
- (UILabel *)messageView{
if (!_messageView){
_messageView = [UILabel labelInitWithText:@"" font:kFontRegular(15) textColor:[DJDKMIMOMColor inputTextColor]];
_messageView.textAlignment = NSTextAlignmentCenter;
_messageView.numberOfLines = 0;
}
return _messageView;
}
-(UIButton *)confirmBtn{
if (!_confirmBtn){
_confirmBtn = [UIButton new];
[_confirmBtn setTitle:YMLocalizedString(@"TTAlertConfig0") forState:UIControlStateNormal];
_confirmBtn.backgroundColor = UIColorFromRGB(0xE6E6F0);
_confirmBtn.layer.cornerRadius = kGetScaleWidth(37)/2;
_confirmBtn.layer.masksToBounds = YES;
[_confirmBtn addTarget:self action:@selector(confirmAction) forControlEvents:UIControlEventTouchUpInside];
}
return _confirmBtn;
}
-(UIButton *)cancelBtn{
if (!_cancelBtn){
_cancelBtn = [UIButton new];
[_cancelBtn setTitle:YMLocalizedString(@"XPShareView7") forState:UIControlStateNormal];
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(110), kGetScaleWidth(37))];
_cancelBtn.backgroundColor = [UIColor colorWithPatternImage:image];
_cancelBtn.layer.cornerRadius = kGetScaleWidth(37)/2;
_cancelBtn.layer.masksToBounds = YES;
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelBtn;
}
@end