package com.isidroid.c23.ext

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.compose.ui.graphics.Color
import androidx.core.content.ContextCompat
import com.isidroid.c23.BuildConfig
import com.isidroid.c23.constant.AppBuildType
import com.isidroid.c23.data.source.settings.Settings
import kotlin.random.Random

fun isStage() = Settings.buildType == AppBuildType.STAGE
fun isDev() = Settings.buildType == AppBuildType.DEV
fun isMock() = Settings.buildType == AppBuildType.MOCK

fun isDebug() = BuildConfig.DEBUG || isDev() || isStage() || isMock()

fun randomColor(): Color {
    val random = Random.Default
    return Color(
        red = random.nextFloat(),
        green = random.nextFloat(),
        blue = random.nextFloat(),
        alpha = 1.0f
    )
}

val Context.hasNotificationPermission: Boolean
    get() {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return true
        return ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED
    }