139 lines
3.7 KiB
Dart
139 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class MessagePage extends StatelessWidget {
|
|
const MessagePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF5F5F7),
|
|
appBar: _buildAppBar(),
|
|
body: _buildMessageList(),
|
|
);
|
|
}
|
|
|
|
PreferredSizeWidget _buildAppBar() {
|
|
return AppBar(
|
|
backgroundColor: Colors.grey.shade200,
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
leading: IconButton(
|
|
onPressed: () {},
|
|
icon: const Icon(Icons.menu, size: 22),
|
|
splashRadius: 20,
|
|
),
|
|
title: const Text(
|
|
'消息',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xFF1C1C1E),
|
|
),
|
|
),
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () {},
|
|
icon: const Icon(Icons.search, size: 22),
|
|
splashRadius: 20,
|
|
),
|
|
IconButton(
|
|
onPressed: () {},
|
|
icon: const Icon(Icons.add_circle_outline, size: 22),
|
|
splashRadius: 20,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildMessageList() {
|
|
return ListView.separated(
|
|
itemCount: _messages.length,
|
|
separatorBuilder: (_, __) => const SizedBox(height: 0),
|
|
itemBuilder: (context, index) {
|
|
final msg = _messages[index];
|
|
return Container(
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border(
|
|
bottom: BorderSide(
|
|
color: Color(0xFFE5E5EA),
|
|
width: 0.6,
|
|
),
|
|
),
|
|
),
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.zero,
|
|
leading: CircleAvatar(
|
|
backgroundColor: Colors.transparent,
|
|
backgroundImage: NetworkImage(msg['avatar']!),
|
|
),
|
|
title: Text(
|
|
msg['name'].toString(),
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF1C1C1E),
|
|
),
|
|
),
|
|
subtitle: Text(
|
|
msg['lastMsg'].toString(),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
color: Color(0xFF8E8E93),
|
|
),
|
|
),
|
|
trailing: Text(
|
|
msg['time'].toString(),
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Color(0xFF8E8E93),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
/// ✅ 假数据
|
|
const List<Map<String, String>> _messages = [
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/men/32.jpg',
|
|
'name': '小刘',
|
|
'lastMsg': '今晚一起吃饭吗?',
|
|
'time': '12:30',
|
|
},
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/women/44.jpg',
|
|
'name': 'AI 助手',
|
|
'lastMsg': '已为你生成总结',
|
|
'time': '11:20',
|
|
},
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/men/65.jpg',
|
|
'name': '产品经理',
|
|
'lastMsg': '新版本评审定在周五',
|
|
'time': '昨天',
|
|
},
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/men/32.jpg',
|
|
'name': '小刘',
|
|
'lastMsg': '今晚一起吃饭吗?',
|
|
'time': '12:30',
|
|
},
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/women/44.jpg',
|
|
'name': 'AI 助手',
|
|
'lastMsg': '已为你生成总结',
|
|
'time': '11:20',
|
|
},
|
|
{
|
|
'avatar': 'https://randomuser.me/api/portraits/men/65.jpg',
|
|
'name': '产品经理',
|
|
'lastMsg': '新版本评审定在周五',
|
|
'time': '昨天',
|
|
},
|
|
]; |