import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_details_page.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PrescriptionsHistoryPage extends StatelessWidget { final VoidCallback showOrderLog; final PrescriptionsViewModel prescriptionsViewModel; PrescriptionsHistoryPage({Key key, this.prescriptionsViewModel, this.showOrderLog}); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getPrescriptionsOrders(showLoading: true), builder: (_, model, widget) => AppScaffold( baseViewModel: prescriptionsViewModel, body: model.state != ViewState.Busy ? prescriptionsViewModel.prescriptionsHistory.length > 0 ? ListView.separated( physics: BouncingScrollPhysics(), padding: EdgeInsets.all(21), separatorBuilder: (context, index) { return SizedBox(height: 12); }, itemBuilder: (context, index) { int status = prescriptionsViewModel.prescriptionsHistory[index].statusId; String _statusDisp = prescriptionsViewModel.prescriptionsHistory[index].statusText; Color _color; if (status == 1) { //pending _color = Color(0xffCC9B14); } else if (status == 2) { //processing _color = Color(0xff2E303A); } else if (status == 3) { //completed _color = Color(0xff359846); } else if (status == 4 || status == 6 || status == 7) { //cancel // Rejected _color = Color(0xffD02127); } return InkWell( onTap: () async { final result = await Navigator.push( context, FadePage( page: PrescriptionsHistoryDetailsPage( prescriptionsOrder: prescriptionsViewModel.prescriptionsHistory[index], ), ), ); if (result != null) { showOrderLog(); } }, child: Container( height: 65, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(10.0), ), boxShadow: [ BoxShadow( color: Color(0xff000000).withOpacity(.05), blurRadius: 27, offset: Offset(0, -3), ), ], ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Container( width: 6, decoration: BoxDecoration( color: _color, borderRadius: BorderRadius.only( topLeft: projectViewModel.isArabic ? Radius.circular(0.0) : Radius.circular(10.0), bottomLeft: projectViewModel.isArabic ? Radius.circular(0.0) : Radius.circular(10.0), topRight: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0.0), bottomRight: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0.0), ), ), ), Expanded( child: Padding( padding: EdgeInsets.only(left: projectViewModel.isArabic ? 6 : 12, right: projectViewModel.isArabic ? 12 : 6), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( _statusDisp, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: _color, letterSpacing: -0.4, height: 16 / 10), ), Text( '${TranslationBase.of(context).orderNo}. ${prescriptionsViewModel.prescriptionsHistory[index].iD}', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), ], ), ), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(prescriptionsViewModel.prescriptionsHistory[index].created)), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 16 / 10), ), Text( DateUtil.formatDateToTimeLang(DateTime.tryParse(prescriptionsViewModel.prescriptionsHistory[index].created), false), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), ), ], ) ], ), ), ), Icon( Icons.arrow_forward, size: 16, ), mWidth(6), ], ), )); }, itemCount: prescriptionsViewModel.prescriptionsHistory.length, ) : getNoDataWidget(context) : Container(), )); } }