refactor: split CollectiblesTab to CollectiblesContainer and Header

This commit is contained in:
Jonathan Rainville 2020-08-18 15:10:30 -04:00 committed by Iuri Matias
parent 9ffd58e5b0
commit 76efdd499b
5 changed files with 135 additions and 90 deletions

View File

@ -31,6 +31,10 @@ Item {
anchors.topMargin: 20 anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 24 anchors.leftMargin: 24
Component.onCompleted: {
walletBtn.enabled = true
}
StyledText { StyledText {
//% "Wallet Tab" //% "Wallet Tab"
text: qsTrId("wallet-tab") text: qsTrId("wallet-tab")

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import "../../../imports" import "../../../imports"
import "../../../shared" import "../../../shared"
import "./components/collectiblesComponents"
Item { Item {
property bool isLoading: true property bool isLoading: true
@ -30,96 +31,10 @@ Item {
Component { Component {
id: collectiblesListComponent id: collectiblesListComponent
Rectangle { CollectiblesContainer {
property bool hovered: false collectibleName: "CryptoKitties"
collectibleIconSource: "../../img/collectibles/CryptoKitties.png"
id: collectibleHeader isLoading: root.isLoading
height: 64
width: parent.width
color: hovered ? Style.current.backgroundHover : Style.current.transparent
border.width: 0
radius: Style.current.radius
Image {
id: collectibleIconImage
source: "../../img/collectibles/CryptoKitties.png"
width: 40
height: 40
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: "CryptoKitties"
anchors.left: collectibleIconImage.right
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Loader {
active: true
sourceComponent: root.isLoading ? loadingComponent : handleComponent
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Component {
id: loadingComponent
LoadingImage {}
}
Component {
id: handleComponent
Item {
id: element1
width: childrenRect.width
height: numberCollectibleText.height
StyledText {
id: numberCollectibleText
color: Style.current.secondaryText
// TODO change with number of current collectible
text: "6"
font.pixelSize: 15
anchors.verticalCenter: parent.verticalCenter
}
SVGImage {
id: caretImg
anchors.verticalCenter: parent.verticalCenter
source: "../../img/caret.svg"
width: 11
anchors.left: numberCollectibleText.right
anchors.leftMargin: Style.current.padding
fillMode: Image.PreserveAspectFit
}
ColorOverlay {
anchors.fill: caretImg
source: caretImg
color: Style.current.black
}
}
}
MouseArea {
enabled: !root.isLoading
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onEntered: {
collectibleHeader.hovered = true
}
onExited: {
collectibleHeader.hovered = false
}
onClicked: {
console.log('Open collectibles')
}
}
} }
} }

View File

@ -0,0 +1,24 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import "../../../../../imports"
import "../../../../../shared"
Item {
property url collectibleIconSource: "../../../../img/collectibles/CryptoKitties.png"
property string collectibleName: "CryptoKitties"
property bool isLoading: true
id: root
CollectiblesHeader {
collectibleName: root.collectibleName
collectibleIconSource: root.collectibleIconSource
isLoading: root.isLoading
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/

View File

@ -0,0 +1,99 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import "../../../../../imports"
import "../../../../../shared"
Rectangle {
property url collectibleIconSource: "../../../../img/collectibles/CryptoKitties.png"
property string collectibleName: "CryptoKitties"
property bool isLoading: true
property bool hovered: false
id: collectibleHeader
height: 64
width: parent.width
color: hovered ? Style.current.backgroundHover : Style.current.transparent
border.width: 0
radius: Style.current.radius
Image {
id: collectibleIconImage
source: collectibleHeader.collectibleIconSource
width: 40
height: 40
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: collectibleHeader.collectibleName
anchors.left: collectibleIconImage.right
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Loader {
active: true
sourceComponent: collectibleHeader.isLoading ? loadingComponent : handleComponent
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Component {
id: loadingComponent
LoadingImage {}
}
Component {
id: handleComponent
Item {
id: element1
width: childrenRect.width
height: numberCollectibleText.height
StyledText {
id: numberCollectibleText
color: Style.current.secondaryText
// TODO change with number of current collectible
text: "6"
font.pixelSize: 15
anchors.verticalCenter: parent.verticalCenter
}
SVGImage {
id: caretImg
anchors.verticalCenter: parent.verticalCenter
source: "../../../../img/caret.svg"
width: 11
anchors.left: numberCollectibleText.right
anchors.leftMargin: Style.current.padding
fillMode: Image.PreserveAspectFit
}
ColorOverlay {
anchors.fill: caretImg
source: caretImg
color: Style.current.black
}
}
}
MouseArea {
enabled: !collectibleHeader.isLoading
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onEntered: {
collectibleHeader.hovered = true
}
onExited: {
collectibleHeader.hovered = false
}
onClicked: {
console.log('Open collectibles')
}
}
}

View File

@ -30,6 +30,7 @@ SOURCES = *.qml \
app/AppLayouts/Profile/Sections/Contacts/*.qml \ app/AppLayouts/Profile/Sections/Contacts/*.qml \
app/AppLayouts/Wallet/*.qml \ app/AppLayouts/Wallet/*.qml \
app/AppLayouts/Wallet/components/*.qml \ app/AppLayouts/Wallet/components/*.qml \
app/AppLayouts/Wallet/components/collectiblesComponents/*.qml \
app/AppLayouts/Wallet/data/*.qml \ app/AppLayouts/Wallet/data/*.qml \
} }
@ -151,6 +152,8 @@ DISTFILES += \
app/AppLayouts/Wallet/ReceiveModal.qml \ app/AppLayouts/Wallet/ReceiveModal.qml \
app/AppLayouts/Wallet/components/HeaderButton.qml \ app/AppLayouts/Wallet/components/HeaderButton.qml \
app/AppLayouts/Profile/Sections/Data/locales.js \ app/AppLayouts/Profile/Sections/Data/locales.js \
app/AppLayouts/Wallet/components/collectiblesComponents/CollectiblesContainer.qml \
app/AppLayouts/Wallet/components/collectiblesComponents/CollectiblesHeader.qml \
fonts/InterStatus/InterStatus-Black.otf \ fonts/InterStatus/InterStatus-Black.otf \
fonts/InterStatus/InterStatus-BlackItalic.otf \ fonts/InterStatus/InterStatus-BlackItalic.otf \
fonts/InterStatus/InterStatus-Bold.otf \ fonts/InterStatus/InterStatus-Bold.otf \