WD:pharmacy intervention approval ui addition
parent
53aa39cab9
commit
e347a35d10
@ -0,0 +1,309 @@
|
||||
import 'dart:ui';
|
||||
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
||||
import 'package:doctor_app_flutter/screens/patients/ReferralDischargedPatientPage.dart';
|
||||
import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart';
|
||||
import 'package:doctor_app_flutter/screens/patients/profile/referral/refer_details/referred-patient-screen.dart';
|
||||
import 'package:doctor_app_flutter/utils/tab_utils.dart';
|
||||
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../config/config.dart';
|
||||
|
||||
class PharmacyIntervention extends StatefulWidget {
|
||||
@override
|
||||
_PharmacyIntervention createState() => _PharmacyIntervention();
|
||||
}
|
||||
|
||||
class _PharmacyIntervention extends State<PharmacyIntervention>
|
||||
with SingleTickerProviderStateMixin {
|
||||
TabController? _tabController;
|
||||
int index = 0;
|
||||
List<dynamic> listOfPharmacyIntervention = List.empty();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
_tabController!.addListener(_handleTabSelection);
|
||||
}
|
||||
|
||||
_handleTabSelection() {
|
||||
setState(() {
|
||||
index = _tabController!.index;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_tabController!.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
|
||||
|
||||
return AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBar: PatientSearchHeader(
|
||||
title: TranslationBase.of(context).pharmacyInterventionApproval,
|
||||
fontSize: 18,
|
||||
showSearchIcon: true,
|
||||
onSearchPressed: () {
|
||||
SearchDialog();
|
||||
},
|
||||
),
|
||||
appBarTitle: TranslationBase.of(context).pharmacyInterventionApproval,
|
||||
body: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 56,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: TabUtils.getBoxTabsBoxDecoration(
|
||||
isActive: index == 0,
|
||||
isFirst: true,
|
||||
projectViewModel: projectsProvider),
|
||||
child: Center(
|
||||
child: TabUtils.getTabText(
|
||||
title: TranslationBase.of(context).pending,
|
||||
isActive: index == 0)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: TabUtils.getBoxTabsBoxDecoration(
|
||||
isActive: index == 1,
|
||||
isMiddle: true,
|
||||
projectViewModel: projectsProvider),
|
||||
child: Center(
|
||||
child: TabUtils.getTabText(
|
||||
title: TranslationBase.of(context).accepted,
|
||||
isActive: index == 1)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: TabUtils.getBoxTabsBoxDecoration(
|
||||
isActive: index == 2,
|
||||
isLast: true,
|
||||
projectViewModel: projectsProvider),
|
||||
child: Center(
|
||||
child: TabUtils.getTabText(
|
||||
title: TranslationBase.of(context).rejected,
|
||||
isActive: index == 2),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: listOfPharmacyIntervention.length,
|
||||
itemBuilder: (context, item) => SizedBox.shrink()),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
void SearchDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true, // user must tap button!
|
||||
builder: (_) {
|
||||
return PharmacyInterventionDialog(
|
||||
onDispose: (dateFrom, dateTo, admissionNumber, patientId) {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class PharmacyInterventionDialog extends StatefulWidget {
|
||||
final Function(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
) onDispose;
|
||||
|
||||
const PharmacyInterventionDialog({super.key, required this.onDispose});
|
||||
|
||||
@override
|
||||
State<PharmacyInterventionDialog> createState() =>
|
||||
_PharmacyInterventionDialogState();
|
||||
}
|
||||
|
||||
class _PharmacyInterventionDialogState
|
||||
extends State<PharmacyInterventionDialog> {
|
||||
final TextEditingController admissionNumber = TextEditingController();
|
||||
|
||||
final TextEditingController patientId = TextEditingController();
|
||||
|
||||
String dateFrom = '';
|
||||
|
||||
String dateTo = '';
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initFromDate();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_titleAndTextField(
|
||||
TranslationBase.of(context).admissionNumber, admissionNumber),
|
||||
SizedBox(height: 4,),
|
||||
|
||||
_titleAndTextField(
|
||||
TranslationBase.of(context).patientID, patientId),
|
||||
SizedBox(height: 4,),
|
||||
|
||||
_dateSelection(TranslationBase.of(context).dateFrom, (date) {
|
||||
setState(() {
|
||||
dateFrom = date;
|
||||
});
|
||||
}, dateFrom),
|
||||
SizedBox(height: 4,),
|
||||
|
||||
_dateSelection(TranslationBase.of(context).dateTo, (date) {
|
||||
setState(() {
|
||||
dateTo = date;
|
||||
});
|
||||
}, dateTo),
|
||||
SizedBox(height: 8,),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: AppButton(
|
||||
title: TranslationBase.of(context).search,
|
||||
hasBorder: true,
|
||||
borderColor: Color(0xFFB8382B),
|
||||
color: AppGlobal.appRedColor,
|
||||
fontColor: Colors.white,
|
||||
onPressed: () async {},
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dateSelection(
|
||||
String title, Function(String) onDateSelected, String selectedDate) {
|
||||
return GestureDetector(
|
||||
onTap: ()=> _selectDate(onDateSelected),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(title),
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
selectedDate,
|
||||
),
|
||||
trailing: Icon(Icons.arrow_drop_down_outlined),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future _selectDate(Function(String) updateDate) async {
|
||||
// if (calenderType == CalenderType.Hijri) {
|
||||
// JDateModel hijriDate = JDateModel(dateTime: DateTime.now());
|
||||
// final JPickerValue? pickedH = await showGlobalDatePicker(
|
||||
// context: context,
|
||||
// pickerType: PickerType.JHijri,
|
||||
// startDate: birthDateInHijri ?? hijriDate,
|
||||
// endDate: JDateModel(
|
||||
// jhijri: JHijri(fDate: hijriDate.dateTime),
|
||||
// ),
|
||||
//
|
||||
// // firstDate: new HijriCalendar()
|
||||
// // ..hYear = 1438
|
||||
// // ..hMonth = 12
|
||||
// // ..hDay = 25,
|
||||
// pickerMode: DatePickerMode.day,
|
||||
// );
|
||||
// if (pickedH != null && birthDateInHijri != pickedH) updateDate(pickedH);
|
||||
// } else {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(DateTime.now().year - 150),
|
||||
lastDate: DateTime(DateTime.now().year + 150),
|
||||
initialEntryMode: DatePickerEntryMode.calendar,
|
||||
builder: (_, child) {
|
||||
return Theme(
|
||||
data: ThemeData.light().copyWith(
|
||||
colorScheme: ColorScheme.fromSwatch(
|
||||
primarySwatch: Colors.red,
|
||||
accentColor: AppGlobal.appRedColor,
|
||||
),
|
||||
dialogBackgroundColor: Colors.white,
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
}
|
||||
|
||||
);
|
||||
if (picked != null) {
|
||||
|
||||
updateDate(getFormattedDate(picked));
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
Widget _titleAndTextField(String title, TextEditingController controller) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(title),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '',
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsetsDirectional.only(start: 10.0),
|
||||
),
|
||||
textAlign: TextAlign.end,
|
||||
controller: controller,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void initFromDate() {
|
||||
var time = DateTime.now();
|
||||
dateFrom = getFormattedDate(time);
|
||||
}
|
||||
|
||||
String getFormattedDate(DateTime time){
|
||||
return DateFormat('MM/dd/yyyy').format(time);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue