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.
 
 
 
 
 

117 lines
3.6 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';
import '../../../widget/message/chat_input_bar.dart';
class ChatPage extends StatefulWidget {
final String userId;
const ChatPage({required this.userId, super.key});
@override
State<ChatPage> createState() => _ChatPageState();
}
class _ChatPageState extends State<ChatPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffF5F5F5),
appBar: AppBar(
title: Text("Chat"),
centerTitle: true,
actions: [
Container(
padding: EdgeInsets.only(right: 16.w),
child: Image.asset(Assets.imagesMore, width: 16.w,),
).onTap(() {
})
],
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {
Get.back();
},
),
),
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");
}
},
),
],
),
);
}
}