import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/material.dart';

import '../../../final_products_page.dart';
import '../ProductTileItem.dart';
import 'ViewAllHomeWidget.dart';

class BestSellerWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BaseView<BestSellerViewModel>(
        onModelReady: (model) => model.getBestSellerProducts(),
        allowAny: true,
        builder: (_, model, wi) => NetworkBaseView(
              isLocalLoader: true,
              baseViewModel: model,
              child: Container(
                child: Column(
                  children: [
                    ViewAllHomeWidget(
                        TranslationBase.of(context).bestSellers,
                        FinalProductsPage(
                          id: "",
                          productType: 20,
                        )),
                    Container(
                      height: MediaQuery.of(context).size.height / 4 + 20,
                      child: ListView.builder(
                        itemBuilder: (ctx, i) =>
                            ProductTileItem(model.bestSellerProduct[i]),
                        scrollDirection: Axis.horizontal,
                        itemCount: model.bestSellerProduct.length,
                      ),
                    ),
                  ],
                ),
              ),
            ));
  }
}
