package com.example.smartlab

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.widget.Button
import android.widget.ImageButton
import android.widget.TextView
import com.example.smartlab.databinding.ActivityCodeEmailBinding


class CodeEmail : AppCompatActivity() {
    lateinit var textView : TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_code_email)
        textView = findViewById(R.id.timer)

        // time count down for 30 seconds,
        // with 1 second as countDown interval
        object : CountDownTimer(60000, 1000) {

            // Callback function, fired on regular interval
            override fun onTick(millisUntilFinished: Long) {
                textView.setText("Отправить код повторно можно будет через " + millisUntilFinished / 1000+" секунд")
            }

            // Callback function, fired
            // when the time is up
            override fun onFinish() {
                textView.setText("ты даун")

                //сюда добавить код чтобы отправляло сообщение на почту(с кодом)
            }
        }.start()
btn_click()
        test1()

    }
    private fun btn_click()
    {
        val btn: ImageButton =findViewById(R.id.email_back)
        btn.setOnClickListener()
        {
            val intent = Intent(this,RegisterUser::class.java )
            startActivity(intent)
        }
    }


    public fun test1()
    {
        var gg: ImageButton = findViewById(R.id.proverka);
        gg.setOnClickListener()
        {
            val intent = Intent(this,CodePassActivity::class.java )
            startActivity(intent)
        }
    }

    /**
     * Kotlin Program to Generate 4 digit OTP
     *//*
    package com.includehelp.basic

    *//**
     * Function for Generate 4 digit OTP String
     * @return
     *//*
    fun generateOTP(): String {
        val randomPin = (Math.random() * 9000).toInt() + 1000
        return randomPin.toString()
    }

    // Main Method Entry Point of Program
    fun main(args: Array<String>) {
        // Call function for Generate OTP
        val otp1 = generateOTP()
        // Print OTP
        println("OTP : $otp1")
    }*/



}
