mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
add superChatType
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
9
lib/models/common/super_chat_type.dart
Normal file
9
lib/models/common/super_chat_type.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
enum SuperChatType {
|
||||||
|
valid('有效时间内显示'),
|
||||||
|
persist('持久显示'),
|
||||||
|
disable('不显示'),
|
||||||
|
;
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
const SuperChatType(this.title);
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/common/widgets/flutter/text_field/controller.dart';
|
|||||||
import 'package:PiliPlus/http/constants.dart';
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
import 'package:PiliPlus/http/live.dart';
|
import 'package:PiliPlus/http/live.dart';
|
||||||
import 'package:PiliPlus/http/video.dart';
|
import 'package:PiliPlus/http/video.dart';
|
||||||
|
import 'package:PiliPlus/models/common/super_chat_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/live_quality.dart';
|
import 'package:PiliPlus/models/common/video/live_quality.dart';
|
||||||
import 'package:PiliPlus/models_new/live/live_danmaku/danmaku_msg.dart';
|
import 'package:PiliPlus/models_new/live/live_danmaku/danmaku_msg.dart';
|
||||||
import 'package:PiliPlus/models_new/live/live_danmaku/live_emote.dart';
|
import 'package:PiliPlus/models_new/live/live_danmaku/live_emote.dart';
|
||||||
@@ -113,7 +114,8 @@ class LiveRoomController extends GetxController {
|
|||||||
bool? isPlaying;
|
bool? isPlaying;
|
||||||
late bool isFullScreen = false;
|
late bool isFullScreen = false;
|
||||||
|
|
||||||
final showSuperChat = Pref.showSuperChat;
|
final superChatType = Pref.superChatType;
|
||||||
|
late final showSuperChat = superChatType != SuperChatType.disable;
|
||||||
|
|
||||||
final headerKey = GlobalKey<TimeBatteryMixin>();
|
final headerKey = GlobalKey<TimeBatteryMixin>();
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ class SuperChatCard extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
required this.onRemove,
|
required this.onRemove,
|
||||||
|
this.persistentSC = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final SuperChatItem item;
|
final SuperChatItem item;
|
||||||
final VoidCallback onRemove;
|
final VoidCallback onRemove;
|
||||||
|
final bool persistentSC;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SuperChatCard> createState() => _SuperChatCardState();
|
State<SuperChatCard> createState() => _SuperChatCardState();
|
||||||
@@ -29,17 +31,19 @@ class _SuperChatCardState extends State<SuperChatCard> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.item.expired) {
|
if (!widget.persistentSC) {
|
||||||
_remove();
|
if (widget.item.expired) {
|
||||||
return;
|
_remove();
|
||||||
}
|
return;
|
||||||
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
}
|
||||||
final offset = widget.item.endTime - now;
|
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
if (offset > 0) {
|
final offset = widget.item.endTime - now;
|
||||||
_remains = offset.obs;
|
if (offset > 0) {
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), _callback);
|
_remains = offset.obs;
|
||||||
} else {
|
_timer = Timer.periodic(const Duration(seconds: 1), _callback);
|
||||||
_remove();
|
} else {
|
||||||
|
_remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/models/common/super_chat_type.dart';
|
||||||
import 'package:PiliPlus/pages/live_room/controller.dart';
|
import 'package:PiliPlus/pages/live_room/controller.dart';
|
||||||
import 'package:PiliPlus/pages/live_room/superchat/superchat_card.dart';
|
import 'package:PiliPlus/pages/live_room/superchat/superchat_card.dart';
|
||||||
import 'package:PiliPlus/pages/search/controller.dart';
|
import 'package:PiliPlus/pages/search/controller.dart';
|
||||||
@@ -21,6 +22,9 @@ class _SuperChatPanelState extends DebounceStreamState<SuperChatPanel, bool>
|
|||||||
@override
|
@override
|
||||||
Duration get duration => const Duration(milliseconds: 300);
|
Duration get duration => const Duration(milliseconds: 300);
|
||||||
|
|
||||||
|
late final persistentSC =
|
||||||
|
widget.controller.superChatType == SuperChatType.persist;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -42,6 +46,7 @@ class _SuperChatPanelState extends DebounceStreamState<SuperChatPanel, bool>
|
|||||||
key: ValueKey(item.id),
|
key: ValueKey(item.id),
|
||||||
item: item,
|
item: item,
|
||||||
onRemove: () => ctr?.add(true),
|
onRemove: () => ctr?.add(true),
|
||||||
|
persistentSC: persistentSC,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (_, _) => const SizedBox(height: 12),
|
separatorBuilder: (_, _) => const SizedBox(height: 12),
|
||||||
|
|||||||
@@ -874,7 +874,6 @@ List<SettingsModel> get extraSettings => [
|
|||||||
onTap: (context, setState) async {
|
onTap: (context, setState) async {
|
||||||
final result = await showDialog<double>(
|
final result = await showDialog<double>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SlideDialog(
|
return SlideDialog(
|
||||||
title: '连接重试次数',
|
title: '连接重试次数',
|
||||||
@@ -900,7 +899,6 @@ List<SettingsModel> get extraSettings => [
|
|||||||
onTap: (context, setState) async {
|
onTap: (context, setState) async {
|
||||||
final result = await showDialog<double>(
|
final result = await showDialog<double>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SlideDialog(
|
return SlideDialog(
|
||||||
title: '连接重试间隔',
|
title: '连接重试间隔',
|
||||||
@@ -928,7 +926,6 @@ List<SettingsModel> get extraSettings => [
|
|||||||
onTap: (context, setState) async {
|
onTap: (context, setState) async {
|
||||||
final result = await showDialog<int>(
|
final result = await showDialog<int>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectDialog<int>(
|
return SelectDialog<int>(
|
||||||
title: '评论展示',
|
title: '评论展示',
|
||||||
@@ -953,7 +950,6 @@ List<SettingsModel> get extraSettings => [
|
|||||||
onTap: (context, setState) async {
|
onTap: (context, setState) async {
|
||||||
final result = await showDialog<int>(
|
final result = await showDialog<int>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectDialog<int>(
|
return SelectDialog<int>(
|
||||||
title: '动态展示',
|
title: '动态展示',
|
||||||
@@ -978,7 +974,6 @@ List<SettingsModel> get extraSettings => [
|
|||||||
onTap: (context, setState) async {
|
onTap: (context, setState) async {
|
||||||
final result = await showDialog<MemberTabType>(
|
final result = await showDialog<MemberTabType>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectDialog<MemberTabType>(
|
return SelectDialog<MemberTabType>(
|
||||||
title: '用户页默认展示TAB',
|
title: '用户页默认展示TAB',
|
||||||
@@ -1194,7 +1189,6 @@ Future<void> audioNormalization(
|
|||||||
String param = '';
|
String param = '';
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('自定义参数'),
|
title: const Text('自定义参数'),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||||
|
import 'package:PiliPlus/models/common/super_chat_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/subtitle_pref_type.dart';
|
import 'package:PiliPlus/models/common/video/subtitle_pref_type.dart';
|
||||||
import 'package:PiliPlus/pages/main/controller.dart';
|
import 'package:PiliPlus/pages/main/controller.dart';
|
||||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||||
@@ -157,11 +158,26 @@ List<SettingsModel> get playSettings => [
|
|||||||
setKey: SettingBoxKey.keyboardControl,
|
setKey: SettingBoxKey.keyboardControl,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
const SwitchModel(
|
NormalModel(
|
||||||
title: '显示 SuperChat (醒目留言)',
|
title: 'SuperChat (醒目留言) 显示类型',
|
||||||
leading: Icon(Icons.live_tv),
|
leading: const Icon(Icons.live_tv),
|
||||||
setKey: SettingBoxKey.showSuperChat,
|
getSubtitle: () => '当前:「${Pref.superChatType.title}」',
|
||||||
defaultVal: true,
|
onTap: (context, setState) async {
|
||||||
|
final result = await showDialog<SuperChatType>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<SuperChatType>(
|
||||||
|
title: 'SuperChat (醒目留言) 显示类型',
|
||||||
|
value: Pref.superChatType,
|
||||||
|
values: SuperChatType.values.map((e) => (e, e.title)).toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
await GStorage.setting.put(SettingBoxKey.superChatType, result.index);
|
||||||
|
setState();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SwitchModel(
|
const SwitchModel(
|
||||||
title: '竖屏扩大展示',
|
title: '竖屏扩大展示',
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ abstract class SettingBoxKey {
|
|||||||
enableAutoEnter = 'enableAutoEnter',
|
enableAutoEnter = 'enableAutoEnter',
|
||||||
enableAutoExit = 'enableAutoExit',
|
enableAutoExit = 'enableAutoExit',
|
||||||
enableOnlineTotal = 'enableOnlineTotal',
|
enableOnlineTotal = 'enableOnlineTotal',
|
||||||
showSuperChat = 'showSuperChat',
|
superChatType = 'superChatType',
|
||||||
keyboardControl = 'keyboardControl',
|
keyboardControl = 'keyboardControl',
|
||||||
pauseOnMinimize = 'pauseOnMinimize',
|
pauseOnMinimize = 'pauseOnMinimize',
|
||||||
pgcSkipType = 'pgcSkipType',
|
pgcSkipType = 'pgcSkipType',
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:PiliPlus/models/common/member/tab_type.dart';
|
|||||||
import 'package:PiliPlus/models/common/msg/msg_unread_type.dart';
|
import 'package:PiliPlus/models/common/msg/msg_unread_type.dart';
|
||||||
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
|
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
|
||||||
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
|
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
|
||||||
|
import 'package:PiliPlus/models/common/super_chat_type.dart';
|
||||||
import 'package:PiliPlus/models/common/super_resolution_type.dart';
|
import 'package:PiliPlus/models/common/super_resolution_type.dart';
|
||||||
import 'package:PiliPlus/models/common/theme/theme_type.dart';
|
import 'package:PiliPlus/models/common/theme/theme_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/audio_quality.dart';
|
import 'package:PiliPlus/models/common/video/audio_quality.dart';
|
||||||
@@ -823,8 +824,11 @@ abstract class Pref {
|
|||||||
static bool get showMemberShop =>
|
static bool get showMemberShop =>
|
||||||
_setting.get(SettingBoxKey.showMemberShop, defaultValue: false);
|
_setting.get(SettingBoxKey.showMemberShop, defaultValue: false);
|
||||||
|
|
||||||
static bool get showSuperChat =>
|
static SuperChatType get superChatType =>
|
||||||
_setting.get(SettingBoxKey.showSuperChat, defaultValue: true);
|
SuperChatType.values[_setting.get(
|
||||||
|
SettingBoxKey.superChatType,
|
||||||
|
defaultValue: SuperChatType.valid.index,
|
||||||
|
)];
|
||||||
|
|
||||||
static bool get minimizeOnExit =>
|
static bool get minimizeOnExit =>
|
||||||
_setting.get(SettingBoxKey.minimizeOnExit, defaultValue: true);
|
_setting.get(SettingBoxKey.minimizeOnExit, defaultValue: true);
|
||||||
|
|||||||
Reference in New Issue
Block a user