moment/src/qml/SidePane/DelegateAccount.qml
miruka 2865d86d19 Refactor SidePane ListView in a flat way
Also adjust some colors (accentBackground)

TODO: Repair Filter rooms field
2019-08-18 03:35:28 -04:00

94 lines
2.8 KiB
QML

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
HInteractiveRectangle {
id: accountDelegate
height: row.height
color: theme.sidePane.account.background
checked: accountDelegate.isCurrent
readonly property bool isCurrent:
window.uiState.page == "Pages/EditAccount/EditAccount.qml" &&
window.uiState.pageProperties.userId == model.data.user_id
readonly property bool collapsed:
! accountRoomList.forceExpand &&
window.uiState.collapseAccounts[model.data.user_id] || false
function toggleCollapse() {
window.uiState.collapseAccounts[model.data.user_id] = ! collapsed
window.uiStateChanged()
}
function activate() {
pageStack.showPage(
"EditAccount/EditAccount", { "userId": model.data.user_id }
)
}
TapHandler { onTapped: accountDelegate.activate() }
HRowLayout {
id: row
width: parent.width
HUserAvatar {
id: avatar
userId: model.data.user_id
displayName: model.data.display_name
avatarUrl: model.data.avatar_url
opacity: collapsed ? theme.sidePane.account.collapsedOpacity : 1
Behavior on opacity { HNumberAnimation {} }
Layout.topMargin: model.index > 0 ? sidePane.currentSpacing / 2 : 0
Layout.bottomMargin: Layout.topMargin
}
HLabel {
id: accountLabel
color: theme.sidePane.account.name
text: model.data.display_name || model.data.user_id
font.pixelSize: theme.fontSize.big
elide: HLabel.ElideRight
leftPadding: sidePane.currentSpacing
verticalAlignment: Text.AlignVCenter
opacity: collapsed ? theme.sidePane.account.collapsedOpacity : 1
Behavior on opacity { HNumberAnimation {} }
Layout.fillWidth: true
Layout.fillHeight: true
}
HUIButton {
id: expandButton
iconName: "expand"
iconDimension: 16
backgroundColor: "transparent"
leftPadding: sidePane.currentSpacing
rightPadding: leftPadding
onClicked: accountDelegate.toggleCollapse()
visible: opacity > 0
opacity:
accountRoomList.forceExpand ? 0 :
collapsed ? theme.sidePane.account.collapsedOpacity + 0.2 :
1
Behavior on opacity { HNumberAnimation {} }
iconTransform: Rotation {
origin.x: expandButton.iconDimension / 2
origin.y: expandButton.iconDimension / 2
angle: collapsed ? 180 : 90
Behavior on angle { HNumberAnimation {} }
}
Layout.fillHeight: true
}
}
}