config.swift 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // config.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/6/14.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import Foundation
  9. //是否连接到collect服务器 直连版本false 需要在Info.plist配置服务器信息
  10. #if DEBUG
  11. let O2IsConnect2Collect = false
  12. #else
  13. let O2IsConnect2Collect = false
  14. #endif
  15. //一些常量
  16. //bugly
  17. let BUGLY_ID = "eeba0b1a8b"
  18. //极光
  19. let JPUSH_APP_KEY = "991b78af0eb51f840e55f395"
  20. let JPUSH_channel = "Publish channel"
  21. //百度
  22. let BAIDU_MAP_KEY = "gTGM45nn5dz7vcRv84a5HuPWSKvbeC2C"
  23. let BAIDU_ASR_APP_ID = "27038300"
  24. let BAIDU_ASR_APP_KEY = "hfrwCw0Z5uiDPxwZ8D0CNoGb"
  25. let BAIDU_ASR_APP_SECRET = "qxV6QrVrpxG46DeeQEnDwY1osp9o9Rwq"
  26. let SCREEN_WIDTH:CGFloat = UIScreen.main.bounds.width;
  27. let SCREEN_HEIGHT:CGFloat = UIScreen.main.bounds.height;
  28. //x, xs : 812 xr, xs max : 896
  29. let iPhoneX = (UIScreen.main.bounds.height == 812 || UIScreen.main.bounds.height == 896) ? true : false
  30. let safeAreaTopHeight:CGFloat = (iPhoneX ? 88 : 64)
  31. //顶部状态栏高度
  32. let IOS11_TOP_STATUSBAR_HEIGHT = iPhoneX ? 44 : 20
  33. //底部安全高度
  34. let IPHONEX_BOTTOM_SAFE_HEIGHT: CGFloat = 34.0
  35. //uiTabBar 高度
  36. let TAB_BAR_HEIGHT: CGFloat = iPhoneX ? (49 + 34) : 49
  37. func RGB(_ r:Float,g:Float,b:Float)->UIColor{
  38. return UIColor(red: CGFloat(r/255.0), green: CGFloat(g/255.0), blue:CGFloat(b/255.0), alpha: 1)
  39. }
  40. //返回字指定名称和大小的字体
  41. func ZFont(_ name:String,_ size:CGFloat) -> UIFont {
  42. return UIFont(name: name, size: size)!
  43. }
  44. //打印字体列表
  45. func printFonts() {
  46. let fontFamilyNames = UIFont.familyNames
  47. for familyName in fontFamilyNames {
  48. print("------------------------------")
  49. print("Font Family Name = [\(familyName)]")
  50. let names = UIFont.fontNames(forFamilyName: familyName)
  51. print("Font Names = [\(names)]")
  52. }
  53. }
  54. //设置页面字体
  55. let setting_item_textFont = UIFont(name: "PingFangTC-Regular", size: 14.0)
  56. let setting_value_textFont = UIFont(name: "PingFangSC-Light", size: 12.0)
  57. let setting_value_textColor = RGB(85, g: 85, b: 85)
  58. let setting_content_textFont = UIFont(name: "PingFangSC-Light", size: 12.0)
  59. let setting_content_textColor = RGB(155, g: 155, b: 155)
  60. let text_primary_color = UIColor(hex: "#333333")
  61. let text_normal_color = UIColor(hex: "#666666")
  62. //基本颜色
  63. var base_color: UIColor {
  64. get {
  65. return O2ThemeManager.color(for: "Base.base_color")!
  66. }
  67. }
  68. let base_blue_color = UIColor.init(hex: "#008be6")
  69. let base_gray_color = RGB(245.0, g: 245.0, b: 245.0)
  70. let base_gray_background_color = RGB(155.0,g:155.0,b:155.0)
  71. let toolbar_background_color = RGB(247,g:247,b:247)
  72. let toolbar_text_color = RGB(108,g: 108,b: 108)
  73. let toolbar_text_font = UIFont(name: "PingFangSC-Regular", size: 14.0)!
  74. let navbar_tint_color = UIColor.white
  75. var navbar_barTint_color: UIColor {
  76. get {
  77. return O2ThemeManager.color(for: "Base.base_color")!
  78. }
  79. }
  80. let navbar_item_font = toolbar_text_font
  81. //导航栏标题字体
  82. let navbar_text_font = UIFont(name: "PingFangSC-Regular", size: 15.0)!
  83. var PROJECTMODE = 0
  84. //随机字符串
  85. class RandomString {
  86. let characters = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  87. /**
  88. 生成随机字符串,
  89. - parameter length: 生成的字符串的长度
  90. - returns: 随机生成的字符串
  91. */
  92. func getRandomStringOfLength(length: Int) -> String {
  93. var ranStr = ""
  94. for _ in 0..<length {
  95. let index = Int(arc4random_uniform(UInt32(characters.count)))
  96. ranStr.append(characters[characters.index(characters.startIndex, offsetBy: index)])
  97. }
  98. return ranStr
  99. }
  100. private init() {
  101. }
  102. static let sharedInstance = RandomString()
  103. }
  104. //显示进度指示