Customize contact details own view

This commit is contained in:
Angela Mazzurco 2017-07-09 17:04:31 +02:00
parent 1917e673f2
commit 61971b5b3d

View File

@ -27,6 +27,20 @@ Item
id: cntDt id: cntDt
property var md property var md
property bool is_contact: cntDt.md.is_contact property bool is_contact: cntDt.md.is_contact
property bool isOwn: cntDt.md.own
Text
{
id: meText
text: "Yourself"
visible: isOwn
anchors.top: parent.top
anchors.topMargin: 6
anchors.horizontalCenter: parent.horizontalCenter
}
AvatarOrColorHash AvatarOrColorHash
{ {
@ -34,7 +48,7 @@ Item
gxs_id: cntDt.md.gxs_id gxs_id: cntDt.md.gxs_id
anchors.top: parent.top anchors.top: meText.bottom
anchors.topMargin: 6 anchors.topMargin: 6
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
@ -68,9 +82,19 @@ Item
Image Image
{ {
source: cntDt.is_contact ? source:
{
if (isOwn)
{
"qrc:/icons/keyring.svg"
}
else
{
cntDt.is_contact ?
"qrc:/icons/rating.svg" : "qrc:/icons/rating.svg" :
"qrc:/icons/rating-unrated.svg" "qrc:/icons/rating-unrated.svg"
}
}
height: parent.height - 4 height: parent.height - 4
sourceSize.height: height sourceSize.height: height
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
@ -81,12 +105,15 @@ Item
anchors.fill: parent anchors.fill: parent
onClicked: onClicked:
{
if (!isOwn)
{ {
var jDt = JSON.stringify({gxs_id: cntDt.md.gxs_id}) var jDt = JSON.stringify({gxs_id: cntDt.md.gxs_id})
if(cntDt.is_contact) if(cntDt.is_contact)
rsApi.request("/identity/remove_contact", jDt, tgCt) rsApi.request("/identity/remove_contact", jDt, tgCt)
else rsApi.request("/identity/add_contact", jDt, tgCt) else rsApi.request("/identity/add_contact", jDt, tgCt)
} }
}
function tgCt() { cntDt.is_contact = !cntDt.is_contact } function tgCt() { cntDt.is_contact = !cntDt.is_contact }
} }