import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/OrderDetails.dart'; class OrderPage extends StatefulWidget { // orderList({this.customerId, this.pageId}); @override _OrderPageState createState() => _OrderPageState(); } class _OrderPageState extends State with SingleTickerProviderStateMixin{ String customerId=""; String page_id=""; List delivered = [] ; List processing = []; List cancelled = []; List pending = []; TabController _tabController; AppSharedPreferences sharedPref = AppSharedPreferences(); @override void initState() { // WidgetsBinding.instance.addPostFrameCallback((_) => getOrder()); super.initState(); _tabController = new TabController(length: 4, vsync: this,); } @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getOrder(customerId, page_id), builder: (_,model, wi )=> AppScaffold( appBarTitle:(TranslationBase.of(context).order), // backgroundColor: Colors.green , // centerTitle: true, // title: Text(TranslationBase.of(context).order, style: TextStyle(color:Colors.white)), // backgroundColor: Colors.green, isShowAppBar: true, isPharmacy:true , body: Container( child: Column( children: [ TabBar( tabs: [ Tab(text: TranslationBase.of(context).delivered), // Tab(text: model.order.length.toString()), Tab(text: TranslationBase.of(context).processing), Tab(text: TranslationBase.of(context).pending), Tab(text: TranslationBase.of(context).cancelled), ], controller: _tabController, ), Divider( color: Colors.grey[350], height: 10, thickness: 6, indent: 0, endIndent: 0, ), Expanded( child: new TabBarView( physics: NeverScrollableScrollPhysics(), children: [ getDeliveredOrder(model), getProcessingOrder(model), getPendingOrder(model), getCancelledOrder(model), ], controller: _tabController, ), ), ], ), ), ), ); } Widget getDeliveredOrder(OrderModelViewModel model){ return Container( width: MediaQuery.of(context).size.width, child: model.order.length != 0 && model.order[0].orderStatusId == 30 ? SingleChildScrollView( child: Column( children: [ ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), itemCount: 2 , itemBuilder: (context, index){ return Container( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderNumber, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( child: Text(model.order[0].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderDate, style: TextStyle(fontSize: 14.0, ), ), ), Container( child: Text(model.order[0].createdOnUtc.toString(), style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), Container( margin: EdgeInsets.all(8.0), child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => OrderDetailsPage())); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20,), ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.blue[700], style: BorderStyle.solid, width: 5.0, ), color: Colors.blue[700], borderRadius: BorderRadius.circular(30.0) ), child: Text( model.order[0].orderStatus.toString(), // TranslationBase.of(context).delivered, style: TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), ), Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ Container( margin: EdgeInsets.only(left: 5), child: Text(model.order[0].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).sar, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( child: Text('12', style: TextStyle(fontSize: 14.0, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).itemsNo, style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 8, indent: 0, endIndent: 0, ), ], ), ); } ) ], ), ) : Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), child: Text(TranslationBase.of(context).noOrder, style: TextStyle( fontSize: 16.0, )), ), ], ), ), ), ); } Widget getProcessingOrder(OrderModelViewModel model){ return Container( child: model.order.length != 0 && model.order[0].orderStatusId == 20 ? SingleChildScrollView( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderNumber, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( child: Text(model.order[0].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderDate, style: TextStyle(fontSize: 14.0, ), ), ), Container( child: Text(model.order[0].createdOnUtc.toString(), style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), Container( margin: EdgeInsets.all(8), child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => OrderDetailsPage())); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20,), ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.green, style: BorderStyle.solid, width: 5.0, ), color: Colors.green, borderRadius: BorderRadius.circular(30.0) ), child: Text( model.order[0].orderStatus.toString(), // TranslationBase.of(context).processing, style: TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), ), Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ Container( margin: EdgeInsets.only(left: 5), child: Text(model.order[0].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).sar, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( child: Text('12', style: TextStyle(fontSize: 14.0, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).itemsNo, style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 8, indent: 0, endIndent: 0, ), ], ), ) : Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), child: Text(TranslationBase.of(context).noOrder, style: TextStyle( fontSize: 16.0, )), ), ], ), ), ), ); } Widget getPendingOrder(OrderModelViewModel model){ return Container( child: model.order.length != 0 && model.order[0].orderStatusId == 10 ? SingleChildScrollView( child: Column( children: [ ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), itemCount: 2 , itemBuilder: (context, index){ return Container( child: SingleChildScrollView( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderNumber, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( child: Text(model.order[0].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderDate, style: TextStyle(fontSize: 14.0, ), ), ), Container( child: Text(model.order[0].createdOnUtc.toString(), style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), Container( margin: EdgeInsets.all( 8.0), child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => OrderDetailsPage())); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20,), ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child:Container( margin: EdgeInsets.all(8.0), padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.orange[300], style: BorderStyle.solid, width: 5.0, ), color: Colors.orange[300], borderRadius: BorderRadius.circular(30.0) ), child: Text( model.order[0].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), ), Container( margin: EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ Container( margin: EdgeInsets.only(left: 5), child: Text(model.order[0].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).sar, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( child: Text('12', style: TextStyle(fontSize: 14.0, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).itemsNo, style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 8, indent: 0, endIndent: 0, ), ], ), ), ); } ) ], ), ) : Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), child: Text(TranslationBase.of(context).noOrder, style: TextStyle( fontSize: 16.0, )), ), ], ), ), ), ); } Widget getCancelledOrder(OrderModelViewModel model){ return Container( child: model.order.length != 0 && model.order[0].orderStatusId == 40 ? SingleChildScrollView( child: Column( children: [ ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), itemCount: 2 , itemBuilder: (context, index){ return Container( child: SingleChildScrollView( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all( 8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderNumber, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( child: Text(model.order[0].id.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text(TranslationBase.of(context).orderDate, style: TextStyle(fontSize: 14.0, ), ), ), Container( child: Text(model.order[0].createdOnUtc.toString(), style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), Container( margin: EdgeInsets.all(8.0), child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => OrderDetailsPage())); }, child: SvgPicture.asset( 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20,), ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child:Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border.all( color: Colors.red[900], style: BorderStyle.solid, width: 5.0, ), color: Colors.red[900], borderRadius: BorderRadius.circular(30.0) ), child: Text( model.order[0].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), ), Container( margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ Container( margin: EdgeInsets.only(left: 5), child: Text(model.order[0].orderTotal.toString(), style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).sar, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ], ), SizedBox( height: 5,), Row( children: [ Container( child: Text('12', style: TextStyle(fontSize: 14.0, ), ), ), Container( margin: EdgeInsets.only(left: 5), child: Text(TranslationBase.of(context).itemsNo, style: TextStyle(fontSize: 14.0, ), ), ), ], ), ], ), ), ], ), Divider( color: Colors.grey[350], height: 20, thickness: 8, indent: 0, endIndent: 0, ), ], ), ), ); } ) ], ), ) : Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( 'assets/images/pharmacy/empty_box.svg'), Container( margin: EdgeInsets.only(top: 10.0), child: Text(TranslationBase.of(context).noOrder, style: TextStyle( fontSize: 16.0, )), ), ], ), ), ), ); } } // filterOrders() { // for () { // if (order.order_status_id === 30 || order.order_status_id === 997 || order.order_status_id === 994) { // complete // this.delivered.push(order); // } else if (order.order_status_id === 40 || order.order_status_id === 200 || order.order_status_id === 996) { // cancelled & order refunded // this.cancelled.push(order); // } else if (order.order_status_id === 10) { // Pending // this.pending.push(order); // } else if (order.order_status_id === 20 || order.order_status_id === 995 || order.order_status_id === 998 || order.order_status_id === 999) { // Processing // this.processing.push(order); // } else { // Processing & other all other status // this.other.push(order); // } // } //}