BottomSheet.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import 'package:douyin_demo/pages/RecommendPage/FriendList.dart';
  2. import 'package:douyin_demo/providers/AtUserProvider.dart';
  3. import 'package:douyin_demo/providers/recommend_provider.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. class ReplyFullList extends StatelessWidget {
  7. ReplyFullList({Key? key, required this.pCtx}) : super(key: key);
  8. final BuildContext pCtx;
  9. @override
  10. Widget build(BuildContext context) {
  11. double rpx = MediaQuery.of(context).size.width / 750;
  12. RecommendProvider provider = Provider.of<RecommendProvider>(pCtx);
  13. Reply reply = provider.reply;
  14. List<Reply> replies = <Reply>[];
  15. replies.add(reply);
  16. replies.add(reply);
  17. replies.add(reply);
  18. ScrollController controller = ScrollController();
  19. return Scaffold(
  20. appBar: PreferredSize(
  21. preferredSize: Size.fromHeight(80 * rpx),
  22. child: AppBar(
  23. leading: Container(),
  24. elevation: 0,
  25. backgroundColor: Colors.grey[50],
  26. actions: <Widget>[
  27. IconButton(
  28. icon: Icon(
  29. Icons.close,
  30. color: Colors.black,
  31. ),
  32. onPressed: () {
  33. Navigator.pop(context);
  34. },
  35. )
  36. ],
  37. title: Text(
  38. "10条评论",
  39. style: TextStyle(color: Colors.grey[700], fontSize: 25 * rpx),
  40. ),
  41. // elevation: 1,
  42. )),
  43. bottomNavigationBar: SafeArea(
  44. child: BottomReplyBar(
  45. pCtx: pCtx,
  46. ),
  47. ),
  48. body: SingleChildScrollView(
  49. controller: controller,
  50. child: Container(
  51. child: genReplyList(replies, controller),
  52. )));
  53. }
  54. }
  55. class ReplyList extends StatelessWidget {
  56. const ReplyList({Key? key, required this.reply, required this.controller}) : super(key: key);
  57. final Reply reply;
  58. final ScrollController controller;
  59. @override
  60. Widget build(BuildContext context) {
  61. double rpx = MediaQuery.of(context).size.width / 750;
  62. List<Reply> replies = <Reply>[];
  63. replies.add(reply);
  64. replies.add(reply);
  65. replies.add(reply);
  66. return Container(
  67. child: Column(
  68. mainAxisSize: MainAxisSize.min,
  69. children: [
  70. Row(
  71. children: [
  72. Container(
  73. width: 100 * rpx,
  74. height: 100 * rpx,
  75. padding: EdgeInsets.all(10 * rpx),
  76. child: CircleAvatar(
  77. backgroundImage: NetworkImage("${reply.replyMakerAvatar}"),
  78. ),
  79. ),
  80. Container(
  81. width: 550 * rpx,
  82. child: ListTile(
  83. title: Text("${reply.replyMakerName}"),
  84. subtitle: Text(
  85. "${reply.replyContent}",
  86. maxLines: 2,
  87. overflow: TextOverflow.ellipsis,
  88. ),
  89. ),
  90. ),
  91. Container(
  92. width: 100 * rpx,
  93. child: IconButton(
  94. onPressed: () {},
  95. icon: Icon(
  96. Icons.favorite,
  97. color: Colors.grey[300],
  98. ),
  99. ),
  100. )
  101. ],
  102. ),
  103. genAfterReplyList(replies, controller)
  104. ],
  105. ),
  106. );
  107. }
  108. }
  109. class AfterReply extends StatelessWidget {
  110. const AfterReply({Key? key, required this.afterReply}) : super(key: key);
  111. final Reply afterReply;
  112. @override
  113. Widget build(BuildContext context) {
  114. double rpx = MediaQuery.of(context).size.width / 750;
  115. return Container(
  116. child: Column(
  117. mainAxisSize: MainAxisSize.min,
  118. children: [
  119. Row(
  120. children: [
  121. Container(
  122. width: 100 * rpx,
  123. ),
  124. Container(
  125. width: 550 * rpx,
  126. child: Row(
  127. crossAxisAlignment: CrossAxisAlignment.start,
  128. children: [
  129. Container(
  130. width: 70 * rpx,
  131. height: 70 * rpx,
  132. margin: EdgeInsets.only(top: 15 * rpx),
  133. padding: EdgeInsets.all(10 * rpx),
  134. child: CircleAvatar(
  135. backgroundImage:
  136. NetworkImage("${afterReply.replyMakerAvatar}"),
  137. ),
  138. ),
  139. Container(
  140. width: 480 * rpx,
  141. child: ListTile(
  142. title: Text("${afterReply.replyMakerName}"),
  143. subtitle: RichText(
  144. text: TextSpan(
  145. text: "${afterReply.replyContent}",
  146. style: TextStyle(color: Colors.grey[500]),
  147. children: [
  148. TextSpan(text: " ${afterReply.whenReplied}")
  149. ]),
  150. ),
  151. ),
  152. )
  153. ],
  154. ),
  155. ),
  156. Container(
  157. width: 100 * rpx,
  158. child: IconButton(
  159. onPressed: () {},
  160. icon: Icon(
  161. Icons.favorite,
  162. color: Colors.grey[300],
  163. ),
  164. ),
  165. )
  166. ],
  167. )
  168. ],
  169. ),
  170. );
  171. }
  172. }
  173. genReplyList(List<Reply> replies, ScrollController controller) {
  174. return ListView.builder(
  175. shrinkWrap: true,
  176. controller: controller,
  177. itemCount: replies.length,
  178. itemBuilder: (context, index) {
  179. return ReplyList(
  180. reply: replies[index],
  181. controller: controller,
  182. );
  183. },
  184. );
  185. }
  186. genAfterReplyList(List<Reply> replies, ScrollController controller) {
  187. return ListView.builder(
  188. shrinkWrap: true,
  189. controller: controller,
  190. itemCount: replies.length <= 2 ? replies.length : 2,
  191. itemBuilder: (context, index) {
  192. return AfterReply(
  193. afterReply: replies[index],
  194. );
  195. },
  196. );
  197. }
  198. class BottomReplyBar extends StatelessWidget {
  199. const BottomReplyBar({Key? key, required this.pCtx}) : super(key: key);
  200. final BuildContext pCtx;
  201. @override
  202. Widget build(BuildContext context) {
  203. TextEditingController _controller = TextEditingController();
  204. double toBottom = MediaQuery.of(context).viewInsets.bottom;
  205. double rpx = MediaQuery.of(context).size.width / 750;
  206. return Container(
  207. padding: EdgeInsets.only(bottom: toBottom),
  208. decoration: BoxDecoration(
  209. border: Border(top: BorderSide(color: Colors.grey[200]!, width: 1))),
  210. child: Row(
  211. children: [
  212. Expanded(
  213. child: Container(
  214. padding: EdgeInsets.only(left: 30 * rpx),
  215. // width: 600*rspx,
  216. child: TextField(
  217. controller: _controller,
  218. decoration: InputDecoration(
  219. hintText: "留下你的精彩评论", border: InputBorder.none),
  220. ),
  221. )),
  222. IconButton(
  223. icon: Icon(
  224. Icons.email,
  225. color: Colors.grey[500],
  226. size: 50 * rpx,
  227. ),
  228. onPressed: () {
  229. showAtFriendPage(pCtx);
  230. },
  231. ),
  232. IconButton(
  233. icon: Icon(Icons.face, color: Colors.grey[500], size: 50 * rpx),
  234. onPressed: () {},
  235. ),
  236. SizedBox(
  237. width: 20 * rpx,
  238. )
  239. ],
  240. ),
  241. );
  242. }
  243. }
  244. showAtFriendPage(BuildContext context) {
  245. Navigator.of(context).push(MaterialPageRoute(
  246. builder: (BuildContext context) {
  247. return MultiProvider(
  248. providers: [
  249. ChangeNotifierProvider(
  250. create: (BuildContext context) {
  251. return AtUserProvider();
  252. },
  253. )
  254. ], child: AtFriendPage());
  255. },
  256. fullscreenDialog: true));
  257. }