together_mobile/lib/screens/contact/components/friend_group.dart

38 lines
927 B
Dart
Raw Normal View History

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';
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';
class FriendGroup extends StatelessWidget with GetItMixin {
FriendGroup({
super.key,
required this.groupName,
});
final String groupName;
2023-06-21 17:44:28 +08:00
@override
Widget build(BuildContext context) {
final friends = watchOnly((Contact contact) => contact.friends);
return ExpansionTile(
2023-08-11 23:02:31 +08:00
title: Text(groupName),
trailing: Text(
get<Contact>().filterGroupFriends(groupName).length.toString(),
),
children: List.generate(
get<Contact>().filterGroupFriends(groupName).length,
(index) => FriendTile(
key: ValueKey(
friends.keys.toList()[index],
),
friendId:
get<Contact>().filterGroupFriends(groupName).keys.toList()[index],
),
),
2023-06-21 17:44:28 +08:00
);
}
}