package com.example.smartlab

import android.annotation.SuppressLint
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.view.View
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import com.example.smartlab.databinding.ActivityLodaingBinding
import com.example.smartlab.databinding.WelcomeWindowBinding
import kotlin.math.round
lateinit var binding: ActivityLodaingBinding
class LoadingActivity : AppCompatActivity() {
    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityLodaingBinding.inflate(layoutInflater)
        setContentView(binding.root)
        val intent = Intent(this, AnalizesActivity::class.java)

        val timer = object: CountDownTimer(30000, 1000) {
            override fun onTick(millisUntilFinished: Long) {

                binding.Rotate.animate().apply {
                    duration = 500
                    rotationYBy(360f)
                    rotationY(360f)
                }.start()
                binding.load.setText("Связываемся с банком...")


                if(millisUntilFinished < 15000){
                    binding.load.setText("Производим оплату...")
                    binding.Rotate.animate().apply {
                        duration = 500
                        rotationXBy(360f)
                        rotationX(360f)
                    }.start()
                }
            }

            override fun onFinish() {
                startActivity(intent)
            }
        }
        timer.start()


    }
}