aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilla Heikkilä <mheikkila@luxoft.com>2018-06-08 10:39:38 +0200
committerBramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>2018-06-08 13:52:09 +0000
commitdda8322657692669afbcb042728cc216dbbd5bf8 (patch)
treebf017a49f8cbaf8dcb0208130a8c12acacef53a1
parent46a5017e1fdea58a934f3a2eef7e6c4f74faa9ec (diff)
[notification] Handle follows NotificationToast and NoticationCenter
- Move NotificationHandle from NotificationCenter to NotificationContent Change-Id: I57a510556b38df4c347d137e77ab59941c02e882 Reviewed-by: Anatoly Kozlov <AnKozlov@luxoft.com> Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
-rw-r--r--sysui/notification/NotificationCenter.qml60
-rw-r--r--sysui/notification/NotificationContent.qml59
2 files changed, 57 insertions, 62 deletions
diff --git a/sysui/notification/NotificationCenter.qml b/sysui/notification/NotificationCenter.qml
index ae30fcd1..2cef5f48 100644
--- a/sysui/notification/NotificationCenter.qml
+++ b/sysui/notification/NotificationCenter.qml
@@ -40,7 +40,7 @@ import com.pelagicore.styles.neptune 3.0
Item {
id: root
- y: root.notificationCenterVisible ? root.dragMaximumY : -root.dragMinimumY
+ y: root.notificationCenterVisible ? 0 : -root.height
height: {
var totalHeight = notificationList.height + root.notificationBottomMargin + root.notificationTopMargin;
@@ -55,8 +55,6 @@ Item {
readonly property int listviewMaxHeight: NeptuneStyle.dp(1720) - root.notificationTopMargin - root.notificationBottomMargin
readonly property int notificationTopMargin: NeptuneStyle.dp(80)
readonly property int notificationBottomMargin: NeptuneStyle.dp(144)
- readonly property int dragMaximumY: 0
- readonly property int dragMinimumY: root.height
readonly property bool notificationCenterVisible: root.notificationModel.notificationCenterVisible
Behavior on y {
@@ -68,10 +66,6 @@ Item {
DefaultNumberAnimation { }
}
- function closeNotificationCenter() {
- root.notificationModel.notificationCenterVisible = !root.notificationModel.notificationCenterVisible;
- }
-
Rectangle {
id: notificationCenterBg
anchors.fill: parent
@@ -138,56 +132,4 @@ Item {
}
}
}
-
- NotificationHandle {
- id: notificationHandle
- anchors.horizontalCenter: root.horizontalCenter
- anchors.top: root.bottom
- dragTarget: root
- drag.minimumY: root.notificationModel.notificationToastVisible ? - NeptuneStyle.dp(130) : - root.dragMinimumY
- drag.maximumY: root.notificationModel.notificationToastVisible ? 0 : root.dragMaximumY
- drag.onActiveChanged: {
- notificationHandle.prevDragY = notificationHandle.dragTarget.y;
- }
-
- onPressed: {
- if (!root.notificationModel.notificationToastVisible) {
- // reset values
- notificationHandle.dragDelta = 0;
- notificationHandle.dragOrigin = notificationHandle.dragTarget.y;
- notificationHandle.prevDragY = notificationHandle.dragTarget.y;
- notificationCenterBg.opacity = 1.0;
-
- // start drag filter timer
- notificationHandle.dragFilterTimer.running = true;
- }
- }
-
- onReleased: {
- if (!root.notificationModel.notificationToastVisible) {
- if (!notificationHandle.drag.active && notificationHandle.swipe) {
- if (root.notificationModel.notificationCenterVisible && notificationHandle.dragDelta > 0) {
- root.notificationModel.notificationCenterVisible = true;
- } else if (root.notificationModel.notificationCenterVisible && notificationHandle.dragDelta < 0) {
- root.notificationModel.notificationCenterVisible = false;
- } else {
- root.notificationModel.notificationCenterVisible = !root.notificationModel.notificationCenterVisible;
- }
- } else {
- root.notificationModel.notificationCenterVisible = !root.notificationModel.notificationCenterVisible;
- }
-
- // stop drag filter timer
- notificationHandle.dragFilterTimer.running = false;
- notificationHandle.dragDelta = notificationHandle.dragTarget.y - notificationHandle.dragOrigin;
-
- if (!root.notificationModel.notificationCenterVisible) {
- notificationCenterBg.opacity = 0.0;
- }
- } else {
- // close notification toast
- root.notificationModel.closeNotification();
- }
- }
- }
}
diff --git a/sysui/notification/NotificationContent.qml b/sysui/notification/NotificationContent.qml
index 5f902d7d..6275c8df 100644
--- a/sysui/notification/NotificationContent.qml
+++ b/sysui/notification/NotificationContent.qml
@@ -39,19 +39,72 @@ ModalOverlay {
id: root
showModalOverlay: notificationCenter.notificationCenterVisible
- onOverlayClicked: notificationCenter.closeNotificationCenter()
+ onOverlayClicked: notificationModel.notificationCenterVisible = false
+
+ NotificationModel {
+ id: notificationModel
+ }
NotificationCenter {
id: notificationCenter
anchors.left: parent.left
anchors.right: parent.right
- notificationModel: NotificationModel { }
+ notificationModel: notificationModel
}
NotificationToast {
+ id: notificationToast
leftPadding: NeptuneStyle.dp(40)
rightPadding: NeptuneStyle.dp(40)
anchors.left: parent.left
anchors.right: parent.right
- notificationModel: notificationCenter.notificationModel
+ notificationModel: notificationModel
+ }
+
+ NotificationHandle {
+ id: notificationHandle
+ anchors.horizontalCenter: root.horizontalCenter
+ anchors.top: notificationToast.y !== -notificationToast.height ? notificationToast.bottom : notificationCenter.bottom
+ dragTarget: notificationToast.y !== -notificationToast.height ? notificationToast : notificationCenter
+ drag.minimumY: notificationModel.notificationToastVisible ? - NeptuneStyle.dp(130) : -notificationCenter.height
+ drag.maximumY: 0
+ drag.onActiveChanged: {
+ notificationHandle.prevDragY = notificationHandle.dragTarget.y;
+ }
+
+ onPressed: {
+ if (!notificationModel.notificationToastVisible) {
+ // reset values
+ notificationHandle.dragDelta = 0;
+ notificationHandle.dragOrigin = notificationHandle.dragTarget.y;
+ notificationHandle.prevDragY = notificationHandle.dragTarget.y;
+
+ // start drag filter timer
+ notificationHandle.dragFilterTimer.running = true;
+ }
+ }
+
+ onReleased: {
+ if (!notificationModel.notificationToastVisible) {
+ if (!notificationHandle.drag.active && notificationHandle.swipe) {
+ if (notificationModel.notificationCenterVisible && notificationHandle.dragDelta > 0) {
+ notificationModel.notificationCenterVisible = true;
+ } else if (notificationModel.notificationCenterVisible && notificationHandle.dragDelta < 0) {
+ notificationModel.notificationCenterVisible = false;
+ } else {
+ notificationModel.notificationCenterVisible = !notificationModel.notificationCenterVisible;
+ }
+ } else {
+ notificationModel.notificationCenterVisible = !notificationModel.notificationCenterVisible;
+ }
+
+ // stop drag filter timer
+ notificationHandle.dragFilterTimer.running = false;
+ notificationHandle.dragDelta = notificationHandle.dragTarget.y - notificationHandle.dragOrigin;
+
+ } else {
+ // close notification toast
+ notificationModel.closeNotification();
+ }
+ }
}
}