Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ResetPasswordVC.swift
- // hubble-ios
- //
- // Created by Appdesk Services PVT. LTD. on 13/02/24.
- // Copyright (c) 2023 hubble-ios. All rights reserved.
- //
- import UIKit
- class ResetPasswordVC: HubbleBaseVC {
- // scrolview
- lazy var contentView: UIView = {
- let view = UIView()
- view.isAccessibilityElement = false
- view.backgroundColor = UIColor.colorWith(hexString: "ffffff", alpha: 0.0)
- return view
- }()
- lazy var scrollView: UIScrollView = {
- let scroll = UIScrollView()
- scroll.translatesAutoresizingMaskIntoConstraints = false
- scroll.showsVerticalScrollIndicator = true
- scroll.isScrollEnabled = true
- scroll.isAccessibilityElement = false
- scroll.addSubview(contentView)
- contentView.snp.makeConstraints { make in
- make.height.equalTo(700)
- make.top.bottom.left.right.width.equalTo(scroll)
- }
- return scroll
- }()
- // navigation bar
- lazy var backButton: UIButton = {
- let button = UIButton()
- button.accessibilityElement(id: AccessIdentifier.backButton, label: AccessLabel.backButton)
- button.backgroundColor = .colorWhiteAlpha1
- button.tintColor = .white
- button.hubbleAction(forControlEvents: .touchUpInside) {
- self.navigationController?.popViewController(animated: true)
- }
- button.corner(cornerRadius: 10)
- button.setImage(.backButton, for: .normal)
- return button
- }()
- let titleLabel: UILabel = {
- let label = UILabel()
- label.font = .fontBold20
- label.text = "Reset Password"
- return label
- }()
- // page Content
- lazy var appIcon: UIImageView = {
- let imageView = UIImageView()
- imageView.image = .hubbleLogo
- imageView.isAccessibilityElement = false
- return imageView
- }()
- lazy var forgotPasswordLabel: UILabel = {
- let label = UILabel()
- label.text = "Reset\nPassword"
- label.font = .fontBold20
- label.numberOfLines = 2
- label.textColor = .white
- label.textAlignment = .center
- return label
- }()
- lazy var descreptionLabel: UILabel = {
- let label = UILabel()
- label.textColor = .white
- label.font = .fontRegular14
- label.numberOfLines = 2
- label.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
- label.textAlignment = .center
- return label
- }()
- lazy var password: (container: UIView, leftImage: UIImageView, fieldTitleLabel: UILabel, textField: UITextField, button: UIButton) = {
- let password = Common.createTextField(leftImage: .lockIcon, placeholder: "signUp_enter_password".myLocalizedString, font: .fontBold16, rightButtonImage: .eyeSlashIcon)
- password.textField.textContentType = .newPassword
- password.button.addTarget(self, action: #selector(passwordTapped), for: .touchUpInside)
- password.textField.isSecureTextEntry = true
- password.fieldTitleLabel.text = "password_text".myLocalizedString
- password.textField.textContentType = .newPassword
- return password
- }()
- lazy var confirmPassword: (container: UIView, leftImage: UIImageView, fieldTitleLabel: UILabel, textField: UITextField, button: UIButton) = {
- let confirmPassword = Common.createTextField(leftImage: .lockIcon, placeholder: "sigUp_enter_confirm_Password".myLocalizedString, font: .fontBold16, rightButtonImage: .eyeSlashIcon)
- confirmPassword.textField.textContentType = .newPassword
- confirmPassword.button.addTarget(self, action: #selector(confirmPasswordTapped), for: .touchUpInside)
- confirmPassword.textField.isSecureTextEntry = true
- confirmPassword.fieldTitleLabel.text = "confirm Password_text".myLocalizedString
- confirmPassword.textField.textContentType = .newPassword
- return confirmPassword
- }()
- lazy var submitButton: UIButton = {
- let button = UIButton()
- button.corner(cornerRadius: 12)
- button.setTitle("reviewRating_Submit_text".myLocalizedString, for: .normal)
- button.setTitleColor(.primaryColor, for: .normal)
- button.hubbleAction(forControlEvents: .touchUpInside) {
- self.submitButtonTapped()
- }
- button.titleLabel?.font = .fontBold20
- button.backgroundColor = .white
- return button
- }()
- var emailString: String = K.emptyString
- override func viewDidLoad() {
- super.viewDidLoad()
- super.isSwipeToBackActive = true
- setupUI()
- }
- @objc func passwordTapped() {
- if password.textField.isSecureTextEntry == true {
- password.textField.isSecureTextEntry = false
- password.button.setImage(.eyeIcon, for: .normal)
- } else {
- password.textField.isSecureTextEntry = true
- password.button.setImage(.eyeSlashIcon, for: .normal)
- }
- }
- @objc func confirmPasswordTapped() {
- if confirmPassword.textField.isSecureTextEntry == true {
- confirmPassword.textField.isSecureTextEntry = false
- confirmPassword.button.setImage(.eyeIcon, for: .normal)
- } else {
- confirmPassword.textField.isSecureTextEntry = true
- confirmPassword.button.setImage(.eyeSlashIcon, for: .normal)
- }
- }
- func submitButtonTapped() {
- let isValidPassword = password.textField.isValid()
- let isPassAndConfirmPassMatched = confirmPassword.textField.isEqual(text: password.textField.text ?? K.emptyString)
- let isValidStrongPassword = password.textField.validateStrongPassword()
- let isValidConfirmStrongPassword = confirmPassword.textField.validateStrongPassword()
- if isValidPassword && isPassAndConfirmPassMatched && isValidStrongPassword && isValidConfirmStrongPassword {
- password.textField.resignFirstResponder()
- confirmPassword.textField.resignFirstResponder()
- } else {
- if !isValidPassword {
- showAlert(message: "validation_signUp_password".myLocalizedString)
- } else if !isValidStrongPassword {
- showAlert(message: "validation_signUp_Strong_password".myLocalizedString)
- } else if !isValidConfirmStrongPassword {
- showAlert(message: "validation_signUp_confirm_strong_password".myLocalizedString)
- } else if !isPassAndConfirmPassMatched {
- showAlert(message: "validation_signUp_confirm_password".myLocalizedString)
- }
- }
- }
- func setupUI() {
- self.view.addSubview(scrollView)
- scrollView.snp.makeConstraints { make in
- make.top.equalTo(self.view.safeAreaLayoutGuide)
- make.bottom.left.right.equalTo(self.view)
- make.width.equalTo(self.view)
- make.bottom.equalTo(self.view.safeAreaLayoutGuide)
- }
- contentView.addSubview(backButton)
- backButton.snp.makeConstraints { make in
- make.top.equalTo(contentView.snp.top).offset(12)
- make.left.equalTo(contentView.snp.left).offset(20)
- make.height.width.equalTo(40)
- }
- contentView.addSubview(titleLabel)
- titleLabel.snp.makeConstraints { make in
- make.top.equalTo(contentView.snp.top).offset(20)
- make.centerX.equalTo(contentView)
- }
- contentView.addSubview(appIcon)
- appIcon.snp.makeConstraints { make in
- make.centerX.equalTo(contentView)
- make.top.equalTo(titleLabel.bottom).offset(24)
- make.height.equalTo(130)
- make.width.equalTo(124)
- }
- contentView.addSubview(forgotPasswordLabel)
- forgotPasswordLabel.snp.makeConstraints { make in
- make.centerX.equalTo(contentView)
- make.top.equalTo(appIcon.bottom).offset(topOffset)
- make.width.equalTo(contentView)
- }
- contentView.addSubview(descreptionLabel)
- descreptionLabel.snp.makeConstraints { make in
- make.centerX.equalTo(contentView)
- make.top.equalTo(forgotPasswordLabel.bottom).offset(24)
- make.width.equalTo(270)
- }
- contentView.addSubview(password.container)
- password.container.snp.makeConstraints { make in
- make.top.equalTo(descreptionLabel.bottom).offset(44)
- make.left.right.equalTo(contentView)
- make.height.equalTo(Common.containerHeight96)
- }
- contentView.addSubview(confirmPassword.container)
- confirmPassword.container.snp.makeConstraints { make in
- make.top.equalTo(password.container.bottom).offset(topOffset)
- make.left.right.equalTo(contentView)
- make.height.equalTo(Common.containerHeight96)
- }
- contentView.addSubview(submitButton)
- submitButton.snp.makeConstraints { make in
- make.top.equalTo(confirmPassword.container.bottom).offset(24)
- make.left.equalTo(contentView).offset(leftOffset)
- make.right.equalTo(contentView).inset(rightInset)
- make.height.equalTo(64)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment