item_following.dart 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'package:cpt_community/components/comments_dialog.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_hooks/flutter_hooks.dart';
  6. import 'package:flutter_riverpod/flutter_riverpod.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:widgets/ext/ex_widget.dart';
  9. import 'package:widgets/my_button.dart';
  10. import 'package:widgets/my_load_image.dart';
  11. import 'package:widgets/my_text_view.dart';
  12. enum MyFollowingType {
  13. isFollowType,
  14. isFollowerType,
  15. }
  16. class MyFollowingListItem extends StatelessWidget {
  17. final MyFollowingType? itemType;
  18. bool? hasBottomDriver = true;
  19. Map<String, dynamic> itemObj;
  20. void Function(dynamic)? onClickAction;
  21. MyFollowingListItem({
  22. super.key,
  23. required this.itemObj,
  24. this.itemType = MyFollowingType.isFollowType,
  25. this.hasBottomDriver=true,
  26. this.onClickAction
  27. });
  28. @override
  29. Widget build(BuildContext context) {
  30. return Column(
  31. children: [
  32. Container(
  33. margin: const EdgeInsets.only(left: 15,right: 15,top: 15,bottom: 15),
  34. child: Row(
  35. mainAxisSize: MainAxisSize.max,
  36. children: [
  37. Expanded(
  38. child: Row(
  39. mainAxisAlignment: MainAxisAlignment.start,
  40. children: [
  41. MyLoadImage(
  42. 'https://img1.baidu.com/it/u=2743394743,692629981&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800',
  43. width: 65,
  44. height: 65,
  45. isCircle: true,
  46. ),
  47. MyTextView(
  48. 'Chin Lan',
  49. fontSize: 17,
  50. isFontMedium: true,
  51. marginLeft: 17,
  52. )
  53. ],
  54. ).onTap((){
  55. // onClickAction?.call(itemObj);
  56. }),
  57. ),
  58. // _buildIsFollowButton(context),
  59. HookConsumer(
  60. builder: (context, ref, child) {
  61. final isFollow = useState(itemObj['isFollow']);
  62. return (!isFollow.value)? MyButton(
  63. text:'+Follow',
  64. onPressed: (){
  65. // todo 调用接口 然后更新状态
  66. isFollow.value = !isFollow.value;
  67. },
  68. textColor: context.appColors.textWhite,
  69. backgroundColor: context.appColors.textPrimary,
  70. fontSize: 14,
  71. fontWeight: FontWeight.w400,
  72. minWidth: 67.5,
  73. minHeight: 30.5,
  74. ): const SizedBox.shrink();
  75. },
  76. )
  77. ],
  78. ),
  79. ),
  80. if(hasBottomDriver!)
  81. Container(
  82. height: 1,
  83. color: context.appColors.dividerDefault,
  84. )
  85. ],
  86. );
  87. }
  88. }