通话记录展示

This commit is contained in:
GYJ
2024-11-23 16:53:30 +08:00
parent a82e726d5f
commit 0f3e728a79
11 changed files with 343 additions and 14 deletions

View File

@@ -0,0 +1,54 @@
import 'dart:async';
import 'package:cashier_reserve/common/channel/call_log_model.dart';
import 'package:event_bus/event_bus.dart';
class EventManager {
static EventBus? _eventBus;
static final Map<dynamic, List<StreamSubscription>> _eventMap = {};
static EventBus? get eventBus => getEventBus();
static EventBus? getEventBus() {
_eventBus ??= EventBus();
return _eventBus;
}
static void postEvent(MyEvent event) {
getEventBus()!.fire(event);
}
static void addListener<T>(dynamic widget, void Function(T event) onData) {
StreamSubscription event = EventManager.eventBus!.on<T>().listen((T e) {
onData(e);
});
List<StreamSubscription>? list = _eventMap[widget];
list ??= [];
list.add(event);
_eventMap[widget] = list;
}
static void cancelListener(dynamic widget) {
List<StreamSubscription>? list = _eventMap[widget];
if (list == null) {
return;
}
for (var event in list) {
event.cancel();
}
}
}
class MyEvent {
String name = '';
}
class GetCallLogEvent extends MyEvent {
List<CallLogModel> callLogs;
bool isLoadMore = false;
bool isSuccess = false;
GetCallLogEvent({this.callLogs = const [], this.isLoadMore = false, this.isSuccess = false});
}