LNCreateOrderSuccessPanel.swift 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // LNCreateOrderSuccessPanel.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/12/22.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. class LNCreateOrderSuccessPanel: LNPopupView {
  11. private let costLabel = UILabel()
  12. override init(frame: CGRect) {
  13. super.init(frame: frame)
  14. setupViews()
  15. }
  16. func update(_ cost: Int) {
  17. costLabel.text = "\(cost)"
  18. }
  19. required init?(coder: NSCoder) {
  20. fatalError("init(coder:) has not been implemented")
  21. }
  22. }
  23. extension LNCreateOrderSuccessPanel {
  24. private func setupViews() {
  25. let bg = UIImageView()
  26. bg.image = .icOrderBg
  27. container.addSubview(bg)
  28. bg.snp.makeConstraints { make in
  29. make.horizontalEdges.equalToSuperview()
  30. make.top.equalToSuperview()
  31. }
  32. let ic = UIImageView()
  33. ic.image = .icOrderSuccess
  34. container.addSubview(ic)
  35. ic.snp.makeConstraints { make in
  36. make.centerX.equalToSuperview()
  37. make.top.equalToSuperview().offset(40)
  38. }
  39. let costView = UIView()
  40. container.addSubview(costView)
  41. costView.snp.makeConstraints { make in
  42. make.centerX.equalToSuperview()
  43. make.top.equalTo(ic.snp.bottom).offset(16)
  44. }
  45. let coin = UIImageView.coinImageView()
  46. costView.addSubview(coin)
  47. coin.snp.makeConstraints { make in
  48. make.leading.centerY.equalToSuperview()
  49. make.width.height.equalTo(24)
  50. }
  51. costLabel.font = .heading_h1
  52. costLabel.textColor = .text_5
  53. costView.addSubview(costLabel)
  54. costLabel.snp.makeConstraints { make in
  55. make.verticalEdges.equalToSuperview()
  56. make.trailing.equalToSuperview()
  57. make.leading.equalTo(coin.snp.trailing).offset(2)
  58. }
  59. let descLabel = UILabel()
  60. descLabel.text = .init(key: "A00120")
  61. descLabel.font = .heading_h2
  62. descLabel.textColor = .init(hex: "#1789FF")
  63. container.addSubview(descLabel)
  64. descLabel.snp.makeConstraints { make in
  65. make.centerX.equalToSuperview()
  66. make.top.equalTo(costView.snp.bottom).offset(2)
  67. }
  68. let confirmButton = UIButton()
  69. confirmButton.setTitle(.init(key: "A00002"), for: .normal)
  70. confirmButton.setTitleColor(.text_1, for: .normal)
  71. confirmButton.titleLabel?.font = .heading_h3
  72. confirmButton.setBackgroundImage(.primary_8, for: .normal)
  73. confirmButton.layer.cornerRadius = 23.5
  74. confirmButton.clipsToBounds = true
  75. confirmButton.addAction(UIAction(handler: { [weak self] _ in
  76. guard let self else { return }
  77. dismiss()
  78. }), for: .touchUpInside)
  79. container.addSubview(confirmButton)
  80. confirmButton.snp.makeConstraints { make in
  81. make.horizontalEdges.equalToSuperview().inset(12)
  82. make.top.equalTo(descLabel.snp.bottom).offset(49)
  83. make.bottom.equalToSuperview().offset(commonBottomInset)
  84. make.height.equalTo(47)
  85. }
  86. }
  87. }