|
@@ -276,31 +276,28 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
|
|
|
func tapButtonSwitch(_ sender: Any) {
|
|
|
|
|
|
- if collectionView.collectionViewLayout == gridLayout {
|
|
|
+ if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
+
|
|
|
// list layout
|
|
|
headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "")
|
|
|
- UIView.animate(withDuration: 0.0, animations: {
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.listLayout, animated: false, completion: { _ in
|
|
|
- self.collectionView.reloadData()
|
|
|
- })
|
|
|
- })
|
|
|
layoutForView?.layout = NCGlobal.shared.layoutList
|
|
|
NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
|
|
|
+
|
|
|
+ self.collectionView.reloadData()
|
|
|
+ self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
+ self.collectionView.setCollectionViewLayout(self.listLayout, animated: true)
|
|
|
+
|
|
|
} else {
|
|
|
+
|
|
|
// grid layout
|
|
|
headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
- UIView.animate(withDuration: 0.0, animations: {
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.gridLayout, animated: false, completion: { _ in
|
|
|
- self.collectionView.reloadData()
|
|
|
- })
|
|
|
- })
|
|
|
layoutForView?.layout = NCGlobal.shared.layoutGrid
|
|
|
NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
|
|
|
- }
|
|
|
|
|
|
- reloadDataSource()
|
|
|
+ self.collectionView.reloadData()
|
|
|
+ self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
+ self.collectionView.setCollectionViewLayout(self.gridLayout, animated: true)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func tapButtonOrder(_ sender: Any) {
|
|
@@ -614,7 +611,7 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
|
|
|
self.headerMenu = header
|
|
|
|
|
|
- if collectionView.collectionViewLayout == gridLayout {
|
|
|
+ if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
header.setImageSwitchList()
|
|
|
header.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
} else {
|
|
@@ -633,7 +630,11 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
header.setRichWorkspaceText(richWorkspaceText)
|
|
|
|
|
|
header.setSectionHeight(heightHeaderSection)
|
|
|
- header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
|
|
|
+ if heightHeaderSection == 0 {
|
|
|
+ header.labelSection.text = ""
|
|
|
+ } else {
|
|
|
+ header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath)
|
|
|
+ }
|
|
|
header.labelSection.textColor = NCBrandColor.shared.label
|
|
|
|
|
|
return header
|
|
@@ -682,7 +683,7 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if isSearching || collectionView.collectionViewLayout == gridLayout || dataSource.numberOfSections() > 1 {
|
|
|
+ if isSearching || layoutForView?.layout == NCGlobal.shared.layoutGrid || dataSource.numberOfSections() > 1 {
|
|
|
if section == 0 {
|
|
|
return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
|
|
|
} else {
|