@@ -14,7 +14,7 @@ import VinOutlineKit
14
14
import VinUtility
15
15
16
16
protocol DocumentsDelegate : AnyObject {
17
- func documentSelectionDidChange( _: DocumentsViewController , documentContainers: [ DocumentContainer ] , documents: [ Document ] , isNew: Bool , isNavigationBranch: Bool , animated: Bool )
17
+ func documentSelectionDidChange( _: DocumentsViewController , documentContainers: [ DocumentContainer ] , documents: [ Document ] , selectRow : EntityID ? , isNew: Bool , isNavigationBranch: Bool , animated: Bool )
18
18
func showGetInfo( _: DocumentsViewController , outline: Outline )
19
19
func exportPDFDocs( _: DocumentsViewController , outlines: [ Outline ] )
20
20
func exportPDFLists( _: DocumentsViewController , outlines: [ Outline ] )
@@ -170,16 +170,28 @@ class DocumentsViewController: UICollectionViewController, MainControllerIdentif
170
170
}
171
171
}
172
172
173
- func selectDocument( _ document: Document ? , isNew: Bool = false , isNavigationBranch: Bool = true , animated: Bool ) {
173
+ func selectDocument( _ document: Document ? , selectRow : EntityID ? = nil , isNew: Bool = false , isNavigationBranch: Bool = true , animated: Bool ) {
174
174
guard let documentContainers else { return }
175
175
176
176
collectionView. deselectAll ( )
177
177
178
178
if let document, let index = documents. firstIndex ( of: document) {
179
179
collectionView. selectItem ( at: IndexPath ( row: index, section: 0 ) , animated: true , scrollPosition: . centeredVertically)
180
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ document] , isNew: isNew, isNavigationBranch: isNavigationBranch, animated: animated)
180
+ delegate? . documentSelectionDidChange ( self ,
181
+ documentContainers: documentContainers,
182
+ documents: [ document] ,
183
+ selectRow: selectRow,
184
+ isNew: isNew,
185
+ isNavigationBranch: isNavigationBranch,
186
+ animated: animated)
181
187
} else {
182
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: isNew, isNavigationBranch: isNavigationBranch, animated: animated)
188
+ delegate? . documentSelectionDidChange ( self ,
189
+ documentContainers: documentContainers,
190
+ documents: [ ] ,
191
+ selectRow: selectRow,
192
+ isNew: isNew,
193
+ isNavigationBranch: isNavigationBranch,
194
+ animated: animated)
183
195
}
184
196
}
185
197
@@ -190,7 +202,13 @@ class DocumentsViewController: UICollectionViewController, MainControllerIdentif
190
202
collectionView. selectItem ( at: IndexPath ( row: i, section: 0 ) , animated: false , scrollPosition: [ ] )
191
203
}
192
204
193
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: documents, isNew: false , isNavigationBranch: false , animated: true )
205
+ delegate? . documentSelectionDidChange ( self ,
206
+ documentContainers: documentContainers,
207
+ documents: documents,
208
+ selectRow: nil ,
209
+ isNew: false ,
210
+ isNavigationBranch: false ,
211
+ animated: true )
194
212
}
195
213
196
214
func deleteCurrentDocuments( ) {
@@ -400,12 +418,24 @@ extension DocumentsViewController {
400
418
guard let documentContainers else { return }
401
419
402
420
guard let selectedIndexPaths = collectionView. indexPathsForSelectedItems else {
403
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: false , isNavigationBranch: false , animated: true )
421
+ delegate? . documentSelectionDidChange ( self ,
422
+ documentContainers: documentContainers,
423
+ documents: [ ] ,
424
+ selectRow: nil ,
425
+ isNew: false ,
426
+ isNavigationBranch: false ,
427
+ animated: true )
404
428
return
405
429
}
406
430
407
431
let selectedDocuments = selectedIndexPaths. map { documents [ $0. row] }
408
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: selectedDocuments, isNew: false , isNavigationBranch: true , animated: true )
432
+ delegate? . documentSelectionDidChange ( self ,
433
+ documentContainers: documentContainers,
434
+ documents: selectedDocuments,
435
+ selectRow: nil ,
436
+ isNew: false ,
437
+ isNavigationBranch: true ,
438
+ animated: true )
409
439
}
410
440
411
441
override func collectionView( _ collectionView: UICollectionView , didSelectItemAt indexPath: IndexPath ) {
@@ -422,12 +452,24 @@ extension DocumentsViewController {
422
452
#endif
423
453
424
454
guard let selectedIndexPaths = collectionView. indexPathsForSelectedItems else {
425
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: false , isNavigationBranch: false , animated: true )
455
+ delegate? . documentSelectionDidChange ( self ,
456
+ documentContainers: documentContainers,
457
+ documents: [ ] ,
458
+ selectRow: nil ,
459
+ isNew: false ,
460
+ isNavigationBranch: false ,
461
+ animated: true )
426
462
return
427
463
}
428
464
429
465
let selectedDocuments = selectedIndexPaths. map { documents [ $0. row] }
430
- delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: selectedDocuments, isNew: false , isNavigationBranch: true , animated: true )
466
+ delegate? . documentSelectionDidChange ( self ,
467
+ documentContainers: documentContainers,
468
+ documents: selectedDocuments,
469
+ selectRow: nil ,
470
+ isNew: false ,
471
+ isNavigationBranch: true ,
472
+ animated: true )
431
473
}
432
474
433
475
private func createLayout( ) -> UICollectionViewLayout {
@@ -503,7 +545,13 @@ extension DocumentsViewController {
503
545
guard animated else {
504
546
self . documents = sortedDocuments
505
547
self . collectionView. reloadData ( )
506
- self . delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: false , isNavigationBranch: isNavigationBranch, animated: true )
548
+ self . delegate? . documentSelectionDidChange ( self ,
549
+ documentContainers: documentContainers,
550
+ documents: [ ] ,
551
+ selectRow: nil ,
552
+ isNew: false ,
553
+ isNavigationBranch: isNavigationBranch,
554
+ animated: true )
507
555
return
508
556
}
509
557
@@ -536,7 +584,13 @@ extension DocumentsViewController {
536
584
self . collectionView. selectItem ( at: indexPath, animated: false , scrollPosition: [ ] )
537
585
self . collectionView. scrollToItem ( at: indexPath, at: [ ] , animated: true )
538
586
} else {
539
- self . delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: false , isNavigationBranch: isNavigationBranch, animated: true )
587
+ self . delegate? . documentSelectionDidChange ( self ,
588
+ documentContainers: documentContainers,
589
+ documents: [ ] ,
590
+ selectRow: nil ,
591
+ isNew: false ,
592
+ isNavigationBranch: isNavigationBranch,
593
+ animated: true )
540
594
}
541
595
}
542
596
@@ -799,7 +853,13 @@ private extension DocumentsViewController {
799
853
func delete( ) {
800
854
let deselect = selectedDocuments. filter ( { documents. contains ( $0) } ) . isEmpty
801
855
if deselect, let documentContainers = self . documentContainers {
802
- self . delegate? . documentSelectionDidChange ( self , documentContainers: documentContainers, documents: [ ] , isNew: false , isNavigationBranch: true , animated: true )
856
+ self . delegate? . documentSelectionDidChange ( self ,
857
+ documentContainers: documentContainers,
858
+ documents: [ ] ,
859
+ selectRow: nil ,
860
+ isNew: false ,
861
+ isNavigationBranch: true ,
862
+ animated: true )
803
863
}
804
864
for document in documents {
805
865
document. account? . deleteDocument ( document)
0 commit comments