Compare commits
52 Commits
ca3f62c709
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e665dea82a | ||
|
|
b511ec5df0 | ||
|
|
c0e53cd3f6 | ||
|
|
4fc7abc5b4 | ||
|
|
e04bf6f405 | ||
|
|
bed761401f | ||
|
|
55463649b2 | ||
|
|
62d2aa17be | ||
|
|
acfb2259cc | ||
|
|
d1d2194861 | ||
|
|
b542f98a91 | ||
|
|
f983b869ba | ||
|
|
ead346bb1b | ||
|
|
8d27e771a7 | ||
|
|
31fe3a4260 | ||
|
|
a2c6cd1d4f | ||
|
|
5fe9f371b2 | ||
|
|
b27fb7ed4c | ||
|
|
919ef611bc | ||
|
|
3eeed888b5 | ||
|
|
322f611522 | ||
|
|
a7d2634c5f | ||
|
|
ae125f1144 | ||
|
|
d66907f636 | ||
|
|
508d69a4f4 | ||
|
|
ee00415d23 | ||
|
|
576b86fbbb | ||
|
|
918742293b | ||
|
|
19c06c71f8 | ||
|
|
3e5f3a7ece | ||
|
|
12fdd6da62 | ||
|
|
15a7319239 | ||
|
|
911fb86611 | ||
|
|
8b4c66ba0d | ||
|
|
1352dc49cc | ||
|
|
51ffe2031d | ||
|
|
c70ed9c504 | ||
|
|
67d798f590 | ||
|
|
d60cce83c9 | ||
|
|
c03d2b969c | ||
|
|
4af4450b94 | ||
|
|
6be4bed2e0 | ||
|
|
d13094c662 | ||
|
|
a9c3087f53 | ||
|
|
1b6d40627d | ||
|
|
67a7d1ad2a | ||
|
|
4ef550f48b | ||
|
|
993a5870c5 | ||
|
|
5a682bb6d7 | ||
|
|
bb5a89a06d | ||
|
|
3036eec3af | ||
|
|
63fc18ea74 |
@@ -1,88 +0,0 @@
|
||||
name: Deploy Flutter to Firebase (Mac)
|
||||
on:
|
||||
push:
|
||||
branches: release
|
||||
|
||||
jobs:
|
||||
deploy-android:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Vérifier l'installation Flutter
|
||||
run: flutter doctor -v
|
||||
|
||||
- name: Installer les dépendances Flutter
|
||||
run: flutter pub get
|
||||
|
||||
- name: Créer les fichiers secrets
|
||||
run: |
|
||||
echo "${{ secrets.ENV_FILE }}" > .env
|
||||
printf '%s' '${{ secrets.FIREBASE_CREDENTIALS }}' > ./android/firebase_credentials.json
|
||||
|
||||
- name: Lancer Fastlane (Force APK)
|
||||
working-directory: ./android
|
||||
env:
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
RAW_PROPERTIES: ${{ secrets.ANDROID_KEY_PROPERTIES }}
|
||||
FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }}
|
||||
run: |
|
||||
# 1. Config Ruby
|
||||
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
|
||||
export GEM_HOME=$PWD/vendor/bundle
|
||||
export GEM_PATH=$PWD/vendor/bundle
|
||||
export PATH=$GEM_HOME/bin:$PATH
|
||||
|
||||
# 2. Keystore & Properties
|
||||
echo "$ANDROID_KEYSTORE_BASE64" | base64 -D > keystore.jks
|
||||
KEYSTORE_PATH=$(pwd)/keystore.jks
|
||||
|
||||
echo "$RAW_PROPERTIES" > temp_props.txt
|
||||
STORE_PASS=$(grep "storePassword" temp_props.txt | cut -d'=' -f2 | tr -d '\r')
|
||||
KEY_PASS=$(grep "keyPassword" temp_props.txt | cut -d'=' -f2 | tr -d '\r')
|
||||
KEY_ALIAS=$(grep "keyAlias" temp_props.txt | cut -d'=' -f2 | tr -d '\r')
|
||||
|
||||
echo "storePassword=$STORE_PASS" > key.properties
|
||||
echo "keyPassword=$KEY_PASS" >> key.properties
|
||||
echo "keyAlias=$KEY_ALIAS" >> key.properties
|
||||
echo "storeFile=$KEYSTORE_PATH" >> key.properties
|
||||
|
||||
# 3. Installation Dépendances
|
||||
rm -rf vendor Gemfile.lock .bundle
|
||||
echo "source 'https://rubygems.org'" > Gemfile
|
||||
echo "gem 'fastlane', '>= 2.210.0'" >> Gemfile
|
||||
echo "gem 'fastlane-plugin-firebase_app_distribution'" >> Gemfile
|
||||
# Patchs Ruby 3.4
|
||||
echo "gem 'abbrev'" >> Gemfile
|
||||
echo "gem 'ostruct'" >> Gemfile
|
||||
echo "gem 'mutex_m'" >> Gemfile
|
||||
echo "gem 'base64'" >> Gemfile
|
||||
echo "gem 'csv'" >> Gemfile
|
||||
echo "gem 'bigdecimal'" >> Gemfile
|
||||
echo "gem 'drb'" >> Gemfile
|
||||
echo "gem 'nkf'" >> Gemfile
|
||||
|
||||
echo "⬇️ Installation..."
|
||||
gem install bundler -v 2.7.2 --force --no-document
|
||||
bundle _2.7.2_ update --jobs 4
|
||||
|
||||
# 4. CONSTRUCTION ET ENVOI MANUEL EN APK 🗝️
|
||||
# On remonte à la racine pour lancer Flutter
|
||||
cd ..
|
||||
|
||||
echo "🚧 Construction de l'APK (Format compatible sans Play Store)..."
|
||||
# C'est cette commande qui change tout : APK au lieu de AppBundle
|
||||
flutter build apk --release
|
||||
|
||||
# On redescend dans le dossier android pour lancer fastlane
|
||||
cd android
|
||||
|
||||
echo "🚀 Envoi de l'APK vers Firebase..."
|
||||
# On pointe vers le fichier APK généré
|
||||
bundle _2.7.2_ exec fastlane run firebase_app_distribution \
|
||||
app:"$FIREBASE_ANDROID_APP_ID" \
|
||||
android_artifact_path:"../build/app/outputs/flutter-apk/app-release.apk" \
|
||||
service_credentials_file:"firebase_credentials.json" \
|
||||
release_notes:"Build APK via Act - Test"
|
||||
226
.gitea/workflows/deploy.yaml
Normal file
226
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,226 @@
|
||||
name: Deploy TravelMate (Full Mobile)
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
|
||||
jobs:
|
||||
# --- JOB 1 : ANDROID (Génération APK) ---
|
||||
deploy-android:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Configuration Flutter & Secrets
|
||||
run: |
|
||||
flutter pub get
|
||||
echo "${{ secrets.ENV_FILE }}" > .env
|
||||
printf '%s' '${{ secrets.FIREBASE_CREDENTIALS }}' > ./android/firebase_credentials.json
|
||||
|
||||
- name: Build & Deploy Android
|
||||
working-directory: ./android
|
||||
env:
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
RAW_PROPERTIES: ${{ secrets.ANDROID_KEY_PROPERTIES }}
|
||||
FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }}
|
||||
run: |
|
||||
# 1. Keystore
|
||||
echo "$ANDROID_KEYSTORE_BASE64" | base64 -D > keystore.jks
|
||||
echo "$RAW_PROPERTIES" > temp_props.txt
|
||||
echo "storePassword=$(grep 'storePassword' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" > key.properties
|
||||
echo "keyPassword=$(grep 'keyPassword' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" >> key.properties
|
||||
echo "keyAlias=$(grep 'keyAlias' temp_props.txt | cut -d'=' -f2 | tr -d '\r')" >> key.properties
|
||||
echo "storeFile=$(pwd)/keystore.jks" >> key.properties
|
||||
|
||||
# 2. Gemfile (Correctifs Ruby 3.4 inclus)
|
||||
echo "source 'https://rubygems.org'" > Gemfile
|
||||
echo "gem 'fastlane', '>= 2.230.0'" >> Gemfile
|
||||
echo "gem 'fastlane-plugin-firebase_app_distribution'" >> Gemfile
|
||||
for g in abbrev ostruct mutex_m base64 csv bigdecimal drb nkf reline logger; do echo "gem '$g'" >> Gemfile; done
|
||||
|
||||
gem install bundler -v 2.7.2 --no-document
|
||||
bundle _2.7.2_ update
|
||||
|
||||
# 3. Build & Envoi
|
||||
cd .. && flutter build apk --release && cd android
|
||||
bundle _2.7.2_ exec fastlane run firebase_app_distribution \
|
||||
app:"$FIREBASE_ANDROID_APP_ID" \
|
||||
android_artifact_path:"../build/app/outputs/flutter-apk/app-release.apk" \
|
||||
service_credentials_file:"firebase_credentials.json"
|
||||
|
||||
# --- JOB 2 : IOS (Génération IPA) ---
|
||||
deploy-ios:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Dépendances iOS & Secrets
|
||||
run: |
|
||||
flutter pub get
|
||||
echo "${{ secrets.ENV_FILE }}" > .env
|
||||
printf '%s' '${{ secrets.FIREBASE_CREDENTIALS }}' > ./ios/firebase_credentials.json
|
||||
cd ios && (pod install --repo-update || pod update)
|
||||
|
||||
- name: Préparer le Code Signing
|
||||
env:
|
||||
P12_BASE: ${{ secrets.IOS_P12_BASE64 }}
|
||||
P12_PASS: ${{ secrets.IOS_P12_PASSWORD }}
|
||||
PROV_BASE: ${{ secrets.IOS_PROVISION_BASE64 }}
|
||||
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
||||
run: |
|
||||
# Créer et configurer le keychain
|
||||
security delete-keychain build.keychain || true
|
||||
security create-keychain -p "" build.keychain
|
||||
security unlock-keychain -p "" build.keychain
|
||||
security list-keychains -d user -s build.keychain $(security list-keychains -d user | xargs)
|
||||
security set-keychain-settings -lut 21600 build.keychain
|
||||
|
||||
# Importer le certificat
|
||||
echo "$P12_BASE" | base64 -D -o cert.p12
|
||||
security import cert.p12 -k build.keychain -P "$P12_PASS" -T /usr/bin/codesign
|
||||
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
|
||||
|
||||
# Installer le profil de provisioning
|
||||
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
|
||||
PROFILE_PATH=~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision
|
||||
echo "$PROV_BASE" | base64 -D -o "$PROFILE_PATH"
|
||||
|
||||
# Extraire l'UUID du profil
|
||||
PROFILE_UUID=$(/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i "$PROFILE_PATH"))
|
||||
echo "Profile UUID: $PROFILE_UUID"
|
||||
|
||||
# Copier avec l'UUID correct
|
||||
cp "$PROFILE_PATH" ~/Library/MobileDevice/Provisioning\ Profiles/$PROFILE_UUID.mobileprovision
|
||||
|
||||
- name: Configurer le projet Xcode
|
||||
env:
|
||||
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
||||
BUNDLE_ID: ${{ secrets.IOS_BUNDLE_ID }}
|
||||
run: |
|
||||
cd ios
|
||||
|
||||
# Extraire le nom du profil de provisioning
|
||||
PROV_NAME=$(/usr/libexec/PlistBuddy -c "Print Name" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
||||
echo "📝 Provisioning Profile Name: $PROV_NAME"
|
||||
|
||||
# Obtenir l'UUID du profil
|
||||
PROFILE_UUID=$(/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
||||
echo "🔑 Profile UUID: $PROFILE_UUID"
|
||||
|
||||
# Sauvegarder les variables pour la prochaine étape
|
||||
echo "$PROV_NAME" > /tmp/prov_name.txt
|
||||
echo "$TEAM_ID" > /tmp/team_id.txt
|
||||
echo "$BUNDLE_ID" > /tmp/bundle_id.txt
|
||||
|
||||
echo "✅ Configuration des paramètres de signing prête"
|
||||
|
||||
- name: Créer exportOptions.plist
|
||||
env:
|
||||
TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
|
||||
BUNDLE_ID: ${{ secrets.IOS_BUNDLE_ID }}
|
||||
run: |
|
||||
# Extraire le nom du profil
|
||||
PROV_NAME=$(/usr/libexec/PlistBuddy -c "Print Name" /dev/stdin <<< $(/usr/bin/security cms -D -i ~/Library/MobileDevice/Provisioning\ Profiles/distribution.mobileprovision))
|
||||
|
||||
cat > ios/exportOptions.plist <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>method</key>
|
||||
<string>ad-hoc</string>
|
||||
<key>teamID</key>
|
||||
<string>$TEAM_ID</string>
|
||||
<key>signingStyle</key>
|
||||
<string>manual</string>
|
||||
<key>provisioningProfiles</key>
|
||||
<dict>
|
||||
<key>$BUNDLE_ID</key>
|
||||
<string>$PROV_NAME</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
- name: Build IPA avec Flutter
|
||||
run: |
|
||||
# Récupérer les variables sauvegardées
|
||||
PROV_NAME=$(cat /tmp/prov_name.txt)
|
||||
TEAM_ID=$(cat /tmp/team_id.txt)
|
||||
BUNDLE_ID=$(cat /tmp/bundle_id.txt)
|
||||
|
||||
echo "📝 Provisioning Profile: $PROV_NAME"
|
||||
echo "🔑 Team ID: $TEAM_ID"
|
||||
echo "📦 Bundle ID: $BUNDLE_ID"
|
||||
|
||||
# Clean
|
||||
flutter clean
|
||||
flutter pub get
|
||||
|
||||
echo "🔨 Build de l'IPA avec Flutter..."
|
||||
|
||||
# Flutter build ipa gère automatiquement le signing des Pods
|
||||
# On utilise SEULEMENT --export-options-plist (pas --export-method)
|
||||
flutter build ipa \
|
||||
--release \
|
||||
--export-options-plist=ios/exportOptions.plist
|
||||
|
||||
echo "✅ Build terminé"
|
||||
echo "📂 Recherche de l'IPA..."
|
||||
|
||||
# L'IPA devrait être dans build/ios/ipa/
|
||||
find build/ios -name "*.ipa" -type f
|
||||
|
||||
IPA_FILE=$(find build/ios/ipa -name "*.ipa" | head -n 1)
|
||||
|
||||
if [ -z "$IPA_FILE" ]; then
|
||||
echo "❌ ERREUR: Aucun fichier IPA trouvé !"
|
||||
echo "📂 Contenu de build/ios/ :"
|
||||
ls -R build/ios/
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ IPA trouvée : $IPA_FILE"
|
||||
echo "📊 Taille : $(du -h "$IPA_FILE" | cut -f1)"
|
||||
|
||||
- name: Vérification et Upload Firebase
|
||||
env:
|
||||
FIREBASE_IOS_APP_ID: ${{ secrets.FIREBASE_IOS_APP_ID }}
|
||||
run: |
|
||||
cd ios
|
||||
|
||||
# Configuration Fastlane
|
||||
echo "source 'https://rubygems.org'" > Gemfile
|
||||
echo "gem 'fastlane', '>= 2.230.0'" >> Gemfile
|
||||
echo "gem 'fastlane-plugin-firebase_app_distribution'" >> Gemfile
|
||||
for g in abbrev ostruct mutex_m base64 csv bigdecimal drb nkf reline logger; do echo "gem '$g'" >> Gemfile; done
|
||||
|
||||
gem install bundler -v 2.7.2 --no-document
|
||||
bundle _2.7.2_ update
|
||||
|
||||
# Recherche de l'IPA
|
||||
IPA_FILE=$(find ../build/ios/ipa -name "*.ipa" | head -n 1)
|
||||
|
||||
if [ -z "$IPA_FILE" ]; then
|
||||
echo "❌ ERREUR : Aucun fichier IPA trouvé !"
|
||||
echo "📂 Structure complète du dossier build :"
|
||||
ls -R ../build/
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ IPA trouvée : $IPA_FILE"
|
||||
echo "📊 Taille : $(du -h "$IPA_FILE" | cut -f1)"
|
||||
|
||||
# Upload vers Firebase
|
||||
bundle _2.7.2_ exec fastlane run firebase_app_distribution \
|
||||
app:"$FIREBASE_IOS_APP_ID" \
|
||||
ipa_path:"$IPA_FILE" \
|
||||
service_credentials_file:"firebase_credentials.json"
|
||||
|
||||
- name: Nettoyage Final
|
||||
if: always()
|
||||
run: |
|
||||
security list-keychains -d user -s login.keychain
|
||||
security delete-keychain build.keychain || true
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -51,3 +51,8 @@ app.*.map.json
|
||||
firestore.rules
|
||||
storage.rules
|
||||
/functions/node_modules
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
.VSCodeCounter
|
||||
|
||||
|
||||
@@ -59,4 +59,4 @@ Travel Mate est une application mobile conçue pour simplifier l'organisation de
|
||||
|
||||
## 🚀 CI/CD & Déploiement
|
||||
|
||||
Les versions de test interne Android sont automatiquement distribuées via **Firebase App Distribution**.
|
||||
Les versions de test interne Android et IOS sont automatiquement distribuées via **Firebase App Distribution**.
|
||||
|
||||
BIN
assets/icons/Icône de l'application.png
Normal file
BIN
assets/icons/Icône de l'application.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
BIN
assets/icons/presentation_image.jpg
Normal file
BIN
assets/icons/presentation_image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 182 KiB |
196
ios/Podfile.lock
196
ios/Podfile.lock
@@ -1205,63 +1205,85 @@ PODS:
|
||||
- BoringSSL-GRPC/Interface (= 0.0.37)
|
||||
- BoringSSL-GRPC/Interface (0.0.37)
|
||||
- cloud_firestore (6.0.3):
|
||||
- Firebase/Firestore (= 12.4.0)
|
||||
- Firebase/Firestore (= 12.6.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- Firebase/Auth (12.4.0):
|
||||
- Firebase/Auth (12.6.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseAuth (~> 12.4.0)
|
||||
- Firebase/CoreOnly (12.4.0):
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- Firebase/Firestore (12.4.0):
|
||||
- FirebaseAuth (~> 12.6.0)
|
||||
- Firebase/CoreOnly (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- Firebase/Firestore (12.6.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseFirestore (~> 12.4.0)
|
||||
- Firebase/Messaging (12.4.0):
|
||||
- FirebaseFirestore (~> 12.6.0)
|
||||
- Firebase/Messaging (12.6.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseMessaging (~> 12.4.0)
|
||||
- Firebase/Storage (12.4.0):
|
||||
- FirebaseMessaging (~> 12.6.0)
|
||||
- Firebase/Storage (12.6.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseStorage (~> 12.4.0)
|
||||
- FirebaseStorage (~> 12.6.0)
|
||||
- firebase_analytics (12.1.0):
|
||||
- firebase_core
|
||||
- FirebaseAnalytics (= 12.6.0)
|
||||
- Flutter
|
||||
- firebase_auth (6.1.1):
|
||||
- Firebase/Auth (= 12.4.0)
|
||||
- Firebase/Auth (= 12.6.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- firebase_core (4.2.1):
|
||||
- Firebase/CoreOnly (= 12.4.0)
|
||||
- firebase_core (4.3.0):
|
||||
- Firebase/CoreOnly (= 12.6.0)
|
||||
- Flutter
|
||||
- firebase_messaging (16.0.4):
|
||||
- Firebase/Messaging (= 12.4.0)
|
||||
- Firebase/Messaging (= 12.6.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- firebase_storage (13.0.3):
|
||||
- Firebase/Storage (= 12.4.0)
|
||||
- Firebase/Storage (= 12.6.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- FirebaseAppCheckInterop (12.4.0)
|
||||
- FirebaseAuth (12.4.0):
|
||||
- FirebaseAppCheckInterop (~> 12.4.0)
|
||||
- FirebaseAuthInterop (~> 12.4.0)
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseCoreExtension (~> 12.4.0)
|
||||
- FirebaseAnalytics (12.6.0):
|
||||
- FirebaseAnalytics/Default (= 12.6.0)
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseInstallations (~> 12.6.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/MethodSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- nanopb (~> 3.30910.0)
|
||||
- FirebaseAnalytics/Default (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseInstallations (~> 12.6.0)
|
||||
- GoogleAppMeasurement/Default (= 12.6.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/MethodSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- nanopb (~> 3.30910.0)
|
||||
- FirebaseAppCheckInterop (12.6.0)
|
||||
- FirebaseAuth (12.6.0):
|
||||
- FirebaseAppCheckInterop (~> 12.6.0)
|
||||
- FirebaseAuthInterop (~> 12.6.0)
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseCoreExtension (~> 12.6.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GTMSessionFetcher/Core (< 6.0, >= 3.4)
|
||||
- RecaptchaInterop (~> 101.0)
|
||||
- FirebaseAuthInterop (12.4.0)
|
||||
- FirebaseCore (12.4.0):
|
||||
- FirebaseCoreInternal (~> 12.4.0)
|
||||
- FirebaseAuthInterop (12.6.0)
|
||||
- FirebaseCore (12.6.0):
|
||||
- FirebaseCoreInternal (~> 12.6.0)
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GoogleUtilities/Logger (~> 8.1)
|
||||
- FirebaseCoreExtension (12.4.0):
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseCoreInternal (12.4.0):
|
||||
- FirebaseCoreExtension (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseCoreInternal (12.6.0):
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- FirebaseFirestore (12.4.0):
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseCoreExtension (~> 12.4.0)
|
||||
- FirebaseFirestoreInternal (~> 12.4.0)
|
||||
- FirebaseSharedSwift (~> 12.4.0)
|
||||
- FirebaseFirestoreInternal (12.4.0):
|
||||
- FirebaseFirestore (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseCoreExtension (~> 12.6.0)
|
||||
- FirebaseFirestoreInternal (~> 12.6.0)
|
||||
- FirebaseSharedSwift (~> 12.6.0)
|
||||
- FirebaseFirestoreInternal (12.6.0):
|
||||
- abseil/algorithm (~> 1.20240722.0)
|
||||
- abseil/base (~> 1.20240722.0)
|
||||
- abseil/container/flat_hash_map (~> 1.20240722.0)
|
||||
@@ -1270,32 +1292,32 @@ PODS:
|
||||
- abseil/strings/strings (~> 1.20240722.0)
|
||||
- abseil/time (~> 1.20240722.0)
|
||||
- abseil/types (~> 1.20240722.0)
|
||||
- FirebaseAppCheckInterop (~> 12.4.0)
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseAppCheckInterop (~> 12.6.0)
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- "gRPC-C++ (~> 1.69.0)"
|
||||
- gRPC-Core (~> 1.69.0)
|
||||
- leveldb-library (~> 1.22)
|
||||
- nanopb (~> 3.30910.0)
|
||||
- FirebaseInstallations (12.4.0):
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseInstallations (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GoogleUtilities/UserDefaults (~> 8.1)
|
||||
- PromisesObjC (~> 2.4)
|
||||
- FirebaseMessaging (12.4.0):
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseInstallations (~> 12.4.0)
|
||||
- FirebaseMessaging (12.6.0):
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseInstallations (~> 12.6.0)
|
||||
- GoogleDataTransport (~> 10.1)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GoogleUtilities/Reachability (~> 8.1)
|
||||
- GoogleUtilities/UserDefaults (~> 8.1)
|
||||
- nanopb (~> 3.30910.0)
|
||||
- FirebaseSharedSwift (12.4.0)
|
||||
- FirebaseStorage (12.4.0):
|
||||
- FirebaseAppCheckInterop (~> 12.4.0)
|
||||
- FirebaseAuthInterop (~> 12.4.0)
|
||||
- FirebaseCore (~> 12.4.0)
|
||||
- FirebaseCoreExtension (~> 12.4.0)
|
||||
- FirebaseSharedSwift (12.6.0)
|
||||
- FirebaseStorage (12.6.0):
|
||||
- FirebaseAppCheckInterop (~> 12.6.0)
|
||||
- FirebaseAuthInterop (~> 12.6.0)
|
||||
- FirebaseCore (~> 12.6.0)
|
||||
- FirebaseCoreExtension (~> 12.6.0)
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GTMSessionFetcher/Core (< 6.0, >= 3.4)
|
||||
- Flutter (1.0.0)
|
||||
@@ -1315,13 +1337,40 @@ PODS:
|
||||
- FlutterMacOS
|
||||
- GoogleSignIn (~> 9.0)
|
||||
- GTMSessionFetcher (>= 3.4.0)
|
||||
- GoogleAdsOnDeviceConversion (3.2.0):
|
||||
- GoogleUtilities/Environment (~> 8.1)
|
||||
- GoogleUtilities/Logger (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- nanopb (~> 3.30910.0)
|
||||
- GoogleAppMeasurement/Core (12.6.0):
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/MethodSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- nanopb (~> 3.30910.0)
|
||||
- GoogleAppMeasurement/Default (12.6.0):
|
||||
- GoogleAdsOnDeviceConversion (~> 3.2.0)
|
||||
- GoogleAppMeasurement/Core (= 12.6.0)
|
||||
- GoogleAppMeasurement/IdentitySupport (= 12.6.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/MethodSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- nanopb (~> 3.30910.0)
|
||||
- GoogleAppMeasurement/IdentitySupport (12.6.0):
|
||||
- GoogleAppMeasurement/Core (= 12.6.0)
|
||||
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
|
||||
- GoogleUtilities/MethodSwizzler (~> 8.1)
|
||||
- GoogleUtilities/Network (~> 8.1)
|
||||
- "GoogleUtilities/NSData+zlib (~> 8.1)"
|
||||
- nanopb (~> 3.30910.0)
|
||||
- GoogleDataTransport (10.1.0):
|
||||
- nanopb (~> 3.30910.0)
|
||||
- PromisesObjC (~> 2.4)
|
||||
- GoogleMaps (9.4.0):
|
||||
- GoogleMaps/Maps (= 9.4.0)
|
||||
- GoogleMaps/Maps (9.4.0)
|
||||
- GoogleSignIn (9.0.0):
|
||||
- GoogleSignIn (9.1.0):
|
||||
- AppAuth (~> 2.0)
|
||||
- AppCheckCore (~> 11.0)
|
||||
- GTMAppAuth (~> 5.0)
|
||||
@@ -1336,6 +1385,9 @@ PODS:
|
||||
- GoogleUtilities/Logger (8.1.0):
|
||||
- GoogleUtilities/Environment
|
||||
- GoogleUtilities/Privacy
|
||||
- GoogleUtilities/MethodSwizzler (8.1.0):
|
||||
- GoogleUtilities/Logger
|
||||
- GoogleUtilities/Privacy
|
||||
- GoogleUtilities/Network (8.1.0):
|
||||
- GoogleUtilities/Logger
|
||||
- "GoogleUtilities/NSData+zlib"
|
||||
@@ -1480,6 +1532,7 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
|
||||
- firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`)
|
||||
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
|
||||
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
||||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||
@@ -1505,6 +1558,7 @@ SPEC REPOS:
|
||||
- AppCheckCore
|
||||
- BoringSSL-GRPC
|
||||
- Firebase
|
||||
- FirebaseAnalytics
|
||||
- FirebaseAppCheckInterop
|
||||
- FirebaseAuth
|
||||
- FirebaseAuthInterop
|
||||
@@ -1518,6 +1572,8 @@ SPEC REPOS:
|
||||
- FirebaseSharedSwift
|
||||
- FirebaseStorage
|
||||
- Google-Maps-iOS-Utils
|
||||
- GoogleAdsOnDeviceConversion
|
||||
- GoogleAppMeasurement
|
||||
- GoogleDataTransport
|
||||
- GoogleMaps
|
||||
- GoogleSignIn
|
||||
@@ -1534,6 +1590,8 @@ SPEC REPOS:
|
||||
EXTERNAL SOURCES:
|
||||
cloud_firestore:
|
||||
:path: ".symlinks/plugins/cloud_firestore/ios"
|
||||
firebase_analytics:
|
||||
:path: ".symlinks/plugins/firebase_analytics/ios"
|
||||
firebase_auth:
|
||||
:path: ".symlinks/plugins/firebase_auth/ios"
|
||||
firebase_core:
|
||||
@@ -1574,33 +1632,37 @@ SPEC CHECKSUMS:
|
||||
AppAuth: 1c1a8afa7e12f2ec3a294d9882dfa5ab7d3cb063
|
||||
AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f
|
||||
BoringSSL-GRPC: dded2a44897e45f28f08ae87a55ee4bcd19bc508
|
||||
cloud_firestore: 79014bb3b303d451717ed5fe69fded8a2b2e8dc2
|
||||
Firebase: f07b15ae5a6ec0f93713e30b923d9970d144af3e
|
||||
firebase_auth: c2b8be95d602d4e8a9148fae72333ef78e69cc20
|
||||
firebase_core: f1aafb21c14f497e5498f7ffc4dc63cbb52b2594
|
||||
firebase_messaging: c17a29984eafce4b2997fe078bb0a9e0b06f5dde
|
||||
firebase_storage: 0ba617a05b24aec050395e4d5d3773c0d7518a15
|
||||
FirebaseAppCheckInterop: f734c802f21fe1da0837708f0f9a27218c8a4ed0
|
||||
FirebaseAuth: 4a2aed737c84114a9d9b33d11ae1b147d6b94889
|
||||
FirebaseAuthInterop: 858e6b754966e70740a4370dd1503dfffe6dbb49
|
||||
FirebaseCore: bb595f3114953664e3c1dc032f008a244147cfd3
|
||||
FirebaseCoreExtension: 7e1f7118ee970e001a8013719fb90950ee5e0018
|
||||
FirebaseCoreInternal: d7f5a043c2cd01a08103ab586587c1468047bca6
|
||||
FirebaseFirestore: 2a6183381cf7679b1bb000eb76a8e3178e25dee2
|
||||
FirebaseFirestoreInternal: 6577a27cd5dc3722b900042527f86d4ea1626134
|
||||
FirebaseInstallations: ae9f4902cb5bf1d0c5eaa31ec1f4e5495a0714e2
|
||||
FirebaseMessaging: d33971b7bb252745ea6cd31ab190d1a1df4b8ed5
|
||||
FirebaseSharedSwift: 93426a1de92f19e1199fac5295a4f8df16458daa
|
||||
FirebaseStorage: 20d6b56fb8a40ebaa03d6a2889fe33dac64adb73
|
||||
cloud_firestore: d7598ff2b1b2064e810f839dbdde2765c0f2052a
|
||||
Firebase: a451a7b61536298fd5cbfe3a746fd40443a50679
|
||||
firebase_analytics: 4f9cca09e65f6c2944a862c6dc86f6bed9fb769c
|
||||
firebase_auth: cfb7237c0d01e87360cb3bf61e02a417c36e19e8
|
||||
firebase_core: ba00a168e719694f38960502ceb560285603d073
|
||||
firebase_messaging: 752f1df5294ead9d72091d4974362d00d4aec201
|
||||
firebase_storage: 5716627614e95c75e243134f65c1b0d6f66a4315
|
||||
FirebaseAnalytics: d0a97a0db6425e5a5d966340b87f92ca7b13a557
|
||||
FirebaseAppCheckInterop: e2178171b4145013c7c1a3cc464d1d446d3a1896
|
||||
FirebaseAuth: 613c463cb43545a7fd2cd99ade09b78ac472c544
|
||||
FirebaseAuthInterop: db06756ef028006d034b6004dc0c37c24f7828d4
|
||||
FirebaseCore: 0e38ad5d62d980a47a64b8e9301ffa311457be04
|
||||
FirebaseCoreExtension: 032fd6f8509e591fda8cb76f6651f20d926b121f
|
||||
FirebaseCoreInternal: 69bf1306a05b8ac43004f6cc1f804bb7b05b229e
|
||||
FirebaseFirestore: 51ce079b9ddcaa481644164eda649d362c2a6396
|
||||
FirebaseFirestoreInternal: 8b1d2b0a1b859b2ddbd63f448c416c5be7367405
|
||||
FirebaseInstallations: 631b38da2e11a83daa4bfb482f79d286a5dfa7ad
|
||||
FirebaseMessaging: a61bc42dcab3f7a346d94bbb54dab2c9435b18b2
|
||||
FirebaseSharedSwift: 79f27fff0addd15c3de19b87fba426f3cc2c964f
|
||||
FirebaseStorage: 550349b1e8f7315834ea08308696e9469d77135d
|
||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||
flutter_local_notifications: a5a732f069baa862e728d839dd2ebb904737effb
|
||||
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
|
||||
Google-Maps-iOS-Utils: 0a484b05ed21d88c9f9ebbacb007956edd508a96
|
||||
google_maps_flutter_ios: 0291eb2aa252298a769b04d075e4a9d747ff7264
|
||||
google_sign_in_ios: 205742c688aea0e64db9da03c33121694a365109
|
||||
GoogleAdsOnDeviceConversion: d68c69dd9581a0f5da02617b6f377e5be483970f
|
||||
GoogleAppMeasurement: 3bf40aff49a601af5da1c3345702fcb4991d35ee
|
||||
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
|
||||
GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438
|
||||
GoogleSignIn: c7f09cfbc85a1abf69187be091997c317cc33b77
|
||||
GoogleSignIn: fcee2257188d5eda57a5e2b6a715550ffff9206d
|
||||
GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1
|
||||
"gRPC-C++": cc207623316fb041a7a3e774c252cf68a058b9e8
|
||||
gRPC-Core: 860978b7db482de8b4f5e10677216309b5ff6330
|
||||
|
||||
@@ -490,7 +490,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 456VVYXDFN;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -499,6 +503,8 @@
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = myiphone;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -673,7 +679,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 456VVYXDFN;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -682,6 +692,8 @@
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = myiphone;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@@ -696,7 +708,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 456VVYXDFN;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -705,6 +721,8 @@
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = myiphone;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
||||
@@ -174,7 +174,11 @@ class ActivityBloc extends Bloc<ActivityEvent, ActivityState> {
|
||||
'Erreur recherche activités: $e',
|
||||
stackTrace,
|
||||
);
|
||||
emit(const ActivityError('Impossible de rechercher les activités'));
|
||||
// Extraire le message d'erreur si disponible
|
||||
final errorMessage = e.toString().replaceAll('Exception: ', '');
|
||||
emit(
|
||||
ActivityError('Impossible de rechercher les activités: $errorMessage'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,14 @@ import '../../repositories/auth_repository.dart';
|
||||
import 'auth_event.dart';
|
||||
import 'auth_state.dart';
|
||||
import '../../services/notification_service.dart';
|
||||
import '../../services/analytics_service.dart';
|
||||
|
||||
/// BLoC for managing authentication state and operations.
|
||||
class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
/// Repository for authentication operations.
|
||||
final AuthRepository _authRepository;
|
||||
final NotificationService _notificationService;
|
||||
final AnalyticsService _analyticsService;
|
||||
|
||||
/// Creates an [AuthBloc] with the provided [authRepository].
|
||||
///
|
||||
@@ -40,8 +42,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
AuthBloc({
|
||||
required AuthRepository authRepository,
|
||||
NotificationService? notificationService,
|
||||
AnalyticsService? analyticsService,
|
||||
}) : _authRepository = authRepository,
|
||||
_notificationService = notificationService ?? NotificationService(),
|
||||
_analyticsService = analyticsService ?? AnalyticsService(),
|
||||
super(AuthInitial()) {
|
||||
on<AuthCheckRequested>(_onAuthCheckRequested);
|
||||
on<AuthSignInRequested>(_onSignInRequested);
|
||||
@@ -76,6 +80,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (user != null) {
|
||||
// Save FCM Token on auto-login
|
||||
await _notificationService.saveTokenToFirestore(user.id!);
|
||||
await _analyticsService.setUserId(user.id);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(AuthUnauthenticated());
|
||||
@@ -107,6 +112,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (user != null) {
|
||||
// Save FCM Token
|
||||
await NotificationService().saveTokenToFirestore(user.id!);
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'login',
|
||||
parameters: {'method': 'email'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(const AuthError(message: 'Invalid email or password'));
|
||||
@@ -138,6 +148,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (user != null) {
|
||||
// Save FCM Token
|
||||
await NotificationService().saveTokenToFirestore(user.id!);
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'sign_up',
|
||||
parameters: {'method': 'email'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(const AuthError(message: 'Failed to create account'));
|
||||
@@ -163,6 +178,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (user != null) {
|
||||
// Save FCM Token
|
||||
await NotificationService().saveTokenToFirestore(user.id!);
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'login',
|
||||
parameters: {'method': 'google'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(
|
||||
@@ -191,6 +211,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
);
|
||||
|
||||
if (user != null) {
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'sign_up',
|
||||
parameters: {'method': 'google'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(const AuthError(message: 'Failed to create account with Google'));
|
||||
@@ -214,6 +239,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
);
|
||||
|
||||
if (user != null) {
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'sign_up',
|
||||
parameters: {'method': 'apple'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(const AuthError(message: 'Failed to create account with Apple'));
|
||||
@@ -239,6 +269,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (user != null) {
|
||||
// Save FCM Token
|
||||
await NotificationService().saveTokenToFirestore(user.id!);
|
||||
await _analyticsService.setUserId(user.id);
|
||||
await _analyticsService.logEvent(
|
||||
name: 'login',
|
||||
parameters: {'method': 'apple'},
|
||||
);
|
||||
emit(AuthAuthenticated(user: user));
|
||||
} else {
|
||||
emit(
|
||||
@@ -261,6 +296,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
await _authRepository.signOut();
|
||||
await _analyticsService.setUserId(null); // Clear user ID
|
||||
emit(AuthUnauthenticated());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@ import '../../blocs/activity/activity_state.dart';
|
||||
import '../../models/trip.dart';
|
||||
import '../../models/activity.dart';
|
||||
import '../../services/activity_cache_service.dart';
|
||||
import '../../services/activity_places_service.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../loading/laoding_content.dart';
|
||||
import '../../blocs/user/user_bloc.dart';
|
||||
import '../../blocs/user/user_state.dart';
|
||||
import '../../services/error_service.dart';
|
||||
import 'activity_detail_dialog.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
class ActivitiesPage extends StatefulWidget {
|
||||
final Trip trip;
|
||||
@@ -38,6 +41,14 @@ class _ActivitiesPageState extends State<ActivitiesPage>
|
||||
List<Activity> _approvedActivities = [];
|
||||
bool _isLoadingTripActivities = false;
|
||||
|
||||
// Autocomplete variables
|
||||
List<Map<String, String>> _suggestions = [];
|
||||
final LayerLink _layerLink = LayerLink();
|
||||
OverlayEntry? _overlayEntry;
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
Timer? _debounceTimer;
|
||||
bool _isLoadingSuggestions = false;
|
||||
|
||||
bool _autoReloadInProgress =
|
||||
false; // Protection contre les rechargements en boucle
|
||||
int _lastAutoReloadTriggerCount =
|
||||
@@ -104,6 +115,9 @@ class _ActivitiesPageState extends State<ActivitiesPage>
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
_searchController.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
_debounceTimer?.cancel();
|
||||
_hideSuggestions();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -277,42 +291,204 @@ class _ActivitiesPageState extends State<ActivitiesPage>
|
||||
}
|
||||
|
||||
Widget _buildSearchBar(ThemeData theme) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
return CompositedTransformTarget(
|
||||
link: _layerLink,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Rechercher restaurants, musées...',
|
||||
hintStyle: TextStyle(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
focusNode: _searchFocusNode,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Rechercher restaurants, musées...',
|
||||
hintStyle: TextStyle(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
suffixIcon: _isLoadingSuggestions
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
onChanged: _onSearchChanged,
|
||||
onSubmitted: (value) {
|
||||
_hideSuggestions();
|
||||
if (value.isNotEmpty) {
|
||||
_performSearch(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
_performSearch(value);
|
||||
}
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onSearchChanged(String value) {
|
||||
if (_debounceTimer?.isActive ?? false) _debounceTimer!.cancel();
|
||||
|
||||
if (value.isEmpty) {
|
||||
_hideSuggestions();
|
||||
return;
|
||||
}
|
||||
|
||||
_debounceTimer = Timer(const Duration(milliseconds: 300), () async {
|
||||
setState(() {
|
||||
_isLoadingSuggestions = true;
|
||||
});
|
||||
|
||||
try {
|
||||
final suggestions = await ActivityPlacesService().fetchSuggestions(
|
||||
query: value,
|
||||
lat: widget.trip.latitude,
|
||||
lng: widget.trip.longitude,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_suggestions = suggestions;
|
||||
_isLoadingSuggestions = false;
|
||||
});
|
||||
|
||||
if (_suggestions.isNotEmpty) {
|
||||
_showSuggestions();
|
||||
} else {
|
||||
_hideSuggestions();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoadingSuggestions = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _showSuggestions() {
|
||||
_overlayEntry?.remove();
|
||||
_overlayEntry = _createOverlayEntry();
|
||||
Overlay.of(context).insert(_overlayEntry!);
|
||||
}
|
||||
|
||||
void _hideSuggestions() {
|
||||
_overlayEntry?.remove();
|
||||
_overlayEntry = null;
|
||||
}
|
||||
|
||||
OverlayEntry _createOverlayEntry() {
|
||||
final renderBox = context.findRenderObject() as RenderBox;
|
||||
final theme = Theme.of(context);
|
||||
final size = renderBox.size;
|
||||
final width = size.width - 32; // padding 16 * 2
|
||||
|
||||
return OverlayEntry(
|
||||
builder: (context) => Positioned(
|
||||
width: width,
|
||||
child: CompositedTransformFollower(
|
||||
link: _layerLink,
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(16, 80), // Adjust vertical offset
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: theme.colorScheme.surface,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 250),
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: _suggestions.length,
|
||||
separatorBuilder: (context, index) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final suggestion = _suggestions[index];
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.location_on_outlined),
|
||||
title: Text(
|
||||
suggestion['description'] ?? '',
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onTap: () {
|
||||
_selectSuggestion(suggestion);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _selectSuggestion(Map<String, String> suggestion) async {
|
||||
_hideSuggestions();
|
||||
_searchController.text = suggestion['description']!;
|
||||
_searchFocusNode.unfocus();
|
||||
|
||||
// Passer à l'onglet "Suggestion" si ce n'est pas déjà fait
|
||||
if (_tabController.index != 2) {
|
||||
_tabController.animateTo(2);
|
||||
}
|
||||
|
||||
// Charger l'activité spécifique via le Bloc ou Service
|
||||
// Ici on va utiliser le Bloc pour ajouter l'activité aux résultats de recherche
|
||||
// Pour ça, il faudrait idéalement un événement "LoadSingleActivity" dans le Bloc
|
||||
// Mais pour faire simple et rapide, on peut faire une recherche "exacte" ou hack:
|
||||
// On charge l'activité manuellement et on l'ajoute comme si c'était un résultat de recherche.
|
||||
|
||||
setState(() {
|
||||
_isLoadingSuggestions = true;
|
||||
});
|
||||
|
||||
try {
|
||||
final activity = await ActivityPlacesService().getActivityByPlaceId(
|
||||
placeId: suggestion['placeId']!,
|
||||
tripId: widget.trip.id!,
|
||||
);
|
||||
|
||||
if (mounted && activity != null) {
|
||||
// Injecter ce résultat unique dans le Bloc
|
||||
context.read<ActivityBloc>().add(
|
||||
RestoreCachedSearchResults(searchResults: [activity]),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
ErrorService().showError(message: "Impossible de charger l'activité");
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoadingSuggestions = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildCategoryTabs(ThemeData theme) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -637,6 +813,23 @@ class _ActivitiesPageState extends State<ActivitiesPage>
|
||||
activity.name.toLowerCase().trim(),
|
||||
);
|
||||
|
||||
// Calculer la distance si c'est une suggestion Google et que le voyage a des coordonnées
|
||||
double? distanceInKm;
|
||||
if (isGoogleSuggestion &&
|
||||
widget.trip.hasCoordinates &&
|
||||
activity.latitude != null &&
|
||||
activity.longitude != null) {
|
||||
final distanceInMeters = Geolocator.distanceBetween(
|
||||
widget.trip.latitude!,
|
||||
widget.trip.longitude!,
|
||||
activity.latitude!,
|
||||
activity.longitude!,
|
||||
);
|
||||
distanceInKm = distanceInMeters / 1000;
|
||||
}
|
||||
|
||||
final isFar = distanceInKm != null && distanceInKm > 50;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
@@ -709,6 +902,40 @@ class _ActivitiesPageState extends State<ActivitiesPage>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (isFar)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.errorContainer,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.error.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: theme.colorScheme.error,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Activité éloignée : ${distanceInKm!.toStringAsFixed(0)} km du lieu du voyage',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onErrorContainer,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// Icône de catégorie
|
||||
|
||||
@@ -24,6 +24,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import '../../services/place_image_service.dart';
|
||||
import '../../services/trip_geocoding_service.dart';
|
||||
import '../../services/logger_service.dart';
|
||||
import '../../firebase_options.dart';
|
||||
|
||||
/// Create trip content widget for trip creation and editing functionality.
|
||||
///
|
||||
@@ -86,16 +87,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
|
||||
/// Google Maps API key for location services
|
||||
static String get _apiKey {
|
||||
if (Platform.isAndroid) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
} else if (Platform.isIOS) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
}
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
|
||||
return DefaultFirebaseOptions.currentPlatform.apiKey;
|
||||
}
|
||||
|
||||
/// Participant management
|
||||
@@ -135,7 +127,11 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _isProgrammaticUpdate = false;
|
||||
|
||||
void _onLocationChanged() {
|
||||
if (_isProgrammaticUpdate) return;
|
||||
|
||||
final query = _locationController.text.trim();
|
||||
|
||||
if (query.length < 2) {
|
||||
@@ -215,15 +211,18 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
|
||||
if (_placeSuggestions.isEmpty) return;
|
||||
|
||||
final overlay = Overlay.of(context);
|
||||
|
||||
// Calculer la largeur correcte en fonction du padding parent (16 margin + 24 padding = 40 de chaque côté)
|
||||
final width = MediaQuery.of(context).size.width - 80;
|
||||
|
||||
_suggestionsOverlay = OverlayEntry(
|
||||
builder: (context) => Positioned(
|
||||
width:
|
||||
MediaQuery.of(context).size.width -
|
||||
32, // Largeur du champ avec padding
|
||||
width: width,
|
||||
child: CompositedTransformFollower(
|
||||
link: _layerLink,
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(0, 60), // Position sous le champ
|
||||
targetAnchor: Alignment.bottomLeft,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -236,6 +235,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: _placeSuggestions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final suggestion = _placeSuggestions[index];
|
||||
@@ -256,7 +256,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context).insert(_suggestionsOverlay!);
|
||||
overlay.insert(_suggestionsOverlay!);
|
||||
}
|
||||
|
||||
void _hideSuggestions() {
|
||||
@@ -265,7 +265,10 @@ class _CreateTripContentState extends State<CreateTripContent> {
|
||||
}
|
||||
|
||||
void _selectSuggestion(PlaceSuggestion suggestion) {
|
||||
_isProgrammaticUpdate = true;
|
||||
_locationController.text = suggestion.description;
|
||||
_isProgrammaticUpdate = false;
|
||||
|
||||
_hideSuggestions();
|
||||
setState(() {
|
||||
_placeSuggestions = [];
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import '../../firebase_options.dart';
|
||||
import '../../services/error_service.dart';
|
||||
import '../../services/map_navigation_service.dart';
|
||||
import '../../services/logger_service.dart';
|
||||
@@ -22,6 +23,7 @@ class MapContent extends StatefulWidget {
|
||||
class _MapContentState extends State<MapContent> {
|
||||
GoogleMapController? _mapController;
|
||||
LatLng _initialPosition = const LatLng(48.8566, 2.3522);
|
||||
LatLng? _currentMapCenter;
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
bool _isLoadingLocation = false;
|
||||
bool _isSearching = false;
|
||||
@@ -33,16 +35,7 @@ class _MapContentState extends State<MapContent> {
|
||||
List<PlaceSuggestion> _suggestions = [];
|
||||
|
||||
static String get _apiKey {
|
||||
if (Platform.isAndroid) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
} else if (Platform.isIOS) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
}
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
|
||||
return DefaultFirebaseOptions.currentPlatform.apiKey;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -321,20 +314,30 @@ class _MapContentState extends State<MapContent> {
|
||||
}
|
||||
}
|
||||
|
||||
// Créer une icône personnalisée à partir de l'icône Material
|
||||
Future<BitmapDescriptor> _createCustomMarkerIcon() async {
|
||||
// Créer une icône personnalisée
|
||||
Future<BitmapDescriptor> _createMarkerIcon(
|
||||
IconData iconData,
|
||||
Color color, {
|
||||
double size = 60.0,
|
||||
}) async {
|
||||
final pictureRecorder = ui.PictureRecorder();
|
||||
final canvas = Canvas(pictureRecorder);
|
||||
const size = 80.0;
|
||||
|
||||
// Dessiner l'icône person_pin_circle en bleu
|
||||
final iconPainter = TextPainter(textDirection: TextDirection.ltr);
|
||||
iconPainter.text = TextSpan(
|
||||
text: String.fromCharCode(Icons.person_pin_circle.codePoint),
|
||||
text: String.fromCharCode(iconData.codePoint),
|
||||
style: TextStyle(
|
||||
fontSize: 70,
|
||||
fontFamily: Icons.person_pin_circle.fontFamily,
|
||||
color: Colors.blue[700],
|
||||
fontSize: size,
|
||||
fontFamily: iconData.fontFamily,
|
||||
package: iconData.fontPackage,
|
||||
color: color,
|
||||
shadows: [
|
||||
Shadow(
|
||||
offset: const Offset(1, 1),
|
||||
blurRadius: 2,
|
||||
color: Colors.black.withValues(alpha: 0.3),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
iconPainter.layout();
|
||||
@@ -364,8 +367,12 @@ class _MapContentState extends State<MapContent> {
|
||||
),
|
||||
);
|
||||
|
||||
// Créer l'icône personnalisée
|
||||
final icon = await _createCustomMarkerIcon();
|
||||
// Créer l'icône personnalisée (plus petite: 60 au lieu de 80)
|
||||
final icon = await _createMarkerIcon(
|
||||
Icons.person_pin_circle,
|
||||
Colors.blue[700]!,
|
||||
size: 60.0,
|
||||
);
|
||||
|
||||
// Ajouter le marqueur avec l'icône
|
||||
setState(() {
|
||||
@@ -374,10 +381,7 @@ class _MapContentState extends State<MapContent> {
|
||||
markerId: const MarkerId('user_location'),
|
||||
position: position,
|
||||
icon: icon,
|
||||
anchor: const Offset(
|
||||
0.5,
|
||||
0.85,
|
||||
), // Ancrer au bas de l'icône (le point du pin)
|
||||
anchor: const Offset(0.5, 0.85), // Ancrer au bas de l'icône
|
||||
infoWindow: InfoWindow(
|
||||
title: 'Ma position',
|
||||
snippet:
|
||||
@@ -401,10 +405,21 @@ class _MapContentState extends State<MapContent> {
|
||||
});
|
||||
|
||||
try {
|
||||
final apiKey = _apiKey;
|
||||
LoggerService.info('MapContent: Searching places with query "$query"');
|
||||
if (apiKey.isEmpty) {
|
||||
LoggerService.error('MapContent: API Key is empty!');
|
||||
} else {
|
||||
// Log first few chars to verify correct key is loaded without leaking full key
|
||||
LoggerService.info(
|
||||
'MapContent: Using API Key starting with ${apiKey.substring(0, 5)}...',
|
||||
);
|
||||
}
|
||||
|
||||
final url = Uri.parse(
|
||||
'https://maps.googleapis.com/maps/api/place/autocomplete/json'
|
||||
'?input=${Uri.encodeComponent(query)}'
|
||||
'&key=$_apiKey'
|
||||
'&key=$apiKey'
|
||||
'&language=fr',
|
||||
);
|
||||
|
||||
@@ -412,11 +427,21 @@ class _MapContentState extends State<MapContent> {
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
LoggerService.info(
|
||||
'MapContent: Response status code: ${response.statusCode}',
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
final status = data['status'];
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
LoggerService.info('MapContent: API Status: $status');
|
||||
|
||||
if (status == 'OK') {
|
||||
final predictions = data['predictions'] as List;
|
||||
LoggerService.info(
|
||||
'MapContent: Found ${predictions.length} predictions',
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_suggestions = predictions
|
||||
@@ -430,13 +455,19 @@ class _MapContentState extends State<MapContent> {
|
||||
_isSearching = false;
|
||||
});
|
||||
} else {
|
||||
LoggerService.error(
|
||||
'MapContent: API Error: $status - ${data['error_message'] ?? "No error message"}',
|
||||
);
|
||||
setState(() {
|
||||
_suggestions = [];
|
||||
_isSearching = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
LoggerService.error('MapContent: HTTP Error ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error('MapContent: Exception during search: $e');
|
||||
_showError('Erreur lors de la recherche de lieux: $e');
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
@@ -444,6 +475,128 @@ class _MapContentState extends State<MapContent> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _performTextSearch(String query) async {
|
||||
if (query.isEmpty) return;
|
||||
|
||||
setState(() {
|
||||
_isSearching = true;
|
||||
_suggestions = []; // Hide suggestions
|
||||
});
|
||||
|
||||
try {
|
||||
final apiKey = _apiKey;
|
||||
// Utiliser le centre actuel de la carte ou la position initiale
|
||||
final center = _currentMapCenter ?? _initialPosition;
|
||||
|
||||
final url = Uri.parse(
|
||||
'https://maps.googleapis.com/maps/api/place/textsearch/json'
|
||||
'?query=${Uri.encodeComponent(query)}'
|
||||
'&location=${center.latitude},${center.longitude}'
|
||||
'&radius=5000' // Rechercher dans un rayon de 5km autour du centre
|
||||
'&key=$apiKey'
|
||||
'&language=fr',
|
||||
);
|
||||
|
||||
final response = await http.get(url);
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final results = data['results'] as List;
|
||||
final List<Marker> newMarkers = [];
|
||||
|
||||
// Garder le marqueur de position utilisateur
|
||||
final userMarker = _markers
|
||||
.where((m) => m.markerId.value == 'user_location')
|
||||
.toList();
|
||||
|
||||
double minLat = center.latitude;
|
||||
double maxLat = center.latitude;
|
||||
double minLng = center.longitude;
|
||||
double maxLng = center.longitude;
|
||||
|
||||
// Créer le marqueur rouge standard personnalisé
|
||||
final markerIcon = await _createMarkerIcon(
|
||||
Icons.location_on,
|
||||
Colors.red,
|
||||
size: 50.0,
|
||||
);
|
||||
|
||||
for (final place in results) {
|
||||
final geometry = place['geometry']['location'];
|
||||
final lat = geometry['lat'];
|
||||
final lng = geometry['lng'];
|
||||
final name = place['name'];
|
||||
final placeId = place['place_id'];
|
||||
|
||||
final position = LatLng(lat, lng);
|
||||
|
||||
// Mettre à jour les bornes
|
||||
if (lat < minLat) minLat = lat;
|
||||
if (lat > maxLat) maxLat = lat;
|
||||
if (lng < minLng) minLng = lng;
|
||||
if (lng > maxLng) maxLng = lng;
|
||||
|
||||
newMarkers.add(
|
||||
Marker(
|
||||
markerId: MarkerId(placeId),
|
||||
position: position,
|
||||
icon: markerIcon,
|
||||
anchor: const Offset(0.5, 0.85), // Standard anchor for pins
|
||||
infoWindow: InfoWindow(
|
||||
title: name,
|
||||
snippet: place['formatted_address'] ?? 'Lieu trouvé',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_markers.clear();
|
||||
if (userMarker.isNotEmpty) {
|
||||
_markers.add(userMarker.first);
|
||||
}
|
||||
_markers.addAll(newMarkers);
|
||||
_isSearching = false;
|
||||
});
|
||||
|
||||
// Ajuster la caméra pour montrer tous les résultats
|
||||
if (newMarkers.isNotEmpty) {
|
||||
_mapController?.animateCamera(
|
||||
CameraUpdate.newLatLngBounds(
|
||||
LatLngBounds(
|
||||
southwest: LatLng(minLat, minLng),
|
||||
northeast: LatLng(maxLat, maxLng),
|
||||
),
|
||||
50.0, // padding
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
FocusScope.of(context).unfocus();
|
||||
} else {
|
||||
_showError('Aucun résultat trouvé pour "$query"');
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_showError('Erreur lors de la recherche: ${response.statusCode}');
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
_showError('Erreur lors de la recherche: $e');
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectPlace(PlaceSuggestion suggestion) async {
|
||||
setState(() {
|
||||
_isSearching = true;
|
||||
@@ -467,13 +620,21 @@ class _MapContentState extends State<MapContent> {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final location = data['result']['geometry']['location'];
|
||||
final result = data['result'];
|
||||
final location = result['geometry']['location'];
|
||||
final lat = location['lat'];
|
||||
final lng = location['lng'];
|
||||
final name = data['result']['name'];
|
||||
final name = result['name'];
|
||||
|
||||
final newPosition = LatLng(lat, lng);
|
||||
|
||||
// Utiliser le marqueur rouge standard personnalisé
|
||||
final markerIcon = await _createMarkerIcon(
|
||||
Icons.location_on,
|
||||
Colors.red,
|
||||
size: 50.0,
|
||||
);
|
||||
|
||||
// Ajouter un marqueur pour le lieu recherché (ne pas supprimer le marqueur de position)
|
||||
setState(() {
|
||||
// Garder le marqueur de position utilisateur
|
||||
@@ -484,6 +645,8 @@ class _MapContentState extends State<MapContent> {
|
||||
Marker(
|
||||
markerId: MarkerId(suggestion.placeId),
|
||||
position: newPosition,
|
||||
icon: markerIcon,
|
||||
anchor: const Offset(0.5, 0.85),
|
||||
infoWindow: InfoWindow(title: name),
|
||||
),
|
||||
);
|
||||
@@ -533,6 +696,9 @@ class _MapContentState extends State<MapContent> {
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_mapController = controller;
|
||||
},
|
||||
onCameraMove: (CameraPosition position) {
|
||||
_currentMapCenter = position.target;
|
||||
},
|
||||
markers: _markers,
|
||||
circles: _circles,
|
||||
myLocationEnabled: false,
|
||||
@@ -664,6 +830,10 @@ class _MapContentState extends State<MapContent> {
|
||||
vertical: 14,
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
onSubmitted: (value) {
|
||||
_performTextSearch(value);
|
||||
},
|
||||
onChanged: (value) {
|
||||
// Ne pas rechercher si c'est juste le remplissage initial
|
||||
if (widget.initialSearchQuery != null &&
|
||||
|
||||
@@ -150,7 +150,9 @@ class ProfileContent extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.white
|
||||
: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
57
lib/components/signup/password_requirements.dart
Normal file
57
lib/components/signup/password_requirements.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PasswordRequirements extends StatelessWidget {
|
||||
final String password;
|
||||
|
||||
const PasswordRequirements({super.key, required this.password});
|
||||
|
||||
bool get _hasMinLength => password.length >= 8;
|
||||
bool get _hasUppercase => password.contains(RegExp(r'[A-Z]'));
|
||||
bool get _hasLowercase => password.contains(RegExp(r'[a-z]'));
|
||||
bool get _hasDigit => password.contains(RegExp(r'[0-9]'));
|
||||
bool get _hasSpecialChar =>
|
||||
password.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>]'));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'Votre mot de passe doit contenir :',
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildRequirement(_hasMinLength, 'Au moins 8 caractères'),
|
||||
_buildRequirement(_hasUppercase, 'Une majuscule'),
|
||||
_buildRequirement(_hasLowercase, 'Une minuscule'),
|
||||
_buildRequirement(_hasDigit, 'Un chiffre'),
|
||||
_buildRequirement(_hasSpecialChar, 'Un caractère spécial'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRequirement(bool isMet, String text) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isMet ? Icons.check_circle : Icons.circle_outlined,
|
||||
color: isMet ? Colors.green : Colors.grey,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: isMet ? Colors.green : Colors.grey,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
140
lib/components/whats_new_dialog.dart
Normal file
140
lib/components/whats_new_dialog.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../services/whats_new_service.dart';
|
||||
|
||||
class WhatsNewDialog extends StatelessWidget {
|
||||
final VoidCallback onDismiss;
|
||||
final List<WhatsNewItem> features;
|
||||
|
||||
const WhatsNewDialog({
|
||||
super.key,
|
||||
required this.onDismiss,
|
||||
required this.features,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primaryContainer,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.auto_awesome,
|
||||
color: theme.colorScheme.primary,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Quoi de neuf ?',
|
||||
style: theme.textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Features List
|
||||
Flexible(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: features.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 16),
|
||||
itemBuilder: (context, index) {
|
||||
final feature = features[index];
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
feature.icon,
|
||||
color: theme.colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
feature.title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
feature.description,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// Marquer comme vu via le service
|
||||
WhatsNewService().markCurrentVersionAsSeen();
|
||||
onDismiss();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
foregroundColor: theme.colorScheme.onPrimary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'C\'est parti !',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WhatsNewItem {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String description;
|
||||
|
||||
const WhatsNewItem({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.description,
|
||||
});
|
||||
}
|
||||
@@ -27,18 +27,6 @@ class DefaultFirebaseOptions {
|
||||
return android;
|
||||
case TargetPlatform.iOS:
|
||||
return ios;
|
||||
case TargetPlatform.macOS:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for macos - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
case TargetPlatform.windows:
|
||||
return windows;
|
||||
case TargetPlatform.linux:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for linux - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
default:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions are not supported for this platform.',
|
||||
@@ -63,15 +51,4 @@ class DefaultFirebaseOptions {
|
||||
iosClientId: '521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.example.travelMate',
|
||||
);
|
||||
|
||||
static const FirebaseOptions windows = FirebaseOptions(
|
||||
apiKey: 'AIzaSyC4t-WOvp22zns9b9t58urznsNAhSHRAag',
|
||||
appId: '1:521527250907:web:53ff98bcdb8c218f7da1fe',
|
||||
messagingSenderId: '521527250907',
|
||||
projectId: 'travelmate-a47f5',
|
||||
authDomain: 'travelmate-a47f5.firebaseapp.com',
|
||||
storageBucket: 'travelmate-a47f5.firebasestorage.app',
|
||||
measurementId: 'G-J246Y7J61M',
|
||||
);
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import 'package:travel_mate/services/expense_service.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:travel_mate/services/notification_service.dart';
|
||||
import 'package:travel_mate/services/map_navigation_service.dart';
|
||||
import 'package:travel_mate/services/analytics_service.dart';
|
||||
import 'blocs/auth/auth_bloc.dart';
|
||||
import 'blocs/auth/auth_event.dart';
|
||||
import 'blocs/theme/theme_bloc.dart';
|
||||
@@ -146,6 +147,10 @@ class MyApp extends StatelessWidget {
|
||||
RepositoryProvider<MapNavigationService>(
|
||||
create: (context) => MapNavigationService(),
|
||||
),
|
||||
// Analysis service
|
||||
RepositoryProvider<AnalyticsService>(
|
||||
create: (context) => AnalyticsService(),
|
||||
),
|
||||
],
|
||||
child: MultiBlocProvider(
|
||||
providers: [
|
||||
@@ -206,6 +211,9 @@ class MyApp extends StatelessWidget {
|
||||
title: 'Travel Mate',
|
||||
navigatorKey: ErrorService.navigatorKey,
|
||||
themeMode: themeState.themeMode,
|
||||
navigatorObservers: [
|
||||
context.read<AnalyticsService>().getAnalyticsObserver(),
|
||||
],
|
||||
// Light theme configuration
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
|
||||
@@ -14,6 +14,8 @@ import '../blocs/auth/auth_event.dart';
|
||||
import '../services/error_service.dart';
|
||||
import '../services/notification_service.dart';
|
||||
import '../services/map_navigation_service.dart';
|
||||
import '../services/whats_new_service.dart';
|
||||
import '../components/whats_new_dialog.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
@@ -57,6 +59,45 @@ class _HomePageState extends State<HomePage> {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Vérifier les nouveautés
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _checkAndShowWhatsNew();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _checkAndShowWhatsNew() async {
|
||||
final service = WhatsNewService();
|
||||
if (await service.shouldShowWhatsNew()) {
|
||||
if (!mounted) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => WhatsNewDialog(
|
||||
onDismiss: () => Navigator.pop(context),
|
||||
features: const [
|
||||
WhatsNewItem(
|
||||
icon: Icons.map_outlined,
|
||||
title: 'Recherche globale',
|
||||
description:
|
||||
'Recherchez des restaurants, musées et plus encore directement depuis la carte.',
|
||||
),
|
||||
WhatsNewItem(
|
||||
icon: Icons.search,
|
||||
title: 'Autocomplétion améliorée',
|
||||
description:
|
||||
'Découvrez des suggestions intelligentes lors de la recherche de lieux et d\'activités.',
|
||||
),
|
||||
WhatsNewItem(
|
||||
icon: Icons.warning_amber_rounded,
|
||||
title: 'Alertes de distance',
|
||||
description:
|
||||
'Soyez averti si une activité est trop éloignée de votre lieu de séjour.',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPage(int index) {
|
||||
|
||||
@@ -88,7 +88,11 @@ class _LoginPageState extends State<LoginPage> {
|
||||
body: BlocConsumer<AuthBloc, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthAuthenticated) {
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
} else if (state is AuthError) {
|
||||
ErrorService().showError(message: state.message);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:sign_in_button/sign_in_button.dart';
|
||||
import 'package:travel_mate/components/loading/laoding_content.dart';
|
||||
import 'package:travel_mate/components/signup/password_requirements.dart';
|
||||
import 'package:travel_mate/components/signup/sign_up_platform_content.dart';
|
||||
import 'package:travel_mate/services/auth_service.dart';
|
||||
import '../blocs/auth/auth_bloc.dart';
|
||||
@@ -66,6 +67,18 @@ class _SignUpPageState extends State<SignUpPage> {
|
||||
if (value.length < 8) {
|
||||
return 'Le mot de passe doit contenir au moins 8 caractères';
|
||||
}
|
||||
if (!value.contains(RegExp(r'[A-Z]'))) {
|
||||
return 'Le mot de passe doit contenir une majuscule';
|
||||
}
|
||||
if (!value.contains(RegExp(r'[a-z]'))) {
|
||||
return 'Le mot de passe doit contenir une minuscule';
|
||||
}
|
||||
if (!value.contains(RegExp(r'[0-9]'))) {
|
||||
return 'Le mot de passe doit contenir un chiffre';
|
||||
}
|
||||
if (!value.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>]'))) {
|
||||
return 'Le mot de passe doit contenir un caractère spécial';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -115,7 +128,11 @@ class _SignUpPageState extends State<SignUpPage> {
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
} else if (state is AuthError) {
|
||||
_errorService.showError(message: state.message);
|
||||
}
|
||||
@@ -209,6 +226,7 @@ class _SignUpPageState extends State<SignUpPage> {
|
||||
controller: _passwordController,
|
||||
validator: _validatePassword,
|
||||
obscureText: _obscurePassword,
|
||||
onChanged: (value) => setState(() {}),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Mot de passe',
|
||||
border: const OutlineInputBorder(
|
||||
@@ -229,6 +247,7 @@ class _SignUpPageState extends State<SignUpPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
PasswordRequirements(password: _passwordController.text),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Champ Confirmation mot de passe
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import '../firebase_options.dart'; // Add this import
|
||||
import '../models/activity.dart';
|
||||
import '../services/error_service.dart';
|
||||
import '../services/logger_service.dart';
|
||||
@@ -16,16 +16,14 @@ class ActivityPlacesService {
|
||||
final ErrorService _errorService = ErrorService();
|
||||
|
||||
static String get _apiKey {
|
||||
if (Platform.isAndroid) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_ANDROID'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
} else if (Platform.isIOS) {
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY_IOS'] ??
|
||||
dotenv.env['GOOGLE_MAPS_API_KEY'] ??
|
||||
'';
|
||||
try {
|
||||
return DefaultFirebaseOptions.currentPlatform.apiKey;
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Impossible de récupérer la clé API Firebase: $e',
|
||||
);
|
||||
return '';
|
||||
}
|
||||
return dotenv.env['GOOGLE_MAPS_API_KEY'] ?? '';
|
||||
}
|
||||
|
||||
/// Recherche des activités près d'une destination
|
||||
@@ -37,83 +35,75 @@ class ActivityPlacesService {
|
||||
int maxResults = 20,
|
||||
int offset = 0,
|
||||
}) async {
|
||||
try {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche d\'activités pour: $destination (max: $maxResults, offset: $offset)',
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche d\'activités pour: $destination (max: $maxResults, offset: $offset)',
|
||||
);
|
||||
|
||||
// 1. Géocoder la destination
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
|
||||
// 2. Rechercher les activités par catégorie ou toutes les catégories
|
||||
List<Activity> allActivities = [];
|
||||
|
||||
if (category != null) {
|
||||
final activities = await _searchByCategory(
|
||||
coordinates['lat']!,
|
||||
coordinates['lng']!,
|
||||
category,
|
||||
tripId,
|
||||
radius,
|
||||
);
|
||||
allActivities.addAll(activities);
|
||||
} else {
|
||||
// Rechercher dans toutes les catégories principales
|
||||
final mainCategories = [
|
||||
ActivityCategory.attraction,
|
||||
ActivityCategory.museum,
|
||||
ActivityCategory.restaurant,
|
||||
ActivityCategory.culture,
|
||||
ActivityCategory.nature,
|
||||
];
|
||||
|
||||
// 1. Géocoder la destination
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
|
||||
// 2. Rechercher les activités par catégorie ou toutes les catégories
|
||||
List<Activity> allActivities = [];
|
||||
|
||||
if (category != null) {
|
||||
for (final cat in mainCategories) {
|
||||
final activities = await _searchByCategory(
|
||||
coordinates['lat']!,
|
||||
coordinates['lng']!,
|
||||
category,
|
||||
cat,
|
||||
tripId,
|
||||
radius,
|
||||
);
|
||||
allActivities.addAll(activities);
|
||||
} else {
|
||||
// Rechercher dans toutes les catégories principales
|
||||
final mainCategories = [
|
||||
ActivityCategory.attraction,
|
||||
ActivityCategory.museum,
|
||||
ActivityCategory.restaurant,
|
||||
ActivityCategory.culture,
|
||||
ActivityCategory.nature,
|
||||
];
|
||||
|
||||
for (final cat in mainCategories) {
|
||||
final activities = await _searchByCategory(
|
||||
coordinates['lat']!,
|
||||
coordinates['lng']!,
|
||||
cat,
|
||||
tripId,
|
||||
radius,
|
||||
);
|
||||
allActivities.addAll(activities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Supprimer les doublons et trier par note
|
||||
final uniqueActivities = _removeDuplicates(allActivities);
|
||||
uniqueActivities.sort((a, b) => (b.rating ?? 0).compareTo(a.rating ?? 0));
|
||||
// 3. Supprimer les doublons et trier par note
|
||||
final uniqueActivities = _removeDuplicates(allActivities);
|
||||
uniqueActivities.sort((a, b) => (b.rating ?? 0).compareTo(a.rating ?? 0));
|
||||
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: ${uniqueActivities.length} activités trouvées au total',
|
||||
);
|
||||
|
||||
// 4. Appliquer la pagination
|
||||
final startIndex = offset;
|
||||
final endIndex = (startIndex + maxResults).clamp(
|
||||
0,
|
||||
uniqueActivities.length,
|
||||
);
|
||||
|
||||
if (startIndex >= uniqueActivities.length) {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: ${uniqueActivities.length} activités trouvées au total',
|
||||
'ActivityPlacesService: Offset $startIndex dépasse le nombre total (${uniqueActivities.length})',
|
||||
);
|
||||
|
||||
// 4. Appliquer la pagination
|
||||
final startIndex = offset;
|
||||
final endIndex = (startIndex + maxResults).clamp(
|
||||
0,
|
||||
uniqueActivities.length,
|
||||
);
|
||||
|
||||
if (startIndex >= uniqueActivities.length) {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Offset $startIndex dépasse le nombre total (${uniqueActivities.length})',
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
final paginatedResults = uniqueActivities.sublist(startIndex, endIndex);
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Retour de ${paginatedResults.length} activités (offset: $offset, max: $maxResults)',
|
||||
);
|
||||
|
||||
return paginatedResults;
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur lors de la recherche: $e',
|
||||
);
|
||||
_errorService.logError('activity_places_service', e);
|
||||
return [];
|
||||
}
|
||||
|
||||
final paginatedResults = uniqueActivities.sublist(startIndex, endIndex);
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Retour de ${paginatedResults.length} activités (offset: $offset, max: $maxResults)',
|
||||
);
|
||||
|
||||
return paginatedResults;
|
||||
}
|
||||
|
||||
/// Géocode une destination pour obtenir les coordonnées
|
||||
@@ -124,7 +114,13 @@ class ActivityPlacesService {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Clé API Google Maps manquante',
|
||||
);
|
||||
throw Exception('Clé API Google Maps non configurée');
|
||||
throw Exception(
|
||||
'Clé API Google Maps non configurée dans DefaultFirebaseOptions. Platform: ${Platform.isAndroid
|
||||
? 'Android'
|
||||
: Platform.isIOS
|
||||
? 'iOS'
|
||||
: 'Autre'}',
|
||||
);
|
||||
}
|
||||
|
||||
final encodedDestination = Uri.encodeComponent(destination);
|
||||
@@ -191,50 +187,52 @@ class ActivityPlacesService {
|
||||
String tripId,
|
||||
int radius,
|
||||
) async {
|
||||
try {
|
||||
final url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=${category.googlePlaceType}'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
final url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=${category.googlePlaceType}'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
|
||||
for (final place in data['results']) {
|
||||
try {
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
for (final place in data['results']) {
|
||||
try {
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
}
|
||||
|
||||
return activities;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche par catégorie: $e',
|
||||
);
|
||||
return [];
|
||||
return activities;
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return [];
|
||||
} else {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur API Places: ${data['status']} - ${data['error_message']}',
|
||||
);
|
||||
throw Exception(
|
||||
'API Places Error: ${data['status']} - ${data['error_message']}',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,62 +355,62 @@ class ActivityPlacesService {
|
||||
required String tripId,
|
||||
int radius = 5000,
|
||||
}) async {
|
||||
try {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche textuelle: $query à $destination',
|
||||
);
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche textuelle: $query à $destination',
|
||||
);
|
||||
|
||||
// Géocoder la destination
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
// Géocoder la destination
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
|
||||
final encodedQuery = Uri.encodeComponent(query);
|
||||
final url =
|
||||
'https://maps.googleapis.com/maps/api/place/textsearch/json'
|
||||
'?query=$encodedQuery in $destination'
|
||||
'&location=${coordinates['lat']},${coordinates['lng']}'
|
||||
'&radius=$radius'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
final encodedQuery = Uri.encodeComponent(query);
|
||||
final url =
|
||||
'https://maps.googleapis.com/maps/api/place/textsearch/json'
|
||||
'?query=$encodedQuery'
|
||||
'&location=${coordinates['lat']},${coordinates['lng']}'
|
||||
'&radius=$radius'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
|
||||
for (final place in data['results']) {
|
||||
try {
|
||||
// Déterminer la catégorie basée sur les types du lieu
|
||||
final types = List<String>.from(place['types'] ?? []);
|
||||
final category = _determineCategoryFromTypes(types);
|
||||
for (final place in data['results']) {
|
||||
try {
|
||||
// Déterminer la catégorie basée sur les types du lieu
|
||||
final types = List<String>.from(place['types'] ?? []);
|
||||
final category = _determineCategoryFromTypes(types);
|
||||
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
}
|
||||
|
||||
return activities;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche textuelle: $e',
|
||||
);
|
||||
return [];
|
||||
return activities;
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return [];
|
||||
} else {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur API Places Text Search: ${data['status']}',
|
||||
);
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,70 +521,63 @@ class ActivityPlacesService {
|
||||
int pageSize,
|
||||
String? nextPageToken,
|
||||
) async {
|
||||
try {
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=${category.googlePlaceType}'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=${category.googlePlaceType}'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
|
||||
if (nextPageToken != null) {
|
||||
url += '&pagetoken=$nextPageToken';
|
||||
}
|
||||
if (nextPageToken != null) {
|
||||
url += '&pagetoken=$nextPageToken';
|
||||
}
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
final results = data['results'] as List? ?? [];
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
final results = data['results'] as List? ?? [];
|
||||
|
||||
// Limiter à pageSize résultats
|
||||
final limitedResults = results.take(pageSize).toList();
|
||||
// Limiter à pageSize résultats
|
||||
final limitedResults = results.take(pageSize).toList();
|
||||
|
||||
for (final place in limitedResults) {
|
||||
try {
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
for (final place in limitedResults) {
|
||||
try {
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': activities,
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche catégorie paginée: $e',
|
||||
);
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
return {
|
||||
'activities': activities,
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} else {
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,75 +590,136 @@ class ActivityPlacesService {
|
||||
int pageSize,
|
||||
String? nextPageToken,
|
||||
) async {
|
||||
// Pour toutes les catégories, on utilise une recherche plus générale
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=tourist_attraction'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
|
||||
if (nextPageToken != null) {
|
||||
url += '&pagetoken=$nextPageToken';
|
||||
}
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
final results = data['results'] as List? ?? [];
|
||||
|
||||
// Limiter à pageSize résultats
|
||||
final limitedResults = results.take(pageSize).toList();
|
||||
|
||||
for (final place in limitedResults) {
|
||||
try {
|
||||
// Déterminer la catégorie basée sur les types du lieu
|
||||
final types = List<String>.from(place['types'] ?? []);
|
||||
final category = _determineCategoryFromTypes(types);
|
||||
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': activities,
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} else {
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Récupère des suggestions d'autocomplétion
|
||||
Future<List<Map<String, String>>> fetchSuggestions({
|
||||
required String query,
|
||||
double? lat,
|
||||
double? lng,
|
||||
}) async {
|
||||
if (query.isEmpty) return [];
|
||||
|
||||
try {
|
||||
// Pour toutes les catégories, on utilise une recherche plus générale
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
'&radius=$radius'
|
||||
'&type=tourist_attraction'
|
||||
'https://maps.googleapis.com/maps/api/place/autocomplete/json'
|
||||
'?input=${Uri.encodeComponent(query)}'
|
||||
'&key=$_apiKey'
|
||||
'&language=fr';
|
||||
|
||||
if (nextPageToken != null) {
|
||||
url += '&pagetoken=$nextPageToken';
|
||||
if (lat != null && lng != null) {
|
||||
url += '&location=$lat,$lng&radius=50000'; // 50km bias
|
||||
}
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
|
||||
if (data['status'] == 'OK') {
|
||||
final List<Activity> activities = [];
|
||||
final results = data['results'] as List? ?? [];
|
||||
|
||||
// Limiter à pageSize résultats
|
||||
final limitedResults = results.take(pageSize).toList();
|
||||
|
||||
for (final place in limitedResults) {
|
||||
try {
|
||||
// Déterminer la catégorie basée sur les types du lieu
|
||||
final types = List<String>.from(place['types'] ?? []);
|
||||
final category = _determineCategoryFromTypes(types);
|
||||
|
||||
final activity = await _convertPlaceToActivity(
|
||||
place,
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
if (activity != null) {
|
||||
activities.add(activity);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur conversion place: $e',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': activities,
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
return (data['predictions'] as List).map<Map<String, String>>((p) {
|
||||
return {
|
||||
'description': p['description'] as String,
|
||||
'placeId': p['place_id'] as String,
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
return [];
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche toutes catégories paginée: $e',
|
||||
LoggerService.error('ActivityPlacesService: Erreur autocomplete: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// Récupère une activité via son Place ID
|
||||
Future<Activity?> getActivityByPlaceId({
|
||||
required String placeId,
|
||||
required String tripId,
|
||||
}) async {
|
||||
try {
|
||||
final details = await _getPlaceDetails(placeId);
|
||||
if (details == null) return null;
|
||||
|
||||
// Créer une map simulant la structure "place" attendue par _convertPlaceToActivity
|
||||
// Note: _getPlaceDetails retourne "result", qui est déjà ce qu'on veut,
|
||||
// mais _convertPlaceToActivity attend le format "search result" qui a geometry au premier niveau.
|
||||
// Heureusement _getPlaceDetails retourne une structure compatible pour geometry/photos etc.
|
||||
|
||||
// On doit s'assurer d'avoir les types pour déterminer la catégorie
|
||||
final types = List<String>.from(details['types'] ?? []);
|
||||
final category = _determineCategoryFromTypes(types);
|
||||
|
||||
return await _convertPlaceToActivity(
|
||||
details, // details a la structure nécessaire (geometry, name, etc)
|
||||
tripId,
|
||||
category,
|
||||
);
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} catch (e) {
|
||||
LoggerService.error('ActivityPlacesService: Erreur get details: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
lib/services/analytics_service.dart
Normal file
54
lib/services/analytics_service.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Service wrapper for Google Analytics
|
||||
class AnalyticsService {
|
||||
final FirebaseAnalytics _analytics = FirebaseAnalytics.instance;
|
||||
|
||||
FirebaseAnalyticsObserver getAnalyticsObserver() =>
|
||||
FirebaseAnalyticsObserver(analytics: _analytics);
|
||||
|
||||
Future<void> logEvent({
|
||||
required String name,
|
||||
Map<String, Object>? parameters,
|
||||
}) async {
|
||||
try {
|
||||
await _analytics.logEvent(name: name, parameters: parameters);
|
||||
} catch (e) {
|
||||
debugPrint('Error logging analytics event: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setUserProperty({
|
||||
required String name,
|
||||
required String? value,
|
||||
}) async {
|
||||
try {
|
||||
await _analytics.setUserProperty(name: name, value: value);
|
||||
} catch (e) {
|
||||
debugPrint('Error setting user property: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setUserId(String? id) async {
|
||||
try {
|
||||
await _analytics.setUserId(id: id);
|
||||
} catch (e) {
|
||||
debugPrint('Error setting user ID: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logScreenView({
|
||||
required String screenName,
|
||||
String? screenClass,
|
||||
}) async {
|
||||
try {
|
||||
await _analytics.logScreenView(
|
||||
screenName: screenName,
|
||||
screenClass: screenClass,
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error logging screen view: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import '../blocs/user/user_state.dart';
|
||||
|
||||
/// Service for managing user operations with Firestore and Firebase Auth.
|
||||
///
|
||||
///
|
||||
/// This service provides functionality for user management including creating,
|
||||
/// retrieving, updating, and deleting user data in Firestore. It also handles
|
||||
/// user authentication state and provides methods for user profile management.
|
||||
|
||||
68
lib/services/whats_new_service.dart
Normal file
68
lib/services/whats_new_service.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../services/logger_service.dart';
|
||||
|
||||
class WhatsNewService {
|
||||
static const String _lastVersionKey = 'last_known_version';
|
||||
|
||||
/// Vérifie si le popup "Nouveautés" doit être affiché.
|
||||
///
|
||||
/// Retourne true si:
|
||||
/// - Ce n'est PAS une nouvelle installation
|
||||
/// - ET la version actuelle est plus récente que la version stockée
|
||||
Future<bool> shouldShowWhatsNew() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
final currentVersion = packageInfo.version;
|
||||
final lastVersion = prefs.getString(_lastVersionKey);
|
||||
|
||||
LoggerService.info(
|
||||
'WhatsNewService: Current=$currentVersion, Last=$lastVersion',
|
||||
);
|
||||
|
||||
// Cas 1: Première installation (lastVersion est null)
|
||||
if (lastVersion == null) {
|
||||
// On sauvegarde la version actuelle pour ne pas afficher le popup
|
||||
// la prochaine fois, et on retourne false maintenant.
|
||||
await prefs.setString(_lastVersionKey, currentVersion);
|
||||
LoggerService.info(
|
||||
'WhatsNewService: Fresh install detected. Marking version $currentVersion as read.',
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cas 2: Mise à jour (lastVersion != currentVersion)
|
||||
if (lastVersion != currentVersion) {
|
||||
// C'est une mise à jour, on doit afficher le popup.
|
||||
// On NE met PAS à jour la version ici, on attend que l'utilisateur ait vu le popup.
|
||||
LoggerService.info(
|
||||
'WhatsNewService: Update detected ($lastVersion -> $currentVersion). Showing popup.',
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cas 3: Même version
|
||||
return false;
|
||||
} catch (e) {
|
||||
LoggerService.error('WhatsNewService: Error checking version: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Marque la version actuelle comme "Vue".
|
||||
/// À appeler quand l'utilisateur ferme le popup.
|
||||
Future<void> markCurrentVersionAsSeen() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
await prefs.setString(_lastVersionKey, packageInfo.version);
|
||||
LoggerService.info(
|
||||
'WhatsNewService: Version ${packageInfo.version} marked as seen.',
|
||||
);
|
||||
} catch (e) {
|
||||
LoggerService.error('WhatsNewService: Error marking seen: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
48
pubspec.lock
48
pubspec.lock
@@ -13,10 +13,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _flutterfire_internals
|
||||
sha256: "8a1f5f3020ef2a74fb93f7ab3ef127a8feea33a7a2276279113660784ee7516a"
|
||||
sha256: e4a1b612fd2955908e26116075b3a4baf10c353418ca645b4deae231c82bf144
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.64"
|
||||
version: "1.3.65"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -401,6 +401,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+4"
|
||||
firebase_analytics:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: firebase_analytics
|
||||
sha256: "8ca4832c7a6d145ce987fd07d6dfbb8c91d9058178342f20de6305fb77b1b40d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "12.1.0"
|
||||
firebase_analytics_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_analytics_platform_interface
|
||||
sha256: d00234716f415f89eb5c2cefb1238d7fd2f3120275d71414b84ae434dcdb7a19
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.5"
|
||||
firebase_analytics_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_analytics_web
|
||||
sha256: e42b294e51aedb4bd4b761a886c8d6b473c44b44aa4c0b47cab06b2c66ac3fba
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.1+1"
|
||||
firebase_auth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -429,10 +453,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: firebase_core
|
||||
sha256: "1f2dfd9f535d81f8b06d7a50ecda6eac1e6922191ed42e09ca2c84bd2288927c"
|
||||
sha256: "29cfa93c771d8105484acac340b5ea0835be371672c91405a300303986f4eba9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.1"
|
||||
version: "4.3.0"
|
||||
firebase_core_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -445,10 +469,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_core_web
|
||||
sha256: ff18fabb0ad0ed3595d2f2c85007ecc794aadecdff5b3bb1460b7ee47cded398
|
||||
sha256: a631bbfbfa26963d68046aed949df80b228964020e9155b086eff94f462bbf1f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.3.0"
|
||||
version: "3.3.1"
|
||||
firebase_messaging:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -713,13 +737,13 @@ packages:
|
||||
source: hosted
|
||||
version: "2.13.1"
|
||||
google_maps_flutter_android:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_maps_flutter_android
|
||||
sha256: f820a3990d4ff23e3baf01ce794f7f08cca9a9ce6c875ec96882d605f6f039df
|
||||
sha256: "3835f6ae5e8b8d4d454d913575069513c9f216e088b87aa5c18cb3610951c6b4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.18.4"
|
||||
version: "2.18.6"
|
||||
google_maps_flutter_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -729,13 +753,13 @@ packages:
|
||||
source: hosted
|
||||
version: "2.15.5"
|
||||
google_maps_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_maps_flutter_platform_interface
|
||||
sha256: f4b9b44f7b12a1f6707ffc79d082738e0b7e194bf728ee61d2b3cdf5fdf16081
|
||||
sha256: e8b1232419fcdd35c1fdafff96843f5a40238480365599d8ca661dde96d283dd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.14.0"
|
||||
version: "2.14.1"
|
||||
google_maps_flutter_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
15
pubspec.yaml
15
pubspec.yaml
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.2+3
|
||||
version: 2026.1.3+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
@@ -64,17 +64,16 @@ dependencies:
|
||||
firebase_messaging: ^16.0.4
|
||||
flutter_local_notifications: ^19.5.0
|
||||
package_info_plus: ^8.3.1
|
||||
google_maps_flutter_platform_interface: ^2.14.1
|
||||
google_maps_flutter_android: ^2.18.6
|
||||
firebase_analytics: ^12.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_launcher_icons: ^0.13.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# The "flutter_lints" package below contains a set of recommended lints to
|
||||
# encourage good coding practices. The lint set provided by the package is
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
|
||||
flutter_lints: ^6.0.0
|
||||
mockito: ^5.4.4
|
||||
build_runner: ^2.4.8
|
||||
@@ -96,8 +95,8 @@ flutter:
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/icons/
|
||||
- .env
|
||||
- assets/icons/
|
||||
- .env
|
||||
#- assets/images/
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
|
||||
Reference in New Issue
Block a user