import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/view_models/tender_detail_view_model.dart';
import 'package:tm_app/views/detail/pages/detail_desktop_page.dart';
import 'package:tm_app/views/detail/pages/detail_mobile_page.dart';
import 'package:tm_app/views/detail/pages/detail_tablet_page.dart';
import 'package:tm_app/views/shared/responsive_builder.dart';

class TenderDetailScreen extends StatefulWidget {
  const TenderDetailScreen({required this.tenderId, super.key});

  final String tenderId;

  @override
  State<TenderDetailScreen> createState() => _TenderDetailScreenState();
}

class _TenderDetailScreenState extends State<TenderDetailScreen> {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      context.read<TenderDetailViewModel>().getTenderDetail(
        id: widget.tenderId,
      );
    });
  }

  @override
  Widget build(BuildContext context) {
    SizeConfig.init(context);
    return ResponsiveBuilder(
      mobile: TenderDetailMobilePage(tenderId: widget.tenderId),
      tablet: TenderDetailTabletPage(tenderId: widget.tenderId),
      desktop: TenderDetailDesktopPage(tenderId: widget.tenderId),
    );
  }
}
