Dekko
Loading...
Searching...
No Matches
ContentBlockedNotice.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Lomiri.Constants 1.0
22
23Item {
24 id: notice
25
26 property bool contentBlocked: false
27 readonly property bool isExpanded: state === "expanded"
28
29 signal allowClicked()
30
31 ListItem {
32 anchors.fill: parent
33 divider.visible: notice.contentBlocked
34 color: Suru.secondaryBackgroundColor
35 Label {
36 anchors {
37 left: parent.left
38 leftMargin: Style.defaultSpacing
39 verticalCenter: parent.verticalCenter
40 right: allowButton.left
41 rightMargin: units.gu(1.5)
42 }
43 elide: Text.ElideRight
44 clip: true
45 visible: notice.contentBlocked
46 text: qsTr("Remote content blocked")
47 }
48
49 Button {
50 id: allowButton
51 height: units.gu(4)
52 width: allowAction.text.width > units.gu(15) ? units.gu(15) : allowAction.text.width
53 anchors {
54 right: parent.right
55 rightMargin: Style.defaultSpacing
56 verticalCenter: parent.verticalCenter
57 }
58 Suru.highlightType: Suru.NegativeHighlight
59 color: Suru.highlightColor
60 action: Action {
61 id: allowAction
62 text: qsTr("Allow")
63 onTriggered: notice.allowClicked()
64 }
65 }
66 }
67
68 state: contentBlocked ? "expanded" : "collapsed"
69 states: [
70 State {
71 name: "collapsed"
72 PropertyChanges {
73 target: notice
74 height: 0
75 }
76 },
77 State {
78 name: "expanded"
79 PropertyChanges {
80 target: notice
81 height: units.gu(6)
82 }
83 }
84 ]
85 // We only want to animate on closing. Looks a bit weird
86 // on expanding while the view is still being constructed.
87 transitions: [
88 Transition {
89 from: "expanded"
90 to: "collapsed"
91 animations: [
92 NumberAnimation {
93 target: notice
94 property: "height"
95 duration: LomiriAnimation.FastDuration
96 }
97 ]
98 }
99 ]
100}