import 'package:doctor_app_flutter/core/viewModel/leave_rechdule_response.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/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/reschedule-leaves/reschedule_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_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import 'package:doctor_app_flutter/util/date-utils.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, isShowAppBar: true, appBarTitle: TranslationBase.of(context).rescheduleLeaves, body: SingleChildScrollView( child: Column(children: [ Container( width: MediaQuery.of(context).size.width, margin: EdgeInsets.all(10), padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 20), decoration: BoxDecoration( color: HexColor('#EAEAEA'), borderRadius: BorderRadius.all(Radius.circular(20))), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(10)), child: IconButton( icon: Icon( Icons.add, size: 35, color: Colors.white, ), onPressed: () { openLeave( context, false, ); }), ), Padding( child: AppText( TranslationBase.of(context).applyForReschedule, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 18, color: HexColor('#7E7E7E')), padding: EdgeInsets.all(10), ), ], ), ), Column( children: model.getReschduleLeave .map((GetRescheduleLeavesResponse item) { return RoundedContainer( child: Column( children: [ Container( decoration: BoxDecoration( border: Border( left: BorderSide( color: item.status == 10 ? Colors.red[800] : item.status == 2 ? HexColor('#CC9B14') : item.status == 9 ? Colors.green : Colors.red, width: 5.0, ))), padding: EdgeInsets.only(left: 10, right: 10), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 4, child: Wrap( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( padding: EdgeInsets.all(3), margin: EdgeInsets.only(top: 10), child: AppText( item.statusDescription, fontWeight: FontWeight.bold, color: item.status == 10 ? Colors.red[800] : item.status == 2 ? HexColor('#CC9B14') : item.status == 9 ? Colors.green : Colors.red, fontSize: 14, ), ), Padding( padding: EdgeInsets.only(top: 10), child: AppText( DateUtils .convertStringToDateFormat( item.createdOn, 'yyyy-MM-dd HH:mm'), fontWeight: FontWeight.bold, )) ]), SizedBox( height: 5, ), Container( child: AppText( item.requisitionType == 1 ? TranslationBase.of(context) .offTime : item.requisitionType == 2 ? TranslationBase.of(context) .holiday : item.requisitionType == 3 ? TranslationBase.of( context) .changeOfSchedule : TranslationBase.of( context) .newSchedule, fontWeight: FontWeight.bold, )), SizedBox( height: 5, ), Row(children: [ AppText(TranslationBase.of(context) .startDate), AppText( DateUtils.convertStringToDateFormat( item.dateTimeFrom, 'yyyy-MM-dd HH:mm'), fontWeight: FontWeight.bold, ) // overflow: // TextOverflow.ellipsis, ]), // overflow: // TextOverflow.ellipsis, SizedBox( height: 5, ), Row( children: [ AppText(TranslationBase.of(context) .endDate), AppText( DateUtils .convertStringToDateFormat( item.dateTimeTo, 'yyyy-MM-dd HH:mm'), fontWeight: FontWeight.bold, ) ], ), SizedBox( height: 5, ), model.coveringDoctors.length > 0 ? Row(children: [ AppText( TranslationBase.of(context) .coveringDoctor, ), AppText( getDoctor( model.coveringDoctors, item.coveringDoctorId), fontWeight: FontWeight.bold, ) ]) : SizedBox(), // AppText( // TranslationBase.of(context) // .reasons, // fontWeight: FontWeight.bold, // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.only( bottom: 5), child: AppText(getReasons( model.allReasons, item.reasonId))), (item.status == 2) ? IconButton( icon: Image.asset( 'assets/images/edit.png'), // color: Colors.green, //Colors.black, onPressed: () => { openLeave(context, true, extendedData: item) }, ) : SizedBox(), ]), ], ), SizedBox( width: 10, ), ], ), ), ], )), ], ), ); }).toList(), ) ]))), ); } openLeave(BuildContext context, isExtend, {extendedData}) { // showModalBottomSheet( // context: context, // builder: (context) { // return new Container( // child: RescheduleLeaveScreen( // isExtend, // extendedData, // )); // }); Navigator.push( context, FadePage( page: 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'] : ""; } }