//
//  Header.h
//  fastservice
//
//  Created by xuning on 5/5/25.
//  Copyright © 2025 FastService. All rights reserved.
//

#ifndef Header_h
#define Header_h

// 百度地图
#define BAIDU_APPKEY @"9fzRTgXAOSma0WLs5ko09vSuw4I6L7Oz"

#ifdef DEBUG
#define DebugLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif

#define theApp() ((AppDelegate *) [[UIApplication sharedApplication] delegate])


#define IMG(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]
#define S(str,...) [NSString stringWithFormat:str,##__VA_ARGS__]

#define RGBAColor(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define kHexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define kRandomColor RGBAColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256),1)

#define COLOR_THEMEGRENN  [UIColor colorWithHexString:@"#4EB97B"]

#define BLUE_COLOR        [UIColor colorWithHexString:@"#4290E5"]
#define YELLOW_COLOR      [UIColor colorWithHexString:@"#edb10f"]
#define PURPLE_COLOR      [UIColor colorWithHexString:@"#9E5BCA"]
#define RED_COLOR         [UIColor colorWithHexString:@"#f25555"]

#define F_3D3B4F_COLOR      [UIColor colorWithHexString:@"#3D3B4F"]
#define F_415058_COLOR      [UIColor colorWithHexString:@"#415058"]
 
#define F_707070_COLOR      [UIColor colorWithHexString:@"#707070"]
#define F_8A8A8A_COLOR      [UIColor colorWithHexString:@"#8a8a8a"]
#define F_BCBCBC_COLOR      [UIColor colorWithHexString:@"#bcbcbc"]
#define F_CFCFCF_COLOR      [UIColor colorWithHexString:@"#cfcfcf"]
#define F_7D7D7d_COLOR      [UIColor colorWithHexString:@"#7D7D7D"]
#define F_9B9B9B_COLOR      [UIColor colorWithHexString:@"#9B9B9B"]
#define F_666666_COLOR      [UIColor colorWithHexString:@"#666666"]
#define F_606060_COLOR      [UIColor colorWithHexString:@"#606060"]
#define F_BBBBBB_COLOR      [UIColor colorWithHexString:@"#BBBBBB"]
#define F_101010_COLOR      [UIColor colorWithHexString:@"#101010"]

#define E9_3_COLOR        [UIColor colorWithHexString:@"#e9e9e9"]
#define F2_3_COLOR        [UIColor colorWithHexString:@"#f2f2f2"]
#define FA_3_COLOR        [UIColor colorWithHexString:@"#fafafa"]
#define F7_3_COLOR        [UIColor colorWithHexString:@"#F7F7F7"]
 
#define BB_3_COLOR      [UIColor colorWithHexString:@"#BBBBBB"]
#define EF_3_COLOR      [UIColor colorWithHexString:@"#efefef"]
#define B2_3_COLOR      [UIColor colorWithHexString:@"#b2b2b2"]

#define DEFAULT_BACKGROUND_COLOR kHexRGB(0xf7f7f7)

#define kViewBorderRadius(View, Radius, Width, Color)\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]];

#define widthScale ([UIScreen mainScreen].bounds.size.width/375.0f)
#define heightScale ([UIScreen mainScreen].bounds.size.height/844.0f)
#define SCREEN_HEIGHT     [[UIScreen mainScreen] bounds].size.height
#define SCREEN_WIDTH      [[UIScreen mainScreen] bounds].size.width
//状态栏高度
#define KSTATUSBAR_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height
//导航条高度
#define KNAVBAR_HEIGHT 44.0
//底部tabbar高度
#define KTABBAR_HEIGHT ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)
//整个顶部的高度
#define KTOP_HEIGHT (KSTATUSBAR_HEIGHT + KNAVBAR_HEIGHT)

//app 版本
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#define APP_BUILD   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

#define AS_SINGLETION( __class ) \
+ (__class *)shared##__class



#define DEF_SINGLETION( __class ) \
+ (__class *)shared##__class \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \
return __singleton__; \
}



#define IS_IPHONEX ({\
BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
if ([[[UIApplication sharedApplication] delegate] window].safeAreaInsets.bottom > 0.0) {\
isPhoneX = YES;\
}\
}\
isPhoneX;\
})

//iphoneX适配差值
#define KiPhoneXSafeAreaDValue ([[UIApplication sharedApplication] statusBarFrame].size.height>20?34:0)



#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
// 字符串是否为空
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
// 数组是否为空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)


#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;

/**
 申明一个 block_self 的指针，指向自身，以用于在block中使用
 */
#if __has_feature(objc_arc)
#define IMP_BLOCK_SELF(type) __weak type *block_self=self;
#else
#define IMP_BLOCK_SELF(type) __block type *block_self=self;
#endif

typedef void(^EventHandler)(id sender);

typedef void(^EventVoidHandler)(void);

typedef void(^EventTwoHandler)(id sender,id sender1);

typedef void(^EventThreeHandler)(id sender,id sender1,id sender2);

typedef void(^RightActionBlock)(id sender,id sender1);
/**
 调用一个block,会判断block不为空
 */
#define BlockCallWithVoidArg(block)  if(block){block();}

/**
 调用一个block,会判断block不为空
 */
#define BlockCallWithOneArg(block,arg)  if(block){block(arg);}
/**
 调用一个block,会判断block不为空
 */
#define BlockCallWithTwoArg(block,arg1,arg2) if(block){block(arg1,arg2);}
/**
 调用一个block,会判断block不为空
 */
#define BlockCallWithThreeArg(block,arg1,arg2,arg3) if(block){block(arg1,arg2,arg3);}



#endif /* Header_h */
