package com.rugvedsarika.privatelog.ui

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.rugvedsarika.privatelog.R
import com.google.android.material.button.MaterialButton

class OnboardingActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val sharedPref = getSharedPreferences("PrivateLogPrefs", Context.MODE_PRIVATE)
        val isFirstRun = sharedPref.getBoolean("IS_FIRST_RUN", true)

        if (!isFirstRun) {
            // Not first run, go straight to main app
            startMainActivity()
            return
        }

        setContentView(R.layout.activity_onboarding)

        findViewById<MaterialButton>(R.id.btn_get_started).setOnClickListener {
            with(sharedPref.edit()) {
                putBoolean("IS_FIRST_RUN", false)
                apply()
            }
            startMainActivity()
        }
    }

    private fun startMainActivity() {
        startActivity(Intent(this, MainActivity::class.java))
        finish()
    }
}
