import Quickshell
import QtQuick
import ZShell.Config
import qs.Components
import qs.Helpers
import qs.Services

Item {
	id: root

	required property bool isCurrent
	required property var modelData // FileSystemEntry-like {path, relativePath}
	required property real tileHeight
	required property real tileWidth
	required property PersistentProperties visibilities

	signal requestActivate

	implicitHeight: tileHeight + Tokens.padding.large * 2
	implicitWidth: tileWidth

	CustomClippingRect {
		id: image

		anchors.horizontalCenter: parent.horizontalCenter
		color: Colors.tPalette.m3surfaceContainer
		implicitHeight: root.tileHeight
		implicitWidth: root.tileWidth
		radius: Tokens.rounding.small
		y: Tokens.padding.large

		MaterialIcon {
			anchors.centerIn: parent
			color: Colors.tPalette.m3outline
			font.pointSize: Tokens.font.size.extraLarge * 2
			font.weight: 600
			text: "image"
		}

		CachingImage {
			anchors.bottom: parent.bottom
			anchors.horizontalCenter: parent.horizontalCenter
			anchors.top: parent.top
			cache: true
			fillMode: Image.PreserveAspectCrop
			height: root.tileHeight
			path: root.modelData ? root.modelData.path : ""
			smooth: root.isCurrent
			sourceSize.height: root.tileHeight
			sourceSize.width: root.tileHeight * (16 / 9)
			width: root.tileHeight * (16 / 9)
		}

		StateLayer {
			onClicked: root.requestActivate()
		}
	}
}
