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.
113 lines
4.0 KiB
Dart
113 lines
4.0 KiB
Dart
import 'package:diplomaticquarterapp/core/model/blooddonation/blood_donation_projects_list_response.dart';
|
|
import 'package:diplomaticquarterapp/core/service/blood/blood_donation_service.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../AlHabibMedicalService/h2o/h20_setting.dart';
|
|
|
|
class BloodDonationBookAppointment extends StatefulWidget {
|
|
const BloodDonationBookAppointment();
|
|
|
|
@override
|
|
State<BloodDonationBookAppointment> createState() => _BloodDonationBookAppointmentState();
|
|
}
|
|
|
|
class _BloodDonationBookAppointmentState extends State<BloodDonationBookAppointment> {
|
|
List<BloodDonationProjectsListResponse> bloodDonationProjectsListResponse = [];
|
|
int _selectedProjectID = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
getBloodDonationProjectsList();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppScaffold(
|
|
isShowAppBar: true,
|
|
showNewAppBar: true,
|
|
backgroundColor: Color(0xffF7F7F7),
|
|
showNewAppBarTitle: true,
|
|
isShowDecPage: true,
|
|
description: TranslationBase.of(context).bloodDonationInfo,
|
|
appBarTitle: TranslationBase.of(context).bloodD,
|
|
body: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(21),
|
|
child: Column(
|
|
children: [
|
|
CommonDropDownView(TranslationBase.of(context).selectProject, "Select Hospital", () {
|
|
List<RadioSelectionDialogModel> list = [];
|
|
|
|
bloodDonationProjectsListResponse.forEach((element) {
|
|
list.add(RadioSelectionDialogModel(element.projectName, element.projectID));
|
|
});
|
|
|
|
showDialog(
|
|
context: context,
|
|
builder: (cxt) => RadioSelectionDialog(
|
|
listData: list,
|
|
selectedIndex: 0,
|
|
onValueSelected: (index) {
|
|
print(index);
|
|
_selectedProjectID = index;
|
|
setState(() {});
|
|
},
|
|
),
|
|
);
|
|
}).withBorderedContainer,
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
getBloodDonationFreeSlots() {
|
|
BloodDonationService service = new BloodDonationService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service.getBloodDonationProjectsList().then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(res['BD_getProjectsHaveBDClinics']);
|
|
if (res["MessageStatus"] == 1) {
|
|
res['BD_getProjectsHaveBDClinics'].forEach((element) {
|
|
bloodDonationProjectsListResponse.add(BloodDonationProjectsListResponse.fromJson(element));
|
|
});
|
|
print(bloodDonationProjectsListResponse.length);
|
|
} else {
|
|
AppToast.showErrorToast(message: res["ErrorEndUserMessage"]);
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
getBloodDonationProjectsList() {
|
|
BloodDonationService service = new BloodDonationService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service.getBloodDonationProjectsList().then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(res['BD_getProjectsHaveBDClinics']);
|
|
if (res["MessageStatus"] == 1) {
|
|
res['BD_getProjectsHaveBDClinics'].forEach((element) {
|
|
bloodDonationProjectsListResponse.add(BloodDonationProjectsListResponse.fromJson(element));
|
|
});
|
|
print(bloodDonationProjectsListResponse.length);
|
|
} else {
|
|
AppToast.showErrorToast(message: res["ErrorEndUserMessage"]);
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
}
|