mod: 输入框样式
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@ -42,6 +43,8 @@ class LiveRoomController extends GetxController {
|
||||
DanmakuController? danmakuController;
|
||||
// 输入控制器
|
||||
TextEditingController inputController = TextEditingController();
|
||||
// 加入直播间提示
|
||||
RxMap<String, String> joinRoomTip = {'userName': '', 'message': ''}.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -176,7 +179,29 @@ class LiveRoomController extends GetxController {
|
||||
onMessageCb: (message) {
|
||||
final List<LiveMessageModel>? liveMsg =
|
||||
LiveUtils.decodeMessage(message);
|
||||
if (liveMsg != null) {
|
||||
if (liveMsg != null && liveMsg.isNotEmpty) {
|
||||
if (liveMsg.first.type == LiveMessageType.online) {
|
||||
print('当前直播间人气:${liveMsg.first.data}');
|
||||
} else if (liveMsg.first.type == LiveMessageType.join ||
|
||||
liveMsg.first.type == LiveMessageType.follow) {
|
||||
// 每隔一秒依次liveMsg中的每一项赋给activeUserName
|
||||
int index = 0;
|
||||
Timer.periodic(const Duration(seconds: 2), (timer) {
|
||||
if (index < liveMsg.length) {
|
||||
if (liveMsg[index].type == LiveMessageType.join ||
|
||||
liveMsg[index].type == LiveMessageType.follow) {
|
||||
joinRoomTip.value = {
|
||||
'userName': liveMsg[index].userName,
|
||||
'message': liveMsg[index].message!,
|
||||
};
|
||||
}
|
||||
index++;
|
||||
} else {
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 过滤出聊天消息
|
||||
var chatMessages =
|
||||
liveMsg.where((msg) => msg.type == LiveMessageType.chat).toList();
|
||||
|
@ -179,6 +179,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppBar(
|
||||
centerTitle: false,
|
||||
@ -263,6 +264,49 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
_liveRoomController,
|
||||
_scrollController,
|
||||
),
|
||||
// Container(
|
||||
// padding: const EdgeInsets.only(
|
||||
// left: 14, right: 14, top: 4, bottom: 4),
|
||||
// margin: const EdgeInsets.only(
|
||||
// bottom: 6,
|
||||
// left: 14,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.grey.withOpacity(0.1),
|
||||
// borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
// ),
|
||||
// child: Obx(
|
||||
// () => AnimatedSwitcher(
|
||||
// duration: const Duration(milliseconds: 300),
|
||||
// transitionBuilder:
|
||||
// (Widget child, Animation<double> animation) {
|
||||
// return FadeTransition(opacity: animation, child: child);
|
||||
// },
|
||||
// child: Text.rich(
|
||||
// key:
|
||||
// ValueKey(_liveRoomController.joinRoomTip['userName']),
|
||||
// TextSpan(
|
||||
// style: const TextStyle(color: Colors.white),
|
||||
// children: [
|
||||
// TextSpan(
|
||||
// text:
|
||||
// '${_liveRoomController.joinRoomTip['userName']} ',
|
||||
// style: TextStyle(
|
||||
// color: Colors.white.withOpacity(0.6),
|
||||
// ),
|
||||
// ),
|
||||
// TextSpan(
|
||||
// text:
|
||||
// '${_liveRoomController.joinRoomTip['message']}',
|
||||
// style: const TextStyle(color: Colors.white),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
// 弹幕输入框
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
@ -271,7 +315,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
top: 4,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
@ -280,6 +325,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _liveRoomController.inputController,
|
||||
@ -309,10 +355,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
// 定位 快速滑动到底部
|
||||
Positioned(
|
||||
right: 20,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 20,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 2),
|
||||
begin: const Offset(0, 4),
|
||||
end: const Offset(0, 0),
|
||||
).animate(CurvedAnimation(
|
||||
parent: fabAnimationCtr,
|
||||
|
Reference in New Issue
Block a user