Display Alexa specific chrome when it is used
[apps/homescreen.git] / homescreen / qml / SpeechChrome.qml
1 import QtQuick 2.0
2 import SpeechChrome 1.0
3
4 Item {
5     id: root
6
7     clip: true
8
9     property bool agentPresent: speechChromeController.agentPresent
10     property string agentName: speechChromeController.agentName
11
12     visible: agentPresent
13
14     Image {
15         id: chromeBarImage
16
17         anchors.top: parent.top
18         source: "./images/SpeechChrome/bar.png"
19
20         Behavior on x {
21             NumberAnimation { duration: 250 }
22         }
23         Behavior on opacity {
24             NumberAnimation { duration: 250 }
25         }
26     }
27
28     Image {
29         id: pushToTalk
30
31         height: parent.height * 0.80
32         width: height
33
34         anchors.left: parent.left
35         anchors.leftMargin: parent.width / 128
36         anchors.verticalCenter: parent.verticalCenter
37         source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"
38
39         MouseArea {
40             anchors.fill: parent
41             onPressed: speechChromeController.pushToTalk()
42         }
43
44         Behavior on opacity {
45             NumberAnimation { duration: 250 }
46         }
47     }
48
49     states: [
50         State {
51             name: "Idle"
52             when: speechChromeController.chromeState == SpeechChromeController.Idle
53             PropertyChanges {
54                 target: chromeBarImage
55                 opacity: 0.0
56                 x: 0
57             }
58             PropertyChanges {
59                 target: pushToTalk
60                 opacity: 1.0
61                 enabled: true
62             }
63         },
64         State {
65             name: "Listening"
66             when: speechChromeController.chromeState == SpeechChromeController.Listening
67             PropertyChanges {
68                 target: chromeBarImage
69                 opacity: 1.0
70                 x: 0
71             }
72             PropertyChanges {
73                 target: pushToTalk
74                 opacity: 0.0
75                 enabled: false
76             }
77         },
78         State {
79             name: "Thinking"
80             when: speechChromeController.chromeState == SpeechChromeController.Thinking
81             PropertyChanges {
82                 target: chromeBarImage
83                 opacity: 1.0
84                 x: root.width - chromeBarImage.width
85             }
86             PropertyChanges {
87                 target: pushToTalk
88                 opacity: 0.0
89                 enabled: false
90             }
91         },
92         State {
93             name: "Speaking"
94             when: speechChromeController.chromeState == SpeechChromeController.Speaking
95             PropertyChanges {
96                 target: chromeBarImage
97                 opacity: 1.0
98                 x: (root.width - chromeBarImage.width) * 0.5
99             }
100             PropertyChanges {
101                 target: pushToTalk
102                 opacity: 0.0
103                 enabled: false
104             }
105         },
106         State {
107             name: "MicrophoneOff"
108             when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff
109             PropertyChanges {
110                 target: chromeBarImage
111                 opacity: 0.0
112                 x: 0
113             }
114             PropertyChanges {
115                 target: pushToTalk
116                 opacity: 1.0
117                 enabled: true
118             }
119         }
120     ]
121 }