初始化
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:event_bus/event_bus.dart';
|
||||
|
||||
typedef EventCallback<T> = void Function(T event);
|
||||
|
||||
class EventBusUtil {
|
||||
//保存单例
|
||||
static final EventBusUtil _instance = EventBusUtil._internal();
|
||||
|
||||
//工厂构造函数
|
||||
factory EventBusUtil() => _instance;
|
||||
|
||||
//初始化eventBus
|
||||
late EventBus _eventBus;
|
||||
|
||||
EventBusUtil._internal() {
|
||||
// 初始化
|
||||
_eventBus = EventBus();
|
||||
}
|
||||
|
||||
/// 订阅stream列表
|
||||
// List<StreamSubscription> subscriptionList;
|
||||
|
||||
/// 开启eventbus订阅 并
|
||||
StreamSubscription on<T>(EventCallback<T> callback) {
|
||||
StreamSubscription stream = _eventBus.on<T>().listen((event) {
|
||||
callback(event);
|
||||
});
|
||||
// subscriptionList.add(stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/// 发送消息
|
||||
void emit(event) {
|
||||
_eventBus.fire(event);
|
||||
}
|
||||
|
||||
/// 移除steam
|
||||
void off(StreamSubscription steam) {
|
||||
steam.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
var eventBus = EventBusUtil._instance;
|
||||
@@ -0,0 +1,48 @@
|
||||
/// 暂停所有视频播放(耳机/蓝牙断开、来电中断时通知长视频/直播/简单播放器暂停,防止外放泄露隐私)
|
||||
class PauseVideoEvent {}
|
||||
|
||||
//刷新动漫详情是否显示顶部
|
||||
class CollectEvent {
|
||||
bool collect;
|
||||
CollectEvent({this.collect = false});
|
||||
}
|
||||
|
||||
class CollectStatusModel {
|
||||
String? id; // 点赞,收藏id值
|
||||
String? type;
|
||||
int? uid; // 用户关注 uid
|
||||
bool? isCollected; // 这个有值,是收藏状态的处理
|
||||
bool? isLiked; // 这个有值,是点赞状态的处理
|
||||
bool? isFollowed; // 这个有值,是关注状态的处理
|
||||
/// 点赞数变化量:点赞 +1,取消点赞 -1
|
||||
int? likeCountDelta;
|
||||
CollectStatusModel({
|
||||
this.id,
|
||||
this.uid,
|
||||
this.isCollected,
|
||||
this.type,
|
||||
this.isLiked,
|
||||
this.isFollowed,
|
||||
this.likeCountDelta,
|
||||
});
|
||||
}
|
||||
|
||||
class ReLoginEvent {}
|
||||
|
||||
class YinseinnerModel {
|
||||
String? routeName;
|
||||
String? id;
|
||||
String? type;
|
||||
YinseinnerModel({this.routeName, this.id, this.type});
|
||||
}
|
||||
|
||||
class TabIndexChanged {
|
||||
int? index;
|
||||
TabIndexChanged({this.index = 0});
|
||||
}
|
||||
|
||||
//acg目录修改
|
||||
class ACGMenuChanged {
|
||||
int? index;
|
||||
ACGMenuChanged({this.index = 0});
|
||||
}
|
||||
Reference in New Issue
Block a user