mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-16 15:16:15 +08:00
opt: live: send danmaku
Closes #618 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/live/danmu_info.dart';
|
||||
import 'package:PiliPlus/models/live/quality.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/widgets/send_danmaku_panel.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/tcp/live.dart';
|
||||
import 'package:PiliPlus/utils/danmaku.dart';
|
||||
@@ -12,11 +13,13 @@ import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/live.dart';
|
||||
import 'package:PiliPlus/models/live/room_info.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/index.dart';
|
||||
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
||||
import '../../models/live/room_info_h5.dart';
|
||||
import '../../utils/video_utils.dart';
|
||||
|
||||
@@ -42,6 +45,10 @@ class LiveRoomController extends GetxController {
|
||||
late List<Map> acceptQnList = <Map>[];
|
||||
RxString currentQnDesc = ''.obs;
|
||||
|
||||
String? savedDanmaku;
|
||||
|
||||
late final isLogin = Accounts.main.isLogin;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -241,4 +248,41 @@ class LiveRoomController extends GetxController {
|
||||
.description;
|
||||
await queryLiveInfo();
|
||||
}
|
||||
|
||||
void onSendDanmaku() {
|
||||
if (!isLogin) {
|
||||
SmartDialog.showToast('未登录');
|
||||
return;
|
||||
}
|
||||
Navigator.of(Get.context!).push(
|
||||
GetDialogRoute(
|
||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||
return SendDanmakuPanel(
|
||||
roomId: roomId,
|
||||
initialValue: savedDanmaku,
|
||||
onSave: (danmaku) => savedDanmaku = danmaku,
|
||||
callback: (danmakuModel) {
|
||||
savedDanmaku = null;
|
||||
plPlayerController.danmakuController?.addDanmaku(danmakuModel);
|
||||
},
|
||||
darkVideoPage: false,
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(0.0, 1.0);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.linear;
|
||||
|
||||
var tween =
|
||||
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user