package de.sebse.fuplanner2.ui.tools.previews

import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import de.sebse.fuplanner2.database.Event
import de.sebse.fuplanner2.utils.Faker
import de.sebse.fuplanner2.utils.getFaker
import java.util.*

class EventPreviewProvider(private val faker: Faker = getFaker()) : PreviewParameterProvider<Event> {
    val title = faker.strings.title()
    override val values = generateSequence(0) { it + 1 }
        .map { getItem(it) }

    private fun getItem(num: Int): Event {
        val isExam = num == 20
        val cal = Calendar.getInstance()
        cal.add(Calendar.DATE, num / 2 * 7 + num % 2 * 3)
        cal.set(Calendar.HOUR, 14 + (num % 2) * 2)
        cal.set(Calendar.MINUTE, 30)
        cal.set(Calendar.SECOND, 0)
        cal.set(Calendar.MILLISECOND, 0)

        return Event(
            faker.primitive.long(0, 100),
            faker.primitive.long(0, 100),
            faker.other.lastRefreshed(),
            title,
            90*60*1000 + (if (isExam) 1L else 0),
            cal.timeInMillis,
            "Hörsaal T9",
            if (isExam) "Klausur" else "Vorlesung",
        )
    }
}
