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.
354 lines
12 KiB
Dart
354 lines
12 KiB
Dart
4 years ago
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/models/Appointments/appoDetailsButtons.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/AppointmentType.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/ArrivedButtons.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/BookedButtons.dart';
|
||
4 years ago
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/BookedButtonsAllowCheckIn.dart';
|
||
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/ConfirmedButtons.dart';
|
||
|
import 'package:diplomaticquarterapp/pages/MyAppointments/models/ConfirmedButtonsAllowCheckIn.dart';
|
||
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
||
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||
|
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
|
||
4 years ago
|
import 'package:flutter/material.dart';
|
||
4 years ago
|
import 'package:url_launcher/url_launcher.dart';
|
||
4 years ago
|
|
||
|
class AppointmentActions extends StatefulWidget {
|
||
4 years ago
|
AppoitmentAllHistoryResultList appo;
|
||
|
TabController tabController;
|
||
|
|
||
|
AppointmentActions({@required this.appo, @required this.tabController});
|
||
|
|
||
4 years ago
|
@override
|
||
|
_AppointmentActionsState createState() => _AppointmentActionsState();
|
||
|
}
|
||
|
|
||
|
class _AppointmentActionsState extends State<AppointmentActions> {
|
||
|
List<AppoDetailsButton> appoButtonsList = [];
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
_getAppointmentActionButtons();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
var size = MediaQuery.of(context).size;
|
||
|
final double itemHeight = ((size.height - kToolbarHeight - 24) * 0.42) / 2;
|
||
|
final double itemWidth = size.width / 2;
|
||
|
|
||
|
return Container(
|
||
|
margin: EdgeInsets.all(5.0),
|
||
|
child: CustomScrollView(
|
||
|
primary: false,
|
||
|
physics: NeverScrollableScrollPhysics(),
|
||
|
slivers: <Widget>[
|
||
|
SliverPadding(
|
||
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||
|
sliver: SliverGrid.count(
|
||
|
crossAxisCount: 2,
|
||
|
childAspectRatio: (itemWidth / itemHeight),
|
||
|
children: appoButtonsList
|
||
|
.map((e) => GestureDetector(
|
||
|
onTap: () {
|
||
|
_handleButtonClicks(e);
|
||
|
},
|
||
|
child: Container(
|
||
|
height: 100.0,
|
||
|
margin: EdgeInsets.all(9.0),
|
||
|
decoration: BoxDecoration(
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Colors.grey[400],
|
||
|
blurRadius: 2.0,
|
||
|
spreadRadius: 0.0)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(10),
|
||
|
color: Colors.white),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: <Widget>[
|
||
|
Container(
|
||
|
margin:
|
||
|
EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
|
||
|
child: Text(e.title,
|
||
|
overflow: TextOverflow.clip,
|
||
|
style: TextStyle(
|
||
|
color: new Color(0xFFc5272d),
|
||
|
letterSpacing: 1.0,
|
||
|
fontSize: 20.0)),
|
||
|
),
|
||
|
Container(
|
||
|
margin:
|
||
|
EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
|
||
|
child: Text(e.subtitle,
|
||
|
overflow: TextOverflow.clip,
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
letterSpacing: 1.0,
|
||
|
fontSize: 15.0)),
|
||
|
),
|
||
|
Container(
|
||
|
alignment: Alignment.bottomRight,
|
||
|
margin:
|
||
4 years ago
|
EdgeInsets.fromLTRB(0.0, 10.0, 10.0, 8.0),
|
||
4 years ago
|
child: Image.asset(e.icon,
|
||
4 years ago
|
width: 45.0, height: 45.0),
|
||
4 years ago
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
))
|
||
|
.toList(),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
_handleButtonClicks(AppoDetailsButton) {
|
||
|
print(AppoDetailsButton.caller);
|
||
4 years ago
|
|
||
|
switch (AppoDetailsButton.caller) {
|
||
|
case "openReschedule":
|
||
|
widget.tabController.animateTo((widget.tabController.index + 1) % 2);
|
||
|
break;
|
||
|
|
||
|
case "onCancelAppointment":
|
||
|
ConfirmDialog dialog = new ConfirmDialog(
|
||
|
context: context,
|
||
|
confirmMessage: TranslationBase.of(context).cancelAppoMsg,
|
||
|
okText: TranslationBase.of(context).confirm,
|
||
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
||
|
okFunction: () => {cancelAppointment()},
|
||
|
cancelFunction: () => {});
|
||
|
dialog.showAlertDialog(context);
|
||
|
break;
|
||
|
|
||
|
case "confirmAppointment":
|
||
|
confirmAppointment();
|
||
|
break;
|
||
4 years ago
|
|
||
|
case "navigateToProject":
|
||
|
openMap(double.parse(widget.appo.latitude),
|
||
|
double.parse(widget.appo.longitude));
|
||
|
break;
|
||
4 years ago
|
}
|
||
4 years ago
|
}
|
||
|
|
||
|
_getAppointmentActionButtons() {
|
||
4 years ago
|
if (widget.appo != null) {
|
||
4 years ago
|
if (isConfirmed()) {
|
||
4 years ago
|
if (widget.appo.isOnlineCheckedIN) {
|
||
4 years ago
|
_getConfirmedCheckInAppoActionsList();
|
||
|
} else {
|
||
|
_getConfirmedAppoActionsList();
|
||
|
}
|
||
|
} else {
|
||
|
print("isConfirmed Null");
|
||
|
}
|
||
|
if (isBooked()) {
|
||
4 years ago
|
if (widget.appo.isOnlineCheckedIN) {
|
||
4 years ago
|
_getBookedCheckInAppoActionsList();
|
||
|
} else {
|
||
|
_getBookedAppoActionsList();
|
||
|
}
|
||
|
} else {
|
||
|
print("isBooked Null");
|
||
|
}
|
||
|
if (isArrived()) {
|
||
4 years ago
|
if (widget.appo.clinicID == 17) {
|
||
4 years ago
|
_getArrivedInvoiceAppoActionsList();
|
||
|
} else {
|
||
|
_getArrivedAppoActionsList();
|
||
|
}
|
||
|
} else {
|
||
|
print("isArrived Null");
|
||
|
}
|
||
|
} else {
|
||
|
print("Appo Null");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool isConfirmed() {
|
||
4 years ago
|
return AppointmentType.isConfirmed(widget.appo);
|
||
4 years ago
|
}
|
||
|
|
||
|
bool isArrived() {
|
||
4 years ago
|
return AppointmentType.isArrived(widget.appo);
|
||
4 years ago
|
}
|
||
|
|
||
|
bool isCheckedIn() {
|
||
4 years ago
|
return widget.appo.isOnlineCheckedIN;
|
||
4 years ago
|
}
|
||
|
|
||
|
bool isBooked() {
|
||
4 years ago
|
return AppointmentType.isBooked(widget.appo);
|
||
4 years ago
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getBookedAppoActionsList() async {
|
||
|
print("_getBookedAppoActionsList");
|
||
4 years ago
|
print(BookedButtons.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < BookedButtons.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: BookedButtons.buttons[i]['title'],
|
||
|
subtitle: BookedButtons.buttons[i]['subtitle'],
|
||
|
icon: BookedButtons.buttons[i]['icon'],
|
||
|
caller: BookedButtons.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getBookedCheckInAppoActionsList() async {
|
||
|
print("_getBookedCheckInAppoActionsList");
|
||
4 years ago
|
print(BookedButtonsAllowCheckIn.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < BookedButtonsAllowCheckIn.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: BookedButtonsAllowCheckIn.buttons[i]['title'],
|
||
|
subtitle: BookedButtonsAllowCheckIn.buttons[i]['subtitle'],
|
||
|
icon: BookedButtonsAllowCheckIn.buttons[i]['icon'],
|
||
|
caller: BookedButtonsAllowCheckIn.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getConfirmedAppoActionsList() async {
|
||
4 years ago
|
print("_getConfirmedAppoActionsList");
|
||
|
print(ConfirmedButtons.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < ConfirmedButtons.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: ConfirmedButtons.buttons[i]['title'],
|
||
|
subtitle: ConfirmedButtons.buttons[i]['subtitle'],
|
||
|
icon: ConfirmedButtons.buttons[i]['icon'],
|
||
|
caller: ConfirmedButtons.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getConfirmedCheckInAppoActionsList() async {
|
||
4 years ago
|
print("_getConfirmedAllowCheckInAppoActionsList");
|
||
|
print(ConfirmedButtonsAllowCheckIn.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < ConfirmedButtonsAllowCheckIn.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: ConfirmedButtonsAllowCheckIn.buttons[i]['title'],
|
||
|
subtitle: ConfirmedButtonsAllowCheckIn.buttons[i]['subtitle'],
|
||
|
icon: ConfirmedButtonsAllowCheckIn.buttons[i]['icon'],
|
||
|
caller: ConfirmedButtonsAllowCheckIn.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getArrivedAppoActionsList() async {
|
||
4 years ago
|
print("_getArrivedAppoActionsList");
|
||
|
print(ArrivedButtons.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < ArrivedButtons.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: ArrivedButtons.buttons[i]['title'],
|
||
|
subtitle: ArrivedButtons.buttons[i]['subtitle'],
|
||
|
icon: ArrivedButtons.buttons[i]['icon'],
|
||
|
caller: ArrivedButtons.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Future<List<AppoDetailsButton>> _getArrivedInvoiceAppoActionsList() async {
|
||
4 years ago
|
print("_getArrivedInvoiceAppoActionsList");
|
||
|
print(ArrivedButtons.buttons);
|
||
4 years ago
|
List<AppoDetailsButton> buttonsList = [];
|
||
4 years ago
|
for (var i = 0; i < ArrivedButtons.buttons.length; i++) {
|
||
4 years ago
|
buttonsList.add(AppoDetailsButton(
|
||
4 years ago
|
title: ArrivedButtons.buttons[i]['title'],
|
||
|
subtitle: ArrivedButtons.buttons[i]['subtitle'],
|
||
|
icon: ArrivedButtons.buttons[i]['icon'],
|
||
|
caller: ArrivedButtons.buttons[i]['caller'],
|
||
4 years ago
|
));
|
||
|
}
|
||
|
setState(() {
|
||
|
appoButtonsList = buttonsList;
|
||
|
});
|
||
|
}
|
||
4 years ago
|
|
||
|
cancelAppointment() {
|
||
|
ConfirmDialog.closeAlertDialog(context);
|
||
|
loading(true);
|
||
|
DoctorsListService service = new DoctorsListService();
|
||
|
service.cancelAppointment(widget.appo).then((res) {
|
||
|
print(res);
|
||
|
if (res['MessageStatus'] == 1) {
|
||
|
AppToast.showSuccessToast(message: res['ErrorEndUserMessage']);
|
||
|
loading(false);
|
||
|
} else {
|
||
|
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
|
||
|
loading(false);
|
||
|
}
|
||
|
}).catchError((err) {
|
||
|
print(err);
|
||
|
loading(false);
|
||
|
});
|
||
|
}
|
||
|
|
||
4 years ago
|
static Future<void> openMap(double latitude, double longitude) async {
|
||
|
String googleUrl =
|
||
|
'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
|
||
|
if (await canLaunch(googleUrl)) {
|
||
|
await launch(googleUrl);
|
||
|
} else {
|
||
|
throw 'Could not open the map.';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
showReminderDialog() {
|
||
|
|
||
|
}
|
||
|
|
||
4 years ago
|
confirmAppointment() {
|
||
|
loading(true);
|
||
|
DoctorsListService service = new DoctorsListService();
|
||
|
service
|
||
|
.confirmAppointment(widget.appo.appointmentNo, widget.appo.clinicID,
|
||
|
widget.appo.projectID)
|
||
|
.then((res) {
|
||
|
if (res['MessageStatus'] == 1) {
|
||
|
AppToast.showSuccessToast(message: res['ErrorEndUserMessage']);
|
||
|
loading(false);
|
||
|
} else {
|
||
|
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
|
||
|
loading(false);
|
||
|
}
|
||
|
}).catchError((err) {
|
||
|
print(err);
|
||
|
loading(false);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
loading(bool flag) {
|
||
|
setState(() {
|
||
|
AppointmentDetails.isLoading = flag;
|
||
|
});
|
||
|
}
|
||
4 years ago
|
}
|