From 56460c937d238002f8f2baac917d1165456dd926 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Mon, 14 Apr 2025 10:29:16 +0800 Subject: [PATCH] mod: send vip colorful dm Signed-off-by: bggRGjQaUbCoE --- lib/http/danmaku.dart | 6 +-- .../detail/widgets/send_danmaku_panel.dart | 50 +++++++++++++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/lib/http/danmaku.dart b/lib/http/danmaku.dart index 00b59943..5c2c4602 100644 --- a/lib/http/danmaku.dart +++ b/lib/http/danmaku.dart @@ -60,7 +60,7 @@ class DanmakuHttp { int? fontsize, // 弹幕字号(默认25) int? pool, // 弹幕池选择(0:普通池 1:字幕池 2:特殊池(代码/BAS弹幕)默认普通池,0) //int? rnd,// 当前时间戳*1000000(若无此项,则发送弹幕冷却时间限制为90s;若有此项,则发送弹幕冷却时间限制为5s) - int? colorful, //60001:专属渐变彩色(需要会员) + bool? colorful, //60001:专属渐变彩色(需要会员) int? checkbox_type, //是否带 UP 身份标识(0:普通;4:带有标识) // String? csrf,//CSRF Token(位于 Cookie) Cookie 方式必要 // String? access_key,// APP 登录 Token APP 方式必要 @@ -77,11 +77,11 @@ class DanmakuHttp { //'aid': aid, 'bvid': bvid, 'progress': progress, - 'color': color, + 'color': colorful == true ? null : color, 'fontsize': fontsize, 'pool': pool, 'rnd': DateTime.now().microsecondsSinceEpoch, - 'colorful': colorful, + 'colorful': colorful == true ? 60001 : null, 'checkbox_type': checkbox_type, 'csrf': await Request.getCsrf(), // 'access_key': access_key, diff --git a/lib/pages/video/detail/widgets/send_danmaku_panel.dart b/lib/pages/video/detail/widgets/send_danmaku_panel.dart index b7a1cf6a..f8b083bb 100644 --- a/lib/pages/video/detail/widgets/send_danmaku_panel.dart +++ b/lib/pages/video/detail/widgets/send_danmaku_panel.dart @@ -6,6 +6,7 @@ import 'package:PiliPlus/main.dart'; import 'package:PiliPlus/pages/common/common_publish_page.dart'; import 'package:PiliPlus/pages/setting/slide_color_picker.dart'; import 'package:PiliPlus/utils/extension.dart'; +import 'package:PiliPlus/utils/storage.dart'; import 'package:canvas_danmaku/models/danmaku_content_item.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -70,6 +71,12 @@ class _SendDanmakuPanelState extends CommonPublishPageState { _mode = (widget.dmConfig?.mode ?? 1).obs; _fontsize = (widget.dmConfig?.fontsize ?? 25).obs; _color = (widget.dmConfig?.color ?? Colors.white).obs; + try { + final userInfo = GStorage.userInfo.get('userInfoCache'); + if (userInfo?.vipStatus == 1) { + _colorList.add(Colors.transparent); + } + } catch (_) {} } @override @@ -231,9 +238,7 @@ class _SendDanmakuPanelState extends CommonPublishPageState { Widget _buildColorItem(Color color) { return GestureDetector( onTap: () { - if (_color.value != color) { - _color.value = color; - } + _color.value = color; }, child: Container( width: 40, @@ -253,6 +258,32 @@ class _SendDanmakuPanelState extends CommonPublishPageState { color: color, borderRadius: BorderRadius.circular(6), ), + child: color == Colors.transparent + ? Stack( + clipBehavior: Clip.none, + alignment: Alignment.center, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + gradient: LinearGradient( + colors: [ + Color(0xFFDD94DA), + Color(0xFF72B2EA), + ], + ), + ), + ), + Container( + margin: const EdgeInsets.all(5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + ], + ) + : null, ), ), ); @@ -263,9 +294,7 @@ class _SendDanmakuPanelState extends CommonPublishPageState { () => Expanded( child: GestureDetector( onTap: () { - if (_mode.value != mode) { - _mode.value = mode; - } + _mode.value = mode; }, child: Container( alignment: Alignment.center, @@ -295,9 +324,7 @@ class _SendDanmakuPanelState extends CommonPublishPageState { () => Expanded( child: GestureDetector( onTap: () { - if (_fontsize.value != fontsize) { - _fontsize.value = fontsize; - } + _fontsize.value = fontsize; }, child: Container( alignment: Alignment.center, @@ -464,6 +491,7 @@ class _SendDanmakuPanelState extends CommonPublishPageState { @override Future onCustomPublish({required String message, List? pictures}) async { SmartDialog.showLoading(msg: '发送中...'); + bool isColorful = _color.value == Colors.transparent; final res = await DanmakuHttp.shootDanmaku( oid: widget.cid, bvid: widget.bvid, @@ -471,7 +499,8 @@ class _SendDanmakuPanelState extends CommonPublishPageState { msg: editController.text, mode: _mode.value, fontsize: _fontsize.value, - color: _color.value.value & 0xFFFFFF, + color: isColorful ? null : _color.value.value & 0xFFFFFF, + colorful: isColorful, ); SmartDialog.dismiss(); if (res['status']) { @@ -487,6 +516,7 @@ class _SendDanmakuPanelState extends CommonPublishPageState { _ => DanmakuItemType.scroll, }, selfSend: true, + isColorful: isColorful, ), ); } else {