newsfeed_card_footer.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import 'package:cpt_community/components/newfeed_card_header.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/widgets.dart';
  5. import 'package:flutter_hooks/flutter_hooks.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:shared/utils/color_utils.dart';
  8. import 'package:shared/utils/log_utils.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_load_image.dart';
  11. import 'package:widgets/my_text_view.dart';
  12. import 'package:widgets/my_like_button.dart';
  13. import '../modules/community/community_page.dart';
  14. // 'id':1,
  15. // 'avator': Assets.communityCamera,
  16. // 'title': 'William Jefferson',
  17. // 'isFollow': false,
  18. // 'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
  19. // 'imageUrls': ['https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500','https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500','https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500'],
  20. // 'time': 'June 17,2016 at 7:23 p.m.',
  21. // 'likeno': 12
  22. class NewsFeedCardFooter extends HookConsumerWidget {
  23. final bool isLike;
  24. int? likes_count = 0;
  25. int? comments_count = 0;
  26. final VoidCallback? onLike;
  27. final VoidCallback? onComment;
  28. final VoidCallback? onShare;
  29. final bool showShare;
  30. final GlobalKey<MyLikeButtonState> likeButtonKey;
  31. NewsFeedCardFooter({
  32. Key? key,
  33. GlobalKey<MyLikeButtonState>? likeButtonKey,
  34. required this.isLike,
  35. this.onLike,
  36. this.likes_count = 0,
  37. this.comments_count = 0,
  38. this.onComment,
  39. this.onShare,
  40. this.showShare = false,
  41. })
  42. : likeButtonKey = likeButtonKey ?? GlobalKey<MyLikeButtonState>(),
  43. super(key: key);
  44. @override
  45. Widget build(BuildContext context, WidgetRef ref) {
  46. final _isLike =useState(isLike);
  47. final _likes_count =useState(likes_count);
  48. final _comments_count =useState(comments_count);
  49. return Container(
  50. height: 40,
  51. width: double.infinity,
  52. // padding: const EdgeInsets.symmetric(horizontal: 16),
  53. child: Row(
  54. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  55. crossAxisAlignment: CrossAxisAlignment.center,
  56. children: [
  57. Expanded(
  58. child: Container(
  59. padding: const EdgeInsets.all(10),
  60. child: Row(
  61. mainAxisAlignment: MainAxisAlignment.center,
  62. children: [
  63. MyLikeButton(
  64. key: likeButtonKey,
  65. isLiked: _isLike.value,
  66. isCustomIcon: true,
  67. onLike: () {
  68. Log.d('点击了like button');
  69. onLike?.call();
  70. },
  71. ),
  72. // 动态的
  73. MyTextView(
  74. 'Like (${_likes_count.value})',
  75. textColor: ColorUtils.string2Color('#767676'),
  76. fontSize: 14,
  77. isFontRegular: true,
  78. textAlign: TextAlign.left,
  79. marginLeft: 8,
  80. )
  81. ],
  82. ),
  83. ).onTap((){
  84. final state = likeButtonKey.currentState;
  85. state?.triggerTap();
  86. }),
  87. ),
  88. Expanded(
  89. child: Container(
  90. padding: const EdgeInsets.all(8),
  91. child: Row(
  92. mainAxisAlignment: MainAxisAlignment.center,
  93. children: [
  94. const MyAssetImage(Assets.communityComments, width: 16,height: 16,),
  95. MyTextView(
  96. 'Comments ($comments_count)',
  97. textColor: ColorUtils.string2Color('#767676'),
  98. fontSize: 14,
  99. isFontRegular: true,
  100. textAlign: TextAlign.left,
  101. marginLeft: 8,
  102. ),
  103. ],
  104. ),
  105. ).onTap((){
  106. // Log.d("点击了comments ${tabsRouterKey.currentState?.controller?.activeIndex}");
  107. // tabsRouterKey.currentState?.controller?.setActiveIndex(2);
  108. onComment?.call();
  109. }),
  110. ),
  111. if(showShare)
  112. Expanded(
  113. child: Container(
  114. padding: const EdgeInsets.all(8),
  115. child: Row(
  116. mainAxisAlignment: MainAxisAlignment.center,
  117. children: [
  118. const MyAssetImage(Assets.communityShare, width: 16,height: 16,),
  119. MyTextView(
  120. 'Share',
  121. textColor: ColorUtils.string2Color('#767676'),
  122. fontSize: 14,
  123. isFontRegular: true,
  124. textAlign: TextAlign.left,
  125. marginLeft: 8,
  126. ),
  127. ],
  128. ),
  129. ).onTap((){
  130. Log.d("点击了share");
  131. onShare?.call();
  132. }),
  133. ),
  134. ]
  135. )
  136. );
  137. }
  138. }