You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
4 years ago
|
import 'package:bytedesk_kefu/bytedesk_kefu.dart';
|
||
|
import 'package:bytedesk_kefu/model/thread.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
// 历史会话列表
|
||
|
class HistoryThreadPage extends StatefulWidget {
|
||
|
HistoryThreadPage({Key key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_HistoryThreadPageState createState() => _HistoryThreadPageState();
|
||
|
}
|
||
|
|
||
|
class _HistoryThreadPageState extends State<HistoryThreadPage> {
|
||
|
int _page = 0;
|
||
|
int _size = 20;
|
||
|
List<Thread> _historyThreadList = [];
|
||
|
//
|
||
|
@override
|
||
|
void initState() {
|
||
|
_getVisitorThreads();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
//
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: Text('历史会话'),
|
||
|
elevation: 0,
|
||
|
),
|
||
|
body: RefreshIndicator(
|
||
|
child: ListView.builder(
|
||
|
padding: EdgeInsets.all(8.0),
|
||
|
itemBuilder: (_, int index) => ListTile(
|
||
|
leading: Image.network(_historyThreadList[index].avatar),
|
||
|
title: Text('${_historyThreadList[index].nickname}, ${_historyThreadList[index].timestamp}'),
|
||
|
subtitle: Text('${_historyThreadList[index].content}'),
|
||
|
),
|
||
|
itemCount: _historyThreadList.length,
|
||
|
),
|
||
|
onRefresh: _onRefresh,
|
||
|
));
|
||
|
}
|
||
|
|
||
|
void _getVisitorThreads() {
|
||
|
BytedeskKefu.getVisitorThreads(_page, _size).then((value) => {
|
||
|
setState(() {
|
||
|
_historyThreadList = value;
|
||
|
})
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<void> _onRefresh() async {
|
||
|
_page++;
|
||
|
_getVisitorThreads();
|
||
|
}
|
||
|
}
|