newsfeed_card_footer.dart 5.5 KB

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