QSLHomeEmptyView.swift 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. //
  2. // QSLHomeEmptyView.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by mac on 2024/4/11.
  6. //
  7. import UIKit
  8. import MarqueeLabel
  9. protocol QSLHomeEmptyViewDelegate: NSObjectProtocol {
  10. func emptyFriPhoneViewClick()
  11. }
  12. class QSLHomeEmptyView: UIView {
  13. weak var delegate: QSLHomeEmptyViewDelegate?
  14. lazy var emptyBgView: UIView = {
  15. let _emptyBgView = UIView()
  16. if let image = UIImage.gradient([UIColor.hexStringColor(hexString: "#F6F6F6", alpha: 0), QSLColor.backGroundColor], size: CGSize(width: qsl_kScreenW, height: 175), locations: [0,22.0 / 175.0], direction: .vertical) {
  17. _emptyBgView.backgroundColor = UIColor(patternImage: image)
  18. }
  19. return _emptyBgView
  20. }()
  21. lazy var emptyFriView: UIView = {
  22. let _emptyFriView = UIView()
  23. _emptyFriView.backgroundColor = .white
  24. _emptyFriView.addRadius(radius: 6)
  25. return _emptyFriView
  26. }()
  27. lazy var emptyFriTitleIcon: UIImageView = {
  28. let _emptyFriTitleIcon = UIImageView()
  29. _emptyFriTitleIcon.image = UIImage.image(color: QSLColor.themeMainColor, size: CGSize(width: 4, height: 16))
  30. return _emptyFriTitleIcon
  31. }()
  32. lazy var emptyFriTitleLabel: UILabel = {
  33. let _emptyFriTitleLabel = UILabel()
  34. _emptyFriTitleLabel.boldFont(15)
  35. _emptyFriTitleLabel.textColor = QSLColor.textColor_333
  36. _emptyFriTitleLabel.text = "查找好友"
  37. return _emptyFriTitleLabel
  38. }()
  39. lazy var emptyFriPhoneView: UIView = {
  40. let _emptyFriPhoneView = UIView()
  41. _emptyFriPhoneView.backgroundColor = QSLColor.backGroundColor
  42. _emptyFriPhoneView.addRadius(radius: 4)
  43. _emptyFriPhoneView.isUserInteractionEnabled = true
  44. let tap = UITapGestureRecognizer(target: self, action: #selector(emptyFriPhoneViewAction))
  45. _emptyFriPhoneView.addGestureRecognizer(tap)
  46. return _emptyFriPhoneView
  47. }()
  48. lazy var emptyFriPhoneLabel: UILabel = {
  49. let _emptyFriPhoneLabel = UILabel()
  50. _emptyFriPhoneLabel.font(14)
  51. _emptyFriPhoneLabel.textColor = QSLColor.textColor_AAA
  52. _emptyFriPhoneLabel.text = "输入手机号码 查看定位"
  53. return _emptyFriPhoneLabel
  54. }()
  55. lazy var lineIcon: UIImageView = {
  56. let _lineIcon = UIImageView()
  57. _lineIcon.image = UIImage.image(color: QSLColor.textColor_AAA, size: CGSize(width: 1, height: 16))
  58. return _lineIcon
  59. }()
  60. lazy var emptyFriAddLabel: UILabel = {
  61. let _emptyFriAddLabel = UILabel()
  62. _emptyFriAddLabel.mediumFont(14)
  63. _emptyFriAddLabel.textColor = QSLColor.textColor_333
  64. _emptyFriAddLabel.text = "查找"
  65. return _emptyFriAddLabel
  66. }()
  67. lazy var emptyInfoView: UIView = {
  68. let _emptyInfoView = UIView()
  69. _emptyInfoView.backgroundColor = UIColor.hexStringColor(hexString:"#E6CD9F")
  70. _emptyInfoView.addRadius(radius: 14)
  71. return _emptyInfoView
  72. }()
  73. lazy var emptyInfoBgImageView: UIImageView = {
  74. let _emptyInfoBgImageView = UIImageView()
  75. _emptyInfoBgImageView.image = UIImage(named: "home_empty_info_bg")
  76. return _emptyInfoBgImageView
  77. }()
  78. lazy var emptyInfoIcon: UIImageView = {
  79. let _emptyInfoIcon = UIImageView()
  80. _emptyInfoIcon.image = UIImage(named: "home_empty_info_icon")
  81. return _emptyInfoIcon
  82. }()
  83. lazy var emptyInfoUserLabel: UILabel = {
  84. let _emptyInfoUserLabel = UILabel()
  85. _emptyInfoUserLabel.font(12)
  86. _emptyInfoUserLabel.textColor = .white
  87. _emptyInfoUserLabel.text = "我:"
  88. return _emptyInfoUserLabel
  89. }()
  90. lazy var emptyInfoAddrLabel: MarqueeLabel = {
  91. // let _emptyInfoAddrLabel = MarqueeLabel(frame: CGRect(x: 0, y: 0, width: qsl_kScreenW - 224.0, height: 17.0), duration: 8.0, fadeLength: 10)
  92. let _emptyInfoAddrLabel = MarqueeLabel(frame: .zero, duration: 8.0, fadeLength: 10)
  93. _emptyInfoAddrLabel.font(12)
  94. _emptyInfoAddrLabel.textColor = .white
  95. _emptyInfoAddrLabel.text = "广东奥林匹克广东奥林匹克广东奥林匹克 "
  96. return _emptyInfoAddrLabel
  97. }()
  98. lazy var emptyInfoCheckLabel: UILabel = {
  99. let _emptyInfoCheckLabel = UILabel()
  100. _emptyInfoCheckLabel.textAlignment = .right
  101. _emptyInfoCheckLabel.font(12)
  102. _emptyInfoCheckLabel.textColor = UIColor.hexStringColor(hexString: "#5A330F")
  103. _emptyInfoCheckLabel.text = "查看轨迹"
  104. return _emptyInfoCheckLabel
  105. }()
  106. override init(frame: CGRect) {
  107. super.init(frame: frame)
  108. addSubview(emptyBgView)
  109. emptyBgView.addSubview(emptyFriView)
  110. emptyFriView.addSubview(emptyFriTitleIcon)
  111. emptyFriView.addSubview(emptyFriTitleLabel)
  112. emptyFriView.addSubview(emptyFriPhoneView)
  113. emptyFriPhoneView.addSubview(emptyFriPhoneLabel)
  114. emptyFriPhoneView.addSubview(lineIcon)
  115. emptyFriPhoneView.addSubview(emptyFriAddLabel)
  116. addSubview(emptyInfoView)
  117. emptyInfoView.addSubview(emptyInfoBgImageView)
  118. emptyInfoView.addSubview(emptyInfoIcon)
  119. emptyInfoView.addSubview(emptyInfoUserLabel)
  120. emptyInfoView.addSubview(emptyInfoAddrLabel)
  121. emptyInfoView.addSubview(emptyInfoCheckLabel)
  122. }
  123. override func layoutSubviews() {
  124. super.layoutSubviews()
  125. emptyBgView.snp.makeConstraints { make in
  126. make.edges.equalTo(0)
  127. }
  128. emptyFriView.snp.makeConstraints { make in
  129. make.left.equalTo(12)
  130. make.right.bottom.equalTo(-12)
  131. make.height.equalTo(127)
  132. }
  133. emptyFriTitleIcon.snp.makeConstraints { make in
  134. make.left.equalTo(12)
  135. make.top.equalTo(20)
  136. }
  137. emptyFriTitleLabel.snp.makeConstraints { make in
  138. make.left.equalTo(emptyFriTitleIcon.snp.right).offset(6)
  139. make.centerY.equalTo(emptyFriTitleIcon.snp.centerY)
  140. }
  141. emptyFriPhoneView.snp.makeConstraints { make in
  142. make.left.equalTo(12)
  143. make.right.equalTo(-12)
  144. make.bottom.equalTo(-25)
  145. make.height.equalTo(44)
  146. }
  147. emptyFriPhoneLabel.snp.makeConstraints { make in
  148. make.left.equalTo(16)
  149. make.centerY.equalTo(emptyFriPhoneView.snp.centerY)
  150. }
  151. emptyFriAddLabel.snp.makeConstraints { make in
  152. make.right.equalTo(-14)
  153. make.centerY.equalTo(emptyFriPhoneView.snp.centerY)
  154. }
  155. lineIcon.snp.makeConstraints { make in
  156. make.right.equalTo(emptyFriAddLabel.snp.left).offset(-11)
  157. make.centerY.equalTo(emptyFriPhoneView.snp.centerY)
  158. }
  159. emptyInfoView.snp.makeConstraints { make in
  160. make.left.equalTo(12);
  161. make.bottom.equalTo(emptyFriView.snp.top).offset(-8);
  162. make.width.equalTo(269);
  163. make.height.equalTo(28)
  164. }
  165. emptyInfoBgImageView.snp.makeConstraints { make in
  166. make.left.top.bottom.equalTo(0)
  167. }
  168. emptyInfoIcon.snp.makeConstraints { make in
  169. make.size.equalTo(CGSize(width: 24, height: 24))
  170. make.left.top.equalTo(2)
  171. make.bottom.equalTo(-2)
  172. }
  173. emptyInfoUserLabel.snp.makeConstraints { make in
  174. make.width.equalTo(22)
  175. make.left.equalTo(emptyInfoIcon.snp.right).offset(6)
  176. make.centerY.equalTo(emptyInfoIcon.snp.centerY)
  177. }
  178. emptyInfoCheckLabel.snp.makeConstraints { make in
  179. make.top.bottom.equalTo(0);
  180. make.right.equalTo(-8);
  181. make.width.equalTo(58)
  182. }
  183. emptyInfoAddrLabel.snp.makeConstraints { make in
  184. make.left.equalTo(emptyInfoUserLabel.snp.right)
  185. make.centerY.equalTo(emptyInfoIcon.snp.centerY)
  186. make.right.equalTo(emptyInfoCheckLabel.snp.left).offset(-8)
  187. make.height.equalTo(17)
  188. }
  189. }
  190. required init?(coder: NSCoder) {
  191. fatalError("init(coder:) has not been implemented")
  192. }
  193. }
  194. extension QSLHomeEmptyView {
  195. @objc func emptyFriPhoneViewAction() {
  196. delegate?.emptyFriPhoneViewClick()
  197. }
  198. }