@buivietphi/skill-mobile-mt 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @buivietphi/skill-mobile-mt might be problematic. Click here for more details.

@@ -0,0 +1,210 @@
1
+ # Performance Prediction — Simulate Before Deploy
2
+
3
+ > Calculate frame rates, bridge calls, and memory before deploying code.
4
+
5
+ ## Performance Prophet Pattern
6
+
7
+ **Predict behavior BEFORE deployment** using mathematical models.
8
+
9
+ ### Frame Budget Calculation
10
+
11
+ ```
12
+ TARGET: 60 FPS = 16.67ms per frame
13
+ PROMOTION: 120 FPS = 8.33ms per frame
14
+
15
+ BUDGET BREAKDOWN (React Native):
16
+ - JavaScript execution: 8ms
17
+ - Bridge calls: 3ms
18
+ - Native rendering: 4ms
19
+ - Layout: 1.67ms
20
+
21
+ RULE: Total < 16.67ms for 60 FPS
22
+ ```
23
+
24
+ ### Predict List Performance
25
+
26
+ ```typescript
27
+ // Given code:
28
+ <FlatList
29
+ data={items} // 50 items
30
+ renderItem={({ item }) => (
31
+ <Item
32
+ title={item.title} // 1 bridge call
33
+ image={item.image} // 1 bridge call
34
+ onPress={() => logEvent(item.id)} // 1 bridge call
35
+ />
36
+ )}
37
+ />
38
+
39
+ // Calculate:
40
+ Bridge calls per item: 3
41
+ Total items: 50
42
+ Total bridge calls: 50 × 3 = 150 calls
43
+ Time per call: ~0.3ms
44
+ Total time: 150 × 0.3ms = 45ms per frame
45
+
46
+ // Prediction:
47
+ 16.67ms (60 FPS budget) vs 45ms (actual)
48
+ Result: 16.67 / 45 = 0.37 → 37% of 60 FPS = 22 FPS
49
+ Verdict: ❌ JANK - Users will notice lag
50
+
51
+ // Auto-fix suggestions:
52
+ 1. Use getItemLayout (saves layout calculations)
53
+ 2. Memoize renderItem component
54
+ 3. Defer logEvent to InteractionManager
55
+ 4. Use native driver for animations
56
+ 5. Implement virtualization (windowSize: 5)
57
+
58
+ Expected after fix: ~12ms per frame → 60 FPS ✓
59
+ ```
60
+
61
+ ### Predict Memory Usage
62
+
63
+ ```
64
+ IMAGE CALCULATION:
65
+ - Image: 1000×1000 pixels
66
+ - Color depth: 4 bytes (RGBA)
67
+ - Memory: 1000 × 1000 × 4 = 4MB per image
68
+
69
+ List with 50 images:
70
+ - No optimization: 50 × 4MB = 200MB
71
+ - With thumbnail (200×200): 50 × 0.16MB = 8MB
72
+ - Verdict: Use thumbnails + lazy load
73
+
74
+ MEMORY BUDGET:
75
+ - iOS: ~120MB baseline
76
+ - Android: ~80MB baseline (varies by device)
77
+ - Target: < 150MB total for stability
78
+ ```
79
+
80
+ ### Predict Bundle Impact
81
+
82
+ ```
83
+ NEW PACKAGE: moment.js
84
+ Size: 230KB minified
85
+ Bundle before: 2.1MB
86
+ Bundle after: 2.33MB
87
+ Impact: +11% bundle size
88
+
89
+ Alternatives:
90
+ - date-fns/esm: 50KB (modular)
91
+ - day.js: 2KB (minimal)
92
+ Recommendation: Use day.js → 98% size reduction
93
+ ```
94
+
95
+ ## Quick Calculations
96
+
97
+ ### 1. FlatList Frame Rate
98
+ ```
99
+ Formula: FPS = 16.67ms / (bridge_calls × 0.3ms + render_time)
100
+
101
+ Example:
102
+ - 100 items
103
+ - 5 bridge calls per item
104
+ - 2ms render time per item
105
+
106
+ Time per frame: (100 × 5 × 0.3ms) + (100 × 2ms) = 150ms + 200ms = 350ms
107
+ FPS: 16.67 / 350 = 0.048 → 4.8 FPS
108
+
109
+ Verdict: ❌ UNUSABLE - Must optimize
110
+ ```
111
+
112
+ ### 2. Animation Smoothness
113
+ ```
114
+ Rule: Use native driver when possible
115
+
116
+ With native driver:
117
+ - Runs at 60 FPS (or 120 FPS ProMotion)
118
+ - No bridge calls per frame
119
+ - Smooth animations
120
+
121
+ Without native driver:
122
+ - JavaScript thread: ~16.67ms budget
123
+ - Each frame: ~2-3 bridge calls
124
+ - Often drops to 30-45 FPS
125
+
126
+ Verdict: Always use { useNativeDriver: true }
127
+ ```
128
+
129
+ ### 3. Network Overhead
130
+ ```
131
+ API Response: 500KB JSON
132
+ Parse time: ~50ms (varies by device)
133
+ UI block: 50ms = 3 frames dropped
134
+
135
+ Optimization:
136
+ - Paginate: 50KB per page → 5ms parse
137
+ - Background thread: 0 frames dropped
138
+ ```
139
+
140
+ ## Platform-Specific Predictions
141
+
142
+ ### React Native
143
+ ```
144
+ KNOWN BOTTLENECKS:
145
+ 1. Bridge calls: 0.3ms each
146
+ 2. console.log: 10-50ms (dev mode)
147
+ 3. Inline styles: Re-creates every render
148
+ 4. Anonymous functions in render: Creates new reference
149
+
150
+ OPTIMIZATION PRIORITY:
151
+ 1. Remove console.log (50ms → 0ms)
152
+ 2. StyleSheet.create (5ms → 0.1ms)
153
+ 3. useCallback/useMemo (prevents re-renders)
154
+ 4. Native driver animations (60 FPS guaranteed)
155
+ ```
156
+
157
+ ### Flutter
158
+ ```
159
+ KNOWN BOTTLENECKS:
160
+ 1. Build method: Should be < 8ms
161
+ 2. setState: Triggers full rebuild
162
+ 3. Large widget trees: O(n) complexity
163
+
164
+ OPTIMIZATION PRIORITY:
165
+ 1. const constructors (immutable widgets)
166
+ 2. ListView.builder vs ListView (O(visible) vs O(n))
167
+ 3. RepaintBoundary (isolate repaints)
168
+ 4. Selective rebuilds (Consumer vs rebuild all)
169
+ ```
170
+
171
+ ## Prediction Workflow
172
+
173
+ ```
174
+ BEFORE IMPLEMENTING:
175
+ 1. Estimate bridge calls (RN) or build time (Flutter)
176
+ 2. Calculate frame budget impact
177
+ 3. Predict FPS: 16.67ms / total_time
178
+ 4. If < 60 FPS: redesign or optimize first
179
+
180
+ AFTER IMPLEMENTING:
181
+ 1. Profile with React DevTools / Flutter DevTools
182
+ 2. Compare predicted vs actual
183
+ 3. Adjust model if off by > 20%
184
+ 4. Document learnings for next time
185
+ ```
186
+
187
+ ## Auto-Suggestions
188
+
189
+ ```
190
+ If prediction shows < 60 FPS:
191
+
192
+ FOR LISTS:
193
+ ✓ Use getItemLayout
194
+ ✓ Memoize renderItem
195
+ ✓ Reduce bridge calls
196
+ ✓ Virtualization (windowSize)
197
+ ✓ Thumbnail images
198
+
199
+ FOR ANIMATIONS:
200
+ ✓ Use native driver
201
+ ✓ Avoid layout animations
202
+ ✓ Prefer transform/opacity
203
+ ✓ Use InteractionManager
204
+
205
+ FOR MEMORY:
206
+ ✓ Image optimization
207
+ ✓ Lazy loading
208
+ ✓ Pagination
209
+ ✓ Clear caches
210
+ ```
@@ -0,0 +1,159 @@
1
+ # Platform Excellence — iOS vs Android Guidelines
2
+
3
+ > Not one-size-fits-all. Follow native platform guidelines.
4
+
5
+ ## Philosophy
6
+
7
+ ❌ **BAD**: Same UI for both platforms
8
+ ✅ **GOOD**: Platform-specific UI, shared business logic
9
+ 🎯 **TARGET**: >80% code sharing, 100% platform-native UX
10
+
11
+ ---
12
+
13
+ ## iOS 18+ Guidelines
14
+
15
+ ### Navigation
16
+ - Use NavigationStack, not legacy NavigationView
17
+ - Tab bar at bottom, always visible
18
+ - Back button top-left, standard chevron
19
+ - Swipe from left edge to go back
20
+
21
+ ### Interactions
22
+ - Haptic feedback for important actions
23
+ - 3D Touch / Haptic Touch context menus
24
+ - Swipe actions (leading/trailing)
25
+ - Pull-to-refresh standard
26
+
27
+ ### Typography
28
+ - SF Pro (system font)
29
+ - Dynamic Type support (accessibility)
30
+ - Hierarchy: Large Title > Title > Headline > Body
31
+
32
+ ### Colors
33
+ - Support Light + Dark mode
34
+ - Use semantic colors (not hardcoded)
35
+ - Respect user's appearance preference
36
+
37
+ ---
38
+
39
+ ## Android 15+ / Material 3
40
+
41
+ ### Navigation
42
+ - Navigation drawer from left
43
+ - Bottom navigation (3-5 items)
44
+ - Back button (system or top-left arrow)
45
+ - Floating Action Button (FAB) for primary action
46
+
47
+ ### Interactions
48
+ - Ripple effect on touch
49
+ - Material You (dynamic colors from wallpaper)
50
+ - Long-press for context menu
51
+ - Swipe-to-dismiss (lists, cards)
52
+
53
+ ### Typography
54
+ - Roboto (system font)
55
+ - Material Type Scale: Display > Headline > Title > Body
56
+
57
+ ### Colors
58
+ - Material 3 color system (primary, secondary, tertiary)
59
+ - Support Light + Dark theme
60
+ - Dynamic color (Material You)
61
+
62
+ ---
63
+
64
+ ## Performance Standards
65
+
66
+ | Metric | iOS | Android |
67
+ |--------|-----|---------|
68
+ | **Cold start** | < 1.0s | < 1.5s |
69
+ | **Memory baseline** | < 120MB | < 100MB |
70
+ | **FPS** | 60 (120 ProMotion) | 60 (90/120 if supported) |
71
+ | **Battery** | < 4%/hour | < 4%/hour |
72
+ | **Touch response** | < 16ms | < 16ms |
73
+
74
+ ---
75
+
76
+ ## Platform-Specific Features
77
+
78
+ ### iOS Only
79
+ - Face ID / Touch ID (biometrics)
80
+ - HealthKit (health data)
81
+ - Apple Pay
82
+ - SiriKit (voice)
83
+ - WidgetKit (home screen widgets)
84
+ - Live Activities (Dynamic Island)
85
+
86
+ ### Android Only
87
+ - Google Pay
88
+ - Widgets (home screen, lock screen)
89
+ - Background services (more flexible)
90
+ - File system access
91
+ - USB/Bluetooth flexibility
92
+
93
+ ---
94
+
95
+ ## Code Sharing Strategy
96
+
97
+ ```
98
+ SHARE (Business Logic):
99
+ ├── API calls
100
+ ├── Data models
101
+ ├── State management
102
+ ├── Business rules
103
+ └── Validation logic
104
+
105
+ PLATFORM-SPECIFIC (UI):
106
+ ├── Navigation patterns
107
+ ├── Gesture handling
108
+ ├── Platform components
109
+ └── Platform animations
110
+ ```
111
+
112
+ Example (React Native):
113
+ ```typescript
114
+ // Shared: business logic
115
+ export const useAuth = () => {
116
+ const login = async (email, password) => { ... } // Shared
117
+ return { login }
118
+ }
119
+
120
+ // Platform-specific: UI
121
+ import { LoginScreen as IOSLogin } from './LoginScreen.ios'
122
+ import { LoginScreen as AndroidLogin } from './LoginScreen.android'
123
+
124
+ export const LoginScreen = Platform.select({
125
+ ios: IOSLogin,
126
+ android: AndroidLogin
127
+ })
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Comparison Matrix
133
+
134
+ | Feature | iOS Guideline | Android Guideline |
135
+ |---------|---------------|-------------------|
136
+ | **Back nav** | Top-left chevron | System back / top-left arrow |
137
+ | **Tab bar** | Bottom, always visible | Bottom navigation |
138
+ | **Search** | Top, expandable | Top, collapsible |
139
+ | **FAB** | Rare, use + in nav bar | Common, bottom-right |
140
+ | **Context menu** | Haptic Touch | Long-press |
141
+ | **Swipe actions** | Leading/trailing | Swipe-to-dismiss |
142
+ | **Notifications** | Banner, center | Banner, top |
143
+ | **Dark mode** | System-controlled | System-controlled |
144
+
145
+ ---
146
+
147
+ ## Anti-Patterns
148
+
149
+ ```
150
+ ❌ Material Design on iOS
151
+ ❌ iOS navigation on Android
152
+ ❌ Ignoring platform conventions
153
+ ❌ "Write once, look mediocre everywhere"
154
+
155
+ ✅ Native look & feel per platform
156
+ ✅ Shared logic, platform UI
157
+ ✅ Respect platform guidelines
158
+ ✅ "Write once, look native everywhere"
159
+ ```