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.
262 lines
13 KiB
Dart
262 lines
13 KiB
Dart
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/date-utils.dart';
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.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/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';
|
|
|
|
class AddRescheduleLeavScreen extends StatelessWidget {
|
|
ProjectViewModel projectsProvider;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectsProvider = Provider.of(context);
|
|
return BaseView<SickLeaveViewModel>(
|
|
onModelReady: (model) =>
|
|
{model.getRescheduleLeave(), model.getCoveringDoctors()},
|
|
builder: (_, model, w) => AppScaffold(
|
|
baseViewModel: model,
|
|
isShowAppBar: true,
|
|
appBarTitle: TranslationBase.of(context).rescheduleLeaves,
|
|
body: SingleChildScrollView(
|
|
child: Column(children: [
|
|
AddNewOrder( onTap: () {
|
|
openLeave(
|
|
context,
|
|
false,
|
|
);
|
|
},label: TranslationBase.of(context).applyForReschedule,),
|
|
Column(
|
|
children: model.getReschduleLeave
|
|
.map<Widget>((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: <Widget>[
|
|
Expanded(
|
|
flex: 4,
|
|
child: Wrap(
|
|
children: <Widget>[
|
|
Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
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(
|
|
AppDateUtils
|
|
.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(
|
|
AppDateUtils.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(
|
|
AppDateUtils
|
|
.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']
|
|
: "";
|
|
}
|
|
}
|