on xenial help sign in
resolve conflict
e2838eeDiego Sarmentero
Dash/Apps/AppPreview.qml+7
@@ -191,12 +191,19 @@ DashPreview {
191 ListItem.ThinDivider { }
191 ListItem.ThinDivider { }
192
192
193 AppReviews {
193 AppReviews {
194+ id: appReviews
194 objectName: "appReviews"
195 objectName: "appReviews"
196+ // TODO: This should make this visible when the feature for reviews/comments is complete.
197+ visible: false
195 anchors { left: parent.left; right: parent.right }
198 anchors { left: parent.left; right: parent.right }
196
199
197 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
200 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
198
201
199 onSendReview: root.sendUserReview(review);
202 onSendReview: root.sendUserReview(review);
203+
204+ onEditing: {
205+ root.ensureVisible(appReviews.textArea);
206+ }
200 }
207 }
201 }
208 }
202 }
209 }
Dash/Apps/AppReviews.qml+3
@@ -23,8 +23,10 @@ Column {
23 id: root
23 id: root
24
24
25 property var model
25 property var model
26+ property alias textArea: reviewField
26
27
27 signal sendReview(string review)
28 signal sendReview(string review)
29+ signal editing
28
30
29 spacing: units.gu(2)
31 spacing: units.gu(2)
30 state: ""
32 state: ""
@@ -93,6 +95,7 @@ Column {
93 if(reviewField.focus){
95 if(reviewField.focus){
94 root.state = "editing";
96 root.state = "editing";
95 reviewField.selectAll();
97 reviewField.selectAll();
98+ root.editing();
96 }
99 }
97 }
100 }
98
101
Dash/DashPreview.qml+13
@@ -20,6 +20,7 @@ import Ubuntu.Components 0.1
20Rectangle {
20Rectangle {
21 id: root
21 id: root
22
22
23+ property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
23 property var previewData
24 property var previewData
24
25
25 property string title: ""
26 property string title: ""
@@ -38,6 +39,14 @@ Rectangle {
38 color: Qt.rgba(0, 0, 0, .3)
39 color: Qt.rgba(0, 0, 0, .3)
39 clip: true
40 clip: true
40
41
42+ function ensureVisible(item) {
43+ var o = leftFlickable.mapFromItem(item, 0, 0, item.width, item.height);
44+ var keyboardY = shell.height - root.keyboardSize;
45+ if ((o.y + o.height) > keyboardY) {
46+ leftFlickable.contentY += o.y + o.height - keyboardY;
47+ }
48+ }
49+
41 Connections {
50 Connections {
42 target: shell.applicationManager
51 target: shell.applicationManager
43 onMainStageFocusedApplicationChanged: {
52 onMainStageFocusedApplicationChanged: {
@@ -128,12 +137,16 @@ Rectangle {
128
137
129 Flickable {
138 Flickable {
130 id: leftFlickable
139 id: leftFlickable
140+ objectName: "leftFlickable"
131 anchors.top: parent.top
141 anchors.top: parent.top
132 anchors.bottom: parent.bottom
142 anchors.bottom: parent.bottom
133 width: root.narrowMode ? contentRow.width : contentRow.width * root.previewWidthRatio
143 width: root.narrowMode ? contentRow.width : contentRow.width * root.previewWidthRatio
134 contentHeight: leftColumn.height
144 contentHeight: leftColumn.height
145+ anchors.bottomMargin: root.keyboardSize
135 clip: true
146 clip: true
136
147
148+ Behavior on contentY { NumberAnimation { duration: 300 } }
149+
137 Column {
150 Column {
138 id: leftColumn
151 id: leftColumn
139 objectName: "leftColumn"
152 objectName: "leftColumn"
tests/qmltests/Dash/Apps/tst_AppPreview.qml+22
@@ -25,6 +25,9 @@ Item {
25 width: units.gu(60)
25 width: units.gu(60)
26 height: units.gu(80)
26 height: units.gu(80)
27
27
28+ // Fake shell
29+ QtObject { id: shell; property int height: appPreview.height }
30+
28 property var calls: []
31 property var calls: []
29
32
30 SignalSpy {
33 SignalSpy {
@@ -114,6 +117,9 @@ Item {
114 reviewField.text = "";
117 reviewField.text = "";
115 data.rating = rating.value;
118 data.rating = rating.value;
116 dataProgress.infoMap["progressbar_source"].value = "service";
119 dataProgress.infoMap["progressbar_source"].value = "service";
120+ var appReviews = findChild(appPreview, "appReviews");
121+ appReviews.visible = false;
122+ appPreview.keyboardSize = 0;
117 }
123 }
118
124
119 function test_actions() {
125 function test_actions() {
@@ -149,6 +155,7 @@ Item {
149
155
150 function test_review_focus() {
156 function test_review_focus() {
151 var appReviews = findChild(appPreview, "appReviews");
157 var appReviews = findChild(appPreview, "appReviews");
158+ appReviews.visible = true;
152 var sendButton = findChild(appReviews, "sendButton");
159 var sendButton = findChild(appReviews, "sendButton");
153 var reviewField = findChild(appReviews, "reviewField");
160 var reviewField = findChild(appReviews, "reviewField");
154
161
@@ -213,5 +220,20 @@ Item {
213 compare(root.calls[0][1], {"error": "DOWNLOAD ERROR"}, "Data of action not found.");
220 compare(root.calls[0][1], {"error": "DOWNLOAD ERROR"}, "Data of action not found.");
214 }
221 }
215
222
223+ function test_automatic_scroll_on_keyboard_shown() {
224+ waitForRendering(appPreview);
225+ var appReviews = findChild(appPreview, "appReviews");
226+ appReviews.visible = true;
227+
228+ var leftFlickable = findChild(appPreview, "leftFlickable");
229+ leftFlickable.contentY = leftFlickable.contentHeight;
230+ var reviewField = findChild(appReviews, "reviewField");
231+ appPreview.keyboardSize = 400;
232+ appReviews.editing(reviewField);
233+ var newFlickPos = leftFlickable.contentY;
234+ var keyboardY = shell.height - appPreview.keyboardSize;
235+ verify(newFlickPos < keyboardY);
236+ }
237+
216 }
238 }
217}
239}