ChandanAppdesk

ForgotPasswordVC

Feb 13th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 6.23 KB | Source Code | 0 0
  1. //
  2. // ForgotPasswordVC.swift
  3. // hubble-ios
  4. //
  5. // Created by Appdesk Services PVT. LTD. on 13/02/24.
  6. // Copyright (c) 2023 hubble-ios. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ForgotPasswordVC: HubbleBaseVC {
  12.  
  13.     // scrolview
  14.     lazy var contentView: UIView = {
  15.         let view = UIView()
  16.         view.isAccessibilityElement = false
  17.         view.backgroundColor = UIColor.colorWith(hexString: "ffffff", alpha: 0.0)
  18.         return view
  19.     }()
  20.  
  21.     lazy var scrollView: UIScrollView = {
  22.         let scroll = UIScrollView()
  23.         scroll.translatesAutoresizingMaskIntoConstraints = false
  24.         scroll.showsVerticalScrollIndicator = true
  25.         scroll.isScrollEnabled = true
  26.         scroll.isAccessibilityElement = false
  27.         scroll.addSubview(contentView)
  28.         contentView.snp.makeConstraints { make in
  29.             make.height.equalTo(700)
  30.             make.top.bottom.left.right.width.equalTo(scroll)
  31.         }
  32.         return scroll
  33.     }()
  34.  
  35.     // navigation bar
  36.     lazy var backButton: UIButton = {
  37.         let button = UIButton()
  38.         button.accessibilityElement(id: AccessIdentifier.backButton, label: AccessLabel.backButton)
  39.         button.backgroundColor = .colorWhiteAlpha1
  40.         button.tintColor = .white
  41.         button.hubbleAction(forControlEvents: .touchUpInside) {
  42.             self.navigationController?.popViewController(animated: true)
  43.         }
  44.         button.corner(cornerRadius: 10)
  45.         button.setImage(.backButton, for: .normal)
  46.         return button
  47.     }()
  48.  
  49.     let titleLabel: UILabel = {
  50.        let label = UILabel()
  51.         label.font = .fontBold20
  52.         label.text = "Forgot Password"
  53.         return label
  54.     }()
  55.  
  56.     // page Content
  57.     lazy var appIcon: UIImageView = {
  58.         let imageView = UIImageView()
  59.         imageView.image = .hubbleLogo
  60.         imageView.isAccessibilityElement = false
  61.         return imageView
  62.     }()
  63.     lazy var forgotPasswordLabel: UILabel = {
  64.         let label = UILabel()
  65.         label.text = "Forgot\nPassword"
  66.         label.font = .fontBold20
  67.         label.numberOfLines = 2
  68.         label.textColor = .white
  69.         label.textAlignment = .center
  70.         return label
  71.     }()
  72.     lazy var descreptionLabel: UILabel = {
  73.         let label = UILabel()
  74.         label.textColor = .white
  75.         label.font = .fontRegular14
  76.         label.numberOfLines = 2
  77.         label.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
  78.         label.textAlignment = .center
  79.         return label
  80.     }()
  81.    
  82.     lazy var email: (container: UIView, leftImage: UIImageView, fieldTitleLabel: UILabel, textField: UITextField, button: UIButton) = {
  83.         let email = Common.createTextField(leftImage: .mailLogo, placeholder: "Enter email", font: .fontRegular18)
  84.         email.fieldTitleLabel.text = "Email"
  85.         email.textField.textContentType = .emailAddress
  86.         email.textField.keyboardType = .emailAddress
  87.         email.textField.text = self.emailString
  88.         return email
  89.     }()
  90.  
  91.     lazy var submitButton: UIButton = {
  92.         let button = UIButton()
  93.         button.corner(cornerRadius: 12)
  94.         button.setTitle("reviewRating_Submit_text".myLocalizedString, for: .normal)
  95.         button.setTitleColor(.primaryColor, for: .normal)
  96.         button.hubbleAction(forControlEvents: .touchUpInside) {
  97.             self.submitButtonTapped()
  98.         }
  99.         button.titleLabel?.font = .fontBold20
  100.         button.backgroundColor = .white
  101.         return button
  102.     }()
  103.    
  104.     var emailString: String = K.emptyString
  105.    
  106.     override func viewDidLoad() {
  107.         super.viewDidLoad()
  108.         super.isSwipeToBackActive = true
  109.         setupUI()
  110.     }
  111.  
  112.     func submitButtonTapped() {
  113.         let isValidEmail = Validation().isValidEmail(email.textField.text ?? K.emptyString)
  114.         if isValidEmail {
  115.             // TODO: Call Send OTP API
  116.         } else {
  117.             showAlert(message: "validation_signUp_email".myLocalizedString)
  118.         }
  119.     }
  120.  
  121.     func setupUI() {
  122.         self.view.addSubview(scrollView)
  123.         scrollView.snp.makeConstraints { make in
  124.             make.top.equalTo(self.view.safeAreaLayoutGuide)
  125.             make.bottom.left.right.equalTo(self.view)
  126.             make.width.equalTo(self.view)
  127.             make.bottom.equalTo(self.view.safeAreaLayoutGuide)
  128.         }
  129.         contentView.addSubview(backButton)
  130.         backButton.snp.makeConstraints { make in
  131.             make.top.equalTo(contentView.snp.top).offset(12)
  132.             make.left.equalTo(contentView.snp.left).offset(20)
  133.             make.height.width.equalTo(40)
  134.         }
  135.         contentView.addSubview(titleLabel)
  136.         titleLabel.snp.makeConstraints { make in
  137.             make.top.equalTo(contentView.snp.top).offset(20)
  138.             make.centerX.equalTo(contentView)
  139.         }
  140.         contentView.addSubview(appIcon)
  141.         appIcon.snp.makeConstraints { make in
  142.             make.centerX.equalTo(contentView)
  143.             make.top.equalTo(titleLabel.bottom).offset(24)
  144.             make.height.equalTo(130)
  145.             make.width.equalTo(124)
  146.         }
  147.         contentView.addSubview(forgotPasswordLabel)
  148.         forgotPasswordLabel.snp.makeConstraints { make in
  149.             make.centerX.equalTo(contentView)
  150.             make.top.equalTo(appIcon.bottom).offset(topOffset)
  151.             make.width.equalTo(contentView)
  152.         }
  153.         contentView.addSubview(descreptionLabel)
  154.         descreptionLabel.snp.makeConstraints { make in
  155.             make.centerX.equalTo(contentView)
  156.             make.top.equalTo(forgotPasswordLabel.bottom).offset(24)
  157.             make.width.equalTo(270)
  158.         }
  159.         contentView.addSubview(email.container)
  160.         email.container.snp.makeConstraints { make in
  161.             make.top.equalTo(descreptionLabel.bottom).offset(44)
  162.             make.left.right.equalTo(contentView)
  163.             make.height.equalTo(Common.containerHeight96)
  164.         }
  165.         contentView.addSubview(submitButton)
  166.         submitButton.snp.makeConstraints { make in
  167.             make.top.equalTo(email.container.bottom).offset(24)
  168.             make.left.equalTo(email.container).offset(leftOffset)
  169.             make.right.equalTo(email.container).inset(rightInset)
  170.             make.height.equalTo(64)
  171.         }
  172.     }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment