2023-06-21 17:44:28 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-04-09 17:23:28 +08:00
|
|
|
import 'package:get_it_mixin/get_it_mixin.dart';
|
2023-08-01 10:01:08 +08:00
|
|
|
|
2024-04-09 17:23:28 +08:00
|
|
|
import '/models/contact_model.dart';
|
2023-06-21 17:44:28 +08:00
|
|
|
import 'friend_tile.dart';
|
|
|
|
|
2023-08-12 18:31:37 +08:00
|
|
|
class FriendGroup extends StatelessWidget with GetItMixin {
|
|
|
|
FriendGroup({
|
2023-08-01 10:01:08 +08:00
|
|
|
super.key,
|
|
|
|
required this.groupName,
|
|
|
|
});
|
|
|
|
|
|
|
|
final String groupName;
|
|
|
|
|
2023-06-21 17:44:28 +08:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-12 18:31:37 +08:00
|
|
|
final friends = watchOnly((Contact contact) => contact.friends);
|
|
|
|
|
2023-08-01 10:01:08 +08:00
|
|
|
return ExpansionTile(
|
2023-08-11 23:02:31 +08:00
|
|
|
title: Text(groupName),
|
2023-08-03 15:51:18 +08:00
|
|
|
trailing: Text(
|
2023-08-12 18:31:37 +08:00
|
|
|
get<Contact>().filterGroupFriends(groupName).length.toString(),
|
2023-08-03 15:51:18 +08:00
|
|
|
),
|
|
|
|
children: List.generate(
|
2023-08-12 18:31:37 +08:00
|
|
|
get<Contact>().filterGroupFriends(groupName).length,
|
2023-08-03 15:51:18 +08:00
|
|
|
(index) => FriendTile(
|
|
|
|
key: ValueKey(
|
2023-08-12 18:31:37 +08:00
|
|
|
friends.keys.toList()[index],
|
2023-08-03 15:51:18 +08:00
|
|
|
),
|
2023-08-12 18:31:37 +08:00
|
|
|
friendId:
|
|
|
|
get<Contact>().filterGroupFriends(groupName).keys.toList()[index],
|
2023-08-03 15:51:18 +08:00
|
|
|
),
|
|
|
|
),
|
2023-06-21 17:44:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|