chat_list.dart 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:e2ee_chat/common/global.dart';
  2. import 'package:e2ee_chat/presenter/chat_list.dart';
  3. import 'package:e2ee_chat/widgets/chat_list_item.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_slidable/flutter_slidable.dart';
  6. import 'package:provider/provider.dart';
  7. class ChatList extends StatefulWidget {
  8. @override
  9. _ChatListState createState() => _ChatListState();
  10. }
  11. class _ChatListState extends State<ChatList> {
  12. @override
  13. Widget build(BuildContext context) {
  14. return ChangeNotifierProvider<ChatListPresenter>(
  15. create: (context) {
  16. return ChatListPresenter();
  17. },
  18. child: Builder(
  19. builder: (context) {
  20. final provider = Provider.of<ChatListPresenter>(context);
  21. final list = provider.chatList;
  22. return RefreshIndicator(
  23. child: ListView.builder(
  24. itemCount: list.length,
  25. itemBuilder: (context, index) {
  26. final _item = list[index];
  27. return Slidable(
  28. actionPane: SlidableDrawerActionPane(),
  29. actionExtentRatio: 0.25,
  30. secondaryActions: <Widget>[
  31. IconSlideAction(
  32. caption: '取消置顶',
  33. color: Colors.black45,
  34. icon: Icons.more_horiz,
  35. onTap: () {},
  36. ),
  37. IconSlideAction(
  38. caption: '删除',
  39. color: Colors.redAccent,
  40. icon: Icons.delete,
  41. onTap: () => {},
  42. ),
  43. ],
  44. child: Padding(
  45. padding: EdgeInsets.only(left: 36, bottom: 20, top: 20),
  46. child: Row(
  47. crossAxisAlignment: CrossAxisAlignment.start,
  48. children: <Widget>[
  49. Expanded(child: ChatListItem(_item)),
  50. _item.isStick
  51. ? Container(
  52. width: 40,
  53. height: 48,
  54. margin: EdgeInsets.only(top: 10, right: 10),
  55. child: Icon(Icons.star))
  56. : Padding(
  57. padding: EdgeInsets.symmetric(horizontal: 24),
  58. )
  59. ],
  60. ),
  61. ),
  62. );
  63. }),
  64. onRefresh: () async {});
  65. },
  66. ),
  67. );
  68. }
  69. }