Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web #78

Open
wants to merge 27 commits into
base: Web-madbouly
Choose a base branch
from
Open

Web #78

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1bf5661
Merge pull request #59 from NonLegit/web
belfooz Dec 22, 2022
583066a
modified posts
Amr146 Dec 23, 2022
2ea2cd7
modified main
Amr146 Dec 23, 2022
1260253
added overview list
Amr146 Dec 23, 2022
00f2999
added overview list
Amr146 Dec 23, 2022
7782cc1
Add files via upload
belfooz Dec 23, 2022
fb4dc9c
Add files via upload
belfooz Dec 23, 2022
fbe3542
Add files via upload
belfooz Dec 23, 2022
d14f44d
Merge branch 'web' into ahmed_fawzy_web
belfooz Dec 23, 2022
bcd5470
Merge pull request #71 from NonLegit/ahmed_fawzy_web
belfooz Dec 23, 2022
39c6dfb
small changes
Amr146 Dec 23, 2022
acbbf8b
Merge branch 'web' into Amr
Amr146 Dec 23, 2022
61a3ccb
Merge pull request #72 from NonLegit/Amr
Amr146 Dec 23, 2022
08dabb6
Update pubspec.yaml
Amr146 Dec 23, 2022
8fe4725
Update home_controller.dart
Amr146 Dec 23, 2022
1e1a6bf
Last change Without Theme
zeinabmoawad Dec 23, 2022
4757990
Merge branch 'Zeinab-Web' into web
zeinabmoawad Dec 23, 2022
bbf5d59
Deleted Message File
zeinabmoawad Dec 23, 2022
5bc7e4e
Merge branch 'web' into Web-madbouly
ahmedmadbouly186 Dec 23, 2022
fac17b7
Merge pull request #73 from NonLegit/Web-madbouly
ahmedmadbouly186 Dec 23, 2022
da661ed
Add files via upload
ahmedmadbouly186 Dec 23, 2022
1ad8ecd
change the provider name
ahmedmadbouly186 Dec 23, 2022
81b802d
remove error include
ahmedmadbouly186 Dec 23, 2022
3255ac2
Merge pull request #74 from NonLegit/Web-madbouly
ahmedmadbouly186 Dec 23, 2022
e5783bd
final web
zeinabmoawad Dec 23, 2022
031b3a2
Merge branch 'Zeinab-Web' into web
zeinabmoawad Dec 23, 2022
e7a144b
Merge branch 'Test_document' into web
ahmedmadbouly186 Dec 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/comments/screens/add_comment_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class _AddCommentScreenState extends State<AddCommentScreen> {
TextEditingController controller = TextEditingController();
@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
//===============================Fetch subreddit data =======================================//

var temp =
ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
parentId = temp['parentId'];
Expand All @@ -27,25 +24,23 @@ class _AddCommentScreenState extends State<AddCommentScreen> {

createComment(String text) async {
if (await Provider.of<PostCommentsProvider>(context, listen: false)
.postComment(parentId, 'Post', text)) {
print('created comment');
}
.postComment(parentId, 'Post', text)) {}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
icon: const Icon(
Icons.close,
size: 20,
),
onPressed: () {
Navigator.pop(context);
},
),
title: Text(
title: const Text(
"Add a comment",
style: TextStyle(fontSize: 20, color: Colors.black),
),
Expand All @@ -57,7 +52,7 @@ class _AddCommentScreenState extends State<AddCommentScreen> {
Navigator.pop(context);
}
: null,
child: Text(
child: const Text(
"Post",
style: TextStyle(
color: Colors.blue,
Expand All @@ -67,11 +62,11 @@ class _AddCommentScreenState extends State<AddCommentScreen> {
],
),
body: Padding(
padding: EdgeInsetsDirectional.all(10),
padding: const EdgeInsetsDirectional.all(10),
child: Column(
children: [
Text(title),
Divider(
const Divider(
height: 10,
),
Expanded(
Expand Down
19 changes: 7 additions & 12 deletions lib/comments/screens/add_reply_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class _AddReplyScreenState extends State<AddReplyScreen> {

@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
//===============================Fetch subreddit data =======================================//

var temp =
ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
parentId = temp['parentId'];
Expand All @@ -52,25 +49,23 @@ class _AddReplyScreenState extends State<AddReplyScreen> {

createComment(String text) async {
if (await Provider.of<PostCommentsProvider>(context, listen: false)
.postComment(parentId, 'Comment', text)) {
print('created comment');
}
.postComment(parentId, 'Comment', text)) {}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
icon: const Icon(
Icons.close,
size: 20,
),
onPressed: () {
Navigator.pop(context);
},
),
title: Text(
title: const Text(
"Reply",
style: TextStyle(fontSize: 20, color: Colors.black),
),
Expand All @@ -82,7 +77,7 @@ class _AddReplyScreenState extends State<AddReplyScreen> {
Navigator.pop(context);
}
: null,
child: Text(
child: const Text(
"Post",
style: TextStyle(
color: Colors.blue,
Expand All @@ -92,7 +87,7 @@ class _AddReplyScreenState extends State<AddReplyScreen> {
],
),
body: Padding(
padding: EdgeInsetsDirectional.all(10),
padding: const EdgeInsetsDirectional.all(10),
child: Column(
children: [
Row(
Expand Down Expand Up @@ -125,11 +120,11 @@ class _AddReplyScreenState extends State<AddReplyScreen> {
),
],
),
SizedBox(
const SizedBox(
height: 10,
),
Text(comment),
Divider(
const Divider(
height: 10,
),
Expanded(
Expand Down
15 changes: 11 additions & 4 deletions lib/comments/widgets/comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import '../models/comment_model.dart';
import 'comment_body.dart';
import 'comment_header.dart';

/// A widget to display a comment in tree

class Comment extends StatefulWidget {
/// The data of the commment
final CommentModel data;

/// The userName
final String userName;

/// The level of comment
final int level;
const Comment(
{super.key, required this.data, required this.userName, this.level = 0});
Expand All @@ -20,7 +27,7 @@ class _CommentState extends State<Comment> {
@override
Widget build(BuildContext context) {
return widget.data.type != null
? Text('more comments')
? const Text('more comments')
: Container(
margin: EdgeInsets.only(bottom: widget.level != 0 ? 0 : 10),
child: Material(
Expand Down Expand Up @@ -61,8 +68,8 @@ class _CommentState extends State<Comment> {
text: widget.data.text ?? '',
),
CommentFooter(
commentVoteStatus: 1,
votes: 20,
commentVoteStatus: 0,
votes: widget.data.votes ?? 0,
data: widget.data,
)
],
Expand All @@ -87,7 +94,7 @@ class _CommentState extends State<Comment> {
level: widget.level + 1,
))
.toList())
: SizedBox()
: const SizedBox()
]),
),
);
Expand Down
72 changes: 5 additions & 67 deletions lib/comments/widgets/comment_footer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,86 +27,24 @@ class _CommentFooterState extends State<CommentFooter> {
int commentVoteStatus;
int votes;
_CommentFooterState(this.commentVoteStatus, this.votes);
// upVote() async {
// if (postVoteStatus != 1) {
// if (await Provider.of<PostProvider>(context, listen: false)
// .updateVotes(widget.id, 1)) {
// setState(() {
// if (postVoteStatus == -1) {
// votes = votes + 2;
// widget.data.votes = (widget.data.votes! + 2);
// } else {
// ++votes;
// widget.data.votes = (widget.data.votes! + 1);
// }
// postVoteStatus = 1;
// widget.data.postVoteStatus = 1.toString();
// });
// }
// } else {
// if (await Provider.of<PostProvider>(context, listen: false)
// .updateVotes(widget.id, 0)) {
// setState(() {
// postVoteStatus = 0;
// widget.data.postVoteStatus = 0.toString();
// widget.data.votes = (widget.data.votes! - 1);
// --votes;
// });
// }
// }
// }

// downVote() async {
// if (postVoteStatus != -1) {
// if (await Provider.of<PostProvider>(context, listen: false)
// .updateVotes(widget.id, -1)) {
// setState(() {
// if (postVoteStatus == 1) {
// votes = votes - 2;
// widget.data.votes = (widget.data.votes! - 2);
// } else {
// --votes;
// widget.data.votes = (widget.data.votes! - 1);
// }
// postVoteStatus = -1;
// widget.data.postVoteStatus = (-1).toString();
// });
// }
// } else {
// if (await Provider.of<PostProvider>(context, listen: false)
// .updateVotes(widget.id, 0)) {
// setState(() {
// postVoteStatus = 0;
// widget.data.postVoteStatus = 0.toString();

// ++votes;
// widget.data.votes = (widget.data.votes! + 1);
// });
// }
// }
// }

upVote() {}
downVote() {}

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsetsDirectional.only(start: 10, end: 10),
margin: const EdgeInsetsDirectional.only(start: 10, end: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommentPopUpMenu(isSaved: true),
const CommentPopUpMenu(isSaved: true),
const SizedBox(
width: 20,
),
InkWell(
onTap: () {
print(widget.data.sId);
print(widget.data.text);
print(widget.data.author?.userName);
print(widget.data.createdAt);
Get.to(AddReplyScreen(), arguments: {
Get.to(const AddReplyScreen(), arguments: {
'parentId': widget.data.sId,
'comment': widget.data.text,
'authorName': widget.data.author?.userName,
Expand Down Expand Up @@ -138,7 +76,7 @@ class _CommentFooterState extends State<CommentFooter> {
child: Tooltip(
message: 'Upvote',
child: Container(
padding: EdgeInsetsDirectional.all(8),
padding: const EdgeInsetsDirectional.all(8),
child: (commentVoteStatus != 1)
? Icon(
Typicons.up_outline,
Expand All @@ -164,7 +102,7 @@ class _CommentFooterState extends State<CommentFooter> {
child: Tooltip(
message: 'Downvote',
child: Container(
padding: EdgeInsetsDirectional.all(8),
padding: const EdgeInsetsDirectional.all(8),
child: (commentVoteStatus != -1)
? Icon(
Typicons.down_outline,
Expand Down
2 changes: 1 addition & 1 deletion lib/comments/widgets/comment_popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CommentPopUpMenu extends StatelessWidget {
children: [
Container(
margin: const EdgeInsetsDirectional.only(end: 5),
child: Icon(Icons.share_outlined),
child: const Icon(Icons.share_outlined),
),
Text(
'Share',
Expand Down
7 changes: 7 additions & 0 deletions lib/comments/widgets/comments_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ import '../models/comment_model.dart';
import '../providers/comments_provider.dart';
import 'comment.dart';

/// This widget displays the comments tree of a post

class CommentsList extends StatefulWidget {
/// The ID of the post to get its comments

final String postId;

/// The user name

final String userName;
const CommentsList({super.key, required this.postId, required this.userName});

Expand Down
4 changes: 2 additions & 2 deletions lib/comments/widgets/view_comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class _ViewCommentState extends State<ViewComment> {
Widget build(BuildContext context) {
return Container(
height: 50,
margin: EdgeInsetsDirectional.only(start: 10),
margin: const EdgeInsetsDirectional.only(start: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (int i = 0; i < widget.level; i++)
VerticalDivider(
const VerticalDivider(
color: Colors.grey,
thickness: 2,
),
Expand Down
Loading