//
//  SigninVC.swift
//  Garmentoo
//
//  Created by ANGEL FS on 24/03/22.
//

import UIKit
import MJSnackBar

class SigninVC: UIViewController {

    
    @IBOutlet weak var mobText: UITextField!
    let validation = Validation()
    var snackBar: MJSnackBar!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.viewLoadingProperties()
    }
    
    //Button Actions
    @IBAction func signupPressed(_ sender: Any) {
        let sb = UIStoryboard(name: "Onboarding", bundle: nil)
        let nextVc = sb.instantiateViewController(withIdentifier: "signup")as! SignUpVC
        self.navigationController?.pushViewController(nextVc, animated: true)
    }
    
    @IBAction func loginTapped(_ sender: Any) {
        let mob : String = (self.mobText.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))!
        let validMobile = self.validation.validPhoneNumber(phoneNumber: mob)
        if mobText.text == ""
        {
            self.showSnackBar(Message:"Please enter the mobile number" , snackbar: self.snackBar)
            return
        }
        else if (validMobile == false)
        {
            self.showSnackBar(Message:"Invalid mobile number" , snackbar: self.snackBar)
            return
        }
        let sb = UIStoryboard(name: "Onboarding", bundle: nil)
        let nextVc = sb.instantiateViewController(withIdentifier: "verificationVC")as! VerificationVC
        self.navigationController?.pushViewController(nextVc, animated: true)
    }
    
}


extension SigninVC
{
    func viewLoadingProperties()
    {
        self.snackBar =  MJSnackBar(onView: self.view)
        self.navigationController?.navigationBar.isHidden = true

    }
}
