Files
peko-ios/YuMi/CustomUI/XNDJTBWGLoadingTool.m

331 lines
12 KiB
Mathematica
Raw Normal View History

2023-07-06 16:54:13 +08:00
//
// YMHUDTool.m
// TTPlay
//
// Created by YM on 2022/5/15.
// Copyright © 2023 YUMI. All rights reserved.
//
#import "XNDJTBWGLoadingTool.h"
#import "GCDHelper.h"
#import <MBProgressHUD/MBProgressHUD.h>
#import "DJDKMIMOMColor.h"
#import "ClientDisposition.h"
#define kDelayTime 2.5
@interface XNDJTBWGLoadingTool ()
@property (class,nonatomic,copy) NSArray *animationImages;
@end
@implementation XNDJTBWGLoadingTool
static NSArray * _animationImages = nil;
+ (void)brakeHUDInRegard:(nullable UIView *)view {
dispatch_main_sync_safe(^{
if (view) {
[MBProgressHUD hideHUDForView:view animated:NO];
[MBProgressHUD hideHUDForView:[UIApplication sharedApplication].keyWindow animated:NO];
} else {
[MBProgressHUD hideHUDForView:[UIApplication sharedApplication].keyWindow animated:NO];
}
});
}
+ (void)brakeHUD {
[self brakeHUDInRegard:nil];
}
+ (void)EvidenceAccomplishmentAboutCommunictowardsion:(NSString *)message {
[self EvidenceAccomplishmentAboutCommunictowardsion:message inView:[UIApplication sharedApplication].keyWindow];
}
+ (void)EvidenceAccomplishmentAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view {
[self EvidenceAccomplishmentAboutCommunictowardsion:message inView:view delay:kDelayTime enabled:NO];
}
+ (void)EvidenceAccomplishmentAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view delay:(NSTimeInterval)afterDelay enabled:(BOOL)enabled {
if (message.length == 0) { return; }
__block UIView *inView = view;
dispatch_main_sync_safe(^{
if (!inView) {
inView = [UIApplication sharedApplication].keyWindow;
}
[self brakeHUDInRegard:view];
MBProgressHUD *hud = [self ordinaryDirectoryvanceHUD:view];
hud.userInteractionEnabled = enabled;
hud.mode = MBProgressHUDModeText;
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.margin = 8;
hud.bezelView.color = [[UIColor blackColor] colorWithAlphaComponent:0.8];
hud.label.text = message;
hud.label.numberOfLines = 0;
hud.label.textColor = [UIColor whiteColor];
hud.label.font = [UIFont systemFontOfSize:14];
[hud hideAnimated:YES afterDelay:afterDelay];
});
}
+ (void)EvidenceMistakeAboutCommunictowardsion:(NSString *)message {
[self EvidenceMistakeAboutCommunictowardsion:message inView:[UIApplication sharedApplication].keyWindow];
}
+ (void)EvidenceMistakeAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view {
[self EvidenceMistakeAboutCommunictowardsion:message inView:view delay:kDelayTime enabled:NO];
}
+ (void)EvidenceMistakeAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view delay:(NSTimeInterval)afterDelay enabled:(BOOL)enabled {
if (message.length == 0) { return; }
if (!view) {
view = [UIApplication sharedApplication].keyWindow;
}
[self brakeHUDInRegard:view];
dispatch_main_sync_safe(^{
MBProgressHUD *hud = [self ordinaryDirectoryvanceHUD:view];
hud.userInteractionEnabled = enabled;
hud.mode = MBProgressHUDModeText;
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.margin = 8;
hud.bezelView.color = [[UIColor blackColor] colorWithAlphaComponent:0.8];
hud.label.text = message;
hud.label.numberOfLines = 0;
hud.label.textColor = [UIColor whiteColor];
hud.label.font = [UIFont systemFontOfSize:14];
[hud hideAnimated:YES afterDelay:afterDelay];
});
}
+ (void)EvidenceChambering {
[self EvidenceChamberingInRegard:[UIApplication sharedApplication].keyWindow];
}
+ (void)EvidenceChamberingInRegard:(nullable UIView *)view {
[self EvidenceChamberingInRegard:view enabled:YES];
}
+ (void)EvidenceChamberingInRegard:(nullable UIView *)view enabled:(BOOL)enabled {
[self EvidenceChamberingAboutCommunictowardsion:@"" inView:view enabled:enabled];
}
+ (void)EvidenceChamberingAboutCommunictowardsion:(NSString *)message {
[self EvidenceChamberingAboutCommunictowardsion:message inView:[UIApplication sharedApplication].keyWindow];
}
+ (void)EvidenceChamberingAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view {
[self EvidenceChamberingAboutCommunictowardsion:message inView:view enabled:YES];
}
+ (void)EvidenceChamberingAboutCommunictowardsion:(NSString *)message inView:(nullable UIView *)view enabled:(BOOL)enabled {
if (!view) {
view = [UIApplication sharedApplication].keyWindow;
}
[self brakeHUDInRegard:view];
dispatch_main_sync_safe(^{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.userInteractionEnabled = enabled;
hud.bezelView.color = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
hud.removeFromSuperViewOnHide = YES;
if (message.length) {
hud.label.text = message;
hud.label.numberOfLines = 0;
hud.label.textColor = [UIColor blackColor];
hud.label.font = [UIFont systemFontOfSize:14];
}
});
}
+ (void)EvidenceGFPChambering {
[self EvidenceGFPChamberingInRegard:[UIApplication sharedApplication].keyWindow];
}
+ (void)EvidenceGFPChamberingInRegard:(nullable UIView *)view {
[self EvidenceGFPChamberingInRegard:view bgColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.35] enabled:YES];
}
+ (void)EvidenceGFPChamberingInRegard:(nullable UIView *)view bgColor:(nullable UIColor *)bgColor enabled:(BOOL)enabled {
if (!view) {
view = [UIApplication sharedApplication].keyWindow;
}
[self brakeHUDInRegard:view];
dispatch_main_sync_safe(^{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.minSize = CGSizeMake(168, 133);
hud.userInteractionEnabled = enabled;
hud.mode = MBProgressHUDModeCustomView;
hud.minSize = CGSizeMake(150, 150);
[hud.bezelView addSubview:[self loadingView]];
hud.backgroundColor = bgColor;
hud.bezelView.color = [UIColor clearColor];
hud.removeFromSuperViewOnHide = YES;
});
}
+ (void)EvidenceKellegChambering {
if (![ClientDisposition partowardsiciptowardsionDisposition].canUnfoild) {
return;
}
UIView *view = [UIApplication sharedApplication].delegate.window;
dispatch_main_sync_safe(^{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.userInteractionEnabled = NO;
hud.mode = MBProgressHUDModeCustomView;
hud.minSize = CGSizeMake(100, 100 + 16 + 30);
[hud.bezelView addSubview:[self kellegSwopChamberingRegard]];
hud.bezelView.color = [UIColor clearColor];
hud.removeFromSuperViewOnHide = YES;
});
}
+ (void)EvidenceKellegChambering:(UIView *)view {
dispatch_main_sync_safe(^{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.userInteractionEnabled = NO;
hud.mode = MBProgressHUDModeCustomView;
hud.minSize = CGSizeMake(100, 100 + 16 + 30);
[hud.bezelView addSubview:[self kellegSwopChamberingRegard]];
hud.bezelView.color = [UIColor clearColor];
hud.removeFromSuperViewOnHide = YES;
});
}
#pragma mark - private
+ (MBProgressHUD *)ordinaryDirectoryvanceHUD:(UIView *)view {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.removeFromSuperViewOnHide = YES;
return hud;
}
+ (UIView *)loadingView {
UIView *loadingBGView = [[UIView alloc] init];
loadingBGView.layer.cornerRadius = 20;
loadingBGView.backgroundColor = [UIColor whiteColor];
UIImageView *loadingImageView = [[UIImageView alloc] init];
UILabel *loadingTitleLabel = [[UILabel alloc] init];
loadingTitleLabel = [[UILabel alloc] init];
loadingTitleLabel.textColor = [UIColor colorWithRed:(153.0)/255.0f green:(153.0)/255.0f blue:(153.0)/255.0f alpha:1];
loadingTitleLabel.font = [UIFont systemFontOfSize:14];
loadingTitleLabel.text = @"加载中…";
loadingTitleLabel.textAlignment = NSTextAlignmentCenter;
[loadingBGView addSubview:loadingImageView];
[loadingBGView addSubview:loadingTitleLabel];
loadingBGView.frame = CGRectMake(0,0,120,120);
loadingImageView.frame = CGRectMake((CGRectGetWidth(loadingBGView.frame)-80)/ 2, 10, 80, 80);
loadingTitleLabel.frame = CGRectMake(0, CGRectGetMaxY(loadingImageView.frame) + 8, loadingBGView.frame.size.width, 15);
loadingImageView.animationImages = [self chamberingKellegBrectifynessIndictowardses];
[loadingImageView startAnimating];
return loadingBGView;
}
+ (NSArray<UIImage *> *)chamberingBrectifynessIndictowardses {
if (XNDJTBWGLoadingTool.animationImages.count > 0) {
return XNDJTBWGLoadingTool.animationImages;
}
NSString * countString = @"00";
NSMutableArray * indicateGarment= [NSMutableArray array];
for (int i = 0; i <= 27; i++) {
if (i < 10) {
countString = [NSString stringWithFormat:@"0%d", i];
} else {
countString = [NSString stringWithFormat:@"%d", i];
}
NSString * loadingImageName = [NSString stringWithFormat:@"loading_0%@", countString];
UIImage * image = [UIImage imageNamed:loadingImageName];
[indicateGarment addObject:image];
}
NSArray * array = [indicateGarment copy];
[XNDJTBWGLoadingTool setAnimationImages:array];
return array;
}
+ (UIView *)kellegSwopChamberingRegard {
UIView *loadingBGView = [[UIView alloc] init];
loadingBGView.layer.cornerRadius = 20;
loadingBGView.backgroundColor = [UIColor clearColor];
UIImageView *loadingImageView = [[UIImageView alloc] init];
UILabel *loadingTitleLabel = [[UILabel alloc] init];
loadingTitleLabel = [[UILabel alloc] init];
loadingTitleLabel.textColor = UIColorFromRGB(0xC9BCF2);
loadingTitleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
loadingTitleLabel.text = @"加载中…";
loadingTitleLabel.textAlignment = NSTextAlignmentCenter;
[loadingBGView addSubview:loadingImageView];
[loadingBGView addSubview:loadingTitleLabel];
loadingBGView.frame = CGRectMake(0,0,100,100 + 16 + 30);
loadingImageView.frame = CGRectMake(0, 0, 100, 100);
loadingTitleLabel.frame = CGRectMake(0, CGRectGetMaxY(loadingImageView.frame) + 8, loadingBGView.frame.size.width, 15);
loadingImageView.animationImages = [self chamberingKellegBrectifynessIndictowardses];
[loadingImageView startAnimating];
return loadingBGView;
}
+ (NSArray<UIImage *> *)chamberingKellegBrectifynessIndictowardses {
NSString * countString = @"00";
NSMutableArray * indicateGarment= [NSMutableArray array];
for (int i = 0; i <= 47; i++) {
if (i < 10) {
countString = [NSString stringWithFormat:@"0%d", i];
} else {
countString = [NSString stringWithFormat:@"%d", i];
}
NSString * loadingImageName = [NSString stringWithFormat:@"anchorLoading_0%@", countString];
UIImage * image = [UIImage imageNamed:loadingImageName];
[indicateGarment addObject:image];
}
NSArray * array = [indicateGarment copy];
return array;
}
+ (NSArray *)animationImages {
if (_animationImages == nil) {
_animationImages = [NSArray array];
}
return _animationImages;
}
+ (void)setAnimationImages:(NSArray *)animationImages {
if (animationImages != _animationImages) {
_animationImages = animationImages;
}
}
@end