import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/leave_rechdule_response.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/reschedule-leaves/reschedule_leave.dart'; import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; class AddRescheduleLeavScreen extends StatelessWidget { ProjectViewModel projectsProvider; @override Widget build(BuildContext context) { projectsProvider = Provider.of(context); return BaseView( onModelReady: (model) => {model.getRescheduleLeave(), model.getCoveringDoctors()}, builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: TranslationBase.of(context).rescheduleLeaves, body: model.getReschduleLeave.length > 0 ? SingleChildScrollView( child: Column( children: [ Container( margin: EdgeInsets.only(left: 15, right: 15, top: 20), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( child: Row( children: [ Expanded( flex: 4, child: AppText( TranslationBase.of(context) .requestLeave), ), IconButton( icon: Icon( Icons.add_circle, color: Colors.red, )) ], ) // AppTextFormField( // hintText: // TranslationBase.of(context).requestLeave, // borderColor: Colors.white, // prefix: IconButton( // icon: Icon( // Icons.add_circle, // color: Colors.red, // )), // // textInputType: TextInputType.text, // readOnly: true, // onTap: () { // openLeave( // context, // false, // ); // return false; // }, // inputFormatter: ONLY_LETTERS, // ) , onTap: () { openLeave( context, false, ); }, ) ], ), ), Column( children: model.getReschduleLeave.map( (GetRescheduleLeavesResponse item) { return CardWithBgWidgetNew( widget: Column( children: [ Container( padding: EdgeInsets.only(left: 10, right: 10), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 4, child: Wrap( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: EdgeInsets.all(3), child: AppText( item.status == 1 ? TranslationBase .of(context) .approved : item.status == 2 ? TranslationBase.of( context) .pending : TranslationBase.of( context) .rejected, fontWeight: FontWeight.bold, color: Colors.white, ), color: item.status == 1 ? Colors.green : item.status == 2 ? Colors .yellow[800] : Colors.red[800], ), SizedBox( height: 5, ), Container( child: AppText( TranslationBase.of( context) .holiday + ' ', fontWeight: FontWeight.bold, )), Row( children: [ Flexible( child: Text( item.dateTimeFrom + ' ' + TranslationBase.of( context) .to + ' ' + item.dateTimeTo, // overflow: // TextOverflow.ellipsis, )) ], ), SizedBox( height: 5, ), AppText( TranslationBase.of( context) .coveringDoctor, fontWeight: FontWeight.bold, ), model.coveringDoctors .length > 0 ? Row(children: [ AppText(getDoctor( model .coveringDoctors, item.coveringDoctorId)) ]) : SizedBox(), AppText( TranslationBase.of( context) .reasons, fontWeight: FontWeight.bold, ), model.allReasons.length > 0 ? Row(children: [ AppText(getReasons( model .allReasons, item.reasonId)) ]) : SizedBox(), ], ), SizedBox( width: 10, ), ], ), ), (item.status == 2) ? Expanded( flex: 1, child: IconButton( icon: Icon( Icons.edit_outlined, size: 30, ), // color: Colors.green, //Colors.black, onPressed: () => { openLeave(context, true, extendedData: item) }, )) : SizedBox(), ], )), SizedBox( height: 10, ), Divider( height: 1, ), ], )); }).toList(), ) ], ), ) : new Builder(builder: (context) { return Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( padding: EdgeInsets.all(40), decoration: BoxDecoration( border: Border.all( color: HexColor('#B8382C'), width: 4), borderRadius: BorderRadius.all(Radius.circular(100))), child: IconButton( icon: Icon( Icons.add, size: 35, ), onPressed: () { openLeave( context, false, ); }), ), Padding( child: AppText( TranslationBase.of(context).noReScheduleLeave, fontWeight: FontWeight.bold, ), padding: EdgeInsets.all(10), ), AppText( TranslationBase.of(context).applyNow, fontWeight: FontWeight.bold, color: HexColor('#B8382C'), ) ], ), )); }), )); } openLeave(BuildContext context, isExtend, {extendedData}) { showModalBottomSheet( context: context, builder: (context) { return new Container( child: RescheduleLeaveScreen( isExtend, extendedData, )); }); } getDoctor(model, doctorId) { var obj; obj = model.where((i) => i['doctorID'].toString() == doctorId).toList(); //print(obj); return obj.length > 0 ? obj[0]['doctorName'] : ""; } getReasons(model, reasonID) { var obj; obj = model.where((i) => i['id'] == reasonID).toList(); //print(obj); return obj.length > 0 ? projectsProvider.isArabic == true ? obj[0]['nameAr'] : obj[0]['nameEn'] : ""; } }