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

47 lines
1.1 KiB
Dart
Raw Normal View History

2023-06-21 17:44:28 +08:00
import 'package:flutter/material.dart';
import 'package:together_mobile/models/contact_model.dart';
import 'package:together_mobile/models/init_get_it.dart';
2023-06-21 17:44:28 +08:00
import 'friend_tile.dart';
class FriendGroup extends StatefulWidget {
const FriendGroup({
super.key,
required this.groupName,
});
final String groupName;
@override
State<FriendGroup> createState() => _FriendGroupState();
}
class _FriendGroupState extends State<FriendGroup> {
late Map<String, FriendSetting> _groupFriends;
late List<FriendTile> _friendTiles;
@override
void initState() {
super.initState();
_groupFriends = getIt.get<Contact>().filterGroupFriends(widget.groupName);
_friendTiles = List.generate(
_groupFriends.length,
(index) => FriendTile(
key: ValueKey(
getIt.get<Contact>().friends.keys.toList()[index],
),
friendId: _groupFriends.keys.toList()[index]),
);
}
2023-06-21 17:44:28 +08:00
@override
Widget build(BuildContext context) {
return ExpansionTile(
title: Text(widget.groupName),
trailing: Text(_friendTiles.length.toString()),
children: _friendTiles,
2023-06-21 17:44:28 +08:00
);
}
}