| 1 |
/* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 |
|
| 3 |
This file is part of the Dekko Project |
| 4 |
|
| 5 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
you may not use this file except in compliance with the License. |
| 7 |
You may obtain a copy of the License at |
| 8 |
|
| 9 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
|
| 11 |
Unless required by applicable law or agreed to in writing, |
| 12 |
software distributed under the License is distributed on an |
| 13 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
| 14 |
either express or implied. See the License for the specific |
| 15 |
language governing permissions and limitations under the License. |
| 16 |
*/ |
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.3 |
| 19 |
|
| 20 |
NotificationBase { |
| 21 |
id: base |
| 22 |
|
| 23 |
anchors.fill: parent |
| 24 |
|
| 25 |
LomiriShape { |
| 26 |
id: notification |
| 27 |
aspect: LomiriShape.DropShadow |
| 28 |
backgroundColor: LomiriColors.porcelain |
| 29 |
width: units.gu(30) |
| 30 |
height: layout.height |
| 31 |
|
| 32 |
anchors.margins: units.gu(3) |
| 33 |
|
| 34 |
ListItemLayout { |
| 35 |
id: layout |
| 36 |
title.text: base.title |
| 37 |
subtitle.text: base.body |
| 38 |
subtitle.maximumLineCount: 4 |
| 39 |
|
| 40 |
Icon { |
| 41 |
height: units.gu(4) |
| 42 |
width: height |
| 43 |
visible: base.hasIcon |
| 44 |
name: base.hasIcon && base.iconName ? base.iconName : "" |
| 45 |
color: base.iconColor |
| 46 |
SlotsLayout.position: SlotsLayout.Leading |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
AbstractButton { |
| 51 |
anchors.fill: parent |
| 52 |
action: base.action |
| 53 |
visible: base.action |
| 54 |
onClicked: { |
| 55 |
if (destroyAnimation.running) { |
| 56 |
destroyAnimation.pause() |
| 57 |
} |
| 58 |
base.closed() |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
SequentialAnimation { |
| 63 |
id: showAnimation |
| 64 |
running: true |
| 65 |
NumberAnimation { target: notification; property: "opacity"; to: 1.0; duration: 500 } |
| 66 |
PauseAnimation { duration: base.displayTime } |
| 67 |
ScriptAction { script: destroyAnimation.restart() } |
| 68 |
} |
| 69 |
|
| 70 |
SequentialAnimation { |
| 71 |
id: destroyAnimation |
| 72 |
NumberAnimation { target: notification; property: "opacity"; to: 0; duration: 500 } |
| 73 |
ScriptAction { script: base.closed() } |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
states: [ |
| 78 |
State { |
| 79 |
when: base.dockedLeft |
| 80 |
AnchorChanges { |
| 81 |
target: notification; |
| 82 |
anchors { |
| 83 |
top: base.top; |
| 84 |
left: base.left; |
| 85 |
right: undefined; |
| 86 |
bottom: undefined; |
| 87 |
} |
| 88 |
} |
| 89 |
}, |
| 90 |
State { |
| 91 |
when: base.dockedRight |
| 92 |
AnchorChanges { |
| 93 |
target: notification; |
| 94 |
anchors { |
| 95 |
top: base.top; |
| 96 |
left: undefined; |
| 97 |
right: base.right; |
| 98 |
bottom: undefined; |
| 99 |
} |
| 100 |
} |
| 101 |
}, |
| 102 |
State { |
| 103 |
when: base.dockedCenter |
| 104 |
AnchorChanges { |
| 105 |
target: notification; |
| 106 |
anchors { |
| 107 |
top: base.top; |
| 108 |
horizontalCenter: base.horizontalCenter; |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
] |
| 113 |
} |