@@ -47,6 +47,10 @@ FocusScope {
48 signal backClicked()
48 signal backClicked()
51+ floatingSeeLess.companionBase = null;
50 function positionAtBeginning() {
54 function positionAtBeginning() {
51 categoryView.positionAtBeginning()
55 categoryView.positionAtBeginning()
@@ -152,11 +156,54 @@ FocusScope {
152 forceNoClip: subPageLoader.open
156 forceNoClip: subPageLoader.open
153 pixelAligned: true
157 pixelAligned: true
155− property Item expandedCategoryItem: null
159+ property string expandedCategoryId: ""
160+ property int runMaximizeAfterSizeChanges: 0
157 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
162 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
158 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
163 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
165+ onExpandedCategoryIdChanged: {
166+ var firstCreated = firstCreatedIndex();
167+ var shrinkingAny = false;
168+ var shrinkHeightDifference = 0;
169+ for (var i = 0; i < createdItemCount(); ++i) {
170+ var baseItem = item(firstCreated + i);
171+ if (baseItem.expandable) {
172+ var shouldExpand = baseItem.category === expandedCategoryId;
173+ if (shouldExpand != baseItem.expanded) {
174+ var animate = false;
175+ if (!subPageLoader.open) {
176+ var animateShrinking = !shouldExpand && baseItem.y + baseItem.item.collapsedHeight + baseItem.seeAllButton.height < categoryView.height;
177+ var animateGrowing = shouldExpand && baseItem.y + baseItem.height < categoryView.height;
178+ animate = shrinkingAny || animateShrinking || animateGrowing;
181+ if (!shouldExpand) {
182+ shrinkingAny = true;
183+ shrinkHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
186+ if (shouldExpand && !subPageLoader.open) {
187+ if (!shrinkingAny) {
188+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAllButton.height);
190+ // If the space that shrinking is smaller than the one we need to grow we'll call maximizeVisibleArea
191+ // after the shrink/grow animation ends
192+ var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
193+ if (growHeightDifference > shrinkHeightDifference) {
194+ runMaximizeAfterSizeChanges = 2;
196+ runMaximizeAfterSizeChanges = 0;
201+ baseItem.expand(shouldExpand, animate);
160 delegate: ListItems.Base {
207 delegate: ListItems.Base {
161 id: baseItem
208 id: baseItem
162 objectName: "dashCategory" + category
209 objectName: "dashCategory" + category
@@ -194,7 +241,7 @@ FocusScope {
194 // This can happen with the VJ that doesn't know how height it will be on creation
241 // This can happen with the VJ that doesn't know how height it will be on creation
195 // so doesn't set expandable until a bit too late for onLoaded
242 // so doesn't set expandable until a bit too late for onLoaded
196 if (expandable) {
243 if (expandable) {
197− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
244+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
198 baseItem.expand(shouldExpand, false /*animate*/);
245 baseItem.expand(shouldExpand, false /*animate*/);
@@ -215,9 +262,23 @@ FocusScope {
215 id: heightBehaviour
262 id: heightBehaviour
216 enabled: false
263 enabled: false
217 animation: UbuntuNumberAnimation {
264 animation: UbuntuNumberAnimation {
265+ duration: UbuntuAnimation.FastDuration
218 onRunningChanged: {
266 onRunningChanged: {
219 if (!running) {
267 if (!running) {
220 heightBehaviour.enabled = false
268 heightBehaviour.enabled = false
269+ if (categoryView.runMaximizeAfterSizeChanges > 0) {
270+ categoryView.runMaximizeAfterSizeChanges--;
271+ if (categoryView.runMaximizeAfterSizeChanges == 0) {
272+ var firstCreated = categoryView.firstCreatedIndex();
273+ for (var i = 0; i < categoryView.createdItemCount(); ++i) {
274+ var baseItem = categoryView.item(firstCreated + i);
275+ if (baseItem.category === categoryView.expandedCategoryId) {
276+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAllButton.height);
@@ -245,7 +306,7 @@ FocusScope {
245 item.objectName = Qt.binding(function() { return categoryId })
306 item.objectName = Qt.binding(function() { return categoryId })
246 item.scopeStyle = scopeView.scopeStyle;
307 item.scopeStyle = scopeView.scopeStyle;
247 if (baseItem.expandable) {
308 if (baseItem.expandable) {
248− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
309+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
249 baseItem.expand(shouldExpand, false /*animate*/);
310 baseItem.expand(shouldExpand, false /*animate*/);
251 updateDelegateCreationRange();
312 updateDelegateCreationRange();
@@ -282,27 +343,6 @@ FocusScope {
283 Connections {
344 Connections {
284 target: categoryView
345 target: categoryView
285− onExpandedCategoryItemChanged: {
286− collapseAllButExpandedCategory();
288− function collapseAllButExpandedCategory() {
289− var item = rendererLoader.item;
290− if (baseItem.expandable) {
291− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
292− if (shouldExpand != baseItem.expanded) {
293− // If the filter animation will be seen start it, otherwise, just flip the switch
294− var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;
295− var growingVisible = shouldExpand && y + height < categoryView.height;
296− if (!subPageLoader.open || shouldExpand) {
297− var animate = shrinkingVisible || growingVisible;
298− baseItem.expand(shouldExpand, animate)
299− if (shouldExpand && !subPageLoader.open) {
300− categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);
306 onOriginYChanged: rendererLoader.updateDelegateCreationRange();
346 onOriginYChanged: rendererLoader.updateDelegateCreationRange();
307 onContentYChanged: rendererLoader.updateDelegateCreationRange();
347 onContentYChanged: rendererLoader.updateDelegateCreationRange();
308 onHeightChanged: rendererLoader.updateDelegateCreationRange();
348 onHeightChanged: rendererLoader.updateDelegateCreationRange();
@@ -352,10 +392,11 @@ FocusScope {
352 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
392 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
354 onClicked: {
394 onClicked: {
355− if (categoryView.expandedCategoryItem !== baseItem) {
395+ if (categoryView.expandedCategoryId !== baseItem.category) {
356− categoryView.expandedCategoryItem = baseItem;
396+ categoryView.expandedCategoryId = baseItem.category;
397+ floatingSeeLess.companionBase = baseItem;
358− categoryView.expandedCategoryItem = null;
399+ categoryView.expandedCategoryId = "";
@@ -455,7 +496,7 @@ FocusScope {
455 objectName: "floatingSeeLess"
496 objectName: "floatingSeeLess"
457 property Item companionTo: companionBase ? companionBase.seeAllButton : null
498 property Item companionTo: companionBase ? companionBase.seeAllButton : null
458− property Item companionBase: categoryView.expandedCategoryItem
499+ property Item companionBase: null
459 property bool showBecausePosition: false
500 property bool showBecausePosition: false
460 property real yOffset: 0
501 property real yOffset: 0
@@ -467,7 +508,7 @@ FocusScope {
467 height: seeLessLabel.font.pixelSize + units.gu(4)
508 height: seeLessLabel.font.pixelSize + units.gu(4)
468 visible: companionTo && showBecausePosition
509 visible: companionTo && showBecausePosition
470− onClicked: categoryView.expandedCategoryItem = null;
511+ onClicked: categoryView.expandedCategoryId = "";
472 function updateVisibility() {
513 function updateVisibility() {
473 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
514 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
@@ -476,6 +517,10 @@ FocusScope {
476 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
517 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
477 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
518 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
478 yOffset = Math.min(yOffset, height);
519 yOffset = Math.min(yOffset, height);
521+ if (!showBecausePosition && categoryView.expandedCategoryId === "") {
522+ companionBase = null;