181 lines
4.9 KiB
QML
181 lines
4.9 KiB
QML
|
import QtQuick 2.14
|
||
|
import QtQuick.Controls 2.14
|
||
|
import QtQuick.Layouts 1.14
|
||
|
|
||
|
import AppLayouts.Chat.views.communities 1.0
|
||
|
import AppLayouts.Chat.controls.community 1.0
|
||
|
|
||
|
import Storybook 1.0
|
||
|
import Models 1.0
|
||
|
|
||
|
import SortFilterProxyModel 0.2
|
||
|
import utils 1.0
|
||
|
|
||
|
SplitView {
|
||
|
orientation: Qt.Vertical
|
||
|
SplitView.fillWidth: true
|
||
|
|
||
|
property bool globalUtilsReady: false
|
||
|
property bool mainModuleReady: false
|
||
|
|
||
|
Logs { id: logs }
|
||
|
|
||
|
QtObject {
|
||
|
function isCompressedPubKey(publicKey) {
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
function getCompressedPk(publicKey) {
|
||
|
return "compressed_" + publicKey
|
||
|
}
|
||
|
|
||
|
function getColorId(publicKey) {
|
||
|
return Math.floor(Math.random() * 10)
|
||
|
}
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
Utils.globalUtilsInst = this
|
||
|
globalUtilsReady = true
|
||
|
|
||
|
}
|
||
|
Component.onDestruction: {
|
||
|
globalUtilsReady = false
|
||
|
Utils.globalUtilsInst = {}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
QtObject {
|
||
|
function getContactDetailsAsJson() {
|
||
|
return JSON.stringify({ ensVerified: true })
|
||
|
}
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
mainModuleReady = true
|
||
|
Utils.mainModuleInst = this
|
||
|
}
|
||
|
Component.onDestruction: {
|
||
|
mainModuleReady = false
|
||
|
Utils.mainModuleInst = {}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ListModel {
|
||
|
id: members
|
||
|
|
||
|
property int counter: 0
|
||
|
|
||
|
function addMember() {
|
||
|
const i = counter++
|
||
|
const key = `pub_key_${i}`
|
||
|
|
||
|
const firstLetters = ["a", "b", "c", "d"]
|
||
|
const firstLetterIdx = Math.min(Math.floor(i / firstLetters.length),
|
||
|
firstLetters.length - 1)
|
||
|
const firstLetter = firstLetters[firstLetterIdx]
|
||
|
|
||
|
append({
|
||
|
alias: "",
|
||
|
colorId: "1",
|
||
|
displayName: `${firstLetter}contact ${i}`,
|
||
|
ensName: "",
|
||
|
icon: "",
|
||
|
isContact: true,
|
||
|
localNickname: "",
|
||
|
onlineStatus: 1,
|
||
|
pubKey: key,
|
||
|
isVerified: true,
|
||
|
isUntrustworthy: false
|
||
|
})
|
||
|
}
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
for (let i = 0; i < 33; i++)
|
||
|
addMember()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Pane {
|
||
|
SplitView.fillWidth: true
|
||
|
SplitView.fillHeight: true
|
||
|
|
||
|
Loader {
|
||
|
anchors.fill: parent
|
||
|
active: globalUtilsReady && mainModuleReady
|
||
|
|
||
|
sourceComponent: CommunityNewAirdropView {
|
||
|
id: communityNewPermissionView
|
||
|
|
||
|
CollectiblesModel {
|
||
|
id: collectiblesModel
|
||
|
}
|
||
|
|
||
|
SortFilterProxyModel {
|
||
|
id: collectiblesModelWithSupply
|
||
|
|
||
|
sourceModel: collectiblesModel
|
||
|
|
||
|
proxyRoles: [
|
||
|
ExpressionRole {
|
||
|
name: "supply"
|
||
|
expression: ((model.index + 1) * 115).toString()
|
||
|
},
|
||
|
ExpressionRole {
|
||
|
name: "infiniteSupply"
|
||
|
expression: !(model.index % 4)
|
||
|
},
|
||
|
ExpressionRole {
|
||
|
name: "chainName"
|
||
|
expression: model.index ? "Optimism" : "Arbitrum"
|
||
|
},
|
||
|
ExpressionRole {
|
||
|
|
||
|
readonly property string icon1: "network/Network=Optimism"
|
||
|
readonly property string icon2: "network/Network=Arbitrum"
|
||
|
|
||
|
name: "chainIcon"
|
||
|
expression: model.index ? icon1 : icon2
|
||
|
}
|
||
|
]
|
||
|
|
||
|
filters: ValueFilter {
|
||
|
roleName: "category"
|
||
|
value: TokenCategories.Category.Community
|
||
|
}
|
||
|
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
Qt.callLater(() => communityNewPermissionView.collectiblesModel = this)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
assetsModel: ListModel {}
|
||
|
collectiblesModel: ListModel {}
|
||
|
membersModel: members
|
||
|
|
||
|
onAirdropClicked: {
|
||
|
logs.logEvent("CommunityNewAirdropView::airdropClicked", ["airdropTokens", "addresses", "membersPubKeys"], arguments)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
LogsAndControlsPanel {
|
||
|
id: logsAndControlsPanel
|
||
|
|
||
|
SplitView.minimumHeight: 100
|
||
|
SplitView.preferredHeight: 160
|
||
|
|
||
|
logsView.logText: logs.logText
|
||
|
|
||
|
ColumnLayout {
|
||
|
MenuSeparator {}
|
||
|
|
||
|
TextEdit {
|
||
|
readOnly: true
|
||
|
selectByMouse: true
|
||
|
text: "valid address: 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc4"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|