|
|
@ -16,6 +16,7 @@ class ChatInputBar extends StatefulWidget { |
|
|
|
|
|
|
|
|
class _ChatInputBarState extends State<ChatInputBar> { |
|
|
class _ChatInputBarState extends State<ChatInputBar> { |
|
|
final TextEditingController _textController = TextEditingController(); |
|
|
final TextEditingController _textController = TextEditingController(); |
|
|
|
|
|
bool _isMoreOptionsVisible = false; |
|
|
|
|
|
|
|
|
void _handleSendMessage() { |
|
|
void _handleSendMessage() { |
|
|
if (_textController.text.isNotEmpty) { |
|
|
if (_textController.text.isNotEmpty) { |
|
|
@ -28,73 +29,161 @@ class _ChatInputBarState extends State<ChatInputBar> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 切换更多选项的显示状态 |
|
|
|
|
|
void _toggleMoreOptions() { |
|
|
|
|
|
setState(() { |
|
|
|
|
|
_isMoreOptionsVisible = !_isMoreOptionsVisible; |
|
|
|
|
|
// 收起键盘 |
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
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( |
|
|
|
|
|
|
|
|
return Column( |
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
children: [ |
|
|
|
|
|
Container( |
|
|
|
|
|
padding: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 16.w), |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
child: Column( |
|
|
children: [ |
|
|
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), |
|
|
|
|
|
|
|
|
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), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
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).onTap(_toggleMoreOptions), |
|
|
|
|
|
], |
|
|
), |
|
|
), |
|
|
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), |
|
|
|
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
), |
|
|
|
|
|
// 更多选项展开视图 |
|
|
|
|
|
_buildMoreOptionsView(), |
|
|
|
|
|
], |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 构建更多选项展开视图 |
|
|
|
|
|
Widget _buildMoreOptionsView() { |
|
|
|
|
|
return AnimatedContainer( |
|
|
|
|
|
duration: Duration(milliseconds: 300), |
|
|
|
|
|
height: _isMoreOptionsVisible ? 180.h : 0, |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
child: _isMoreOptionsVisible |
|
|
|
|
|
? Container( |
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h), |
|
|
|
|
|
child: Column( |
|
|
|
|
|
children: [ |
|
|
|
|
|
SizedBox(height: 10.h), |
|
|
|
|
|
// 第一行选项 |
|
|
|
|
|
Row( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
|
children: [ |
|
|
|
|
|
// 图片选项 |
|
|
|
|
|
Column( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Container( |
|
|
|
|
|
width: 60.w, |
|
|
|
|
|
height: 60.w, |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: Color(0xffF0F5FF), |
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w), |
|
|
|
|
|
), |
|
|
|
|
|
padding: EdgeInsets.all(10.w), |
|
|
|
|
|
child: Image.asset(Assets.imagesPhoto, width: 40.w, height: 40.w), |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 8.h), |
|
|
|
|
|
Text( |
|
|
|
|
|
"图片", |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
|
color: Colors.black, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(width: 40.w), |
|
|
|
|
|
// 相机选项 |
|
|
|
|
|
Column( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Container( |
|
|
|
|
|
width: 60.w, |
|
|
|
|
|
height: 60.w, |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: Color(0xffF0F5FF), |
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w), |
|
|
|
|
|
), |
|
|
|
|
|
padding: EdgeInsets.all(10.w), |
|
|
|
|
|
child: Image.asset(Assets.imagesCamera, width: 40.w, height: 40.w), |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 8.h), |
|
|
|
|
|
Text( |
|
|
|
|
|
"相机", |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
|
color: Colors.black, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
) |
|
|
|
|
|
: null, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |