QSLRoadMainView.swift 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. //
  2. // QSLRoadMainView.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2024/12/3.
  6. //
  7. import UIKit
  8. protocol QSLRoadMainViewDelegate: NSObjectProtocol {
  9. func startTimeClickAction()
  10. func endTimeClickAction()
  11. func searchClickAction()
  12. }
  13. class QSLRoadMainView: UIView {
  14. weak var delegate: QSLRoadMainViewDelegate?
  15. lazy var contentView: UIView = {
  16. let view = UIView(frame: CGRect(x: 0, y: 0, width: QSLConst.qsl_kScreenW, height: 369.rpx))
  17. view.backgroundColor = QSLColor.backGroundColor
  18. view.addFourCorner(topLeft: 12.rpx, topRight: 12.rpx, bottomLeft: 0, bottomRight: 0)
  19. return view
  20. }()
  21. lazy var avatarImageView: UIImageView = {
  22. let imageView = UIImageView()
  23. imageView.image = UIImage(named: "friends_cell_other_avatar")
  24. return imageView
  25. }()
  26. lazy var titleLabel: UILabel = {
  27. let label = UILabel()
  28. label.text("儿子的轨迹")
  29. label.mediumFont(16)
  30. label.textColor = QSLColor.Color_202020
  31. return label
  32. }()
  33. lazy var timeView: UIView = {
  34. let view = UIView()
  35. view.backgroundColor = .white
  36. view.addRadius(radius: 8.rpx)
  37. return view
  38. }()
  39. lazy var startTimeView: UIView = {
  40. let view = UIView()
  41. view.backgroundColor = QSLColor.backGroundColor
  42. view.addRadius(radius: 4.rpx)
  43. view.addBorder(borderWidth: 1.rpx, borderColor: .hexStringColor(hexString: "#F2F2F2"))
  44. view.isUserInteractionEnabled = true
  45. let tap = UITapGestureRecognizer(target: self, action: #selector(startTimeAction))
  46. view.addGestureRecognizer(tap)
  47. return view
  48. }()
  49. lazy var startTimeLabel: UILabel = {
  50. let label = UILabel()
  51. label.text("开始时间:2023-07-07 14:33")
  52. label.font(14)
  53. label.textColor = QSLColor.Color_202020
  54. return label
  55. }()
  56. lazy var startTimeArrow: UIImageView = {
  57. let imageView = UIImageView()
  58. imageView.image = UIImage(named: "route_time_arrow")
  59. return imageView
  60. }()
  61. lazy var endTimeView: UIView = {
  62. let view = UIView()
  63. view.backgroundColor = QSLColor.backGroundColor
  64. view.addRadius(radius: 4.rpx)
  65. view.addBorder(borderWidth: 1.rpx, borderColor: .hexStringColor(hexString: "#F2F2F2"))
  66. view.isUserInteractionEnabled = true
  67. let tap = UITapGestureRecognizer(target: self, action: #selector(endTimeAction))
  68. view.addGestureRecognizer(tap)
  69. return view
  70. }()
  71. lazy var endTimeLabel: UILabel = {
  72. let label = UILabel()
  73. label.text("结束时间:2023-07-08 14:33")
  74. label.font(14)
  75. label.textColor = QSLColor.Color_202020
  76. return label
  77. }()
  78. lazy var endTimeArrow: UIImageView = {
  79. let imageView = UIImageView()
  80. imageView.image = UIImage(named: "route_time_arrow")
  81. return imageView
  82. }()
  83. lazy var startAddressPoint: UIView = {
  84. let view = UIView()
  85. view.addRadius(radius: 3.5.rpx)
  86. view.backgroundColor = .hexStringColor(hexString: "#12C172")
  87. return view
  88. }()
  89. lazy var startAddressLabel: UILabel = {
  90. let label = UILabel()
  91. label.numberOfLines = 0
  92. label.text("起点:")
  93. label.font(13)
  94. label.textColor = .hexStringColor(hexString: "#A7A7A7")
  95. return label
  96. }()
  97. lazy var lineView: UIView = {
  98. let view = UIView()
  99. view.backgroundColor = .hexStringColor(hexString: "#F5F5F5")
  100. return view
  101. }()
  102. lazy var endAddressPoint: UIView = {
  103. let view = UIView()
  104. view.addRadius(radius: 3.5.rpx)
  105. view.backgroundColor = .hexStringColor(hexString: "#F3353A")
  106. return view
  107. }()
  108. lazy var endAddressLabel: UILabel = {
  109. let label = UILabel()
  110. label.numberOfLines = 0
  111. label.text("终点:")
  112. label.font(13)
  113. label.textColor = .hexStringColor(hexString: "#A7A7A7")
  114. return label
  115. }()
  116. lazy var searchBtn: UIButton = {
  117. let btn = UIButton()
  118. btn.gradientBackgroundColor(color1: .hexStringColor(hexString: "#15CBA1"), color2: .hexStringColor(hexString: "#1FE0BA"), width: 280.rpx, height: 44.rpx, direction: .horizontal)
  119. btn.addRadius(radius: 22.rpx)
  120. btn.title("查询轨迹")
  121. btn.textColor(.white)
  122. btn.mediumFont(16.rpx)
  123. btn.addTarget(self, action: #selector(searchAction), for: .touchUpInside)
  124. return btn
  125. }()
  126. override init(frame: CGRect) {
  127. super.init(frame: frame)
  128. initView()
  129. }
  130. required init?(coder: NSCoder) {
  131. fatalError("init(coder:) has not been implemented")
  132. }
  133. }
  134. extension QSLRoadMainView {
  135. @objc func searchAction() {
  136. delegate?.searchClickAction()
  137. }
  138. @objc func startTimeAction() {
  139. delegate?.startTimeClickAction()
  140. }
  141. @objc func endTimeAction() {
  142. delegate?.endTimeClickAction()
  143. }
  144. }
  145. extension QSLRoadMainView {
  146. func initView() {
  147. self.backgroundColor = .clear
  148. addSubview(contentView)
  149. contentView.snp.makeConstraints { make in
  150. make.left.right.bottom.equalTo(0)
  151. make.height.equalTo(369.rpx)
  152. }
  153. contentView.addSubview(avatarImageView)
  154. avatarImageView.snp.makeConstraints { make in
  155. make.size.equalTo(CGSize(width: 32.rpx, height: 32.rpx))
  156. make.left.equalTo(12.rpx)
  157. make.top.equalTo(16.rpx)
  158. }
  159. contentView.addSubview(titleLabel)
  160. titleLabel.snp.makeConstraints { make in
  161. make.left.equalTo(avatarImageView.snp.right).offset(8.rpx)
  162. make.centerY.equalTo(avatarImageView.snp.centerY)
  163. }
  164. contentView.addSubview(timeView)
  165. timeView.snp.makeConstraints { make in
  166. make.left.equalTo(8.rpx)
  167. make.right.equalTo(-8.rpx)
  168. make.top.equalTo(56.rpx)
  169. make.bottom.equalTo(-QSLConst.qsl_kTabbarBottom)
  170. }
  171. timeView.addSubview(startTimeView)
  172. startTimeView.snp.makeConstraints { make in
  173. make.left.equalTo(20.rpx)
  174. make.right.equalTo(-17.rpx)
  175. make.top.equalTo(20.rpx)
  176. make.height.equalTo(36.rpx)
  177. }
  178. startTimeView.addSubview(startTimeLabel)
  179. startTimeLabel.snp.makeConstraints { make in
  180. make.left.equalTo(12.rpx)
  181. make.centerY.equalToSuperview()
  182. }
  183. startTimeView.addSubview(startTimeArrow)
  184. startTimeArrow.snp.makeConstraints { make in
  185. make.size.equalTo(CGSize(width: 20.rpx, height: 20.rpx))
  186. make.right.equalTo(-12.rpx)
  187. make.centerY.equalToSuperview()
  188. }
  189. timeView.addSubview(endTimeView)
  190. endTimeView.snp.makeConstraints { make in
  191. make.left.equalTo(20.rpx)
  192. make.right.equalTo(-17.rpx)
  193. make.top.equalTo(startTimeView.snp.bottom).offset(12.rpx)
  194. make.height.equalTo(36.rpx)
  195. }
  196. endTimeView.addSubview(endTimeLabel)
  197. endTimeLabel.snp.makeConstraints { make in
  198. make.left.equalTo(12.rpx)
  199. make.centerY.equalToSuperview()
  200. }
  201. endTimeView.addSubview(endTimeArrow)
  202. endTimeArrow.snp.makeConstraints { make in
  203. make.size.equalTo(CGSize(width: 20.rpx, height: 20.rpx))
  204. make.right.equalTo(-12.rpx)
  205. make.centerY.equalToSuperview()
  206. }
  207. timeView.addSubview(startAddressPoint)
  208. startAddressPoint.snp.makeConstraints { make in
  209. make.size.equalTo(CGSize(width: 7.rpx, height: 7.rpx))
  210. make.left.equalTo(20.rpx)
  211. make.top.equalTo(endTimeView.snp.bottom).offset(32.rpx)
  212. }
  213. timeView.addSubview(startAddressLabel)
  214. startAddressLabel.snp.makeConstraints { make in
  215. make.left.equalTo(startAddressPoint.snp.right).offset(10.rpx)
  216. make.right.equalTo(-17.rpx)
  217. make.centerY.equalTo(startAddressPoint.snp.centerY)
  218. }
  219. timeView.addSubview(lineView)
  220. lineView.snp.makeConstraints { make in
  221. make.width.equalTo(1.rpx)
  222. make.height.equalTo(27.rpx)
  223. make.top.equalTo(startAddressPoint.snp.bottom).offset(8.rpx)
  224. make.centerX.equalTo(startAddressPoint.snp.centerX)
  225. }
  226. timeView.addSubview(endAddressPoint)
  227. endAddressPoint.snp.makeConstraints { make in
  228. make.size.equalTo(CGSize(width: 7.rpx, height: 7.rpx))
  229. make.left.equalTo(20.rpx)
  230. make.top.equalTo(lineView.snp.bottom).offset(8.rpx)
  231. }
  232. timeView.addSubview(endAddressLabel)
  233. endAddressLabel.snp.makeConstraints { make in
  234. make.left.equalTo(endAddressPoint.snp.right).offset(10.rpx)
  235. make.right.equalTo(-17.rpx)
  236. make.centerY.equalTo(endAddressPoint.snp.centerY)
  237. }
  238. timeView.addSubview(searchBtn)
  239. searchBtn.snp.makeConstraints { make in
  240. make.size.equalTo(CGSize(width: 280.rpx, height: 44.rpx))
  241. make.centerX.equalToSuperview()
  242. make.bottom.equalTo(-24.rpx)
  243. }
  244. }
  245. }