import 'package:hmg_patient_app/core/enum/viewstate.dart';
import 'package:hmg_patient_app/core/viewModels/pharmacyModule/BrandViewModel.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/others/network_base_view.dart';
import 'package:flutter/material.dart';

import '../../product-brands.dart';
import '../manufacturerItem.dart';
import 'ViewAllHomeWidget.dart';

class ShopByBrandWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BaseView<BrandViewModel>(
        onModelReady: (model) => model.getTopManufacturerList(),
        allowAny: true,
        builder: (_, model, wi) => NetworkBaseView(
              isLocalLoader: true,
              baseViewModel: model,
              child: Container(
                child: Column(
                  children: [
                    ViewAllHomeWidget(TranslationBase.of(context).shopByBrands,
                        ProductBrandsPage()),
                    if (model.state != ViewState.BusyLocal)
                      Container(
                        height: 150,
                        child: ListView.builder(
                          itemBuilder: (ctx, i) =>
                              ManufacturerItem(model.manufacturerList[i]),
                          scrollDirection: Axis.horizontal,
                          itemCount: model.manufacturerList.length,
                        ),
                      )
                    else
                      Container(
                        height: 80,
                        child: Center(
                          child: CircularProgressIndicator(
                            backgroundColor: Colors.white,
                            valueColor: AlwaysStoppedAnimation<Color>(
                              Colors.grey[500]!,
                            ),
                          ),
                        ),
                      ),
                  ],
                ),
              ),
            ));
  }
}
