package com.ponzischeme89.memby.ui

internal enum class HomeGreetingPeriod(val words: String) {
    MORNING("Good morning"),
    AFTERNOON("Good afternoon"),
    EVENING("Good evening"),
}

internal fun homeGreetingPeriod(hourOfDay: Int): HomeGreetingPeriod = when (hourOfDay) {
    in 5..11 -> HomeGreetingPeriod.MORNING
    in 12..16 -> HomeGreetingPeriod.AFTERNOON
    else -> HomeGreetingPeriod.EVENING
}

/** The greeting lives between leaving the hero and leaving Continue Watching. */
internal fun shouldShowHomeGreeting(
    hasHero: Boolean,
    focusedRowId: String?,
    rowIds: List<String>,
): Boolean {
    if (!hasHero || focusedRowId == null) return false
    val focusedIndex = rowIds.indexOf(focusedRowId)
    val continueIndex = rowIds.indexOf("continue")
    return focusedIndex >= 0 && continueIndex >= 0 && focusedIndex <= continueIndex
}
