mod: lint

mod: tweaks

opt: publish page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-04 11:37:13 +08:00
parent 2cfad80214
commit caa58e9d7d
313 changed files with 2751 additions and 2789 deletions

View File

@@ -57,7 +57,7 @@ class LiveRoomController extends GetxController {
}
}
playerInit(source) async {
Future<void> playerInit(source) async {
await plPlayerController.setDataSource(
DataSource(
videoSource: source,
@@ -69,8 +69,6 @@ class LiveRoomController extends GetxController {
'referer': HttpString.baseUrl
},
),
// 硬解
enableHA: true,
autoplay: true,
direction: isPortrait.value ? 'vertical' : 'horizontal',
);
@@ -230,13 +228,14 @@ class LiveRoomController extends GetxController {
@override
void onClose() {
scrollController.removeListener(listener);
scrollController.dispose();
scrollController
..removeListener(listener)
..dispose();
super.onClose();
}
// 修改画质
void changeQn(int qn) async {
Future<void> changeQn(int qn) async {
if (currentQn == qn) {
return;
}

View File

@@ -49,167 +49,141 @@ class _ReplyPageState extends CommonPublishPageState<LiveSendDmPanel> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return MediaQuery.removePadding(
removeTop: true,
context: context,
child: GestureDetector(
onTap: Get.back,
child: LayoutBuilder(
builder: (context, constraints) {
bool isH = constraints.maxWidth > constraints.maxHeight;
late double padding = constraints.maxWidth * 0.12;
return Padding(
padding: EdgeInsets.symmetric(horizontal: isH ? padding : 0),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: GestureDetector(
onTap: () {},
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
buildInputView(theme),
buildPanelContainer(theme.colorScheme.surface),
],
),
),
),
);
},
return SafeArea(
bottom: false,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
constraints: const BoxConstraints(maxWidth: 640),
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
color: theme.colorScheme.surface,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
...buildInputView(theme),
buildPanelContainer(Colors.transparent),
],
),
),
),
);
}
@override
Widget? customPanel(double height) => SizedBox(
height: height,
child: LiveEmotePanel(
onChoose: onChooseEmote,
roomId: liveRoomController.roomId,
onSendEmoticonUnique: (emote) {
onCustomPublish(
message: emote.emoticonUnique!,
dmType: 1,
emoticonOptions: '[object Object]',
emoticonUnique: emote.emoji,
);
},
),
Widget? get customPanel => LiveEmotePanel(
onChoose: onChooseEmote,
roomId: liveRoomController.roomId,
onSendEmoticonUnique: (emote) {
onCustomPublish(
message: emote.emoticonUnique!,
dmType: 1,
emoticonOptions: '[object Object]',
emoticonUnique: emote.emoji,
);
},
);
Widget buildInputView(ThemeData theme) {
return Container(
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
color: theme.colorScheme.surface,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding:
const EdgeInsets.only(top: 12, right: 15, left: 15, bottom: 10),
child: Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Listener(
onPointerUp: (event) {
if (readOnly.value) {
updatePanelType(PanelType.keyboard);
selectKeyboard.value = true;
List<Widget> buildInputView(ThemeData theme) {
return [
Container(
padding:
const EdgeInsets.only(top: 12, right: 15, left: 15, bottom: 10),
child: Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Listener(
onPointerUp: (event) {
if (readOnly.value) {
updatePanelType(PanelType.keyboard);
selectKeyboard.value = true;
}
},
child: Obx(
() => TextField(
controller: editController,
minLines: 1,
maxLines: 2,
autofocus: false,
readOnly: readOnly.value,
onChanged: (value) {
bool isEmpty = value.trim().isEmpty;
if (!isEmpty && !enablePublish.value) {
enablePublish.value = true;
} else if (isEmpty && enablePublish.value) {
enablePublish.value = false;
}
liveRoomController.savedDanmaku = value;
},
child: Obx(
() => TextField(
controller: editController,
minLines: 1,
maxLines: 2,
autofocus: false,
readOnly: readOnly.value,
onChanged: (value) {
bool isEmpty = value.trim().isEmpty;
if (!isEmpty && !enablePublish.value) {
enablePublish.value = true;
} else if (isEmpty && enablePublish.value) {
enablePublish.value = false;
}
liveRoomController.savedDanmaku = value;
},
focusNode: focusNode,
decoration: InputDecoration(
hintText: "输入弹幕内容",
border: InputBorder.none,
hintStyle: TextStyle(fontSize: 14)),
style: theme.textTheme.bodyLarge,
inputFormatters: [LengthLimitingTextInputFormatter(20)],
),
focusNode: focusNode,
decoration: const InputDecoration(
hintText: "输入弹幕内容",
border: InputBorder.none,
hintStyle: TextStyle(fontSize: 14),
),
style: theme.textTheme.bodyLarge,
inputFormatters: [LengthLimitingTextInputFormatter(20)],
),
),
),
Divider(
height: 1,
color: theme.dividerColor.withOpacity(0.1),
),
Container(
height: 52,
padding: const EdgeInsets.only(left: 12, right: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() => ToolbarIconButton(
tooltip: '输入',
onPressed: () {
if (!selectKeyboard.value) {
selectKeyboard.value = true;
updatePanelType(PanelType.keyboard);
}
},
icon: const Icon(Icons.keyboard, size: 22),
selected: selectKeyboard.value,
),
),
const SizedBox(width: 10),
Obx(
() => ToolbarIconButton(
tooltip: '表情',
onPressed: () {
if (selectKeyboard.value) {
selectKeyboard.value = false;
updatePanelType(PanelType.emoji);
}
},
icon: const Icon(Icons.emoji_emotions, size: 22),
selected: !selectKeyboard.value,
),
),
const Spacer(),
Obx(
() => FilledButton.tonal(
onPressed: enablePublish.value ? onPublish : null,
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 10),
visualDensity: const VisualDensity(
horizontal: -2,
vertical: -2,
),
),
child: const Text('发送'),
),
),
],
),
),
],
),
),
);
Divider(
height: 1,
color: theme.dividerColor.withOpacity(0.1),
),
Container(
height: 52,
padding: const EdgeInsets.only(left: 12, right: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(
() => ToolbarIconButton(
tooltip: '输入',
onPressed: () {
if (!selectKeyboard.value) {
selectKeyboard.value = true;
updatePanelType(PanelType.keyboard);
}
},
icon: const Icon(Icons.keyboard, size: 22),
selected: selectKeyboard.value,
),
),
const SizedBox(width: 10),
Obx(
() => ToolbarIconButton(
tooltip: '表情',
onPressed: () {
if (selectKeyboard.value) {
selectKeyboard.value = false;
updatePanelType(PanelType.emoji);
}
},
icon: const Icon(Icons.emoji_emotions, size: 22),
selected: !selectKeyboard.value,
),
),
const Spacer(),
Obx(
() => FilledButton.tonal(
onPressed: enablePublish.value ? onPublish : null,
style: FilledButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
visualDensity: VisualDensity.compact,
),
child: const Text('发送'),
),
),
],
),
),
];
}
@override

