feat(CreateCommunityPopup): introduce canGoNext and nextAction for modal pages

This commit is contained in:
Pascal Precht 2022-08-18 17:29:55 +02:00 committed by r4bbit.eth
parent 3509de8673
commit f2dea729a1
1 changed files with 28 additions and 6 deletions

View File

@ -32,16 +32,31 @@ StatusStackModal {
nextButton: StatusButton { nextButton: StatusButton {
objectName: "createCommunityNextBtn" objectName: "createCommunityNextBtn"
text: qsTr("Next") font.weight: Font.Medium
enabled: nameInput.valid && descriptionTextInput.valid text: typeof currentItem.nextButtonText !== "undefined" ? currentItem.nextButtonText : qsTr("Next")
onClicked: currentIndex++ enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
onClicked: {
let nextAction = currentItem.nextAction
if (typeof(nextAction) == "function") {
return nextAction()
}
root.currentIndex++
}
} }
finishButton: StatusButton { finishButton: StatusButton {
objectName: "createCommunityFinalBtn" objectName: "createCommunityFinalBtn"
text: qsTr("Create Community") font.weight: Font.Medium
enabled: introMessageInput.valid && outroMessageInput.valid text: root.isDiscordImport ? qsTr("Start Discord import") : qsTr("Create Community")
onClicked: d.createCommunity() enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
onClicked: {
let nextAction = currentItem.nextAction
if (typeof (nextAction) == "function") {
return nextAction()
}
if (!root.isDiscordImport)
d.createCommunity()
}
} }
onAboutToShow: nameInput.input.edit.forceActiveFocus() onAboutToShow: nameInput.input.edit.forceActiveFocus()
@ -50,6 +65,8 @@ StatusStackModal {
StatusScrollView { StatusScrollView {
id: generalView id: generalView
readonly property bool canGoNext: nameInput.valid && descriptionTextInput.valid
ColumnLayout { ColumnLayout {
id: generalViewLayout id: generalViewLayout
width: generalView.availableWidth width: generalView.availableWidth
@ -135,12 +152,16 @@ StatusStackModal {
} }
} }
}, },
ColumnLayout { ColumnLayout {
id: introOutroMessageView id: introOutroMessageView
spacing: 11 spacing: 11
readonly property bool canGoNext: introMessageInput.valid && outroMessageInput.valid
CommunityIntroMessageInput { CommunityIntroMessageInput {
id: introMessageInput id: introMessageInput
input.edit.objectName: "createCommunityIntroMessageInput" input.edit.objectName: "createCommunityIntroMessageInput"
input.tabNavItem: outroMessageInput.input.edit
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@ -152,6 +173,7 @@ StatusStackModal {
CommunityOutroMessageInput { CommunityOutroMessageInput {
id: outroMessageInput id: outroMessageInput
input.edit.objectName: "createCommunityOutroMessageInput" input.edit.objectName: "createCommunityOutroMessageInput"
input.tabNavItem: introMessageInput.input.edit
Layout.fillWidth: true Layout.fillWidth: true
} }