first step form change clinic

merge-requests/120/head
Elham Rababah 6 years ago
parent dc81540b7a
commit ef8dfc5b5f

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/models/clinic_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import '../models/user_model.dart'; import '../models/user_model.dart';
@ -16,6 +17,7 @@ const MEMBER_CHECK_ACTIVATION_CODE_NEW =
const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
List <ClinicModel>doctorsClinicList=[];
Future<dynamic> login(UserModel userInfo) async { Future<dynamic> login(UserModel userInfo) async {
try { try {
dynamic localRes; dynamic localRes;
@ -99,6 +101,11 @@ class AuthProvider with ChangeNotifier {
await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
response['List_DoctorsClinic'].forEach((v) {
doctorsClinicList.add(new ClinicModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: activationCodeModel); }, body: activationCodeModel);

@ -1,27 +1,34 @@
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/models/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/profile_req_Model.dart';
import 'package:doctor_app_flutter/providers/auth_provider.dart';
import 'package:doctor_app_flutter/providers/doctor_reply_provider.dart'; import 'package:doctor_app_flutter/providers/doctor_reply_provider.dart';
import 'package:doctor_app_flutter/providers/medicine_provider.dart';
import 'package:doctor_app_flutter/providers/hospital_provider.dart'; import 'package:doctor_app_flutter/providers/hospital_provider.dart';
import 'package:doctor_app_flutter/providers/medicine_provider.dart';
import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; import 'package:doctor_app_flutter/providers/referral_patient_provider.dart';
import 'package:doctor_app_flutter/providers/referred_patient_provider.dart'; import 'package:doctor_app_flutter/providers/referred_patient_provider.dart';
import 'package:doctor_app_flutter/screens/QR_reader_screen.dart';
import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import '../routes.dart';
import '../widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:percent_indicator/circular_percent_indicator.dart'; import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:platform_action_sheet/platform_action_sheet.dart';
import 'package:provider/provider.dart';
import '../presentation/doctor_app_icons.dart'; import '../routes.dart';
import '../widgets/dashboard/dashboard_item_icons_texts.dart'; import '../widgets/dashboard/dashboard_item_icons_texts.dart';
import '../widgets/dashboard/dashboard_item_texts_widget.dart'; import '../widgets/dashboard/dashboard_item_texts_widget.dart';
import '../widgets/shared/app_texts_widget.dart';
import '../widgets/shared/rounded_container_widget.dart'; import '../widgets/shared/rounded_container_widget.dart';
import 'doctor/doctor_reply_screen.dart'; import 'doctor/doctor_reply_screen.dart';
import 'doctor/my_referral_patient_screen.dart'; import 'doctor/my_referral_patient_screen.dart';
import 'doctor/my_referred_patient_screen.dart'; import 'doctor/my_referred_patient_screen.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
class DashboardScreen extends StatefulWidget { class DashboardScreen extends StatefulWidget {
DashboardScreen({Key key, this.title}) : super(key: key); DashboardScreen({Key key, this.title}) : super(key: key);
@ -33,11 +40,14 @@ class DashboardScreen extends StatefulWidget {
} }
class _DashboardScreenState extends State<DashboardScreen> { class _DashboardScreenState extends State<DashboardScreen> {
HospitalProvider projectsProvider; HospitalProvider hospitalProvider;
AuthProvider authProvider;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectsProvider = Provider.of(context); hospitalProvider = Provider.of(context);
authProvider = Provider.of(context);
print(authProvider.doctorsClinicList);
return SafeArea( return SafeArea(
bottom: true, bottom: true,
child: Scaffold( child: Scaffold(
@ -60,12 +70,20 @@ class _DashboardScreenState extends State<DashboardScreen> {
), ),
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
), ),
Container( InkWell(
margin: EdgeInsets.only(left: 10, top: 10, right: 10), onTap: () {
child: Icon( showCupertinoPicker(
Icons.settings, context: context,
size: SizeConfig.textMultiplier * 2.5, actionList: authProvider.doctorsClinicList);
)) },
child: Container(
margin:
EdgeInsets.only(left: 10, top: 10, right: 10),
child: Icon(
Icons.settings,
size: SizeConfig.textMultiplier * 2.5,
)),
)
]), ]),
Container( Container(
margin: EdgeInsets.only(left: 10, top: 5), margin: EdgeInsets.only(left: 10, top: 5),
@ -408,17 +426,119 @@ class _DashboardScreenState extends State<DashboardScreen> {
)), )),
], ],
), ),
//)
// ,
//constraints: new BoxConstraints(),
), ),
), ),
), ),
); );
// Container( }
List<ActionSheetAction> buildActionSheetAction(
{List<ClinicModel> actionList, List defaultActionList}) {
List<ActionSheetAction> AList = [];
actionList.forEach((element) {
print(element.clinicID);
AList.add(ActionSheetAction(
text: element.clinicName,
onPressed: () => Navigator.pop(context),
isCancel: true,
defaultAction: true,
));
});
return AList;
}
showCupertinoPicker(
{context, List<ClinicModel> actionList, decKey, onSelectFun}) {
showModalBottomSheet(
isDismissible: false,
isScrollControlled: true,
context: context,
builder: (BuildContext builder) {
return Container(
// height: 500,
height: SizeConfig.realScreenHeight * 0.4,
color: Color(0xfff7f7f7),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
color: Color(0xfff7f7f7),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
CupertinoButton(
child: Text(
'Cancel'.toUpperCase(),
// style: TextStyle(context)
),
onPressed: () {
Navigator.pop(context);
},
),
CupertinoButton(
child: Text(
'Done'.toUpperCase(),
// style: textStyle(context),
),
onPressed: () {
Navigator.pop(context);
// onSelectFun(cupertinoPickerIndex);
},
)
],
),
),
Container(
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child: Column(
children: actionList
.map((e) => Container(
child: InkWell(
onTap: changeClinic(e.clinicID),
child: Text(
e.clinicName,
style: TextStyle(fontSize: 15),
)),
))
.toList(),
))
],
),
);
});
}
changeClinic(clinicId) async{
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile =
new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: doctorProfile.doctorID,
clinicID: clinicId,
license: true,
projectID: doctorProfile.projectID,
tokenID: '',
languageID: 2);
// authProvider.getDocProfiles(docInfo)
authProvider.getDocProfiles(docInfo.toJson()).then((res)async {
if (res['MessageStatus'] == 1) {
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
Map profile1 = await sharedPref.getObj(DOCTOR_PROFILE);
print(1);
// ); } else {
// changeLoadingStata(false);
// helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
// changeLoadingStata(false);
helpers.showErrorToast(err);
});
} }
} }

@ -363,7 +363,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
'Please Select Clinic') 'Please Select Clinic')
.then((clinicInfo) { .then((clinicInfo) {
ClinicModel clinic = ClinicModel.fromJson(clinicInfo); ClinicModel clinic = ClinicModel.fromJson(clinicInfo);
print(clinicInfo);
getDocProfiles(clinic, changeLoadingStata); getDocProfiles(clinic, changeLoadingStata);
}); });
} }
@ -435,18 +434,15 @@ class _VerifyAccountState extends State<VerifyAccount> {
languageID: 2); languageID: 2);
authProv.getDocProfiles(docInfo.toJson()).then((res) { authProv.getDocProfiles(docInfo.toJson()).then((res) {
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
print("DoctorProfileList ${res['DoctorProfileList'][0]}");
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata); loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);
} else { } else {
changeLoadingStata(false); changeLoadingStata(false);
helpers.showErrorToast(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']);
} }
}).catchError((err) { }).catchError((err) {
print('$err');
changeLoadingStata(false); changeLoadingStata(false);
helpers.showErrorToast(err);
print('$err');
helpers.showErrorToast();
}); });
} }
} }

Loading…
Cancel
Save