#include "../avatarui_common.lua"

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

    local item = Ui.Frame
    {
        w = 350,
        h = 50,

        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",

            w = 350,
            h = 50,

            Ui.Rect
            {
                resizeToParent = true,
                cornerRadius = 7,
                color = 0x10000009B
            },

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

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

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

                w = 41,
                h = 41,
                color = { 0.8, 0.8, 0.8 },

                id = "lockIcon",
                path = "avatarui/resources/lockicon.png",
                visible = bindSkin.isLocked
            },

            Ui.Image
            {
                id = "tickMark",

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

                w = 42,
                h = 42,

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

        onPreDraw = function(self)
            UiClipRect(self.w + 3, self.h + 3)
        end
    }

    return item:new(obj)
end
