File size: 6,600 Bytes
4f675f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import GeneralBiz
import FusionUI
import FunctionPanel
import Purchase 1.0
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import GeneralBizUI

import VECreator
Item {
    id: root
    property string iconUrl: ""
    property string title: ""
    property var contextId
    property bool selected: false
    property bool showloading: false
    property bool showStaticImage: false
    property string vipIconSource: ""
    property size vipIconSize: Qt.size(0,0)
    property size vipIconSourceSize: Qt.size(0,0)
    property string vipUseLeftText: ""
    property bool enabledButtonOpacity: false  // Do you need to gray the button icon?
    property color selectedBorderColor: LVColor.Brand_Primary_Default
    property alias imageFillMode: resourceImage.fillMode

    opacity: (enabledButtonOpacity && !enabled) ? 0.2 : 1

    signal click(var contextId)
    Column {
        id: column
        height: parent.height
        width: parent.width
        spacing: 4
        Rectangle{
            id: img
            radius: 8
            width: 62
            height: 62
            border.width: 1.5
            border.color: LVColor.Fill_Background_Level5

            Image{
                source: "qrc:/FunctionPanel/resources/beautyItemEmpty.svg"
                width: 24
                height: 24
                sourceSize: Qt.size(24, 24)
                visible: showStaticImage ? !staticImage.visible : !resourceImage.visible
                anchors.centerIn: parent
            }
            AnimatedImage {
                id: resourceImage
                anchors.fill: parent
                source: iconUrl
                playing: false
                asynchronous: AbTestConfigSettings.enableAnimatedImageAsync
                visible: iconUrl.length > 0 && !showStaticImage
                layer.enabled: AppPerformanceGlobalConfig.layerVisibleOptimizeEnable ? resourceImage.visible : true
                layer.effect: OpacityMask {
                    maskSource: Item {
                        width: resourceImage.width
                        height: resourceImage.height
                        Rectangle {
                            anchors.centerIn: parent
                            width: resourceImage.width
                            height:resourceImage.height

                            radius: 8
                        }
                    }
                }
            }

            Image {
                id: staticImage
                visible: iconUrl.length > 0 && showStaticImage
                source: iconUrl
                width: img.width
                height: img.height
                sourceSize: Qt.size(img.width, img.height)
                antialiasing: true
                smooth: true
                anchors.fill: parent
            }
            Image {
                id: vipLogo
                visible: vipIconSource.length > 0
                source: vipIconSource
                width: vipIconSize.width
                height: vipIconSize.height
                sourceSize: vipIconSourceSize
                antialiasing: true
                smooth: true
                anchors {
                    left: parent.left
                    leftMargin: 3
                    top: parent.top
                    topMargin: 3
                }
            }
            Rectangle {
                id: loading_image
                visible: showloading
                color: LVColor.Alpha50B_Black_05

                anchors{
                    right: parent.right
                    bottom: parent.bottom
                    rightMargin: 4
                    bottomMargin: 4
                }
                width: 18
                height: width
                radius: width / 2

                Image {
                    source: "qrc:/MaterialPanel/resource/Base/loading.svg"
                    width: 18
                    height: width
                    smooth: true
                    antialiasing: true
                    sourceSize: Qt.size(width * 2, height * 2)

                    NumberAnimation {
                        running: loading_image.visible
                        loops: Animation.Infinite
                        target: loading_image
                        from: 0
                        to: 360
                        property: "rotation"
                        duration: 1000
                    }
                }
            }

            Rectangle {
                // Border Rect
                id: imgBorderRect
                visible: showStaticImage ? staticImage.visible : resourceImage.visible
                radius: 8
                anchors.fill: showStaticImage ? staticImage : resourceImage
                color: LVColor.Clear
                border.color: LVColor.Clear

                border.width: 1.5
            }

            color: LVColor.Fill_Background_Level5
            MouseArea{
                hoverEnabled: true
                anchors.fill: parent
                onClicked: {
                    root.click(contextId)
                }
                onEntered: {
                    resourceImage.playing = true
                }
                onExited: {
                    resourceImage.playing = false
                }
            }
            LVToolTip {
                anchors.fill: parent
                needClickEvent: true
                needFollowMouse: true
                offsetY: 4
                text: vipUseLeftText
                visible: vipUseLeftText.length > 0
                onClicked: {
                    root.click(contextId)
                }
            }
        }

        Text{
            id: text
            anchors.horizontalCenter: column.horizontalCenter
            text: title
            horizontalAlignment: Text.AlignHCenter
            width: column.width
            font: LVFont.OverlineRegular10
            color: LVColor.Text_Tertiary
            elide: Text.ElideRight
            LVToolTip {
                anchors.fill: parent
                visible: parent.truncated
                text: parent.text
            }
        }
    }
    onSelectedChanged: {
        img.border.color = selected ? selectedBorderColor : LVColor.Clear
        imgBorderRect.border.color = selected ? selectedBorderColor : LVColor.Clear
    }
}