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

import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import de.sebse.fuplanner2.database.Announcement
import de.sebse.fuplanner2.database.Attachment
import de.sebse.fuplanner2.utils.Faker
import de.sebse.fuplanner2.utils.getFaker

class AnnouncementPreviewProvider(private val faker: Faker = getFaker()) : PreviewParameterProvider<Announcement> {
    override val values = generateSequence { getItem() }

    private fun getItem(): Announcement {
        val title = faker.strings.title()
        return Announcement(
            faker.primitive.long(0, 100),
            faker.primitive.long(0, 100),
            faker.other.lastRefreshed(),
            faker.strings.uuid(title),
            title,
            faker.strings.lorem(100, 1000),
            faker.other.date(-20, -2),
            "${faker.name.firstName()} ${faker.name.lastName()}",
            AttachmentPreviewProvider(faker).values
                .take(faker.primitive.int(1, 4))
                .toList()
        )
    }
}

class AttachmentPreviewProvider(private val faker: Faker = getFaker()) : PreviewParameterProvider<Attachment> {
    override val values = generateSequence { getItem() }

    private fun getItem(): Attachment {
        return Attachment(
            faker.internet.url(),
            faker.strings.title(),
            faker.internet.mime()
        )
    }
}
