Define_Const.h 6.6 KB
//
//  Define_Const.h
//  coffee-app-ios
//
//  Created by 钱鋆 on 15/8/11.
//  Copyright (c) 2015年 xn. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Define_Const : NSObject

// 判断是否是iphoneX
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)


// 根据状态栏高度判断是否开启了热点
#define STATUS_BAR_BIGGER_THAN_20 [UIApplication sharedApplication].statusBarFrame.size.height > 20

// 从云信移植
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#define IOS8            ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0)
#define kStatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height

#pragma mark 根据给定的标注尺寸计算实际宽度
/**
*  @author qianjun
*
*  @brief 根据给定的标注尺寸计算实际宽度
*
*  @param width      给定标注尺寸下的控件宽度
*  @param basicWidth 给定标注图的宽度
*
*  @return 计算后的真实宽度
*/
#define f_CalcRealWidth(width,basicWidth) (float)width/(float)basicWidth*(float)ScreenWidth

#pragma mark 根据给定的标注尺寸计算实际高度
/**
*  @author qianjun
*
*  @brief 根据给定的标注尺寸计算实际高度
*
*  @param height      给定标注尺寸下的控件高度
*  @param basicHeight 给定的标注图的高度
*
*  @return 计算后的真实高度
*/
#define f_CalcRealHeight(height,basicHeight) (float)height/(float)basicHeight*(float)ScreenHeight

#pragma mark 根据标注尺寸(基于iPhone5尺寸)计算实际宽度
/**
 *  @author qianjun
 *
 *  @brief 根据标注尺寸(基于iPhone5尺寸)计算实际宽度
 *
 *  @param widthForiPhone5 iPhone5标注图下的实际宽度
 *
 *  @return 计算后的真实宽度
 */
#define f_CalcRealWidthByiPhone5(widthForiPhone5) (float)widthForiPhone5/640.0f*(float)ScreenWidth

#pragma mark 根据标注尺寸(基于iPhone5尺寸)计算实际高度
/**
 *  @author qianjun
 *
 *  @brief 根据标注尺寸(基于iPhone5尺寸)计算实际高度
 *
 *  @param heightForiPhone5 iPhone5标注图下的实际高度
 *
 *  @return 计算后的真实高度
 */
#define f_CalcRealHeightByiPhone5(heightForiPhone5) (float)heightForiPhone5/1136.0f*(float)ScreenHeight

#pragma mark 根据标注尺寸(基于iPhone6尺寸)计算实际宽度
/**
 *  @author qianjun
 *
 *  @brief 根据标注尺寸(基于iPhone6尺寸)计算实际宽度
 *
 *  @param widthForiPhone6 iPhone6标注图下的实际宽度
 *
 *  @return 计算后的真实宽度
 */
#define f_CalcRealWidthByiPhone6(widthForiPhone6) (float)widthForiPhone6/750.0f*(float)ScreenWidth

#pragma mark 根据标注尺寸(基于iPhone6尺寸)计算实际高度
/**
 *  @author qianjun
 *
 *  @brief 根据标注尺寸(基于iPhone6尺寸)计算实际高度
 *
 *  @param heightForiPhone6 iPhone6标注图下的实际高度
 *
 *  @return 计算后的真实高度
 */
#define f_CalcRealHeightByiPhone6(heightForiPhone6) (float)heightForiPhone6/1334.0f*(float)ScreenHeight

#pragma mark 根据开发注尺寸(基于iPhone7尺寸)计算实际宽度
/**
 *  @author zsq
 *
 *  @brief 根据开发尺寸(基于iPhone7尺寸)计算实际宽度
 *
 *  @param widthForiPhone7 iPhone7开发图下的实际宽度
 *
 *  @return 计算后的真实宽度
 */
#define f_CalcDevWidthByiPhone7(widthForiPhone7) widthForiPhone7/375.0f*ScreenWidth

#pragma mark 根据开发尺寸(基于iPhone7尺寸)计算实际高度
/**
 *  @author zsq
 *
 *  @brief 根据开发尺寸(基于iPhone7尺寸)计算实际高度
 *
 *  @param heightForiPhone7 iPhone7开发图下的实际高度
 *
 *  @return 计算后的真实高度
 */
#define f_CalcDevHeightByiPhone7(heightForiPhone7) (float)heightForiPhone7/(667.0f)*(float)ScreenHeight

#define f_CalcRealWidthByiPhoneX(widthForiPhoneX) (float)widthForiPhoneX/1125.0f*(float)ScreenWidth
#define f_CalcRealHeightByiPhoneX(widthForiPhoneX) (float)widthForiPhoneX/2436.0f*(float)ScreenWidth

#pragma mark 当前设备屏幕宽度
/**
 *  @author qianjun
 *
 *  @brief 当前设备屏幕宽度
 */
#define ScreenWidth  ([[UIScreen mainScreen] bounds].size.width)

#pragma mark 当前设备屏幕高度
/**
 *  @author qianjun
 *
 *  @brief 当前设备屏幕高度
 */
#define ScreenHeight  ([[UIScreen mainScreen] bounds].size.height)

#define APPDELEGATE ((AppDelegate*)[[UIApplication sharedApplication] delegate])
//系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
//定义手势密码
#define KGESTUREPWD @"gesturePWD"

//#define g_Server @"192.168.1.46"
#define g_Server @"im.xiniunet.com"
#define g_Port 5222
#define g_Tenant_ID @"800000"

#define SERVER @"im.xiniunet.com"
#define RESOURCE @"/XINIU_PC"
#define GROUPFLAG @"@group"
#define TENANTFLAG @"@tenant"

#define g_FILE_SERVER @"112.124.121.74"
#define g_FILE_PORT 9094

// 通知定义
#define NOTIFICATION_CHANGE_GROUPNAME @"notification_change_groupname"
#define NOTIFICATION_GROUP @"notification_group"
#define NOTIFICATION_LOGOUT @"notification_logout"

#define NOTI_TENANTMEMBER_INFO @"noti_tenantmember_info"
#define NOTI_USER_PRESENCE @"noti_user_presence"
#define NOTI_DOWNFILE_RESULT @"noti_download_file"

// 云信相关的通知
#define NOTI_NIM_LOGOUT @"NOTI_NIMSDK_LOGOUT"

// 短信验证码登录
#define NOTI_SMSLOGIN_SAVEUSERINFO @"NOTI_SMSLOGIN_SAVEUSERINFO"

#define IOS8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0)
#define IOS10_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue]>=10.0)
#define iOS13_OR_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 13.0f)

#define kNavBarHeight 44.0
//#define BOTTOM_OFFSET ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)
#define BOTTOM_OFFSET 49.0
#define TOP_OFFSET (kStatusBarHeight + kNavBarHeight)

//#define SAFEAREA_BOTTOM ([[UIApplication sharedApplication] statusBarFrame].size.height>20?34:0)
#define SAFEAREA_BOTTOM 34.0

#define DEFAULT_SESSION @"638159439018725376"

#define enumToString(value)  @#value

// 禁用函数,编译时提示错误
#define UNAVAILABLE(__arg__) __attribute__((unavailable(__arg__)))

// 这是云信的通知定义,位于NTESSystemNotificationCell中
typedef NS_ENUM(NSInteger, NotificationHandleType) {
    // 待处理
    NotificationHandleTypePending = 0,
    // 已同意
    NotificationHandleTypeOk,
    // 已拒绝
    NotificationHandleTypeNo,
    // 已过期
    NotificationHandleTypeOutOfDate
};


typedef void(^ForumShareSelectFinishBlock)(NSObject *);

@end