package com.zaojiao.component.common

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import coil.compose.AsyncImage

object Images {
    @Composable
    fun Network(
        modifier: Modifier = Modifier,
        url: String,
        description: String? = null,
        contentScale: ContentScale = ContentScale.Crop,
    ) {
        AsyncImage(
            model = url,
            contentDescription = description,
            modifier = modifier,
            contentScale = contentScale,
            error = ColorPainter(Colors.FF999999),
        )
    }

    @Composable
    fun Resource(
        modifier: Modifier = Modifier,
        @DrawableRes id: Int,
        description: String? = null,
        contentScale: ContentScale = ContentScale.Crop,
    ) {
        Image(
            painter = painterResource(id = id),
            contentDescription = description,
            modifier = modifier,
            contentScale = contentScale,
        )
    }
}