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.
문자 AppString.dart에서 import 해서 쓰도록 변경
- Loading branch information
Showing
9 changed files
with
278 additions
and
252 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
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,127 +1,130 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
import '../../../model/CommentModel.dart'; | ||
import '../provider/UserInfoProvider.dart'; | ||
import 'DeleteConfirmationDialog.dart'; | ||
import 'EditCommentDialog.dart'; | ||
import 'DeleteConfirmationDialogWidget.dart'; | ||
import 'EditCommentDialogWidget.dart'; | ||
|
||
class CommentItemWidget extends ConsumerWidget { | ||
class CommentItemWidget extends StatelessWidget { | ||
final CommentModel comment; | ||
final String userName; | ||
final String userProfileImageUrl; | ||
final String postID; | ||
final void Function(String commentID) onDelete; | ||
final void Function(String commentID, String newContent) onEdit; | ||
|
||
const CommentItemWidget({super.key, required this.comment}); | ||
const CommentItemWidget({ | ||
super.key, | ||
required this.comment, | ||
required this.userName, | ||
required this.userProfileImageUrl, | ||
required this.postID, | ||
required this.onDelete, | ||
required this.onEdit, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final postUserInfo = ref.watch(postUserInfoProvider(comment.userID)); | ||
Widget build(BuildContext context) { | ||
final TextEditingController editController = TextEditingController(text: comment.content); | ||
|
||
return postUserInfo.when( | ||
data: (userInfo) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 8.0), | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
CircleAvatar( | ||
backgroundImage: NetworkImage(userInfo.profileImageUrl), | ||
radius: 20, | ||
), | ||
const SizedBox(width: 12), | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 8.0), | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
CircleAvatar( | ||
backgroundImage: NetworkImage(userProfileImageUrl), | ||
radius: 20, | ||
), | ||
const SizedBox(width: 12), | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row( | ||
children: [ | ||
Row( | ||
children: [ | ||
Text( | ||
userInfo.name, | ||
style: const TextStyle( | ||
fontWeight: FontWeight.bold, | ||
fontSize: 16, | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
Text( | ||
DateFormat.yMMMd().format(comment.createdAt), | ||
style: const TextStyle( | ||
fontSize: 12, | ||
color: Colors.grey, | ||
), | ||
), | ||
const Spacer(), | ||
PopupMenuButton<String>( | ||
icon: const Icon(Icons.more_vert), | ||
onSelected: (value) { | ||
if (value == 'edit') { | ||
showDialog( | ||
context: context, | ||
builder: (context) => EditCommentDialog( | ||
commentID: comment.commentID, | ||
postID: comment.postID, | ||
ref: ref, | ||
editController: editController, | ||
), | ||
); | ||
} else if (value == 'delete') { | ||
showDialog( | ||
context: context, | ||
builder: (context) => DeleteConfirmationDialog( | ||
commentID: comment.commentID, | ||
postID: comment.postID, | ||
ref: ref, | ||
), | ||
); | ||
} | ||
}, | ||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ | ||
const PopupMenuItem<String>( | ||
value: 'edit', | ||
child: Text('수정'), | ||
Text( | ||
userName, | ||
style: const TextStyle( | ||
fontWeight: FontWeight.bold, | ||
fontSize: 16, | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
Text( | ||
DateFormat.yMMMd().format(comment.createdAt), | ||
style: const TextStyle( | ||
fontSize: 12, | ||
color: Colors.grey, | ||
), | ||
), | ||
const Spacer(), | ||
PopupMenuButton<String>( | ||
icon: const Icon(Icons.more_vert), | ||
onSelected: (value) { | ||
if (value == 'edit') { | ||
showDialog( | ||
context: context, | ||
builder: (context) => EditCommentDialogWidget( | ||
commentID: comment.commentID, | ||
postID: postID, | ||
editController: editController, | ||
onEdit: onEdit, // onEdit 콜백 전달 | ||
), | ||
const PopupMenuItem<String>( | ||
value: 'delete', | ||
child: Text('삭제'), | ||
); | ||
} else if (value == 'delete') { | ||
showDialog( | ||
context: context, | ||
builder: (context) => DeleteConfirmationDialogWidget( | ||
commentID: comment.commentID, | ||
onDelete: onDelete, // onDelete 콜백 전달 | ||
), | ||
], | ||
), | ||
], | ||
), | ||
const SizedBox(height: 4), | ||
Text(comment.content), | ||
const SizedBox(height: 8), | ||
Row( | ||
children: [ | ||
IconButton( | ||
icon: const Icon(Icons.thumb_up_alt_outlined, size: 20), | ||
onPressed: () { | ||
// 좋아요 버튼 기능 | ||
}, | ||
), | ||
IconButton( | ||
icon: const Icon(Icons.thumb_down_alt_outlined, size: 20), | ||
onPressed: () { | ||
// 싫어요 버튼 기능 | ||
}, | ||
); | ||
} | ||
}, | ||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ | ||
const PopupMenuItem<String>( | ||
value: 'edit', | ||
child: Text('수정'), | ||
), | ||
IconButton( | ||
icon: const Icon(Icons.comment_outlined, size: 20), | ||
onPressed: () { | ||
// 댓글 버튼 기능 | ||
}, | ||
const PopupMenuItem<String>( | ||
value: 'delete', | ||
child: Text('삭제'), | ||
), | ||
], | ||
) | ||
], | ||
), | ||
const SizedBox(height: 4), | ||
Text(comment.content), | ||
const SizedBox(height: 8), | ||
Row( | ||
children: [ | ||
IconButton( | ||
icon: const Icon(Icons.thumb_up_alt_outlined, size: 20), | ||
onPressed: () { | ||
// 좋아요 버튼 기능 | ||
}, | ||
), | ||
IconButton( | ||
icon: const Icon(Icons.thumb_down_alt_outlined, size: 20), | ||
onPressed: () { | ||
// 싫어요 버튼 기능 | ||
}, | ||
), | ||
IconButton( | ||
icon: const Icon(Icons.comment_outlined, size: 20), | ||
onPressed: () { | ||
// 댓글 버튼 기능 | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
], | ||
), | ||
), | ||
); | ||
}, | ||
loading: () => const CircularProgressIndicator(), | ||
error: (error, stackTrace) => const Icon(Icons.error), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.