Book Appointment check login

merge-requests/34/merge
haroon amjad 5 years ago
parent 760db6a873
commit 732ab90b2f

@ -1,7 +1,12 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorProfile.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:rating_bar/rating_bar.dart';
@ -14,6 +19,8 @@ class DoctorProfile extends StatefulWidget {
DoctorList doctor;
DoctorProfileList docProfileList;
AuthenticatedUser authUser;
DoctorProfile({@required this.doctor, @required this.docProfileList});
@override
@ -28,6 +35,8 @@ class _DoctorProfileState extends State<DoctorProfile>
@override
void initState() {
_tabController = new TabController(length: 2, vsync: this);
widget.authUser = new AuthenticatedUser();
getPatientData();
super.initState();
}
@ -175,13 +184,43 @@ class _DoctorProfileState extends State<DoctorProfile>
);
}
getPatientData() async {
AppSharedPreferences sharedPref = AppSharedPreferences();
if (await sharedPref.getObject(USER_PROFILE) != null) {
var data =
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
setState(() {
print(data);
widget.authUser = data;
});
}
}
void goToBookConfirm() {
if (DocAvailableAppointments.areSlotsAvailable)
navigateToBookConfirm(context);
else
if (DocAvailableAppointments.areSlotsAvailable) {
if (widget.authUser.patientID != null) {
navigateToBookConfirm(context);
} else {
ConfirmDialog dialog = new ConfirmDialog(
context: context,
confirmMessage: "You have to login to use this service",
okText: TranslationBase.of(context).confirm,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () => {navigateToLogin()},
cancelFunction: () => {});
dialog.showAlertDialog(context);
}
} else
AppToast.showErrorToast(message: "Please select Time Slot to continue");
}
navigateToLogin() {
ConfirmDialog.closeAlertDialog(context);
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
}
Future navigateToBookConfirm(context) async {
Navigator.push(
context,

@ -0,0 +1,45 @@
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AlertDialogBox {
final BuildContext context;
final confirmMessage;
final okText;
final Function okFunction;
AlertDialogBox(
{@required this.context,
@required this.confirmMessage,
@required this.okText,
@required this.okFunction});
showAlertDialog(BuildContext context) {
Widget continueButton =
FlatButton(child: Text(this.okText), onPressed: this.okFunction);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text(TranslationBase.of(context).confirm),
content: Text(this.confirmMessage),
actions: [
continueButton,
],
);
// show the dialog
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
static closeAlertDialog(BuildContext context) {
Navigator.of(context).pop();
}
}
Loading…
Cancel
Save