generated from jwson-automation/blueberry_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/2024-summer' into feature/naverLogin
- Loading branch information
Showing
40 changed files
with
1,205 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# PowerShell 스크립트로 .env 파일 생성 | ||
|
||
# 현재 작업 중인 디렉터리 경로 가져오기 | ||
$TargetDir = Get-Location | ||
|
||
# .env 파일 내용 | ||
$envContent = @" | ||
# please replace 'your_api_key_here' with your actual API key | ||
GOOGLE_API_KEY=your_api_key_here | ||
GPT_API_KEY=your_api_key_here | ||
# Other environment variables can be added here | ||
"@ | ||
|
||
# .env 파일 생성 | ||
$envFilePath = Join-Path -Path $TargetDir -ChildPath ".env" | ||
Write-Output "Creating .env file at: $envFilePath" | ||
|
||
# UTF-8 인코딩으로 파일 생성 | ||
$envContent | Out-File -FilePath $envFilePath -Encoding utf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# .env 파일 생성 | ||
echo "# please replace 'your_api_key_here' with your actual API key" > ".env" | ||
echo "GOOGLE_API_KEY=your_api_key_here" >> ".env" | ||
echo "GPT_API_KEY=your_api_key_here" >> ".env" | ||
echo "# Other environment variables can be added here" >> ".env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
lib/feature/friendsList/provider/FriendsListImageProvider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
// 친구목록 이미지 URL을 제공하는 Provider | ||
final friendsListImageProvider = | ||
FutureProvider.family<String, String>((ref, imageName) async { | ||
final storageRef = FirebaseStorage.instance.ref('profileimage/$imageName'); | ||
final downloadUrl = await storageRef.getDownloadURL(); | ||
return downloadUrl; | ||
}); |
95 changes: 72 additions & 23 deletions
95
lib/feature/friendsList/provider/FriendsListProvider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,90 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
import '../../../model/FriendModel.dart'; | ||
import '../../../utils/AppStrings.dart'; | ||
import '../../userreport/provider/UserReportBottomSheetWidget.dart'; | ||
|
||
// 친구 목록을 제공하는 Provider | ||
// 친구목록을 제공하는 Provider | ||
final friendsListProvider = StreamProvider<List<FriendModel>>((ref) { | ||
final firestore = FirebaseFirestore.instance; | ||
|
||
const userId = 'eztqDqrvEXDc8nqnnrB8'; // 로그인을 가정한 임시 유저 ID | ||
|
||
return firestore | ||
.collection('users_test') | ||
.doc(userId) | ||
.collection('friends') | ||
.snapshots() | ||
.map((snapshot) { | ||
return snapshot.docs.map((doc) { | ||
final data = doc.data(); | ||
return FriendModel.fromJson({ | ||
...data, | ||
'lastConnect': | ||
(data['lastConnect'] as Timestamp).toDate().toIso8601String(), | ||
}); | ||
}).toList(); | ||
.asyncMap((snapshot) async { | ||
final friendModels = await Future.wait(snapshot.docs.map((doc) async { | ||
final userID = doc['userID'] as String; | ||
final userDoc = | ||
await firestore.collection('users_test').doc(userID).get(); | ||
|
||
if (userDoc.exists) { | ||
return FriendModel.fromJson(userDoc.data()!); | ||
} else { | ||
throw Exception(AppStrings.userNotFoundErrorMessage); | ||
} | ||
}).toList()); | ||
|
||
return friendModels; | ||
}); | ||
}); | ||
|
||
// 친구목록 이미지 URL을 제공하는 Provider | ||
final friendsListImageProvider = | ||
FutureProvider.family<String, String>((ref, imageName) async { | ||
final ref = FirebaseStorage.instance.ref('friends-profile/$imageName'); | ||
return await ref.getDownloadURL(); | ||
final deleteFriendProvider = | ||
Provider<Future<void> Function(BuildContext, FriendModel)>((ref) { | ||
return (BuildContext context, FriendModel friend) async { | ||
final firestore = FirebaseFirestore.instance; | ||
const userId = 'eztqDqrvEXDc8nqnnrB8'; // 로그인을 가정한 임시 유저 ID | ||
|
||
await firestore | ||
.collection('users_test') | ||
.doc(userId) | ||
.collection('friends') | ||
.doc(friend.userID) | ||
.delete(); | ||
|
||
ref.invalidate(friendsListProvider); | ||
|
||
if (context.mounted) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar(content: Text(AppStrings.friendDeleteSuccessMessage)), | ||
); | ||
} | ||
}; | ||
}); | ||
|
||
// /// 이미지 URL을 제공하는 공용 Provider | ||
// final imageProvider = FutureProvider.family<String, String>((ref, imagePath) async { | ||
// final ref = FirebaseStorage.instance.ref(imagePath); | ||
// return await ref.getDownloadURL(); | ||
// }); | ||
// ui 팝업 메뉴 선택시 처리하는 함수 | ||
void handleMenuSelection( | ||
BuildContext context, WidgetRef ref, int value, FriendModel friend) async { | ||
switch (value) { | ||
case 1: | ||
// 삭제 | ||
final deleteFriend = ref.read(deleteFriendProvider); | ||
Navigator.of(context).pop(); | ||
await deleteFriend(context, friend); | ||
break; | ||
case 2: | ||
Navigator.of(context).pop(); | ||
if (context.mounted) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar(content: Text('차단 기능이 아직 구현되지 않았습니다.')), | ||
); | ||
} | ||
break; | ||
case 3: | ||
// 신고 | ||
Navigator.of(context).pop(); | ||
showModalBottomSheet( | ||
context: context, | ||
isScrollControlled: true, | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.vertical(top: Radius.circular(25.0)), | ||
), | ||
builder: (context) => UserReportBottomSheetWidget(friend: friend), | ||
); | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.