import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../../../application/category/category_loader/category_loader_bloc.dart';
import '../../../../../application/product/product_loader/product_loader_bloc.dart';
import '../../../../../common/theme/theme.dart';
import '../../../../../injection.dart';
import 'widgets/home_left_panel.dart';
import 'widgets/home_right_panel.dart';

@RoutePage()
class HomePage extends StatelessWidget implements AutoRouteWrapper {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return const Hero(
      tag: 'confirmation_screen',
      child: Scaffold(
        backgroundColor: AppColor.white,
        body: Column(
          children: [
            Expanded(
              child: Row(
                children: [
                  Expanded(flex: 3, child: HomeLeftPanel()),
                  Expanded(flex: 2, child: HomeRightPanel()),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  Widget wrappedRoute(BuildContext context) => MultiBlocProvider(
    providers: [
      BlocProvider(
        create: (context) =>
            getIt<CategoryLoaderBloc>()
              ..add(const CategoryLoaderEvent.getCategories()),
      ),
      BlocProvider(
        create: (context) =>
            getIt<ProductLoaderBloc>()
              ..add(const ProductLoaderEvent.getProduct()),
      ),
    ],
    child: this,
  );
}
