Skip to content

Commit 87ba671

Browse files
committed
Add comprehensive documentation and deprecation annotations for v0.9.0
Documentation: - Add Apple-style documentation to all public APIs - Update copyright headers to 2016-2026 across all files - Add ANNOUNCEMENT.md API Comparison section (0.8.2 vs 0.9.0) - Document migration path from DataSource to Direct Data pattern - Add code examples and usage guides Deprecations: - Mark SwiftDataTableDataSource protocol as deprecated - Mark reload() method as deprecated (use setData instead) - Mark largeScale() as deprecated (use automatic instead) - Remove dead code: reloadRowsOnly() method - Delete obsolete ANNOUNCEMENTS.md draft file New files: - DataStyles.swift, DataTableCellSizingMode.swift - DataTableColumnOrder.swift, DataTableCustomCellProvider.swift - DataTableRowHeightMode.swift, DataTableTextLayout.swift - SearchBarPosition.swift - DataTableCellRepresentable.swift (renamed) - DataTableSupplementaryElementRepresentable.swift (renamed) Tests: - Update test file headers - Add comprehensive documentation to test classes Demos: - Update all demo view controllers with proper headers - Improve explanation views with documentation
1 parent d6c7a14 commit 87ba671

File tree

110 files changed

+3485
-643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3485
-643
lines changed

ANNOUNCEMENT.md

Lines changed: 174 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,174 @@ config.rowHeightMode = .automatic(estimated: 60)
347347

348348
---
349349

350+
## API Comparison: 0.8.2 vs 0.9.0
351+
352+
### Deprecated APIs
353+
354+
The following APIs are deprecated in 0.9.0 and will be removed in a future version:
355+
356+
| Deprecated | Replacement | Reason |
357+
|------------|-------------|--------|
358+
| `SwiftDataTableDataSource` protocol | Direct data pattern | No animated diffing, boilerplate-heavy |
359+
| `reload()` method | `setData(_:animatingDifferences:)` | Resets scroll, no animations |
360+
| `largeScale(estimatedHeight:prefetchWindow:)` | `automatic(estimated:prefetchWindow:)` | Renamed for clarity |
361+
362+
### Data Flow Comparison
363+
364+
**0.8.2 DataSource Pattern (Deprecated):**
365+
```
366+
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
367+
│ Your Data │────▶│ DataSource Methods │────▶│ SwiftDataTable │
368+
│ [Item] array │ │ (4 protocol funcs) │ │ reload() │
369+
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘
370+
371+
• No diffing
372+
• No animations
373+
• Scroll resets to top
374+
```
375+
376+
**0.9.0 Direct Data Pattern:**
377+
```
378+
┌─────────────────────┐ ┌─────────────────────┐
379+
│ Your Data │────▶│ SwiftDataTable │
380+
│ [Item] array │ │ setData() + diffing │
381+
└─────────────────────┘ └─────────────────────┘
382+
383+
• Automatic diffing
384+
• Animated ins/del/move
385+
• Scroll position preserved
386+
• Cell-level updates only
387+
```
388+
389+
### Feature Comparison
390+
391+
| Feature | 0.8.2 (DataSource) | 0.9.0 (Direct Data) |
392+
|---------|-------------------|---------------------|
393+
| **Setup Complexity** | Implement 4 protocol methods | Pass data to initializer |
394+
| **Type Safety** | Manual `DataTableValueType` arrays | Generic `DataTableColumn<T>` |
395+
| **Animated Updates** | ❌ No | ✅ Yes |
396+
| **Scroll Preservation** | ❌ Resets to top | ✅ Maintains position |
397+
| **Cell-Level Diffing** | ❌ Full row reload | ✅ Only changed cells |
398+
| **Identity Tracking** | Manual | Automatic via `Identifiable` |
399+
| **Code Lines** | ~30+ lines | ~5 lines |
400+
401+
### Side-by-Side Code Comparison
402+
403+
<table>
404+
<tr>
405+
<th>0.8.2 DataSource Pattern (Deprecated)</th>
406+
<th>0.9.0 Direct Data Pattern</th>
407+
</tr>
408+
<tr>
409+
<td>
410+
411+
```swift
412+
class MyVC: UIViewController,
413+
SwiftDataTableDataSource {
414+
var items: [Item] = []
415+
let dataTable = SwiftDataTable()
416+
417+
override func viewDidLoad() {
418+
super.viewDidLoad()
419+
dataTable.dataSource = self
420+
}
421+
422+
func numberOfColumns(in: SwiftDataTable) -> Int {
423+
return 3
424+
}
425+
426+
func numberOfRows(in: SwiftDataTable) -> Int {
427+
return items.count
428+
}
429+
430+
func dataTable(_ dt: SwiftDataTable,
431+
dataForRowAt index: Int) -> DataTableRow {
432+
let item = items[index]
433+
return [
434+
.string(item.name),
435+
.int(item.age),
436+
.string(item.status)
437+
]
438+
}
439+
440+
func dataTable(_ dt: SwiftDataTable,
441+
headerTitleForColumnAt col: Int) -> String {
442+
["Name", "Age", "Status"][col]
443+
}
444+
445+
func updateData() {
446+
items = fetchNewItems()
447+
dataTable.reload() // No animation, scroll resets
448+
}
449+
}
450+
```
451+
452+
</td>
453+
<td>
454+
455+
```swift
456+
class MyVC: UIViewController {
457+
var items: [Item] = []
458+
var dataTable: SwiftDataTable!
459+
460+
override func viewDidLoad() {
461+
super.viewDidLoad()
462+
dataTable = SwiftDataTable(
463+
data: items,
464+
columns: [
465+
.init("Name", \.name),
466+
.init("Age", \.age),
467+
.init("Status", \.status)
468+
]
469+
)
470+
}
471+
472+
func updateData() {
473+
items = fetchNewItems()
474+
dataTable.setData(
475+
items,
476+
animatingDifferences: true
477+
)
478+
// ✅ Automatic diffing
479+
// ✅ Smooth animations
480+
// ✅ Scroll preserved
481+
// ✅ Only changed cells update
482+
}
483+
}
484+
485+
// Just add Identifiable conformance
486+
struct Item: Identifiable {
487+
let id: Int
488+
let name: String
489+
let age: Int
490+
let status: String
491+
}
492+
```
493+
494+
</td>
495+
</tr>
496+
</table>
497+
498+
### Migration Checklist
499+
500+
- [ ] Remove `SwiftDataTableDataSource` conformance from your view controllers
501+
- [ ] Add `Identifiable` conformance to your model types
502+
- [ ] Replace protocol methods with `DataTableColumn` definitions
503+
- [ ] Replace `dataTable.reload()` with `dataTable.setData(_:animatingDifferences:)`
504+
- [ ] (Optional) Use typed API: `SwiftDataTable(data: items, columns: [...])`
505+
- [ ] (Optional) Enable text wrapping: `config.textLayout = .wrap`
506+
- [ ] (Optional) Enable auto heights: `config.rowHeightMode = .automatic(estimated: 44)`
507+
508+
### Benefits of Migration
509+
510+
1. **Less Code**: ~80% reduction in boilerplate
511+
2. **Better UX**: Animated row changes instead of jarring reloads
512+
3. **Performance**: Cell-level diffing means less work for UIKit
513+
4. **Type Safety**: Compiler catches column/model mismatches
514+
5. **Scroll Stability**: Users don't lose their place during updates
515+
516+
---
517+
350518
## Superseded Patterns
351519

352520
The following patterns still work but have better alternatives:
@@ -372,7 +540,7 @@ This release also addresses deprecated iOS APIs internally:
372540

373541
## Migration Guide
374542

375-
### From 0.8.x
543+
### From 0.8.2
376544

377545
**No breaking changes** - your existing code continues to work. The new APIs are additive.
378546

@@ -422,15 +590,18 @@ table.setData(users, animatingDifferences: true)
422590

423591
## Large-Scale Mode (100k+ Rows)
424592

425-
For tables with massive datasets, enable large-scale mode for lazy measurement and optimal scroll performance:
593+
For tables with massive datasets, enable automatic mode with lazy measurement for optimal scroll performance:
426594

427595
```swift
428596
var config = DataTableConfiguration()
429-
config.rowHeightMode = .largeScale(estimatedHeight: 44, prefetchWindow: 10)
597+
config.rowHeightMode = .automatic(estimated: 44, prefetchWindow: 10)
430598

431599
let table = SwiftDataTable(data: massiveDataset, columns: columns, options: config)
432600
```
433601

602+
> **Note**: The `.largeScale()` function is deprecated. Use `.automatic(estimated:prefetchWindow:)` instead.
603+
> The functionality is identical - only the name changed for API consistency.
604+
434605
### How It Works
435606

436607
- **Lazy Measurement**: Rows start with estimated heights and are measured on-demand as they scroll into view

ANNOUNCEMENTS.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

Example/DemoSwiftDataTables/App/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// AppDelegate.swift
33
// SwiftDataTables
44
//
5-
// Created by pavankataria on 03/09/2017.
6-
// Copyright (c) 2017 pavankataria. All rights reserved.
5+
// Created by Pavan Kataria on 03/09/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
77
//
88

99
import UIKit

Example/DemoSwiftDataTables/App/MenuTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//
22
// MenuTableViewController.swift
3-
// SwiftDataTables_Example
3+
// SwiftDataTables
44
//
55
// Created by Pavan Kataria on 13/06/2018.
6-
// Copyright © 2017 Pavan Kataria. All rights reserved.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
77
//
88

99
import Foundation

Example/DemoSwiftDataTables/Demos/AutoLayoutStressTest/AutoLayoutStressTestDemoViewController+Explanation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//
22
// AutoLayoutStressTestDemoViewController+Explanation.swift
3-
// DemoSwiftDataTables
3+
// SwiftDataTables
4+
//
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
47
//
58

69
import UIKit

Example/DemoSwiftDataTables/Demos/AutoLayoutStressTest/AutoLayoutStressTestDemoViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//
22
// AutoLayoutStressTestDemoViewController.swift
3-
// DemoSwiftDataTables
3+
// SwiftDataTables
44
//
5-
// Demonstrates smooth row height transitions with dynamic AutoLayout content.
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
67
//
78

89
import UIKit

Example/DemoSwiftDataTables/Demos/CellLevelUpdates/CellLevelUpdatesDemoViewController+Explanation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//
22
// CellLevelUpdatesDemoViewController+Explanation.swift
3-
// DemoSwiftDataTables
3+
// SwiftDataTables
4+
//
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
47
//
58

69
import UIKit

Example/DemoSwiftDataTables/Demos/CellLevelUpdates/CellLevelUpdatesDemoViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//
22
// CellLevelUpdatesDemoViewController.swift
3-
// DemoSwiftDataTables
3+
// SwiftDataTables
44
//
5-
// Created for SwiftDataTables.
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
67
//
78

89
import UIKit

Example/DemoSwiftDataTables/Demos/ColumnSortability/ColumnSortabilityDemoViewController+Explanation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//
22
// ColumnSortabilityDemoViewController+Explanation.swift
3-
// DemoSwiftDataTables
3+
// SwiftDataTables
4+
//
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
47
//
58

69
import UIKit

Example/DemoSwiftDataTables/Demos/ColumnSortability/ColumnSortabilityDemoViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// ColumnSortabilityDemoViewController.swift
33
// SwiftDataTables
44
//
5-
// Interactive demo for per-column sortability control.
5+
// Created by Pavan Kataria on 22/02/2017.
6+
// Copyright © 2016-2026 Pavan Kataria. All rights reserved.
67
//
78

89
import UIKit

0 commit comments

Comments
 (0)