diff --git a/lib/widgets/comment_section.dart b/lib/widgets/comment_section.dart new file mode 100644 index 0000000..3b73205 --- /dev/null +++ b/lib/widgets/comment_section.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:lemmy_api_client/lemmy_api_client.dart'; + +import '../comment_tree.dart'; +import 'comment.dart'; + +/// Manages comments section, sorts them +class CommentSection extends HookWidget { + final List rawComments; + final List comments; + final int postCreatorId; + + CommentSection(this.rawComments, {@required this.postCreatorId}) + : comments = CommentTree.fromList(rawComments), + assert(postCreatorId != null); + + @override + Widget build(BuildContext context) => Column(children: [ + // sorting menu goes here + if (comments.isEmpty) + Padding( + padding: EdgeInsets.symmetric(vertical: 50), + child: Text( + 'no comments yet', + style: TextStyle(fontStyle: FontStyle.italic), + ), + ), + for (var com in comments) Comment(com, postCreatorId: postCreatorId), + ]); +} diff --git a/lib/widgets/comments.dart b/lib/widgets/comments.dart deleted file mode 100644 index 7a34f58..0000000 --- a/lib/widgets/comments.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:lemmy_api_client/lemmy_api_client.dart'; - -import '../comment_tree.dart'; -import 'comment.dart'; - -/// Manages comments section, sorts them -class Comments extends HookWidget { - final List rawComments; - final List comments; - final int postCreatorId; - - Comments(this.rawComments, {@required this.postCreatorId}) - : comments = CommentTree.fromList(rawComments), - assert(postCreatorId != null); - - @override - Widget build(BuildContext context) { - return Column(children: [ - // sorting menu goes here - if (comments.isEmpty) - Padding( - padding: EdgeInsets.symmetric(vertical: 50), - child: Text( - 'no comments yet', - style: TextStyle(fontStyle: FontStyle.italic), - ), - ), - for (var com in comments) Comment(com, postCreatorId: postCreatorId), - ]); - } -}