You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

100 lines
3.3 KiB

import 'package:dating_touchme_app/extension/ex_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../generated/assets.dart';
class ChatInputBar extends StatefulWidget {
final ValueChanged<String> onSendMessage;
const ChatInputBar({required this.onSendMessage, super.key});
@override
State<ChatInputBar> createState() => _ChatInputBarState();
}
class _ChatInputBarState extends State<ChatInputBar> {
final TextEditingController _textController = TextEditingController();
void _handleSendMessage() {
if (_textController.text.isNotEmpty) {
// 使用GetX日志而不是print
if (Get.isLogEnable) {
Get.log("发送消息: ${_textController.text}");
}
widget.onSendMessage(_textController.text);
_textController.clear();
}
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 16.w),
color: Colors.white,
child: Column(
children: [
SizedBox(height: 10.h),
Row(
children: [
Expanded(
child: Container(
height: 40.h,
decoration: BoxDecoration(
color: Color(0xffF5F5F5),
borderRadius: BorderRadius.circular(5.h),
),
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: TextField(
controller: _textController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "请输入聊天内容~",
hintStyle: TextStyle(fontSize: 14.sp, color: Colors.grey),
),
style: TextStyle(fontSize: 14.sp, color: Colors.black),
),
),
),
SizedBox(width: 12.w),
// 发送按钮
Container(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(5.h),
),
child: Text(
"发送",
style: TextStyle(
fontSize: 14.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
).onTap(_handleSendMessage),
],
),
SizedBox(height: 12.h),
// 底部工具栏
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// 语音按钮
Image.asset(Assets.imagesAudio, width: 24.w, height: 24.w),
// 视频按钮
Image.asset(Assets.imagesVideo, width: 24.w, height: 24.w),
// 礼物按钮
Image.asset(Assets.imagesGift, width: 24.w, height: 24.w),
// 表情按钮
Image.asset(Assets.imagesEmoji, width: 24.w, height: 24.w),
// 更多按钮
Image.asset(Assets.imagesAdd, width: 24.w, height: 24.w),
],
),
],
),
);
}
}