[Merge] lp:~renatofilho/address-book-app/swipe-to-delete2 into lp:~phablet-team/address-book-app/staging
Tiago Salem Herrmann
tiago.herrmann at canonical.com
Fri Jun 27 18:59:34 UTC 2014
Review: Needs Fixing
please, remove the unused code.
Diff comments:
> === modified file 'src/imports/ContactList/ContactListPage.qml'
> --- src/imports/ContactList/ContactListPage.qml 2014-06-27 12:54:15 +0000
> +++ src/imports/ContactList/ContactListPage.qml 2014-06-27 17:14:33 +0000
> @@ -141,20 +141,10 @@
> multipleSelection: !pickMode ||
> mainPage.pickMultipleContacts || (contactExporter.active && contactExporter.isMultiple)
>
> - anchors.fill: parent
> -
> leftSideAction: Action {
> iconName: "delete"
> text: i18n.tr("Delete")
> - onTriggered: {
> - value.makeDisappear()
> - }
> - }
> -
> - onContactDisappeared: {
> - if (contact) {
> - contactModel.removeContact(contact.contactId)
> - }
> + onTriggered: contactModel.removeContact(value._contact.contactId)
> }
>
> onCountChanged: {
>
> === modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt'
> --- src/imports/Ubuntu/Contacts/CMakeLists.txt 2014-06-18 18:19:09 +0000
> +++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2014-06-27 17:14:33 +0000
> @@ -12,6 +12,7 @@
> DialogButtons.qml
> FastScroll.qml
> FastScroll.js
> + ListItemWithActions.qml
> MostCalledModel.qml
> MultipleSelectionListView.qml
> MultipleSelectionVisualModel.qml
>
> === modified file 'src/imports/Ubuntu/Contacts/ContactDelegate.qml'
> --- src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-06-23 18:31:56 +0000
> +++ src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-06-27 17:14:33 +0000
> @@ -20,7 +20,7 @@
> import Ubuntu.Components.ListItems 0.1 as ListItem
> import "Contacts.js" as ContactsJS
>
> -Item {
> +ListItemWithActions {
> id: root
>
> property bool showAvatar: true
> @@ -32,6 +32,7 @@
> property variant titleFields: [ Name.FirstName, Name.LastName ]
> property bool detailsShown: false
> property int loaderOpacity: 0.0
> + property var _contact: contact
>
> signal clicked(int index, QtObject contact)
> signal pressAndHold(int index, QtObject contact)
> @@ -47,6 +48,10 @@
> height: delegate.height
> implicitHeight: delegate.height + (pickerLoader.item ? pickerLoader.item.height : 0)
> width: parent ? parent.width : 0
> + color: Theme.palette.normal.background
> +
> + onItemClicked: root.clicked(index, contact)
> + onItemPressAndHold: root.pressAndHold(index, contact)
>
> Item {
> id: delegate
> @@ -67,12 +72,6 @@
> visible: root.selected || root.detailsShown
> }
>
> - MouseArea {
> - anchors.fill: parent
> - onClicked: root.clicked(index, contact)
> - onPressAndHold: root.pressAndHold(index, contact)
> - }
> -
> ContactAvatar {
> id: avatar
>
> @@ -181,6 +180,7 @@
> clip: true
> height: root.implicitHeight
> loaderOpacity: 1.0
> + locked: true
> // FIXME: Setting detailsShown to true on expanded state cause the property to change to false and true during the state transition, and that
> // causes the loader to load twice
> //detailsShown: true
>
> === modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml'
> --- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-06-19 15:38:16 +0000
> +++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-06-27 17:14:33 +0000
> @@ -275,6 +275,10 @@
> titleFields: contactListView.titleFields
> isCurrentItem: ListView.isCurrentItem
>
> + // actions
> + leftSideAction: contactListView.leftSideAction
> + rightSideActions: contactListView.rightSideActions
> +
> onDetailClicked: contactListView.detailClicked(contact, detail, action)
> onInfoRequested: contactListView._fetchContact(index, contact)
>
> @@ -282,11 +286,32 @@
> ListView.onRemove: SequentialAnimation {
> ScriptAction {
This script action is empty
> script: {
> + console.debug("will remove")
> + }
> + }
> + PropertyAction {
> + target: contactDelegate
> + property: "ListView.delayRemove"
> + value: true
> + }
> + UbuntuNumberAnimation {
> + target: contactDelegate
> + property: "height"
> + to: 1
> + }
> + ScriptAction {
> + script: {
> + console.debug(remove )
please, remove this debug.
> if (contactDelegate.state !== "") {
> contactListView.currentIndex = -1
> }
> }
> }
> + PropertyAction {
> + target: contactDelegate
> + property: "ListView.delayRemove"
> + value: false
> + }
> }
>
> onClicked: {
>
> === added file 'src/imports/Ubuntu/Contacts/ListItemWithActions.qml'
> --- src/imports/Ubuntu/Contacts/ListItemWithActions.qml 1970-01-01 00:00:00 +0000
> +++ src/imports/Ubuntu/Contacts/ListItemWithActions.qml 2014-06-27 17:14:33 +0000
> @@ -0,0 +1,293 @@
> +/*
> + * Copyright (C) 2012-2014 Canonical, Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 3.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +import QtQuick 2.2
> +import Ubuntu.Components 0.1
> +
> +Item {
> + id: root
> +
> + property Action leftSideAction: null
> + property list<Action> rightSideActions
> + property double defaultHeight: units.gu(8)
> + property bool locked: false
> + property Action activeAction: null
> + property var activeItem: null
> + property bool triggerActionOnMouseRelease: false
> + property alias color: main.color
> + default property alias contents: main.children
> +
> + readonly property double actionWidth: units.gu(5)
> + readonly property double threshold: 0.4
> + readonly property string swipeState: main.x == 0 ? "Normal" : main.x > 0 ? "LeftToRight" : "RightToLeft"
> +
> + signal itemClicked(var mouse)
> + signal itemPressAndHold(var mouse)
> +
> + function returnToBoundsRTL()
> + {
> + var xOffset = Math.abs(main.x)
> + var actionFullWidth = actionWidth + units.gu(1)
> +
> + if (xOffset < actionFullWidth) {
> + main.x = 0
> + } else if (xOffset > (actionFullWidth * rightActionsRepeater.count)) {
> + main.x = - (actionFullWidth * rightActionsRepeater.count)
> + } else {
> + for (var i = rightActionsRepeater.count; i >= 2; i--) {
> + if (xOffset >= (actionFullWidth * i)) {
> + main.x = -(actionWidth * i)
> + return
> + }
> + }
> + main.x = -actionWidth
> + }
> + }
> +
> + function returnToBoundsLTR()
> + {
> + var finalX = leftActionView.width
> + if (main.x > (finalX * root.threshold))
> + main.x = finalX
> + else
> + main.x = 0
> + }
> +
> + function returnToBounds()
> + {
> + if (main.x < 0) {
> + returnToBoundsRTL()
> + } else if (main.x > 0) {
> + returnToBoundsLTR()
> + }
> + }
> +
> + function contains(item, point)
> + {
> + return (point.x >= item.x) && (point.x <= (item.x + item.width)) && (point.y >= item.y) && (point.y <= (item.y + item.height));
> + }
> +
> + function getActionAt(point)
> + {
> + if (contains(leftActionView, point)) {
> + return leftSideAction
> + } else if (contains(rightActionsView, point)) {
> + var newPoint = root.mapToItem(rightActionsView, point.x, point.y)
> + for (var i = 0; i < rightActionsRepeater.count; i++) {
> + var child = rightActionsRepeater.itemAt(i)
> + if (contains(child, newPoint)) {
> + return rightSideActions[i]
> + }
> + }
> + }
> + return null
> + }
> +
> + function updateActiveAction()
> + {
> + var xOffset = Math.abs(main.x)
> + if (main.x < 0) {
> + for (var i = rightActionsRepeater.count - 1; i >= 0; i--) {
> + var child = rightActionsRepeater.itemAt(i)
> + var childOffset = rightActionsView.width - child.x
> + if (xOffset <= childOffset) {
> + root.activeItem = child
> + root.activeAction = root.rightSideActions[i]
> + return
> + }
> + }
> + } else {
> + root.activeAction = null
> + }
> + }
> +
> + function resetSwipe()
> + {
> + main.x = 0
> + }
> +
> + height: defaultHeight
> + clip: height !== defaultHeight
> + //color: Theme.palette.selected.field
please, remove this one too
> +
> + Rectangle {
> + id: leftActionView
> +
> + anchors {
> + top: parent.top
> + bottom: parent.bottom
> + left: parent.left
> + }
> + width: height
> + visible: leftSideAction
> + color: "red"
> +
> + Icon {
> + anchors.centerIn: parent
> + name: leftSideAction ? leftSideAction.iconName : ""
> + color: Theme.palette.selected.field
> + height: units.gu(3)
> + width: units.gu(3)
> + }
> + }
> +
> + Item {
> + id: rightActionsView
> +
> + anchors {
> + top: main.top
> + right: parent.right
> + bottom: main.bottom
> + }
> + width: rightActionsRepeater.count * (root.actionWidth + units.gu(1))
> + Row {
> + anchors.fill: parent
> + spacing: units.gu(1)
> + Repeater {
> + id: rightActionsRepeater
> +
> + model: rightSideActions
> + Item {
> + property alias image: img
> +
> + anchors {
> + top: parent.top
> + bottom: parent.bottom
> + }
> + width: root.actionWidth
> +
> + Icon {
> + id: img
> +
> + anchors.centerIn: parent
> + width: units.gu(3)
> + height: units.gu(3)
> + name: iconName
> + color: root.activeAction === modelData || !root.triggerActionOnMouseRelease ? UbuntuColors.lightAubergine : Theme.palette.selected.background
> + }
> + }
> + }
> + }
> + }
> +
> +
> + Rectangle {
> + id: main
> +
> + anchors {
> + top: parent.top
> + bottom: parent.bottom
> + }
> +
> + width: parent.width
> + Behavior on x {
> + UbuntuNumberAnimation {
> + easing.type: Easing.OutElastic
> + duration: UbuntuAnimation.SlowDuration
> + }
> + }
> + }
> +
> + SequentialAnimation {
> + id: triggerAction
> +
> + property var currentItem: root.activeItem ? root.activeItem.image : null
> +
> + running: false
> + ParallelAnimation {
> + UbuntuNumberAnimation {
> + target: triggerAction.currentItem
> + property: "opacity"
> + from: 1.0
> + to: 0.0
> + duration: UbuntuAnimation.SlowDuration
> + easing {type: Easing.InOutBack; }
> + }
> + UbuntuNumberAnimation {
> + target: triggerAction.currentItem
> + properties: "width, height"
> + from: units.gu(3)
> + to: root.actionWidth
> + duration: UbuntuAnimation.SlowDuration
> + easing {type: Easing.InOutBack; }
> + }
> + }
> + ScriptAction {
> + script: {
> + root.activeAction.triggered(root)
> + }
> + }
> + PropertyAction {
> + target: triggerAction.currentItem
> + properties: "width, height"
> + value: units.gu(3)
> + }
> + PropertyAction {
> + target: triggerAction.currentItem
> + properties: "opacity"
> + value: 1.0
> + }
> + UbuntuNumberAnimation {
> + target: main
> + property: "x"
> + to: 0
> + easing.type: Easing.OutElastic
> + duration: UbuntuAnimation.SlowDuration
> + }
> + }
> +
> + MouseArea {
> + id: mouseArea
> +
> + property bool locked: root.locked || ((root.leftSideAction === null) && (root.rightSideActions.count === 0))
> +
> + anchors.fill: parent
> + drag {
> + target: locked ? null : main
> + axis: Drag.XAxis
> + minimumX: -rightActionsView.width
> + maximumX: leftActionView.visible ? leftActionView.width : 0
> + }
> +
> + onReleased: {
> + if (root.triggerActionOnMouseRelease && root.activeAction) {
> + triggerAction.start()
> + } else {
> + root.returnToBounds()
> + }
> + }
> + onClicked: {
> + if (main.x === 0) {
> + root.itemClicked(mouse)
> + return
> + }
> +
> + var action = getActionAt(Qt.point(mouse.x, mouse.y))
> + if (action) {
> + action.triggered(root)
> + }
> + root.resetSwipe()
> + }
> +
> + onPositionChanged: updateActiveAction()
> + onPressAndHold: {
> + if (main.x === 0) {
> + root.itemPressAndHold(mouse)
> + }
> + }
> + z: -1
> + }
> +}
>
> === modified file 'src/imports/Ubuntu/Contacts/MostCalledModel.qml'
> --- src/imports/Ubuntu/Contacts/MostCalledModel.qml 2014-06-23 17:22:37 +0000
> +++ src/imports/Ubuntu/Contacts/MostCalledModel.qml 2014-06-27 17:14:33 +0000
> @@ -132,6 +132,7 @@
> id: contactDelegate
>
> readonly property alias contact: contactFetch.contact
> + property var contents
>
> onDetailClicked: root.detailClicked(contact, detail, action)
> onInfoRequested: root.infoRequested(index, contact)
> @@ -143,6 +144,7 @@
> titleDetail: ContactDetail.DisplayLabel
> titleFields: [ DisplayLabel.Label ]
> isCurrentItem: root.currentIndex === index
> + locked: true
>
> // collapse the item before remove it, to avoid crash
> ListView.onRemove: SequentialAnimation {
> @@ -167,17 +169,20 @@
> }
> }
>
> - ContactWatcher {
> - id: contactWatcher
> -
> - phoneNumber: participant
> - onContactIdChanged: contactFetch.fetchContact(contactId)
> - }
> -
> - ContactFetch {
> - id: contactFetch
> -
> - model: contactsModel
> + // delegate does not support more than one child
> + contents: Item {
> + ContactWatcher {
> + id: contactWatcher
> +
> + phoneNumber: participant
> + onContactIdChanged: contactFetch.fetchContact(contactId)
> + }
> +
> + ContactFetch {
> + id: contactFetch
> +
> + model: contactsModel
> + }
> }
> }
> }
>
> === modified file 'src/imports/Ubuntu/Contacts/qmldir'
> --- src/imports/Ubuntu/Contacts/qmldir 2014-06-18 18:19:09 +0000
> +++ src/imports/Ubuntu/Contacts/qmldir 2014-06-27 17:14:33 +0000
> @@ -16,4 +16,5 @@
> internal ContactJs Contacts.js
> internal FastScroll FastScroll.qml
> internal FastScrollJs FastScroll.js
> +internal ListItemWithActions ListItemWithActions.qml
> internal MostCalledModel MostCalledModel.qml
>
--
https://code.launchpad.net/~renatofilho/address-book-app/swipe-to-delete2/+merge/224822
Your team Ubuntu Phablet Team is subscribed to branch lp:~phablet-team/address-book-app/staging.
More information about the Ubuntu-reviews
mailing list