import 'package:app/widgets/room/core/count_down_vm.dart';
import 'package:app/request/dto/room/room_list_item_dto.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'controls/top_bar.dart';
import 'widgets/status_view.dart';
import 'viewmodel/tch_room_vm.dart';

class TRoomPage extends StatefulWidget {
  final RoomListItemDto roomInfo;

  const TRoomPage({
    super.key,
    required this.roomInfo,
  });

  @override
  State<TRoomPage> createState() => _TRoomPageState();
}

class _TRoomPageState extends State<TRoomPage> {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider<TchRoomVM>(
          create: (_) => TchRoomVM(info: widget.roomInfo),
        ),
        ChangeNotifierProxyProvider<TchRoomVM, CountDownVM>(
          create: (_) => CountDownVM(),
          update: (_, tchVM, countDownVM) {
            countDownVM!.bind(tchVM.roomInfo);
            return countDownVM;
          },
        ),
      ],
      child: Scaffold(
        backgroundColor: Color(0xff2c3032),
        appBar: TopBar(),
        body: StatusView(),
      ),
    );
  }
}
