You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart

66 lines
2.8 KiB
Dart

import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/MostViewedViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/final_products_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
import 'package:flutter/material.dart';
class MostViewedWidget extends StatelessWidget {
const MostViewedWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BaseView<MostViewedViewModel>(
onModelReady: (model) => model.getMostViewedProducts(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
isLocalLoader: true,
baseViewModel: model,
child: Container(
child: Column(
children: [
ViewAllHomeWidget(
TranslationBase.of(context).mostViewed,
FinalProductsPage(
id: "",
productType: 4,
)),
if (model.state != ViewState.BusyLocal)
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade300, width: 0.1),
borderRadius: BorderRadius.circular(8),
),
height: MediaQuery.of(context).size.height / 3 + 1,
child: ListView.builder(
itemBuilder: (ctx, i) => ProductTileItem(
model.mostViewedProducts[i],
MediaQuery.of(context).size.height / 4 + 20),
scrollDirection: Axis.horizontal,
itemCount: model.mostViewedProducts.length,
),
)
else
Container(
height: 80,
child: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.grey[500],
),
),
),
),
],
),
),
));
}
}