button_list.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import 'package:douyin_demo/pages/RecommendPage/BottomSheet.dart';
  2. import 'package:douyin_demo/providers/recommend_provider.dart';
  3. import 'package:douyin_demo/widgets/FavAnimation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. import 'icon_text.dart';
  7. class ButtonList extends StatefulWidget {
  8. ButtonList({Key? key}) : super(key: key);
  9. _ButtonListState createState() => _ButtonListState();
  10. }
  11. class _ButtonListState extends State<ButtonList> {
  12. @override
  13. Widget build(BuildContext context) {
  14. double rpx = MediaQuery.of(context).size.width / 750;
  15. RecommendProvider provider = Provider.of<RecommendProvider>(context);
  16. List<IconAnimationStage> stages1 = <IconAnimationStage>[];
  17. stages1.add(IconAnimationStage(
  18. color: Colors.grey[100]!,
  19. start: 1.0,
  20. end: 0.0,
  21. duration: Duration(milliseconds: 200)));
  22. stages1.add(IconAnimationStage(
  23. color: Colors.redAccent,
  24. start: 0.0,
  25. end: 1.3,
  26. duration: Duration(milliseconds: 300)));
  27. stages1.add(IconAnimationStage(
  28. color: Colors.redAccent,
  29. start: 1.3,
  30. end: 1.0,
  31. duration: Duration(milliseconds: 100)));
  32. List<IconAnimationStage> stages2 = <IconAnimationStage>[];
  33. stages2.add(IconAnimationStage(
  34. color: Colors.grey[100]!,
  35. start: 1.0,
  36. end: 1.2,
  37. duration: Duration(milliseconds: 200)));
  38. stages2.add(IconAnimationStage(
  39. color: Colors.grey[100]!,
  40. start: 1.2,
  41. end: 1.0,
  42. duration: Duration(milliseconds: 200)));
  43. List<IconAnimationStage> stages3 = <IconAnimationStage>[];
  44. stages3.add(IconAnimationStage(
  45. color: Colors.redAccent,
  46. start: 1.0,
  47. end: 1.2,
  48. duration: Duration(milliseconds: 200)));
  49. stages3.add(IconAnimationStage(
  50. color: Colors.grey[100]!,
  51. start: 1.2,
  52. end: 1.0,
  53. duration: Duration(milliseconds: 200)));
  54. double iconSize = 70 * rpx;
  55. return Container(
  56. child: Column(
  57. mainAxisAlignment: MainAxisAlignment.spaceAround,
  58. crossAxisAlignment: CrossAxisAlignment.center,
  59. children: [
  60. Container(
  61. width: 90 * rpx,
  62. height: 105 * rpx,
  63. child: Stack(
  64. children: [
  65. Container(
  66. // decoration: BoxDecoration(c),
  67. width: 90 * rpx,
  68. height: 90 * rpx,
  69. child: CircleAvatar(
  70. backgroundImage:
  71. NetworkImage("${provider.mainInfo.avatarUrl}"),
  72. )),
  73. Positioned(
  74. bottom: 0,
  75. left: 25 * rpx,
  76. child: Container(
  77. width: 40 * rpx,
  78. height: 40 * rpx,
  79. decoration: BoxDecoration(
  80. color: Colors.redAccent,
  81. borderRadius: BorderRadius.circular(25)),
  82. child: Icon(
  83. Icons.add,
  84. size: 20,
  85. color: Colors.white,
  86. ),
  87. ),
  88. )
  89. ],
  90. )),
  91. IconText(
  92. text: "${provider.mainInfo.favCount}",
  93. icon: !provider.mainInfo.ifFaved
  94. ? AnimatedIconWidget(
  95. key: UniqueKey(),
  96. animationList: stages1,
  97. icon: Icons.favorite,
  98. size: iconSize,
  99. provider: provider,
  100. callback: () {
  101. provider.tapFav();
  102. },
  103. callbackDelay: Duration(seconds: 1),
  104. )
  105. : AnimatedIconWidget(
  106. key: UniqueKey(),
  107. animationList: stages3,
  108. icon: Icons.favorite,
  109. size: iconSize,
  110. provider: provider,
  111. callback: () {
  112. provider.tapFav();
  113. }, callbackDelay: Duration(seconds: 1),
  114. ),
  115. ),
  116. IconText(
  117. text: "${provider.mainInfo.replyCount}",
  118. icon: AnimatedIconWidget(
  119. animationList: stages2,
  120. icon: Icons.comment,
  121. size: iconSize,
  122. callbackDelay: Duration(milliseconds: 200),
  123. callback: () {
  124. showBottom(context, provider);
  125. },
  126. provider: RecommendProvider(),
  127. ),
  128. ),
  129. IconText(
  130. text: "${provider.mainInfo.shareCount}",
  131. icon: AnimatedIconWidget(
  132. animationList: stages2,
  133. icon: Icons.reply,
  134. size: iconSize,
  135. callback: () {},
  136. callbackDelay: Duration(seconds: 1),
  137. provider: RecommendProvider(),
  138. ),
  139. ),
  140. ],
  141. ),
  142. );
  143. }
  144. showBottom(context, provider) {
  145. double height = MediaQuery.of(context).size.height;
  146. provider.setScreenHeight(height);
  147. provider.hideBottomBar();
  148. showModalBottomSheet(
  149. shape: RoundedRectangleBorder(
  150. borderRadius: BorderRadiusDirectional.circular(10)),
  151. context: context,
  152. builder: (_) {
  153. return Container(
  154. height: 600,
  155. child: GestureDetector(
  156. onTap: () {
  157. FocusScope.of(context).requestFocus(FocusNode());
  158. },
  159. child: ReplyFullList(pCtx: context)));
  160. });
  161. }
  162. }