Delete and unsubscribe confirmation page
This commit is contained in:
parent
90564364a5
commit
8eebb09707
4 changed files with 108 additions and 3 deletions
87
touch/Confirmation.qml
Normal file
87
touch/Confirmation.qml
Normal file
|
@ -0,0 +1,87 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* gPodder QML UI Reference Implementation
|
||||
* Copyright (c) 2013, Thomas Perl <m@thp.io>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
import 'common/constants.js' as Constants
|
||||
import 'icons/icons.js' as Icons
|
||||
|
||||
SlidePage {
|
||||
id: confirmation
|
||||
|
||||
property alias title: header.title
|
||||
property alias icon: icon.icon
|
||||
property alias color: header.color
|
||||
property var callback: undefined
|
||||
|
||||
SlidePageHeader {
|
||||
id: header
|
||||
color: Constants.colors.destructive
|
||||
title: 'Confirmation'
|
||||
}
|
||||
|
||||
PIcon {
|
||||
id: icon
|
||||
size: 300
|
||||
anchors.centerIn: parent
|
||||
color: header.color
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (confirmation.callback !== undefined) {
|
||||
confirmation.callback();
|
||||
confirmation.closePage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PLabel {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: icon.bottom
|
||||
margins: 30 * pgst.scalef
|
||||
}
|
||||
|
||||
text: 'Tap to confirm'
|
||||
color: header.color
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
bottom: parent.bottom
|
||||
margins: 60 * pgst.scalef
|
||||
}
|
||||
|
||||
spacing: 30 * pgst.scalef
|
||||
|
||||
PLabel {
|
||||
text: 'Swipe right to cancel'
|
||||
color: Constants.colors.text
|
||||
}
|
||||
|
||||
PIcon {
|
||||
color: Constants.colors.text
|
||||
icon: Icons.arrow_right
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,7 +75,12 @@ Item {
|
|||
color: (episodeItem.isPlaying || progress > 0) ? titleLabel.color : Constants.colors.destructive
|
||||
icon: Icons.trash
|
||||
visible: downloadState != Constants.state.deleted
|
||||
onClicked: py.call('main.delete_episode', [id]);
|
||||
onClicked: {
|
||||
var ctx = { py: py, id: id };
|
||||
pgst.showConfirmation('Delete episode', Icons.trash, function () {
|
||||
ctx.py.call('main.delete_episode', [ctx.id]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
IconMenuItem {
|
||||
|
|
|
@ -54,8 +54,13 @@ SlidePage {
|
|||
icon: Icons.trash
|
||||
color: Constants.colors.destructive
|
||||
onClicked: {
|
||||
py.call('main.unsubscribe', [episodesPage.podcast_id]);
|
||||
episodesPage.closePage();
|
||||
episodesPage.unPull();
|
||||
|
||||
var ctx = { py: py, id: episodesPage.podcast_id, page: episodesPage };
|
||||
pgst.showConfirmation('Unsubscribe', Icons.trash, function () {
|
||||
ctx.py.call('main.unsubscribe', [ctx.id]);
|
||||
ctx.page.closePage();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,14 @@ Item {
|
|||
|
||||
property bool loadPageInProgress: false
|
||||
|
||||
function showConfirmation(title, icon, callback) {
|
||||
loadPage('Confirmation.qml', {
|
||||
title: title,
|
||||
icon: icon,
|
||||
callback: callback,
|
||||
});
|
||||
}
|
||||
|
||||
function loadPage(filename, properties) {
|
||||
if (pgst.loadPageInProgress) {
|
||||
console.log('ignoring loadPage request while load in progress');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue