TSAppUpdateAlertVC.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // TSAppUpdateAlertVC.swift
  3. // TSLiveWallpaper
  4. //
  5. // Created by 100Years on 2025/6/19.
  6. //
  7. class TSAppUpdateAlertVC: TSBaseVC {
  8. lazy var alertContent: UIView = {
  9. let alertContent = UIView()
  10. return alertContent
  11. }()
  12. lazy var closeBtn: TSUIExpandedTouchButton = {
  13. let closeBtn = TSUIExpandedTouchButton()
  14. closeBtn.setUpButton(image:.appUpdateClose){ [weak self] in
  15. guard let self = self else { return }
  16. self.dismiss(animated: true)
  17. }
  18. return closeBtn
  19. }()
  20. override func createView() {
  21. setNavBarViewHidden(true)
  22. view.backgroundColor = .black.withAlphaComponent(0.8)
  23. contentView.addSubview(alertContent)
  24. alertContent.snp.makeConstraints { make in
  25. make.leading.equalTo(32)
  26. make.trailing.equalTo(-32)
  27. make.centerY.equalToSuperview()
  28. }
  29. let bgImageView = UIImageView.createImageView(image:.appUpdateBg,contentMode: .scaleToFill)
  30. bgImageView.cornerRadius = 20.0
  31. alertContent.addSubview(bgImageView)
  32. bgImageView.snp.makeConstraints { make in
  33. make.edges.equalToSuperview()
  34. }
  35. contentView.addSubview(closeBtn)
  36. closeBtn.snp.makeConstraints { make in
  37. make.centerX.equalToSuperview()
  38. make.top.equalTo(alertContent.snp.bottom).offset(20)
  39. make.width.height.equalTo(24)
  40. }
  41. setUpAlertContent()
  42. }
  43. }
  44. extension TSAppUpdateAlertVC {
  45. func setUpAlertContent(){
  46. let leading = 16.0
  47. let titleLab = UILabel.createLabel(text: "New Update Available!".localized,font: .font(size: 20,weight: .semibold),textColor: .white)
  48. alertContent.addSubview(titleLab)
  49. titleLab.snp.makeConstraints { make in
  50. make.leading.equalTo(leading)
  51. make.trailing.equalTo(-80)
  52. make.top.equalTo(24)
  53. }
  54. let iconImageView = UIImageView.createImageView(image:.appUpdateIcon)
  55. alertContent.addSubview(iconImageView)
  56. iconImageView.snp.makeConstraints { make in
  57. make.top.equalTo(-24)
  58. make.trailing.equalTo(-12)
  59. make.width.height.equalTo(96)
  60. }
  61. let text:String = "🎨 Fresh styles, more vibrant than ever".localized + "\n" + "✨ Trendy effects for more magic".localized + "\n" + "⚡ Even faster speed".localized
  62. let infoLab = UILabel.createLabel(text: text,font: .font(size: 14),textColor: .white)
  63. alertContent.addSubview(infoLab)
  64. infoLab.snp.makeConstraints { make in
  65. make.top.equalTo(titleLab.snp.bottom).offset(40)
  66. make.left.equalTo(leading)
  67. make.right.equalTo(-leading)
  68. }
  69. infoLab.setLineSpacing(10.0)
  70. let infoLab1 = UILabel.createLabel(text: "Update now to unlock the best experience".localized,font: .font(size: 14),textColor: .white)
  71. alertContent.addSubview(infoLab1)
  72. infoLab1.snp.makeConstraints { make in
  73. make.top.equalTo(infoLab.snp.bottom).offset(30)
  74. make.leading.equalTo(leading)
  75. make.trailing.equalTo(-leading)
  76. }
  77. let updateBtn = UIButton.createButton(title: "Update".localized,backgroundColor: .white,font: .font(size: 16,weight: .medium),titleColor: "#111111".uiColor,corner: 24.0){ [weak self] in
  78. guard let self = self else { return }
  79. if let url = URL(string: "https://apps.apple.com/app/id\(appid)"),
  80. UIApplication.shared.canOpenURL(url) {
  81. UIApplication.shared.open(url)
  82. self.dismiss(animated: true)
  83. }
  84. }
  85. alertContent.addSubview(updateBtn)
  86. updateBtn.snp.makeConstraints { make in
  87. make.top.equalTo(infoLab1.snp.bottom).offset(24)
  88. make.leading.equalTo(38)
  89. make.trailing.equalTo(-38)
  90. make.height.equalTo(48)
  91. make.bottom.equalTo(-20)
  92. }
  93. }
  94. }