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/your_tenders_view_model.dart';
import 'package:tm_app/views/shared/responsive_builder.dart';
import 'package:tm_app/views/your_tenders/pages/your_tenders_desktop_page.dart';
import 'package:tm_app/views/your_tenders/pages/your_tenders_mobile_page.dart';
import 'package:tm_app/views/your_tenders/pages/your_tenders_tablet_page.dart';

import '../../../data/services/model/request_models/get_tenders_request_model/get_tenders_request_model.dart';

class YourTendersScreen extends StatefulWidget {
  const YourTendersScreen({super.key});

  @override
  State<YourTendersScreen> createState() => _YourTendersScreenState();
}

class _YourTendersScreenState extends State<YourTendersScreen> {
  late final YourTendersViewModel viewModel;
  @override
  void initState() {
    super.initState();
    viewModel = context.read<YourTendersViewModel>();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final requestModel = GetTendersRequestModel();
      viewModel.getTenders(requestModel: requestModel, reset: true);
    });
  }

  @override
  Widget build(BuildContext context) {
    SizeConfig.init(context);
    return const ResponsiveBuilder(
      mobile: YourTendersMobilePage(),
      tablet: YourTendersTabletPage(),
      desktop: YourTendersDesktopPage(),
    );
  }
}
