LNMineWalletInfoView.swift 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // LNMineWalletInfoView.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/12/19.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. class LNMineWalletInfoView: UIView {
  11. private let coinCountLabel = UILabel()
  12. private let diamondCountLabel = UILabel()
  13. override init(frame: CGRect) {
  14. super.init(frame: frame)
  15. setupViews()
  16. LNEventDeliver.addObserver(self)
  17. onUserWalletInfoChanged(info: myWalletInfo)
  18. }
  19. required init?(coder: NSCoder) {
  20. fatalError("init(coder:) has not been implemented")
  21. }
  22. }
  23. extension LNMineWalletInfoView: LNPurchaseManagerNotify {
  24. func onUserWalletInfoChanged(info: LNUserWalletInfo) {
  25. coinCountLabel.text = info.coin.toDisplay
  26. diamondCountLabel.text = info.diamond.toDisplay
  27. }
  28. }
  29. extension LNMineWalletInfoView {
  30. private func setupViews() {
  31. layer.cornerRadius = 12
  32. backgroundColor = .fill
  33. onTap { [weak self] in
  34. guard let self else { return }
  35. pushToWallet()
  36. }
  37. let titleLabel = UILabel()
  38. titleLabel.font = .heading_h3
  39. titleLabel.textColor = .text_5
  40. titleLabel.text = .init(key: "A00215")
  41. addSubview(titleLabel)
  42. titleLabel.snp.makeConstraints { make in
  43. make.leading.equalToSuperview().offset(16)
  44. make.top.equalToSuperview().offset(12)
  45. }
  46. let coinView = UIView()
  47. coinView.backgroundColor = .init(hex: "#FFC4000D")
  48. coinView.layer.cornerRadius = 12
  49. addSubview(coinView)
  50. coinView.snp.makeConstraints { make in
  51. make.leading.equalToSuperview().offset(16)
  52. make.top.equalTo(titleLabel.snp.bottom).offset(12)
  53. make.bottom.equalToSuperview().offset(-12)
  54. }
  55. let coinIc = UIImageView()
  56. coinIc.image = .icCoin
  57. coinIc.alpha = 0.2
  58. coinView.addSubview(coinIc)
  59. coinIc.snp.makeConstraints { make in
  60. make.bottom.trailing.equalToSuperview()
  61. make.top.equalToSuperview().offset(14)
  62. make.width.height.equalTo(50)
  63. }
  64. let coinTextView = UIView()
  65. coinView.addSubview(coinTextView)
  66. coinTextView.snp.makeConstraints { make in
  67. make.centerY.equalToSuperview()
  68. make.leading.equalToSuperview().offset(12)
  69. }
  70. coinCountLabel.text = "0"
  71. coinCountLabel.font = .heading_h2
  72. coinCountLabel.textColor = .text_5
  73. coinTextView.addSubview(coinCountLabel)
  74. coinCountLabel.snp.makeConstraints { make in
  75. make.leading.equalToSuperview()
  76. make.top.equalToSuperview()
  77. make.trailing.equalToSuperview()
  78. }
  79. let coinLabel = UILabel()
  80. coinLabel.text = .init(key: "A00216")
  81. coinLabel.font = .heading_h5
  82. coinLabel.textColor = .text_5
  83. coinTextView.addSubview(coinLabel)
  84. coinLabel.snp.makeConstraints { make in
  85. make.leading.equalToSuperview()
  86. make.top.equalTo(coinCountLabel.snp.bottom)
  87. make.bottom.equalToSuperview()
  88. make.trailing.lessThanOrEqualToSuperview()
  89. }
  90. let diamondView = UIView()
  91. diamondView.backgroundColor = .init(hex: "#008FFF0D")
  92. diamondView.layer.cornerRadius = 12
  93. addSubview(diamondView)
  94. diamondView.snp.makeConstraints { make in
  95. make.leading.equalTo(coinView.snp.trailing).offset(10)
  96. make.size.equalTo(coinView)
  97. make.centerY.equalTo(coinView)
  98. make.trailing.equalToSuperview().offset(-16)
  99. }
  100. let diamondIc = UIImageView()
  101. diamondIc.image = .icDiamond
  102. diamondIc.alpha = 0.2
  103. diamondView.addSubview(diamondIc)
  104. diamondIc.snp.makeConstraints { make in
  105. make.bottom.trailing.equalToSuperview()
  106. make.width.height.equalTo(50)
  107. }
  108. let diamondTextView = UIView()
  109. diamondView.addSubview(diamondTextView)
  110. diamondTextView.snp.makeConstraints { make in
  111. make.centerY.equalToSuperview()
  112. make.leading.equalToSuperview().offset(12)
  113. }
  114. diamondCountLabel.text = "0"
  115. diamondCountLabel.font = .heading_h2
  116. diamondCountLabel.textColor = .text_5
  117. diamondTextView.addSubview(diamondCountLabel)
  118. diamondCountLabel.snp.makeConstraints { make in
  119. make.leading.equalToSuperview()
  120. make.top.equalToSuperview()
  121. make.trailing.equalToSuperview()
  122. }
  123. let diamondLabel = UILabel()
  124. diamondLabel.text = .init(key: "A00217")
  125. diamondLabel.font = .heading_h5
  126. diamondLabel.textColor = .text_5
  127. diamondTextView.addSubview(diamondLabel)
  128. diamondLabel.snp.makeConstraints { make in
  129. make.leading.equalToSuperview()
  130. make.top.equalTo(diamondCountLabel.snp.bottom)
  131. make.bottom.equalToSuperview()
  132. make.trailing.lessThanOrEqualToSuperview()
  133. }
  134. subviews.forEach { $0.isUserInteractionEnabled = false }
  135. }
  136. }