This repository has been archived on 2024-10-18. You can view files and clone it, but cannot push or open issues or pull requests.
ftc_patient_app/lib/view/screens/clients/currentHealthIssues/widget/IssueDetailPopupWidget.dart

261 lines
11 KiB
Dart

import 'package:flutter/material.dart';
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
import 'package:ftc_mobile_app/models/clients/HealthIssuesDetailsModel.dart';
import 'package:ftc_mobile_app/models/profileData/user_data.dart';
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
class IssueDetailPopupWidget extends StatefulWidget {
const IssueDetailPopupWidget({
super.key,
required this.userData,
required this.data,
required this.onActionChange,
required this.onUpdateButtonTap,
});
final UserData userData;
final HealthIssueDetailsModel data;
final Function(bool status, HealthIssueDetailsModel data) onActionChange;
final Function(HealthIssueDetailsModel data) onUpdateButtonTap;
static const actionActive = "Active";
static const actionResolved = "Resolved";
@override
State<IssueDetailPopupWidget> createState() => _IssueDetailPopupWidgetState();
}
class _IssueDetailPopupWidgetState extends State<IssueDetailPopupWidget> {
final Map<String, bool> actionsMap = {
IssueDetailPopupWidget.actionActive: true,
IssueDetailPopupWidget.actionResolved: false
};
String selectedValue = IssueDetailPopupWidget.actionActive;
@override
void initState() {
selectedValue = widget.data.status
? IssueDetailPopupWidget.actionActive
: IssueDetailPopupWidget.actionResolved;
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: Get.width,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.maxFinite,
padding: REdgeInsets.symmetric(horizontal: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Health Note',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w400,
),
),
CustomTextWidget(
text: widget.data.healthNote,
fontSize: 14.sp,
fontWeight: FontWeight.bold,
textAlign: TextAlign.left,
isExpanded: false),
],
),
),
Container(
width: 90.r,
height: 32.r,
decoration: BoxDecoration(
borderRadius: 24.toRadius(),
color: (selectedValue ==
IssueDetailPopupWidget.actionActive)
? Colors.red.withOpacity(0.3)
: Colors.green.withOpacity(0.3),
),
child: DropdownButtonHideUnderline(
child: DropdownButtonFormField(
onTap: () {
FocusScopeNode().unfocus();
},
value: selectedValue,
dropdownColor: Colors.white,
borderRadius: 4.toRadius(),
decoration: InputDecoration(
isDense: true,
border: InputBorder.none,
suffixIcon: Icon(Icons.arrow_drop_down_sharp,
size: 18,
color: (selectedValue ==
IssueDetailPopupWidget.actionActive)
? Colors.red
: Colors.green)
.paddingOnly(right: 12.r),
suffixIconConstraints: BoxConstraints.tightFor(
width: 24.r, height: 32.r),
// contentPadding: REdgeInsets.only(left: 0),
),
elevation: 4,
icon: FrequentFunctions.noWidget,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 10.sp,
color: Colors.black),
hint: Text(
"Select...",
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 12.sp,
color: CustomAppColors.kLightTextColor,
),
),
selectedItemBuilder: (_) {
return actionsMap.keys.map(
(e) {
return DropdownMenuItem<String>(
value: e,
child: Container(
// color: (selectedValue == e)
// ? (selectedValue ==
// IssueDetailPopupWidget
// .actionActive)
// ? Colors.red.withOpacity(0.3)
// : Colors.green.withOpacity(0.3)
// : Colors.white,
alignment: Alignment.center,
child: Text(
e,
style: TextStyle(
color: (selectedValue == e)
? (selectedValue ==
IssueDetailPopupWidget
.actionActive)
? Colors.red
: Colors.green
: Colors.black),
),
),
);
},
).toList();
},
items: actionsMap.keys
.map(
(e) => DropdownMenuItem<String>(
value: e,
child: Text(e),
),
)
.toList(),
// padding: EdgeInsets.zero,
isExpanded: true,
// iconSize: 20.h,
// icon: Padding(
// padding: REdgeInsets.only(right: 0.0),
// child: Icon(Icons.arrow_drop_down_sharp,
// size: 18,
// color: Colors.black),
// ),
onChanged: (v) {
if (v != null) {
setState(() {
selectedValue = v;
widget.onActionChange(
actionsMap[v]!, widget.data);
});
}
},
),
),
)
],
),
),
8.verticalSpace,
Divider(
height: 1,
color: Colors.grey.withOpacity(0.3),
),
Container(
width: double.maxFinite,
padding: REdgeInsets.symmetric(horizontal: 12, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
textAlign: TextAlign.left,
TextSpan(
children: [
TextSpan(
text: "Complaint: ",
style: TextStyle(
fontSize: 12.sp, fontWeight: FontWeight.w600),
),
TextSpan(
text: widget.data.complaint,
style: TextStyle(
fontSize: 12.sp, fontWeight: FontWeight.w400),
),
],
),
),
4.verticalSpace,
Text.rich(
textAlign: TextAlign.left,
TextSpan(
children: [
TextSpan(
text: "Last Update: ",
style: TextStyle(
fontSize: 12.sp, fontWeight: FontWeight.w600),
),
TextSpan(
text: DateFormat("MMM/dd/yyyy").format(
DateTime.parse(widget.data.updatedAt)
.toLocal()),
style: TextStyle(
fontSize: 12.sp, fontWeight: FontWeight.w400),
),
],
),
),
],
),
),
16.verticalSpace,
Center(
child: SizedBox(
width: 120.r,
height: 32.r,
child: CustomAppButton(
onTap: () => widget.onUpdateButtonTap(widget.data),
buttonText: "Update",
),
),
),
],
),
),
],
);
}
}