|
|
|
@ -4,12 +4,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
import '../../generated/assets.dart'; |
|
|
|
import '../../../widget/message/chat_input_bar.dart'; |
|
|
|
|
|
|
|
class ChatPage extends StatefulWidget { |
|
|
|
|
|
|
|
String userId; |
|
|
|
final String userId; |
|
|
|
|
|
|
|
ChatPage({required this.userId, super.key}); |
|
|
|
const ChatPage({required this.userId, super.key}); |
|
|
|
|
|
|
|
@override |
|
|
|
State<ChatPage> createState() => _ChatPageState(); |
|
|
|
@ -19,6 +20,7 @@ class _ChatPageState extends State<ChatPage> { |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Scaffold( |
|
|
|
backgroundColor: Color(0xffF5F5F5), |
|
|
|
appBar: AppBar( |
|
|
|
title: Text("Chat"), |
|
|
|
centerTitle: true, |
|
|
|
@ -37,8 +39,78 @@ class _ChatPageState extends State<ChatPage> { |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
body: Container( |
|
|
|
|
|
|
|
body: Column( |
|
|
|
children: [ |
|
|
|
// 消息列表区域 |
|
|
|
Expanded( |
|
|
|
child: SingleChildScrollView( |
|
|
|
reverse: true, |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
child: Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
// 时间戳 |
|
|
|
Text( |
|
|
|
"昨天下午14:46", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12.sp, |
|
|
|
color: Colors.grey, |
|
|
|
), |
|
|
|
textAlign: TextAlign.center, |
|
|
|
), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
// 消息项 |
|
|
|
Row( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
// 头像 |
|
|
|
Container( |
|
|
|
width: 40.w, |
|
|
|
height: 40.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.circular(20.w), |
|
|
|
image: DecorationImage( |
|
|
|
image: AssetImage(Assets.imagesAvatarsExample), |
|
|
|
fit: BoxFit.cover, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 8.w), |
|
|
|
// 消息气泡 |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.white, |
|
|
|
borderRadius: BorderRadius.only( |
|
|
|
topRight: Radius.circular(12.w), |
|
|
|
bottomLeft: Radius.circular(12.w), |
|
|
|
bottomRight: Radius.circular(12.w), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
"你好", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
color: Colors.black, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
// 使用抽离的聊天输入栏组件 |
|
|
|
ChatInputBar( |
|
|
|
onSendMessage: (message) { |
|
|
|
// 处理发送消息 |
|
|
|
if (Get.isLogEnable) { |
|
|
|
Get.log("接收到消息: $message"); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|