# סיכום סשן — 0009
תאריך: 2026-05-12 02:00
אפליקציה: VitVital
נושא: Firebase + M1.2

## מה נבנה/הושלם

### Firebase Setup (חוסם build מסשן 0006 — נפתר)
- פרויקט `vitvital` נוצר דרך Firebase MCP
- `flutter create --platforms=android,web .` הורץ
- `flutterfire configure --project=vitvital` → `firebase_options.dart` + `google-services.json`
- Package name שונה: `com.example.vitvital` → `com.vitruvius.vitvital`
- `MainActivity.kt` הועבר ל-`com/vitruvius/vitvital/`
- Firestore `(default)` נוצר ב-`europe-west1` דרך Firebase CLI
- `firestore.rules` + `firestore.indexes.json` נוצרו ופורסו
- Firebase Auth הופעל: Email/Password + Google Sign-In (דרך `firebase_init` + `firebase deploy --only auth`)
- SHA-1 debug fingerprint נוסף דרך Firebase MCP
- `flutterfire configure` הורץ שוב → `google-services.json` עם `oauth_client` type 1+3

### M1.2 — Health Connect Baseline
- `AndroidManifest.xml`: 20 HC permissions + `SHOW_PERMISSIONS_RATIONALE` intent-filter + `ViewPermissionUsageActivity`
- `dashboard_screen.dart`: StatefulWidget, requestPermissions flow, snapshot יומי מ-HC (צעדים, קלוריות, מרחק, HR, HRV, SpO₂, טמפרטורה, שינה עם bar ו-stages)
- `body_screen.dart`: StatefulWidget, משקל נוכחי + BMI card, fl_chart LineChart 30 יום, history list (10 רשומות אחרונות)
- `app-debug.apk` בנוי בהצלחה (157MB)

## החלטות שהתקבלו
- Package name: `com.vitruvius.vitvital` (לא `com.example`) — Vitruvius branding
- Firestore region: `europe-west1` — קרוב לישראל, ב-Spark plan
- `receive_sharing_intent` הוסר מ-pubspec — גורם ל-JVM target conflict, לא נדרש עד M1.5
- `minSdk = 26` — דרישת `health` package v11
- `isCoreLibraryDesugaringEnabled = true` — דרישת `flutter_local_notifications`
- compileOptions Java 1.8 + jvmTarget 1.8 — מניעת JVM conflict בין plugins

## בעיות שנפתרו

### JVM Target Mismatch
- `receive_sharing_intent`: Java 1.8, Kotlin 21 → גרם ל-build failure
- ניסינו global override ב-`build.gradle.kts` → `afterEvaluate` לא עובד, `compilerOptions` DSL חדש
- **פתרון:** הסרת `receive_sharing_intent` + compileOptions Java 1.8

### `HealthDataType.FLOORS_CLIMBED` לא קיים
- health package v11 לא כולל `FLOORS_CLIMBED` כ-enum value
- **פתרון:** הוסרה מ-`kAllReadTypes` ומה-aggregation switch

### Firebase Auth ב-404
- `identitytoolkit.googleapis.com` Admin API החזיר 404 כי Auth לא מאותחל
- ניסיון: Service Usage API לאפשר identitytoolkit → לא פתר
- **פתרון:** `mcp__firebase__firebase_init` עם `auth.providers.googleSignIn` → `firebase deploy --only auth`

### `oauth_client` ריק ב-google-services.json
- Google Sign-In דורש `client_type 1` (Android) + `client_type 3` (web)
- הם נוצרים רק אחרי `firebase deploy --only auth` + SHA-1 registered + `flutterfire configure` שוב
- **פתרון:** deploy auth → הוסף SHA-1 → הרץ flutterfire שוב → oauth_client type 1+3 ✓

### Firestore דרך Firebase MCP נכשל
- `firestore_create_database` החזיר "billing required"
- **פתרון:** `firebase.exe firestore:databases:create "(default)" --location=europe-west1` דרך CLI

## מה לא עבד / צריך להיזהר
- `firebase_update_environment` לא מספיק לבד — צריך `firebase.json` עם `firestore` config לפני `firebase deploy`
- `firebase init firestore --non-interactive` — פותח interactive prompt גם עם `--non-interactive`
- `JavaVersion.VERSION_17.toString()` מחזיר "17" לא "1.7" — זה תקין אבל גורם לבעיות עם plugins ישנים
- `afterEvaluate {}` ב-`subprojects {}` נכשל אם `project.evaluationDependsOn(":app")` קיים
- Chrome extension לא היה מחובר — computer-use request_access timeout

## קבצים שנוצרו/שונו
```
android/app/build.gradle.kts          — namespace, applicationId, minSdk=26, desugaring, compileOptions 1.8
android/build.gradle.kts              — (ללא שינוי סופי — ניסיונות global JVM override בוטלו)
android/app/src/main/AndroidManifest.xml — 20 HC permissions + intent-filters
android/app/src/main/kotlin/com/vitruvius/vitvital/MainActivity.kt — package updated
lib/firebase_options.dart             — נוצר על ידי flutterfire (web + android)
android/app/google-services.json      — oauth_client type 1+3
lib/screens/dashboard/dashboard_screen.dart — M1.2 real UI
lib/screens/body/body_screen.dart     — M1.2 real UI + fl_chart
lib/services/health_connect_service.dart — הוסרה FLOORS_CLIMBED
firebase.json                         — Firestore + Auth + Flutter config
firestore.rules                        — security rules (userId-scoped)
firestore.indexes.json                 — ריק
pubspec.yaml                          — הוסרה receive_sharing_intent
```

## הצעד הבא — M1.3 Qingping
1. OAuth flow עם `flutter_web_auth_2`: `GET /oauth/authorize` → callback scheme → `POST /oauth/token`
2. Store tokens: Firestore `oauth_tokens/{uid}` (access + refresh + expiry)
3. Qingping service: `getDevices()` → `getDeviceData(deviceMac, from, to)` → BIA metrics
4. Map Qingping JSON → `BodyComposition` model (14 שדות S400)
5. כתיבה: Firestore `body_composition` + `health.writeHealthData(WEIGHT)`
6. BodyScreen: הצג נתוני Qingping + refresh button
7. AndroidManifest: custom scheme `vitvital://oauth` לcallback
