From ecf3610ac51e4d87e167d6ba8fb0f8ca45f5a00d Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Mon, 11 Dec 2023 12:16:25 +0100 Subject: [PATCH] - AccountController: replace section.addExpanded() with expansion CollectionViewAction - CollectionViewAction: add missing parts in implementation for .expand() to expand cells, add status awareness (double expansion collapses them again) - CollectionViewSection: check cell expansion status before expanding the cell (double expansion collapses them again) --- ios-sdk | 2 +- .../Account/Controller/AccountController.swift | 6 ++++-- .../CollectionViewAction.swift | 18 +++++++++++++----- .../CollectionViewSection.swift | 8 +++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ios-sdk b/ios-sdk index 70e9c289e..57b05c6d6 160000 --- a/ios-sdk +++ b/ios-sdk @@ -1 +1 @@ -Subproject commit 70e9c289edd5b1cdb6113332aaed709a03c53ffb +Subproject commit 57b05c6d62bce4301915f08e1a3a97b52a0ac04a diff --git a/ownCloudAppShared/Client/Account/Controller/AccountController.swift b/ownCloudAppShared/Client/Account/Controller/AccountController.swift index 5cedc4fec..250c944ec 100644 --- a/ownCloudAppShared/Client/Account/Controller/AccountController.swift +++ b/ownCloudAppShared/Client/Account/Controller/AccountController.swift @@ -475,10 +475,12 @@ public class AccountController: NSObject, OCDataItem, OCDataItemVersioning, Acco if let quickAccessFolderDataSource = specialItemsDataSources[.quickAccessFolder] { sources.append(quickAccessFolderDataSource) } - + if configuration.expandQuickAccess, let accountControllerSection = accountControllerSection, let quickAccessItemRef = accountControllerSection.collectionViewController?.wrap(references: [ specialItemsDataReferences[.quickAccessFolder]! ], forSection: accountControllerSection.identifier).first { - accountControllerSection.addExpanded(item: quickAccessItemRef) + accountControllerSection.collectionViewController?.addActions([ + CollectionViewAction(kind: .expand(animated: false), itemReference: quickAccessItemRef) + ]) } } diff --git a/ownCloudAppShared/Client/Collection Views/CollectionViewAction.swift b/ownCloudAppShared/Client/Collection Views/CollectionViewAction.swift index 7b2179484..faa442be1 100644 --- a/ownCloudAppShared/Client/Collection Views/CollectionViewAction.swift +++ b/ownCloudAppShared/Client/Collection Views/CollectionViewAction.swift @@ -93,11 +93,19 @@ public class CollectionViewAction: NSObject { viewController.performDataSourceUpdate { updateDone in if let datasource = viewController.collectionViewDataSource, let sectionID { var sectionSnapshot = datasource.snapshot(for: sectionID) - sectionSnapshot.expand([ itemRef ]) - datasource.apply(sectionSnapshot, to: sectionID, animatingDifferences: animated, completion: { - completion?() - updateDone() - }) + if !sectionSnapshot.isExpanded(itemRef) { + sectionSnapshot.expand([ itemRef ]) + + if let section = viewController.sectionsByID[sectionID] { + let childSnapshot = section.provideHierarchicContent(for: collectionView, parentItemRef: itemRef, existingSectionSnapshot: nil) + sectionSnapshot.replace(childrenOf: itemRef, using: childSnapshot) + + datasource.apply(sectionSnapshot, to: sectionID, animatingDifferences: animated, completion: { + completion?() + updateDone() + }) + } + } } else { completion?() updateDone() diff --git a/ownCloudAppShared/Client/Collection Views/CollectionViewSection.swift b/ownCloudAppShared/Client/Collection Views/CollectionViewSection.swift index 8edc2a1f2..ee6a6cf2f 100644 --- a/ownCloudAppShared/Client/Collection Views/CollectionViewSection.swift +++ b/ownCloudAppShared/Client/Collection Views/CollectionViewSection.swift @@ -432,10 +432,12 @@ public class CollectionViewSection: NSObject, OCDataItem, OCDataItemVersioning { if let collectionView = collectionViewController?.collectionView { for expandedItemRef in expandedItemRefs { if sectionSnapshot.contains(expandedItemRef) { - sectionSnapshot.expand([expandedItemRef]) + if !sectionSnapshot.isExpanded(expandedItemRef) { + sectionSnapshot.expand([expandedItemRef]) - let childSnapshot = provideHierarchicContent(for: collectionView, parentItemRef: expandedItemRef, existingSectionSnapshot: nil) - sectionSnapshot.replace(childrenOf: expandedItemRef, using: childSnapshot) + let childSnapshot = provideHierarchicContent(for: collectionView, parentItemRef: expandedItemRef, existingSectionSnapshot: nil) + sectionSnapshot.replace(childrenOf: expandedItemRef, using: childSnapshot) + } } } }