Commit 0b56121f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(MainWindow/Contacts): use new style

parent e3eb67a9
...@@ -10,6 +10,31 @@ import App.Styles 1.0 ...@@ -10,6 +10,31 @@ import App.Styles 1.0
// =================================================================== // ===================================================================
ColumnLayout { ColumnLayout {
function _filter (text) {
Utils.assert(
contacts.setFilterFixedString != null,
'`contacts.setFilterFixedString` must be defined.'
)
Utils.assert(
contacts.invalidate != null,
'`contacts.invalidate` must be defined.'
)
contacts.setFilterFixedString(text)
contacts.invalidate()
}
function _removeContact (contact) {
Utils.openConfirmDialog(contact, {
descriptionText: qsTr('removeContactDescription'),
exitHandler: function (status) {
console.log('remove contact', status)
},
title: qsTr('removeContactTitle')
})
}
spacing: 0 spacing: 0
// ----------------------------------------------------------------- // -----------------------------------------------------------------
...@@ -20,24 +45,22 @@ ColumnLayout { ...@@ -20,24 +45,22 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: ContactsStyle.bar.height Layout.preferredHeight: ContactsStyle.bar.height
color: ContactsStyle.bar.color color: ContactsStyle.bar.backgroundColor
RowLayout { RowLayout {
anchors.fill: parent anchors {
anchors.leftMargin: ContactsStyle.bar.leftMargin fill: parent
anchors.rightMargin: ContactsStyle.bar.rightMargin leftMargin: ContactsStyle.bar.leftMargin
rightMargin: ContactsStyle.bar.rightMargin
spacing: 20 }
spacing: ContactsStyle.spacing
TextField { TextField {
Layout.fillWidth: true Layout.fillWidth: true
icon: 'filter' icon: 'filter'
placeholderText: qsTr('searchContactPlaceholder') placeholderText: qsTr('searchContactPlaceholder')
onTextChanged: { onTextChanged: _filter(text)
contacts.setFilterFixedString(text)
contacts.invalidate()
}
} }
ExclusiveButtons { ExclusiveButtons {
...@@ -67,115 +90,134 @@ ColumnLayout { ...@@ -67,115 +90,134 @@ ColumnLayout {
ScrollableListView { ScrollableListView {
anchors.fill: parent anchors.fill: parent
spacing: ContactsStyle.contacts.spacing spacing: 0
model: ContactsListModel { model: ContactsListModel {
id: contacts id: contacts
} }
delegate: Rectangle { delegate: Borders {
id: contact borderColor: ContactsStyle.contact.border.color
bottomWidth: ContactsStyle.contact.border.width
color: '#FFFFFF' height: ContactsStyle.contact.height
height: 50
width: parent.width width: parent.width
MouseArea { Rectangle {
anchors.fill: parent id: contact
hoverEnabled: true
onEntered: contact.state = 'hover'
onExited: contact.state = ''
}
Item { anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter color: ContactsStyle.contact.backgroundColor.normal
height: 30
width: parent.width
RowLayout { RowLayout {
anchors.fill: parent anchors {
anchors.leftMargin: 15 fill: parent
anchors.rightMargin: 25 leftMargin: ContactsStyle.contact.leftMargin
spacing: 15 rightMargin: ContactsStyle.contact.rightMargin
}
spacing: ContactsStyle.contact.spacing
// Avatar. // Avatar.
Avatar { Avatar {
Layout.fillHeight: parent.height Layout.preferredHeight: ContactsStyle.contact.avatarSize
Layout.preferredWidth: 30 Layout.preferredWidth: ContactsStyle.contact.avatarSize
image: $contact.avatar image: $contact.avatar
username: $contact.username username: $contact.username
} }
// Presence.
Item {
Layout.fillHeight: parent.height
Layout.preferredWidth: 20
PresenceLevel {
anchors.fill: parent
level: $contact.presenceLevel
}
}
// Username. // Username.
Text { Text {
Layout.fillHeight: parent.height Layout.preferredWidth: ContactsStyle.contact.username.width
Layout.fillWidth: true color: ContactsStyle.contact.username.color
clip: true elide: Text.ElideRight
color: '#5A585B'
font.bold: true font.bold: true
text: $contact.username text: $contact.username
verticalAlignment: Text.AlignVCenter
} }
// Actions. // Container.
Row { Item {
id: actions Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
spacing: 50
visible: false
ActionBar { Item {
iconSize: parent.height id: container1
ActionButton { anchors.fill: parent
icon: 'video_call'
onClicked: CallsWindow.show() PresenceLevel {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
height: ContactsStyle.contact.presenceLevelSize
width: ContactsStyle.contact.presenceLevelSize
level: $contact.presenceLevel
} }
}
ActionButton { Item {
icon: 'call' id: container2
onClicked: CallsWindow.show()
anchors.fill: parent
visible: false
ActionBar {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
iconSize: ContactsStyle.contact.actionButtonsSize
ActionButton {
icon: 'video_call'
onClicked: CallsWindow.show()
}
ActionButton {
icon: 'call'
onClicked: CallsWindow.show()
}
ActionButton {
icon: 'chat'
onClicked: window.setView('Conversation')
}
} }
ActionButton { ActionButton {
icon: 'chat' anchors {
onClicked: window.setView('Conversation') right: parent.right
verticalCenter: parent.verticalCenter
}
icon: 'delete'
iconSize: ContactsStyle.contact.deleteButtonSize
onClicked: _removeContact($contact)
} }
} }
ActionButton {
iconSize: parent.height
icon: 'delete'
onClicked: Utils.openConfirmDialog(contact, {
descriptionText: qsTr('removeContactDescription'),
exitHandler: function (status) {
console.log('remove contact', status)
},
title: qsTr('removeContactTitle')
})
}
} }
} }
}
states: State { MouseArea {
name: 'hover' anchors.fill: parent
PropertyChanges { target: contact; color: '#D1D1D1' } hoverEnabled: true
PropertyChanges { target: actions; visible: true }
onEntered: contact.state = 'hover'
onExited: contact.state = ''
}
// -----------------------------------------------------------
states: State {
name: 'hover'
PropertyChanges {
color: ContactsStyle.contact.backgroundColor.hovered
target: contact
}
PropertyChanges { target: container1; visible: false }
PropertyChanges { target: container2; visible: true }
}
} }
} }
} }
......
...@@ -7,15 +7,38 @@ import Common 1.0 ...@@ -7,15 +7,38 @@ import Common 1.0
QtObject { QtObject {
property color backgroundColor: '#FFFFFF' property color backgroundColor: '#FFFFFF'
property int spacing: 20
property QtObject bar: QtObject { property QtObject bar: QtObject {
property color color: '#F3F3F3' property color backgroundColor: '#F3F3F3'
property int height: 60 property int height: 60
property int leftMargin: 18 property int leftMargin: 18
property int rightMargin: 18 property int rightMargin: 18
} }
property QtObject contacts: QtObject { property QtObject contact: QtObject {
property int spacing: 1 property int actionButtonsSize: 36
property int avatarSize: 30
property int deleteButtonSize: 16
property int height: 50
property int leftMargin: 15
property int presenceLevelSize: 12
property int rightMargin: 25
property int spacing: 15
property QtObject backgroundColor: QtObject {
property color normal: '#FFFFFF'
property color hovered: '#E2E9EF'
}
property QtObject border: QtObject {
property color color: '#E8E8E8'
property int width: 1
}
property QtObject username: QtObject {
property color color: '#4B5964'
property int width: 220
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment