LNJoinUsReviewViewController.swift 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // LNJoinUsReviewViewController.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/1/20.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. extension UIView {
  11. func pushToJoinUsReview(_ animated: Bool = true) {
  12. let vc = LNJoinUsReviewViewController()
  13. let fromJoin = navigationController?.viewControllers.last is LNJoinUsViewController
  14. if fromJoin, var viewControllers = navigationController?.viewControllers {
  15. viewControllers.removeLast()
  16. viewControllers.append(vc)
  17. navigationController?.setViewControllers(viewControllers, animated: true)
  18. } else {
  19. navigationController?.pushViewController(vc, animated: true)
  20. }
  21. }
  22. }
  23. class LNJoinUsReviewViewController: LNViewController {
  24. override func viewDidLoad() {
  25. super.viewDidLoad()
  26. setupViews()
  27. }
  28. }
  29. extension LNJoinUsReviewViewController {
  30. private func setupViews() {
  31. navigationBarColor = .clear
  32. title = .init(key: "B00031")
  33. let bg = UIImageView()
  34. bg.image = .icJoinUsReviewBg
  35. bg.backgroundColor = .white
  36. view.addSubview(bg)
  37. bg.snp.makeConstraints { make in
  38. make.horizontalEdges.equalToSuperview()
  39. make.top.equalTo(fakeNaviBgView)
  40. }
  41. let infoView = buildInfoView()
  42. view.addSubview(infoView)
  43. infoView.snp.makeConstraints { make in
  44. make.horizontalEdges.equalToSuperview()
  45. make.centerY.equalToSuperview().multipliedBy(0.75)
  46. }
  47. }
  48. private func buildInfoView() -> UIView {
  49. let container = UIView()
  50. let icon = UIImageView()
  51. icon.image = .icJoinUsReview
  52. container.addSubview(icon)
  53. icon.snp.makeConstraints { make in
  54. make.centerX.equalToSuperview()
  55. make.top.equalToSuperview()
  56. }
  57. let titleLabel = UILabel()
  58. titleLabel.text = .init(key: "B00061")
  59. titleLabel.font = .heading_h3
  60. titleLabel.textColor = .text_5
  61. titleLabel.numberOfLines = 0
  62. titleLabel.textAlignment = .center
  63. container.addSubview(titleLabel)
  64. titleLabel.snp.makeConstraints { make in
  65. make.horizontalEdges.equalToSuperview().inset(32)
  66. make.top.equalTo(icon.snp.bottom).offset(10)
  67. }
  68. let descLabel = UILabel()
  69. descLabel.text = .init(key: "B00062")
  70. descLabel.font = .body_s
  71. descLabel.textColor = .text_5
  72. descLabel.numberOfLines = 0
  73. descLabel.textAlignment = .center
  74. container.addSubview(descLabel)
  75. descLabel.snp.makeConstraints { make in
  76. make.horizontalEdges.equalToSuperview().inset(32)
  77. make.bottom.equalToSuperview()
  78. make.top.equalTo(titleLabel.snp.bottom).offset(4)
  79. }
  80. return container
  81. }
  82. }
  83. #if DEBUG
  84. import SwiftUI
  85. struct LNJoinUsReviewViewControllerPreview: UIViewControllerRepresentable {
  86. func makeUIViewController(context: Context) -> some UIViewController {
  87. LNJoinUsReviewViewController()
  88. }
  89. func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
  90. }
  91. #Preview(body: {
  92. LNJoinUsReviewViewControllerPreview()
  93. })
  94. #endif