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:
22
YuMi/CustomUI/UIImageView/NetImageConfig.h
Normal file
22
YuMi/CustomUI/UIImageView/NetImageConfig.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// NetImageConfig.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by zu on 2021/11/25.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "UIImageConstant.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NetImageConfig : NSObject
|
||||
|
||||
@property (nonatomic, assign) BOOL autoLoad;
|
||||
@property (nonatomic, assign) ImageType imageType;
|
||||
@property (nonatomic, assign) CGFloat radius;
|
||||
@property (nonatomic, strong) UIImage * placeHolder;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
21
YuMi/CustomUI/UIImageView/NetImageConfig.m
Normal file
21
YuMi/CustomUI/UIImageView/NetImageConfig.m
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// NetImageConfig.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by zu on 2021/11/25.
|
||||
//
|
||||
|
||||
#import "NetImageConfig.h"
|
||||
|
||||
@implementation NetImageConfig
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_autoLoad = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
45
YuMi/CustomUI/UIImageView/NetImageView.h
Normal file
45
YuMi/CustomUI/UIImageView/NetImageView.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// NetImageView.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by zu on 2021/11/2.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "UIImageConstant.h"
|
||||
#import "NetImageConfig.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void(^LoadCompletion)(UIImage *_Nullable image, NSURL * url);
|
||||
typedef void(^LoadFail)(NSError *error);
|
||||
|
||||
typedef NS_ENUM(NSInteger, NetImageState){
|
||||
NetImageStateUnload = 1,
|
||||
NetImageStateLoading,
|
||||
NetImageStateLoaded,
|
||||
};
|
||||
|
||||
@interface NetImageView : UIImageView
|
||||
|
||||
@property (nonatomic, assign, readonly) NetImageState state;
|
||||
@property (nonatomic, copy) NSString* imageUrl;
|
||||
@property (nonatomic, assign) NSInteger backgroundLightType; // 0: non; 1: gold; 2: gray; 3: purple
|
||||
|
||||
- (instancetype)initWithUrl:(NSString * _Nonnull)imageUrl;
|
||||
- (instancetype)initWithConfig:(NetImageConfig * _Nullable)config;
|
||||
- (instancetype)initWithUrl:(NSString * _Nonnull)imageUrl config:(NetImageConfig * _Nullable)config;
|
||||
|
||||
- (UIImage *)lightImage:(NSInteger)type;
|
||||
|
||||
- (void)loadImage:(LoadCompletion _Nullable)completion;
|
||||
- (void)loadImageWithUrl:(NSString * _Nonnull)imageUrl completion:(LoadCompletion _Nullable)completion;
|
||||
- (void)loadImageWithUrl:(NSString * _Nonnull)imageUrl completion:(LoadCompletion _Nullable)completion fail:(LoadFail _Nullable)fail;
|
||||
|
||||
- (void)updateConfigPlaceHolder:(UIImage *)image;
|
||||
|
||||
- (void)cancelLoadImage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
151
YuMi/CustomUI/UIImageView/NetImageView.m
Normal file
151
YuMi/CustomUI/UIImageView/NetImageView.m
Normal file
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// NetImageView.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by zu on 2021/11/2.
|
||||
//
|
||||
|
||||
#import "NetImageView.h"
|
||||
#import <UIImageView+WebCache.h>
|
||||
#import <SDImageCache.h>
|
||||
|
||||
@interface NetImageView()
|
||||
|
||||
@property (nonatomic, assign, readwrite) NetImageState state;
|
||||
@property (nonatomic, copy) NSString * innerConfigUrl;
|
||||
@property (nonatomic, strong) NetImageConfig * config;
|
||||
@property (nonatomic, strong) UIImageView *lightImageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NetImageView
|
||||
|
||||
- (instancetype)initWithUrl:(NSString *)url {
|
||||
return [self initWithUrl:url config:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithConfig:(NetImageConfig *)config {
|
||||
return [self initWithUrl:@"" config:config];
|
||||
}
|
||||
|
||||
- (instancetype)initWithUrl:(NSString *)url config:(NetImageConfig *)config {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_state = NetImageStateUnload;
|
||||
_config = config;
|
||||
if (_config.autoLoad) {
|
||||
[self setImageUrl:url];
|
||||
} else {
|
||||
[self initImageUrl:url];
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cancelLoadImage {
|
||||
[self sd_cancelCurrentImageLoad];
|
||||
}
|
||||
|
||||
- (void)initImageUrl:(NSString *)imageUrl {
|
||||
_imageUrl = imageUrl;
|
||||
_innerConfigUrl = [UIImageConstant configUrl:_imageUrl type:self.config.imageType radius:self.config.radius];
|
||||
}
|
||||
|
||||
- (void)setBackgroundLightType:(NSInteger)backgroundLightType {
|
||||
_backgroundLightType = backgroundLightType;
|
||||
if (!_lightImageView) {
|
||||
_lightImageView = [[UIImageView alloc] init];
|
||||
[self insertSubview:_lightImageView atIndex:0];
|
||||
[_lightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
switch (_backgroundLightType) {
|
||||
case 1:
|
||||
_lightImageView.image = [UIImage imageNamed:@"room_pk_result_avatar_bg_yellow"];
|
||||
break;
|
||||
case 2:
|
||||
_lightImageView.image = [UIImage imageNamed:@"room_pk_result_avatar_bg_gray"];
|
||||
break;
|
||||
case 3:
|
||||
_lightImageView.image = [UIImage imageNamed:@"room_pk_result_avatar_bg_purple"];
|
||||
break;
|
||||
default:
|
||||
_lightImageView.image = nil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImage *)lightImage:(NSInteger)type {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return [UIImage imageNamed:@"room_pk_result_avatar_bg_yellow"];
|
||||
case 2:
|
||||
return [UIImage imageNamed:@"room_pk_result_avatar_bg_gray"];
|
||||
case 3:
|
||||
return [UIImage imageNamed:@"room_pk_result_avatar_bg_purple"];
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setImageUrl:(NSString *)imageUrl {
|
||||
[self initImageUrl:imageUrl];
|
||||
[self loadImage:nil fail:nil];
|
||||
}
|
||||
|
||||
- (void)loadImage:(LoadCompletion)completion {
|
||||
[self loadImage:completion fail:nil];
|
||||
}
|
||||
|
||||
- (void)loadImageWithUrl:(NSString *)imageUrl completion:(LoadCompletion)completion {
|
||||
[self initImageUrl:imageUrl];
|
||||
[self loadImage:completion fail:nil];
|
||||
}
|
||||
|
||||
- (void)loadImageWithUrl:(NSString * _Nonnull)imageUrl completion:(LoadCompletion _Nullable)completion fail:(LoadFail _Nullable)fail{
|
||||
[self initImageUrl:imageUrl];
|
||||
[self loadImage:completion fail:fail];
|
||||
}
|
||||
|
||||
- (void)loadImage:(LoadCompletion _Nullable)completion fail:(LoadFail _Nullable)fail{
|
||||
self.state = NetImageStateLoading;
|
||||
@kWeakify(self);
|
||||
[self sd_setImageWithURL:[NSURL URLWithString:self.innerConfigUrl]
|
||||
placeholderImage:self.config.placeHolder
|
||||
options:SDWebImageRetryFailed | SDWebImageQueryMemoryData | SDWebImageQueryDiskDataSync
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
@kStrongify(self);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (error) {
|
||||
self.state = NetImageStateUnload;
|
||||
if (fail){
|
||||
fail(error);
|
||||
}
|
||||
} else {
|
||||
self.image = image;
|
||||
self.state = NetImageStateLoaded;
|
||||
if (completion) {
|
||||
completion(image, imageURL);
|
||||
};
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (NetImageConfig *)config {
|
||||
if (!_config) {
|
||||
_config = [[NetImageConfig alloc] init];
|
||||
}
|
||||
return _config;
|
||||
}
|
||||
|
||||
- (void)updateConfigPlaceHolder:(UIImage *)image {
|
||||
self.config.placeHolder = image;
|
||||
if (self.state == NetImageStateUnload) {
|
||||
self.image = image;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
53
YuMi/CustomUI/UIImageView/UIImageConstant.h
Normal file
53
YuMi/CustomUI/UIImageView/UIImageConstant.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// UIImageViewConstant.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/17.
|
||||
// 存放一些 加载图片 需要做的裁剪的key
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIImageConstant : NSObject
|
||||
|
||||
|
||||
#pragma mark - 图片相关的
|
||||
UIKIT_EXTERN NSString * const kImageTypeRoomFace; //房间表情
|
||||
UIKIT_EXTERN NSString * const kImageTypeRoomGift; //房间礼物
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserIcon; //用户头像60x60
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserLibaryDetail;//用户相册大图nil
|
||||
UIKIT_EXTERN NSString * const kImageTypeCornerAvatar;//圆角图形,会先把图形裁剪成正方形,并且转换为png
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserInfoAlbum;//用户信息里面相册
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserCardLevel;///用户资料卡中 等级以高度20等比例缩放
|
||||
UIKIT_EXTERN NSString * const kImageTypeMonentsPhoto;///动态中的图片
|
||||
typedef NS_ENUM(NSUInteger, ImageType){
|
||||
ImageTypeRoomFace = 1, //房间表情
|
||||
ImageTypeRoomGift, //房间礼物
|
||||
ImageTypeUserIcon, //用户头像60x60
|
||||
ImageTypeUserLibaryDetail, //用户相册大图
|
||||
ImageTypeCornerAvatar, //圆角图形,会先把图形裁剪成正方形,并且转换为png
|
||||
ImageTypeUserInfoAlbum, ///用户信息里面相册
|
||||
ImageTypeUserCardLevel, /// 用户资料卡中 等级以高度20等比例缩放
|
||||
ImageTypeMonentsPhoto, ///动态中的图片
|
||||
};
|
||||
|
||||
///展位图
|
||||
|
||||
/// 头像的默认占位图
|
||||
+ (UIImage *)defaultAvatarPlaceholder;
|
||||
///空白头像缺省图
|
||||
+ (UIImage *)defaultEmptyAvatarPlaceholder;
|
||||
/// 空白图的占位图
|
||||
+ (UIImage *)defaultEmptyPlaceholder;
|
||||
+ (UIImage *)defaultEmptyPlaceholder_UFO;
|
||||
/// banner的占位图
|
||||
+ (UIImage *)defaultBannerPlaceholder;
|
||||
|
||||
+ (NSString*)configUrl:(NSString*)url type:(ImageType)type;
|
||||
+ (NSString*)configUrl:(NSString*)url radius:(CGFloat)radius;
|
||||
+ (NSString*)configUrl:(NSString*)url type:(ImageType)type radius:(CGFloat)radius;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
119
YuMi/CustomUI/UIImageView/UIImageConstant.m
Normal file
119
YuMi/CustomUI/UIImageView/UIImageConstant.m
Normal file
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// UIImageViewConstant.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/17.
|
||||
//
|
||||
|
||||
#import "UIImageConstant.h"
|
||||
|
||||
@implementation UIImageConstant
|
||||
|
||||
/// 房间表情
|
||||
NSString * const kImageTypeRoomFace = @"";
|
||||
/// 房间礼物
|
||||
NSString * const kImageTypeRoomGift = @"";
|
||||
/// 用户头像150x150
|
||||
NSString * const kImageTypeUserIcon = @"imageMogr2/auto-orient/thumbnail/150x150";
|
||||
/// 用户相册大图
|
||||
NSString * const kImageTypeUserLibaryDetail = @"imageMogr2/auto-orient/thumbnail/300x300";
|
||||
NSString * const kImageTypeCornerAvatar = @"imageMogr2/auto-orient/thumbnail/300x300/format/png";
|
||||
/// 用户信息里面相册
|
||||
NSString * const kImageTypeUserInfoAlbum = @"imageMogr2/auto-orient/blur/375x375";
|
||||
/// 用户信息里面相册
|
||||
NSString * const kImageTypeUserCardLevel = @"imageMogr2/thumbnail/x40";
|
||||
/// 动态中的图片 400 * 400
|
||||
NSString * const kImageTypeMonentsPhoto = @"imageMogr2/auto-orient/thumbnail/400x400";
|
||||
|
||||
/// 头像的默认占位图
|
||||
+ (UIImage *)defaultAvatarPlaceholder {
|
||||
return [UIImage imageNamed:@"common_avatar"];
|
||||
}
|
||||
|
||||
///空白头像缺省图
|
||||
+ (UIImage *)defaultEmptyAvatarPlaceholder {
|
||||
return [UIImage imageNamed:@"common_avatar"];
|
||||
}
|
||||
|
||||
/// 空白图的占位图
|
||||
+ (UIImage *)defaultEmptyPlaceholder {
|
||||
return [UIImage imageNamed:@"common_empty"];
|
||||
}
|
||||
/// banner的占位图
|
||||
+ (UIImage *)defaultBannerPlaceholder {
|
||||
return [UIImage imageNamed:@"common_banner"];
|
||||
}
|
||||
|
||||
+ (UIImage *)defaultEmptyPlaceholder_UFO {
|
||||
return [UIImage imageNamed:@"common_empty_UFO"];
|
||||
}
|
||||
|
||||
|
||||
+ (NSString *)configUrl:(NSString *)url type:(ImageType)type {
|
||||
return [self configUrl:url type:type radius:0];
|
||||
}
|
||||
|
||||
+ (NSString *)configUrl:(NSString *)url radius:(CGFloat)radius {
|
||||
return [self configUrl:url type:-1 radius:radius];
|
||||
}
|
||||
|
||||
+ (NSString *)configUrl:(NSString *)url type:(ImageType)type radius:(CGFloat)radius {
|
||||
if (!url || url.length <= 0) return nil;
|
||||
NSMutableString *urlString = [NSMutableString stringWithString:url];
|
||||
NSString *configUrl = nil;
|
||||
switch (type) {
|
||||
case ImageTypeUserIcon:
|
||||
configUrl = kImageTypeUserIcon;
|
||||
break;
|
||||
case ImageTypeCornerAvatar:
|
||||
configUrl = kImageTypeCornerAvatar;
|
||||
break;
|
||||
case ImageTypeRoomFace:
|
||||
configUrl = kImageTypeRoomFace;
|
||||
break;
|
||||
case ImageTypeUserLibaryDetail:
|
||||
configUrl = kImageTypeUserLibaryDetail;
|
||||
break;
|
||||
case ImageTypeRoomGift:
|
||||
configUrl = kImageTypeRoomGift;
|
||||
break;
|
||||
case ImageTypeUserInfoAlbum:
|
||||
configUrl = kImageTypeUserInfoAlbum;
|
||||
break;
|
||||
case ImageTypeUserCardLevel:
|
||||
configUrl = kImageTypeUserCardLevel;
|
||||
break;
|
||||
case ImageTypeMonentsPhoto:
|
||||
configUrl = kImageTypeMonentsPhoto;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (configUrl) {
|
||||
if ([url containsString:@"?"]) {
|
||||
[urlString appendString:@"|"];
|
||||
}else{
|
||||
[urlString appendString:@"?"];
|
||||
}
|
||||
[urlString appendString:configUrl];
|
||||
}
|
||||
|
||||
if (radius > 0) {
|
||||
[urlString appendString:[NSString stringWithFormat:@"|roundPic/radius/%f", radius]];
|
||||
}
|
||||
|
||||
return percentEscapeString(urlString);
|
||||
}
|
||||
|
||||
NSString *percentEscapeString(NSString *string) {
|
||||
// 创建一个包含所有不需要百分比编码的字符集
|
||||
NSMutableCharacterSet *allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
|
||||
|
||||
// 手动删除你想要百分比编码的字符, 其余的非字符将会变成带 % 的转义符
|
||||
[allowedCharacterSet removeCharactersInString:@"|"];
|
||||
|
||||
return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user