//
// Const.swift
//
// Created by 刘刘峰 on 2019/11/3.
// Copyright © 2019 刘刘峰. All rights reserved.
//
import Foundation
import UIKit
import SnapKit
import Kingfisher
import Toast
import SwiftMessages
@_exported import SwiftyJSON
@_exported import HandyJSON
@_exported import IQKeyboardManagerSwift
@_exported import SwifterSwift
@_exported import Moya
let kScreenBounds = UIScreen.main.bounds
let kScreenWidth = UIScreen.main.bounds.size.width
let kScreenHeigth = UIScreen.main.bounds.size.height
let DominantColor = UIColor.init(red: 242/255.0, green: 77/255.0, blue: 51/255.0, alpha: 1)
let FooterViewColor = UIColor.init(red: 240/255.0, green: 241/255.0, blue: 244/255.0, alpha: 1)
// iphone X
let isIphoneX = kScreenHeigth == 812 ? true : false
let isIphone11 = kScreenHeigth == 896 ? true : false
let isIphoneXAll = isIphoneX||isIphone11
let isPad = DeviceInfo.isIPad()
//let ZYIsiPhoneX: Bool = UIScreen.instancesRespond(to: #selector(getter: UIScreen.currentMode)) && UIScreen.main.currentMode!.size == CGSize(width: 1125, height: 2436)
// navigationBarHeight
let navigationBarHeight : CGFloat = isIphoneXAll ? 88 : 64
// tabBarHeight
let tabBarHeight : CGFloat = isIphoneXAll ? 49 + 34 : 49
let statusBarHeight: CGFloat = isIphoneXAll ? 44 : 20
//@available(iOS 13.0, *)
//let kkwindow = (UIApplication.shared.connectedScenes.first?.delegate as? UIWindowSceneDelegate)?.window as? UIWindow
let kkwindow = UIApplication.shared.windows.first
//MARK:通用闭包
public typealias LFCallBack = ()->()
public typealias LFIndexCallBack = (_ selectRow:Int)->()
public typealias LFStringCallBack = (_ String:String)->()
public typealias LFButtonCallBack = (_ sender:UIButton)->()
//public typealias LFDataCallBack = (_ dataCenter:PXSDataCenter)->()
enum AppConstants {
//MARK: - 是否是测试环境
static let NetDebug: Bool = true
//MARK: - 随机颜色
static let ColorDebug: Bool = false
//MARK: - 日志输出
static let LogDebug: Bool = true
//存储-用户信息-键
static let CurrentLoginUserInfo: String = ""
static let KeyChainService: String = ""
//存储-网络请求token-键
static let NetworkToken: String = "NetworkToken"
//MARK: - 协议(http/https)(含“//”后缀,不能为空)
enum AppURLProtocol {
//测试
static let DebugProtocol = "https://"
//生产
static let ProduceProtocol = "https://"
}
//MARK: - 地址(host) (不能为空)
enum AppURLHOST {
//测试
static let DebugHOST = "项目测试域名"
//生产
static let ProduceHOST = "项目生产域名"
}
//MARK: - 端口(port),(含“:”前缀,如果 URL_PORT 为空,则不含)
enum AppURLPort {
//测试
static let DebugPort = ""
//生产
static let ProducePort = ""
}
//MARK: - 接口地址
enum AppInterfaceAddress {
//登录
static let Login = "接口地址路由"
}
//MARK: - APP的key
enum AppKey {
static let UMeng = "三方Key"
//......
}
//MARK: - APP的密钥
enum AppSecret {
static let UMeng = "三方密钥"
//......
}
//MARK: - 错误类型
enum ErrorType {
static let ServerError = "服务器异常"
}
}
//MARK: - 日志输出
// <T>: 为泛型,外界传入什么就是什么
func DLog<T>(_ message: T, file: String = #file, method: String = #function, line: Int = #line) {
if AppConstants.LogDebug {
print("\(method)[\(line)]:\(message)")
}
}
//MARK: - frame 相关
/************************ 屏幕尺寸 ***************************/
public enum AppFrame {
static let ScreenBounds = UIScreen.main.bounds
// 屏幕宽度
static let ScreenWidth = ScreenBounds.size.width
// 屏幕高度
static let ScreenHeight = ScreenBounds.size.height
// iPhone4
static let iPhone4 = ScreenHeight < 568 ? true : false
// iPhone 5
static let iPhone5 = ScreenHeight == 568 ? true : false
// iPhone 6
static let iPhone6 = ScreenHeight == 667 ? true : false
// iphone 6P
static let iPhone6P = ScreenHeight == 736 ? true : false
// iphone X XS
static let iPhoneX = ScreenHeight == 812 ? true : false
// iphone XR XSMax
static let iPhoneXR = ScreenHeight == 896 ? true : false
// navigationBarHeight
static let kNavigationBarHeight : CGFloat = iPhoneX ? 88 : 64
// tabBarHeight
static let kTabBarHeight : CGFloat = iPhoneX ? 49 + 34 : 49
/** 如果是iPhoneX按照Plus 尺寸计算比例 */
static let Scale_Height = iPhoneX ? 736.0/667.0 : ScreenHeight / 667
static let Scale_Width = ScreenWidth / 375
}
func ADAPTX(x:CGFloat) -> CGFloat {
return AppFrame.Scale_Width * x
}
func ADAPTY(y:CGFloat) -> CGFloat {
return AppFrame.Scale_Height * y
}
// MARK: ============================================================================
// MARK: 设置颜色
//MARK: - AppColor 相关
public enum AppColor {
static let clear = UIColor.clear
//APP主题色
// static let themeColor = RGB0X(hexValue: 0x3eb2e5)
// static let themeColor = RGB0X(hexValue: 0x03a9f4)
static let themeColor = RGB0X(hexValue: 0xF78934)
//2196f3
//白色
static let white = RGB0X(hexValue: 0xFFFFFF)
//APP红色
static let red = RGB0X(hexValue: 0xff2323)
//APP蓝色
static let blue = RGB0X(hexValue: 0x488ff0)
//APP黑色
static let black = RGB0X(hexValue: 0x252525)
//APP深灰色
static let darkgGray = RGB0X(hexValue: 0x666666)
//APP灰色
static let gray = RGB0X(hexValue: 0x989796)
//APP轻灰色
static let lightGray = RGB0X(hexValue: 0xcccccc)
//APP背景色
static let vcBgColor = RGB0X(hexValue: 0xF7F7F7)
static let lineColor = RGB0X(hexValue: 0xF0EFED)
//热门标签
static let hotColor = RGB0X(hexValue: 0xFC868B)
//推荐标签
static let recomColor = RGB0X(hexValue: 0x6AD8B3)
}
/// RGBA的颜色设置
func RGB(_ r:CGFloat, g:CGFloat, b:CGFloat) -> UIColor {
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1.0)
}
func RGBA(_ r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat) -> UIColor {
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a)
}
func HEXA(hexValue: Int, a: CGFloat) -> (UIColor) {
return UIColor(red: ((CGFloat)((hexValue & 0xFF0000) >> 16)) / 255.0,
green: ((CGFloat)((hexValue & 0xFF00) >> 8)) / 255.0,
blue: ((CGFloat)(hexValue & 0xFF)) / 255.0,
alpha: a)
}
func RGB0X(hexValue: Int) -> (UIColor) {
return HEXA(hexValue: hexValue, a: 1.0)
}
// MARK: ============================================================================
// MARK: 设置字体
//MARK: - AppFont相关
func FONT(font: CGFloat) -> UIFont {
return UIFont.systemFont(ofSize: font)
}
func FONT_BOLD(font: CGFloat) -> UIFont {
return UIFont.boldSystemFont(ofSize: font)
}
public enum AppFont {
static let font10 = FONT(font: 10)
static let font11 = FONT(font: 11)
static let font12 = FONT(font: 12)
static let font13 = FONT(font: 13)
static let font14 = FONT(font: 14)
static let font16 = FONT(font: 16)
static let font14_Blod = FONT_BOLD(font: 14)
static let font16_Blod = FONT_BOLD(font: 16)
static let font18_Blod = FONT_BOLD(font: 18)
}
// MARK: ============================================================================
// MARK: 界面UI固定尺寸
//MARK: - AppSize 相关
public enum AppSize {
static let margin = 10
}
网友评论