#include "../avatarui_common.lua"

Avatar.ModdedSkinItemView = function(obj)
    local bindSkin = Ui.bind().viewModel.skinModel
    local ds = Ui.bind().drawState

    local item = Ui.Frame
    {
        w = 368,
        h = 42,

        mainView = {
            margin = 
            { 
                top = bindSkin.isLocked:bnot():band(ds.pressed):band(2):bor(0), 
                left = bindSkin.isLocked:bnot():band(ds.pressed):band(2):bor(0)
            }
        },

        Ui.Frame
        {
            id = "mainView",
            resizeToParent = true,

            Ui.RectOutline
            {
                id = "highlight",
                resizeToParent = true,
                thickness = 2,
                cornerRadius = 4,
                color = bindSkin.isFocused:band({ 1, 1, 0.5 }):bor({ 0.7, 0.7, 0.3}),
                visible = bindSkin.isFocused:bor(Ui.bind().parent.drawState.hovered)
            },

            Ui.Rect
            {
                id = "preview",

                vAlign = Ui.V.Middle,
                w = 36,
                h = 36,
                margin = { left = 3 },

                cornerRadius = 4,
                fillImagePath = bindSkin.preview
            },

            Ui.Text
            {
                vAlign = Ui.V.Middle,
                margin = { left = 50 },
                id = "skinName",
                font = { "medium.ttf", 22 },
                text = bindSkin.name,
                color = { 1, 1, 1, 0.8 },
                uniformHeight = true
            },

            Ui.Image
            {
                id = "tickMark",

                vAlign = Ui.V.Middle,
                hAlign = Ui.H.Right,
                margin = { right = 3 },

                w = 36,
                h = 36,

                path = "avatarui/resources/tickmark.png",
                visible = bindSkin.isSelected
            }
        }
    }

    return item:new(obj)
end
