Skip to content

Commit

Permalink
chore(CommunityNewAirdropView): Adjust MembersDropdown to updated design
Browse files Browse the repository at this point in the history
  • Loading branch information
micieslak committed May 8, 2023
1 parent 1f3ae97 commit a5d339e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 5 deletions.
33 changes: 33 additions & 0 deletions storybook/pages/MembersDropdownPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,39 @@ SplitView {
sourceComponent: ColumnLayout {
readonly property MembersDropdown membersDropdown: loader.item

RowLayout {
RadioButton {
id: addModeRadioButton

text: "add mode"
checked: true

Binding {
target: membersDropdown
property: "mode"
value: addModeRadioButton.checked
? MembersDropdown.Mode.Add
: MembersDropdown.Mode.Update
}
}

RadioButton {
text: "update mode"
}

CheckBox {
id: forceButtonDisabledCheckBox

text: "force button disabled"

Binding {
target: membersDropdown
property: "forceButtonDisabled"
value: forceButtonDisabledCheckBox.checked
}
}
}

RowLayout {
Label {
text: "maximum list height:"
Expand Down
40 changes: 35 additions & 5 deletions ui/app/AppLayouts/Chat/controls/community/MembersDropdown.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ StatusDropdown {
id: root

property var selectedKeys: []
property bool forceButtonDisabled: false
property int maximumListHeight: 288

property alias model: listView.model
Expand All @@ -23,6 +24,12 @@ StatusDropdown {

property bool fixedYPosition: !anchors.centerIn && margins < 0

enum Mode {
Add, Update
}

property int mode: MembersDropdown.Mode.Add

signal backButtonClicked
signal addButtonClicked

Expand All @@ -36,7 +43,10 @@ StatusDropdown {
bottomInset: 10
bottomPadding: padding + bottomInset

onOpened: filterInput.text = ""
onOpened: {
listView.positionViewAtBeginning()
filterInput.text = ""
}

QtObject {
id: d
Expand All @@ -45,6 +55,7 @@ StatusDropdown {
readonly property int delegateHeight: 47

readonly property int vPadding: root.topPadding + root.bottomPadding
readonly property int scrollBarWidth: 4

readonly property int availableExternalHeight:
(root.Overlay.overlay ? root.Overlay.overlay.height : 0) - root.bottomMargin -
Expand Down Expand Up @@ -122,6 +133,10 @@ StatusDropdown {
Layout.fillWidth: true
Layout.fillHeight: true

verticalScrollBar {
implicitWidth: d.scrollBarWidth + ScrollBar.vertical.padding * 2
}

visible: count > 0

header: StatusCheckBox {
Expand Down Expand Up @@ -225,10 +240,25 @@ StatusDropdown {
Layout.fillWidth: true

textFillWidth: true
enabled: root.selectedKeys.length > 0
text: enabled
? qsTr("Add %n member(s)", "", root.selectedKeys.length)
: qsTr("Add")

enabled: {
if (root.forceButtonDisabled)
return false

if (root.mode === MembersDropdown.Mode.Add)
return root.selectedKeys.length > 0

return true
}

text: {
if (root.mode === MembersDropdown.Mode.Update)
return qsTr("Update members")

return root.selectedKeys.length > 0
? qsTr("Add %n member(s)", "", root.selectedKeys.length)
: qsTr("Add")
}

onClicked: root.addButtonClicked()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,24 @@ StatusScrollView {
onCommunityMembersSelected: {
recipientTypeSelectionDropdown.close()
membersDropdown.selectedKeys = selectedKeysFilter.keys

const hasSelection = selectedKeysFilter.keys.length !== 0

membersDropdown.mode = hasSelection
? MembersDropdown.Mode.Update
: MembersDropdown.Mode.Add

airdropRecipientsSelector.openPopup(membersDropdown)
}
}

MembersDropdown {
id: membersDropdown

forceButtonDisabled:
mode === MembersDropdown.Mode.Update &&
JSON.stringify(selectedKeys) === JSON.stringify(selectedKeysFilter.keys)

model: SortFilterProxyModel {
sourceModel: membersModel

Expand Down

0 comments on commit a5d339e

Please sign in to comment.