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.
135 lines
3.9 KiB
135 lines
3.9 KiB
import 'package:flutter/material.dart';
|
|
import 'package:dating_touchme_app/generated/assets.dart';
|
|
|
|
class FriendTab extends StatefulWidget {
|
|
const FriendTab({super.key});
|
|
|
|
@override
|
|
State<FriendTab> createState() => _FriendTabState();
|
|
}
|
|
|
|
class _FriendTabState extends State<FriendTab> {
|
|
// 模拟数据 - 好友列表
|
|
final List<Map<String, dynamic>> _friendList = [
|
|
{
|
|
"id": 1,
|
|
"name": "林园园",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": true,
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "李晖",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": false,
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "李哲",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": false,
|
|
},
|
|
{
|
|
"id": 4,
|
|
"name": "李夏",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": true,
|
|
},
|
|
{
|
|
"id": 5,
|
|
"name": "张雪",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": false,
|
|
},
|
|
{
|
|
"id": 6,
|
|
"name": "王强",
|
|
"avatar": Assets.imagesAvatarsExample,
|
|
"isOnline": true,
|
|
},
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.builder(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
itemCount: _friendList.length,
|
|
itemBuilder: (context, index) {
|
|
final friend = _friendList[index];
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// 头像
|
|
Stack(
|
|
children: [
|
|
Container(
|
|
width: 50,
|
|
height: 50,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(25),
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(25),
|
|
child: Image.asset(friend["avatar"], fit: BoxFit.cover),
|
|
),
|
|
),
|
|
if (friend["isOnline"] == true)
|
|
Positioned(
|
|
bottom: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: 12,
|
|
height: 12,
|
|
decoration: BoxDecoration(
|
|
color: Colors.green,
|
|
borderRadius: BorderRadius.circular(6),
|
|
border: Border.all(color: Colors.white, width: 2),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
// 信息
|
|
Expanded(
|
|
child: Container(
|
|
margin: const EdgeInsets.only(left: 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
friend["name"],
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
friend["isOnline"] == true ? "在线" : "离线",
|
|
style: TextStyle(
|
|
color: friend["isOnline"] == true ? Colors.green : Colors.grey,
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// 箭头图标
|
|
const Icon(Icons.arrow_forward_ios, size: 16, color: Colors.grey),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|