package com.applemand.zmanim.core.notifications

import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.core.content.getSystemService

object Channels {
    const val CHANNEL_ZMANIM = "ch_zmanim"
    const val CHANNEL_REMINDERS = "ch_reminders"
    const val CHANNEL_DAILY = "ch_daily"

    fun ensure(context: Context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
        val nm = context.getSystemService<NotificationManager>() ?: return

        listOf(
            NotificationChannel(CHANNEL_ZMANIM, "Zmanim",
                NotificationManager.IMPORTANCE_HIGH).apply {
                description = "Candle lighting, havdalah, fast times"
            },
            NotificationChannel(CHANNEL_REMINDERS, "Reminders",
                NotificationManager.IMPORTANCE_DEFAULT).apply {
                description = "Rosh Chodesh, holidays"
            },
            NotificationChannel(CHANNEL_DAILY, "Daily summary",
                NotificationManager.IMPORTANCE_LOW).apply {
                description = "Morning Hebrew date + Daf Yomi"
            },
        ).forEach(nm::createNotificationChannel)
    }
}
