| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import 'package:e2ee_chat/common/global.dart';
- import 'package:e2ee_chat/presenter/chat_list.dart';
- import 'package:e2ee_chat/widgets/chat_list_item.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_slidable/flutter_slidable.dart';
- import 'package:provider/provider.dart';
- class ChatList extends StatefulWidget {
- @override
- _ChatListState createState() => _ChatListState();
- }
- class _ChatListState extends State<ChatList> {
- @override
- Widget build(BuildContext context) {
- return ChangeNotifierProvider<ChatListPresenter>(
- create: (context) {
- return ChatListPresenter();
- },
- child: Builder(
- builder: (context) {
- final provider = Provider.of<ChatListPresenter>(context);
- final list = provider.chatList;
- return RefreshIndicator(
- child: ListView.builder(
- itemCount: list.length,
- itemBuilder: (context, index) {
- final _item = list[index];
- return Slidable(
- actionPane: SlidableDrawerActionPane(),
- actionExtentRatio: 0.25,
- secondaryActions: <Widget>[
- IconSlideAction(
- caption: '取消置顶',
- color: Colors.black45,
- icon: Icons.more_horiz,
- onTap: () {},
- ),
- IconSlideAction(
- caption: '删除',
- color: Colors.redAccent,
- icon: Icons.delete,
- onTap: () => {},
- ),
- ],
- child: Padding(
- padding: EdgeInsets.only(left: 36, bottom: 20, top: 20),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Expanded(child: ChatListItem(_item)),
- _item.isStick
- ? Container(
- width: 40,
- height: 48,
- margin: EdgeInsets.only(top: 10, right: 10),
- child: Icon(Icons.star))
- : Padding(
- padding: EdgeInsets.symmetric(horizontal: 24),
- )
- ],
- ),
- ),
- );
- }),
- onRefresh: () async {});
- },
- ),
- );
- }
- }
|