mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-12 15:24:39 +00:00
chore(AirdropSettingsPanel) simplified, storybook page improved
- added "back" navigation in storybook - no need to use states and StackViewStates component
This commit is contained in:
parent
6ccb832800
commit
7f3f425a36
@ -61,17 +61,25 @@ SplitView {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Back"
|
||||
onClicked: loader.item.navigateBack()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
SplitView.fillWidth: true
|
||||
SplitView.fillHeight: true
|
||||
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
|
||||
anchors.fill: parent
|
||||
active: globalUtilsReady && mainModuleReady
|
||||
|
||||
sourceComponent: AirdropsSettingsPanel {
|
||||
id: airdropsSettingsPanel
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 50
|
||||
assetsModel: AssetsModel {}
|
||||
|
@ -1,16 +1,14 @@
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
import QtQuick.Layouts 1.14
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
import AppLayouts.Communities.layouts 1.0
|
||||
import AppLayouts.Communities.views 1.0
|
||||
|
||||
import utils 1.0
|
||||
|
||||
SettingsPageLayout {
|
||||
StackView {
|
||||
id: root
|
||||
|
||||
// id, name, image, color, owner properties expected
|
||||
@ -28,18 +26,21 @@ SettingsPageLayout {
|
||||
property var airdropFees: null
|
||||
|
||||
property int viewWidth: 560 // by design
|
||||
property string previousPageName: depth > 1 ? qsTr("Airdrops") : ""
|
||||
|
||||
signal airdropClicked(var airdropTokens, var addresses, var membersPubKeys)
|
||||
|
||||
signal airdropFeesRequested(var contractKeysAndAmounts, var addresses)
|
||||
|
||||
signal navigateToMintTokenSettings(bool isAssetType)
|
||||
|
||||
function navigateBack() {
|
||||
stackManager.pop(StackView.Immediate)
|
||||
pop(StackView.Immediate)
|
||||
}
|
||||
|
||||
function selectToken(key, amount, type) {
|
||||
if (depth > 1)
|
||||
pop(StackView.Immediate)
|
||||
|
||||
root.push(newAirdropView, StackView.Immediate)
|
||||
d.selectToken(key, amount, type)
|
||||
}
|
||||
|
||||
@ -50,56 +51,21 @@ SettingsPageLayout {
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property string welcomeViewState: "WELCOME"
|
||||
readonly property string newAirdropViewState: "NEW_AIRDROP"
|
||||
|
||||
readonly property string welcomePageTitle: qsTr("Airdrops")
|
||||
readonly property string newAirdropViewPageTitle: qsTr("New airdrop")
|
||||
|
||||
signal selectToken(string key, int amount, int type)
|
||||
signal addAddresses(var addresses)
|
||||
}
|
||||
|
||||
content: StackView {
|
||||
anchors.fill: parent
|
||||
initialItem: welcomeView
|
||||
initialItem: SettingsPage {
|
||||
implicitWidth: 0
|
||||
pageTitle: qsTr("Airdrops")
|
||||
|
||||
Component.onCompleted: stackManager.pushInitialState(d.welcomeViewState)
|
||||
buttons: StatusButton {
|
||||
text: qsTr("New Airdrop")
|
||||
|
||||
onClicked: root.push(newAirdropView, StackView.Immediate)
|
||||
}
|
||||
|
||||
state: stackManager.currentState
|
||||
states: [
|
||||
State {
|
||||
name: d.welcomeViewState
|
||||
PropertyChanges {target: root; title: d.welcomePageTitle}
|
||||
PropertyChanges {target: root; previousPageName: ""}
|
||||
PropertyChanges {target: root; primaryHeaderButton.visible: true}
|
||||
PropertyChanges {target: root; primaryHeaderButton.text: qsTr("New Airdrop")}
|
||||
},
|
||||
State {
|
||||
name: d.newAirdropViewState
|
||||
PropertyChanges {target: root; title: d.newAirdropViewPageTitle}
|
||||
PropertyChanges {target: root; previousPageName: d.welcomePageTitle}
|
||||
PropertyChanges {target: root; primaryHeaderButton.visible: false}
|
||||
}
|
||||
]
|
||||
|
||||
onPrimaryHeaderButtonClicked: {
|
||||
if(root.state !== d.newAirdropViewState)
|
||||
stackManager.push(d.newAirdropViewState, newAirdropView, null, StackView.Immediate)
|
||||
}
|
||||
|
||||
StackViewStates {
|
||||
id: stackManager
|
||||
|
||||
stackView: root.contentItem
|
||||
}
|
||||
|
||||
// Mint tokens possible view contents:
|
||||
Component {
|
||||
id: welcomeView
|
||||
|
||||
WelcomeSettingsView {
|
||||
contentItem: WelcomeSettingsView {
|
||||
viewWidth: root.viewWidth
|
||||
image: Style.png("community/airdrops8_1")
|
||||
title: qsTr("Airdrop community tokens")
|
||||
@ -115,9 +81,14 @@ SettingsPageLayout {
|
||||
Component {
|
||||
id: newAirdropView
|
||||
|
||||
EditAirdropView {
|
||||
SettingsPage {
|
||||
pageTitle: qsTr("New airdrop")
|
||||
|
||||
contentItem: EditAirdropView {
|
||||
id: view
|
||||
|
||||
padding: 0
|
||||
|
||||
communityDetails: root.communityDetails
|
||||
assetsModel: root.assetsModel
|
||||
collectiblesModel: root.collectiblesModel
|
||||
@ -129,8 +100,9 @@ SettingsPageLayout {
|
||||
|
||||
onAirdropClicked: {
|
||||
root.airdropClicked(airdropTokens, addresses, membersPubKeys)
|
||||
stackManager.clear(d.welcomeViewState, StackView.Immediate)
|
||||
root.pop(StackView.Immediate)
|
||||
}
|
||||
|
||||
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings(isAssetType)
|
||||
|
||||
Component.onCompleted: {
|
||||
@ -141,3 +113,4 @@ SettingsPageLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,9 +563,6 @@ StatusSectionLayout {
|
||||
target: mintPanel
|
||||
|
||||
function onAirdropToken(tokenKey, type, addresses) {
|
||||
// Here it is forced a navigation to the new airdrop form, like if it was clicked the header button
|
||||
airdropPanel.primaryHeaderButtonClicked()
|
||||
|
||||
// Force a token selection to be airdroped with default amount 1
|
||||
airdropPanel.selectToken(tokenKey, 1, type)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user