use cvkg_core::{View, Never, Rect, Renderer};

/// Static image view
pub struct Image {
    name: String,
}

impl Image {
    /// Create a new Image view from an asset name or path.
    pub fn new(name: impl Into<String>) -> Self {
        Self { name: name.into() }
    }
}

impl View for Image {
    type Body = Never;
    fn body(self) -> Self::Body { unreachable!() }

    fn render(&self, renderer: &mut dyn Renderer, rect: Rect) {
        renderer.draw_image(&self.name, rect);
    }
}

/// Asynchronous image view that loads from a URL or slow source
pub struct AsyncImage {
    url: String,
    // In a real implementation, this would track loading state
}

impl AsyncImage {
    /// Create a new AsyncImage view from a URL.
    pub fn new(url: impl Into<String>) -> Self {
        Self { url: url.into() }
    }
}

impl View for AsyncImage {
    type Body = Never;
    fn body(self) -> Self::Body { unreachable!() }

    fn render(&self, renderer: &mut dyn Renderer, rect: Rect) {
        // For now, we just draw it as a normal image.
        // The underlying renderer/asset system should handle the caching.
        renderer.draw_image(&self.url, rect);
    }
}
