import 'package:flutter/material.dart';

import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart';
import '../../../../../widget/userAvatar.dart';

class ParticipantsListView extends StatefulWidget {
  final GetParticipantsResponse participantsResponse;
  const ParticipantsListView(this.participantsResponse, {super.key});

  @override
  State<ParticipantsListView> createState() => _ParticipantsListViewState();
}

class _ParticipantsListViewState extends State<ParticipantsListView> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Teilnehmende"),
      ),
      body: ListView(
        children: widget.participantsResponse.data.map((participant) {
          return ListTile(
            leading: UserAvatar(id: participant.actorId),
            title: Text(participant.displayName),
            subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
          );
        }).toList(),
      ),
    );
  }
}
