refactor(AccessExistingCommunityPopup): use StatusQ components to create components
This commit is contained in:
parent
d2232cd5c2
commit
37861bf853
|
@ -4,17 +4,19 @@ import QtGraphicalEffects 1.13
|
|||
import QtQuick.Dialogs 1.3
|
||||
|
||||
import utils 1.0
|
||||
import "../../../../../shared"
|
||||
import "../../../../../shared/popups"
|
||||
import "../../../../../shared/controls"
|
||||
import "../../../../../shared/panels"
|
||||
import "../../../../../shared/status"
|
||||
|
||||
// TODO: replace with StatusModal
|
||||
ModalPopup {
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Popups 0.1
|
||||
import StatusQ.Controls 0.1 as StatusQControls
|
||||
|
||||
import "../../../../../shared/controls"
|
||||
|
||||
StatusModal {
|
||||
id: popup
|
||||
width: 400
|
||||
height: 400
|
||||
anchors.centerIn: parent
|
||||
|
||||
property string keyValidationError: ""
|
||||
|
||||
|
@ -30,14 +32,19 @@ ModalPopup {
|
|||
}
|
||||
|
||||
//% "Access existing community"
|
||||
title: qsTrId("access-existing-community")
|
||||
header.title: qsTrId("access-existing-community")
|
||||
|
||||
onClosed: {
|
||||
popup.destroy();
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
contentItem: Item {
|
||||
width: popup.width - 32
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 16
|
||||
anchors.rightMargin: 16
|
||||
height: childrenRect.height
|
||||
|
||||
StyledTextArea {
|
||||
id: keyInput
|
||||
|
@ -47,7 +54,7 @@ ModalPopup {
|
|||
customHeight: 110
|
||||
}
|
||||
|
||||
StyledText {
|
||||
StatusBaseText {
|
||||
id: infoText1
|
||||
//% "Entering a community key will grant you the ownership of that community. Please be responsible with it and don’t share the key with people you don’t trust."
|
||||
text: qsTrId("entering-a-community-key-will-grant-you-the-ownership-of-that-community--please-be-responsible-with-it-and-don-t-share-the-key-with-people-you-don-t-trust-")
|
||||
|
@ -56,41 +63,41 @@ ModalPopup {
|
|||
anchors.topMargin: Style.current.bigPadding
|
||||
width: parent.width
|
||||
font.pixelSize: 13
|
||||
color: Style.current.secondaryText
|
||||
color: Theme.palette.baseColor1
|
||||
}
|
||||
}
|
||||
|
||||
footer: StatusButton {
|
||||
id: btnBack
|
||||
//% "Import"
|
||||
text: qsTrId("import")
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
if (!validate()) {
|
||||
return
|
||||
rightButtons: [
|
||||
StatusQControls.StatusButton {
|
||||
//% "Import"
|
||||
text: qsTrId("import")
|
||||
onClicked: {
|
||||
if (!validate()) {
|
||||
return
|
||||
}
|
||||
|
||||
let communityKey = keyInput.text.trim()
|
||||
if (!communityKey.startsWith("0x")) {
|
||||
communityKey = "0x" + communityKey
|
||||
}
|
||||
|
||||
const error = chatsModel.communities.importCommunity(communityKey, Utils.uuid())
|
||||
|
||||
if (error) {
|
||||
creatingError.text = error
|
||||
return creatingError.open()
|
||||
}
|
||||
|
||||
popup.close()
|
||||
}
|
||||
|
||||
let communityKey = keyInput.text.trim()
|
||||
if (!communityKey.startsWith("0x")) {
|
||||
communityKey = "0x" + communityKey
|
||||
MessageDialog {
|
||||
id: creatingError
|
||||
//% "Error importing the community"
|
||||
title: qsTrId("error-importing-the-community")
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
|
||||
const error = chatsModel.communities.importCommunity(communityKey, Utils.uuid())
|
||||
|
||||
if (error) {
|
||||
creatingError.text = error
|
||||
return creatingError.open()
|
||||
}
|
||||
|
||||
popup.close()
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: creatingError
|
||||
//% "Error importing the community"
|
||||
title: qsTrId("error-importing-the-community")
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue