HealthProbe / REFACTORING_DATA_TYPE_VIEWS.md
Newer Older
143 lines | 5.331kb
Bogdan Timofte authored 3 weeks ago
1
# Data Type Views Optimization – Visual Redesign
2

            
3
## Summary
4

            
5
Optimized data type detail views by replacing table-heavy layouts with graphics-based visual indicators. Emphasis on **deduplication**, **symbol-driven transitions**, and **evolution visualization** rather than textual data rows.
6

            
7
---
8

            
9
## New Components Created
10

            
11
### 1. **MetricComparisonCard** (`Views/DataTypes/MetricComparisonCard.swift`)
12
Visual metric comparison between current and previous snapshot with:
13
- Side-by-side value boxes for "Now" vs "Before"
14
- Delta indicator with directional arrow (↑ ↓ -)
15
- Percentage change display
16
- Color-coded severity badge
17
- Deduplicates textual row-based comparison
18

            
19
### 2. **TypeEvolutionTimeline** (`Views/DataTypes/TypeEvolutionTimeline.swift`)
20
Timeline visualization across multiple snapshots showing:
21
- Bar chart of count evolution over time
22
- Current snapshot highlighted
23
- Vertical connectors showing increase/decrease transitions (▲ ▼)
24
- Compact stats row (Min/Max/Latest)
25
- Deduplicates redundant date/count rows
26

            
27
### 3. **RecordChangeIndicator** (`Views/DataTypes/RecordChangeIndicator.swift`)
28
Visual record change summary with:
29
- Two interactive buttons: "Added" (green) and "Gone" (red)
30
- Percentage breakdowns
31
- Stacked progress bar visualization
32
- Navigates to detail lists on tap
33
- More compact than section-based rows
34

            
35
### 4. **DataTypeRangeIndicator** (`Views/DataTypes/DataTypeRangeIndicator.swift`)
36
Data range visualization showing:
37
- Earliest and latest date with calendar icons
38
- Day span counter in center
39
- Gradient timeline bar
40
- Quality badge for incomplete captures
41
- Single card replaces 3 rows (Earliest, Latest, Quality)
42

            
43
---
44

            
45
## Refactored Views
46

            
47
### `DataTypeSnapshotDetailView` (Snapshots folder)
48

            
49
**Before:**
50
- List-based layout with 8+ sections
51
- `summarySection`: repeated count values in rows
52
- `rangeSection`: 2 separate date rows + quality row
53
- `changeSummarySection`: 5 rows of comparison data
54
- `recordNavigationSection`: navigation links as rows
55

            
56
**After:**
57
- ScrollView with VStack layout
58
- Uses 4 optimized components:
59
  - `MetricComparisonCard` (replaces summary + comparison rows)
60
  - `TypeEvolutionTimeline` (replaces implicit count history)
61
  - `DataTypeRangeIndicator` (replaces 3 date/quality rows)
62
  - `RecordChangeIndicator` (replaces navigation rows)
63
- 220 lines removed (40% reduction)
64
- Empty state graphics instead of generic text
65

            
66
### `DataTypesView` (DataTypes folder)
67

            
68
**Before:**
69
- `TypeDiffRow`: dense text-only row
70
  - Stacked metrics with labels and values
71
  - Hard to scan visually
72
  - Minimal visual hierarchy
73

            
74
**After:**
75
- Enhanced `TypeDiffRow` with:
76
  - Color-coded metric boxes (Now / Before)
77
  - Directional delta indicator (↑ green, ↓ red, - gray, ✨ new)
78
  - Severity badge on same row
79
  - Better visual rhythm and scanability
80
- Added navigation to detail view
81
- Compact metrics display with proper typography hierarchy
82

            
83
---
84

            
85
## Design Improvements
86

            
87
### Deduplication Achieved
88
- **Before:** Same information repeated in text form (rows) + badge visualization
89
- **After:** Information expressed once through visual components
90
  - Counts → colored metric boxes
91
  - Delta direction → arrow icons
92
  - Change severity → color + badge
93
  - Date ranges → timeline visualization
94

            
95
### Graphics > Tables
96
- Vertical bar chart for evolution (TypeEvolutionTimeline)
97
- Gradient timeline for date ranges (DataTypeRangeIndicator)
98
- Progress bar for record distribution (RecordChangeIndicator)
99
- Directional arrows for transitions (↑ ↓ -) instead of text labels
100

            
101
### Visual Transitions & Evolution
102
- **Direction indicators:** ↑ increase (green), ↓ decrease (red), - stable (gray), ✨ new
103
- **Timeline bars:** Show 5-point progression of counts over time
104
- **Gradient fills:** Earliest → Latest date range
105
- **Icon rendering:** Hierarchical SF Symbols for signal priority
106

            
107
---
108

            
109
## File Changes Summary
110

            
111
| File | Change | Impact |
112
|------|--------|--------|
113
| `DataTypeSnapshotDetailView.swift` | Replaced List + sections with ScrollView + cards | -220 lines, more visual |
114
| `DataTypesView.swift` | Enhanced row design + navigation | Better scannability |
115
| `MetricComparisonCard.swift` | NEW | Shows current vs previous at a glance |
116
| `TypeEvolutionTimeline.swift` | NEW | Visualizes count trends over time |
117
| `RecordChangeIndicator.swift` | NEW | Visual record diff summary |
118
| `DataTypeRangeIndicator.swift` | NEW | Compact date range + quality display |
119

            
120
---
121

            
122
## Testing Checklist
123

            
124
- [ ] `MetricComparisonCard` preview renders in Light/Dark modes
125
- [ ] `TypeEvolutionTimeline` handles 2+ snapshots correctly
126
- [ ] `RecordChangeIndicator` buttons navigate to record lists
127
- [ ] `DataTypeRangeIndicator` shows complete state with/without dates
128
- [ ] `DataTypeSnapshotDetailView` displays all 4 cards in correct order
129
- [ ] Navigation from list to detail view works
130
- [ ] Empty states show proper icons
131
- [ ] Accessibility labels set on interactive elements
132
- [ ] VoiceOver reads evolution timeline sensibly
133
- [ ] No health values visible without explicit tap
134

            
135
---
136

            
137
## Next Steps
138

            
139
- Integrate updated views into live app preview
140
- Verify record list navigation paths
141
- Test with varying data volumes (1 snapshot, 10+, sparse data)
142
- Adjust spacing/typography based on visual testing
143
- Consider adding animation to timeline transitions