recommend_provider.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import 'package:flutter/material.dart';
  2. class RecommendProvider extends State<StatefulWidget>
  3. with ChangeNotifier, TickerProviderStateMixin {
  4. bool ifShowBottom = true;
  5. double screenHeight = 1.0;
  6. List<MainInfo> infos = <MainInfo>[];
  7. List<MainInfo> followed = <MainInfo>[];
  8. late TabController controller;
  9. late MainInfo mainInfo;
  10. late Reply reply;
  11. RecommendProvider() {
  12. controller = TabController(vsync: this, length: 2);
  13. mainInfo = MainInfo(
  14. avatarUrl:
  15. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  16. content:
  17. "奥斯卡答复哈士大夫哈师大发输电和健康阿萨德鸿福路口氨基酸的鸿福路口啊,奥斯卡答复哈士大夫哈师大发输电和健康阿萨德鸿福路口氨基酸的鸿福路口啊",
  18. favCount: 109,
  19. replyCount: 212,
  20. shareCount: 317,
  21. userName: "马有发",
  22. videoPath: "assets/images/pingguo.jpeg",
  23. desc: "马友发做的一个有意思的模拟抖音的小App,用的Flutter哦~",
  24. ifFaved: false);
  25. reply = Reply(
  26. ifFaved: true,
  27. afterReplies: <Reply>[],
  28. replyContent: "真可爱,真好看,真厉害~真可爱,真好看,真厉害~",
  29. replyMakerAvatar:
  30. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  31. replyMakerName: "ABC",
  32. whenReplied: "3小时前");
  33. infos.add(MainInfo(
  34. avatarUrl:
  35. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  36. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  37. favCount: 219,
  38. replyCount: 329,
  39. shareCount: 1222,
  40. userName: "范德彪",
  41. videoPath: "assets/images/sky.jpg",
  42. desc: "这个天空的图有点好看",
  43. ifFaved: true));
  44. infos.add(MainInfo(
  45. avatarUrl:
  46. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  47. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  48. favCount: 119,
  49. replyCount: 189,
  50. shareCount: 262,
  51. userName: "马大帅",
  52. videoPath: "assets/images/temple.jpg",
  53. desc: "我喜欢拜佛",
  54. ifFaved: true));
  55. infos.add(MainInfo(
  56. avatarUrl:
  57. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  58. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  59. favCount: 98,
  60. replyCount: 222,
  61. shareCount: 1983,
  62. userName: "ABC",
  63. videoPath: "assets/images/woman.jpg",
  64. desc: "黑色女人有黑色的美",
  65. ifFaved: true));
  66. followed.add(MainInfo(
  67. avatarUrl:
  68. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  69. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  70. favCount: 219,
  71. replyCount: 329,
  72. shareCount: 1222,
  73. userName: "范德彪",
  74. videoPath: "assets/images/whitehouse.jpg",
  75. desc: "这个天空的图有点好看",
  76. ifFaved: true));
  77. followed.add(MainInfo(
  78. avatarUrl:
  79. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  80. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  81. favCount: 119,
  82. replyCount: 189,
  83. shareCount: 262,
  84. userName: "马大帅",
  85. videoPath: "assets/images/waterdrop.jpg",
  86. desc: "我喜欢拜佛",
  87. ifFaved: true));
  88. followed.add(MainInfo(
  89. avatarUrl:
  90. "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
  91. content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
  92. favCount: 98,
  93. replyCount: 222,
  94. shareCount: 1983,
  95. userName: "ABC",
  96. videoPath: "assets/images/woman2.jpg",
  97. desc: "黑色女人有黑色的美",
  98. ifFaved: true));
  99. }
  100. setScreenHeight(height) {
  101. screenHeight = height;
  102. notifyListeners();
  103. }
  104. setTabController(ctrl) {
  105. controller = ctrl;
  106. // notifyListeners();
  107. }
  108. hideBottomBar() {
  109. ifShowBottom = false;
  110. notifyListeners();
  111. }
  112. tapFav() {
  113. mainInfo.ifFaved = !mainInfo.ifFaved;
  114. if (mainInfo.ifFaved) {
  115. mainInfo.favCount += 1;
  116. } else {
  117. mainInfo.favCount -= 1;
  118. }
  119. notifyListeners();
  120. }
  121. @override
  122. Widget build(BuildContext context) {
  123. return Container();
  124. }
  125. }
  126. class MainInfo {
  127. String avatarUrl;
  128. String userName;
  129. String content;
  130. int favCount;
  131. int replyCount;
  132. int shareCount;
  133. String videoPath;
  134. String desc;
  135. bool ifFaved;
  136. MainInfo(
  137. {required this.avatarUrl,
  138. required this.content,
  139. required this.favCount,
  140. required this.replyCount,
  141. required this.shareCount,
  142. required this.userName,
  143. required this.videoPath,
  144. required this.desc,
  145. required this.ifFaved});
  146. }
  147. class Reply {
  148. String replyMakerName;
  149. String replyMakerAvatar;
  150. String replyContent;
  151. String whenReplied;
  152. bool ifFaved;
  153. List<Reply> afterReplies;
  154. Reply(
  155. {required this.ifFaved,
  156. required this.afterReplies,
  157. required this.replyContent,
  158. required this.replyMakerAvatar,
  159. required this.replyMakerName,
  160. required this.whenReplied});
  161. }