View File

@@ -73,8 +73,9 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
videoSourceInit();
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
plPlayerController.autoEnterFullscreen();
plPlayerController.addStatusLister(playerListener);
plPlayerController
..autoEnterFullscreen()
..addStatusLister(playerListener);
_listener = plPlayerController.isFullScreen.listen((isFullScreen) {
if (isFullScreen != _isFullScreen) {
_isFullScreen = isFullScreen;
@@ -93,7 +94,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
}
void _updateFontSize() async {
Future<void> _updateFontSize() async {
if (Platform.isAndroid) {
_isPipMode =
await const MethodChannel("floating").invokeMethod('inPipAlready');
@@ -125,8 +126,9 @@ class _LiveRoomPageState extends State<LiveRoomPage>
ScreenBrightness().resetApplicationScreenBrightness();
PlPlayerController.setPlayCallBack(null);
_liveRoomController.msgStream?.close();
plPlayerController.removeStatusLister(playerListener);
plPlayerController.dispose();
plPlayerController
..removeStatusLister(playerListener)
..dispose();
super.dispose();
}
@@ -329,10 +331,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
left: 0,
right: 0,
bottom: 0,
child: Padding(
padding: EdgeInsets.only(bottom: 0),
child: _buildInputWidget,
),
child: _buildInputWidget,
),
),
],
@@ -360,13 +359,13 @@ class _LiveRoomPageState extends State<LiveRoomPage>
);
}
final Color _color = Color(0xFFEEEEEE);
final Color _color = const Color(0xFFEEEEEE);
PreferredSizeWidget get _buildAppBar => AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
toolbarHeight: isFullScreen ? 0 : null,
titleTextStyle: TextStyle(color: Colors.white),
titleTextStyle: const TextStyle(color: Colors.white),
title: Obx(
() {
return _liveRoomController.roomInfoH5.value == null
@@ -551,7 +550,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
right: 10,
bottom: 25 + MediaQuery.of(context).padding.bottom,
),
decoration: BoxDecoration(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
@@ -617,7 +616,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
},
transitionDuration: const Duration(milliseconds: 500),
transitionBuilder: (context, animation, secondaryAnimation, child) {
var tween = Tween(begin: Offset(0.0, 1.0), end: Offset.zero)
var tween = Tween(begin: const Offset(0.0, 1.0), end: Offset.zero)
.chain(CurveTween(curve: Curves.linear));
return SlideTransition(
position: animation.drive(tween),

View File

@@ -8,19 +8,20 @@ import 'package:get/get.dart';
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
const BottomControl({
super.key,
required this.plPlayerController,
required this.liveRoomCtr,
required this.onRefresh,
super.key,
this.subTitleStyle = const TextStyle(fontSize: 12),
this.titleStyle = const TextStyle(fontSize: 14),
});
final PlPlayerController plPlayerController;
final LiveRoomController liveRoomCtr;
final VoidCallback onRefresh;
final TextStyle subTitleStyle = const TextStyle(fontSize: 12);
final TextStyle titleStyle = const TextStyle(fontSize: 14);
final TextStyle subTitleStyle;
final TextStyle titleStyle;
@override
Size get preferredSize => const Size(double.infinity, kToolbarHeight);

View File

@@ -1,6 +1,5 @@
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/pages/live_room/controller.dart';
import 'package:PiliPlus/services/loggeer.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@@ -26,10 +25,11 @@ class LiveRoomChat extends StatelessWidget {
children: [
Obx(
() => ListView.separated(
padding: const EdgeInsets.all(0),
padding: EdgeInsets.zero,
controller: liveRoomController.scrollController,
separatorBuilder: (context, index) => const SizedBox(height: 6),
itemCount: liveRoomController.messages.length,
physics: const ClampingScrollPhysics(),
itemBuilder: (context, index) {
return Container(
alignment: Alignment.centerLeft,
@@ -40,7 +40,7 @@ class LiveRoomChat extends StatelessWidget {
decoration: BoxDecoration(
color: isPP == true
? Colors.black.withOpacity(0.3)
: Color(0x15FFFFFF),
: const Color(0x15FFFFFF),
borderRadius: const BorderRadius.all(Radius.circular(18)),
),
child: Text.rich(
@@ -159,5 +159,3 @@ class LiveRoomChat extends StatelessWidget {
}
}
}
final PiliLogger logger = getLogger();

View File

@@ -94,7 +94,7 @@ class LiveHeaderControl extends StatelessWidget implements PreferredSizeWidget {
plPlayerController.isFullScreen.value,
true,
),
icon: Icon(
icon: const Icon(
size: 18,
Icons.schedule,
color: Colors.white,