class_name ItemUI extends Control

@export var name_label: Label
@export var icon_texture: TextureRect

var _default_text: String
var _default_icon: Texture2D

func _ready() -> void:
    _default_text = name_label.text
    _default_icon = icon_texture.texture

func bind(_item: Option):
    if _item.is_none():
        unbind()
    else:
        var item = _item.unwrap()
        name_label.text = item.name
        icon_texture.texture = item.icon

func unbind():
    name_label.text = _default_text
    icon_texture.texture = _default_icon
