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/client_profile_screen.dart

322 lines
9.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
import 'package:ftc_mobile_app/view/custom_widgets/my_circle_image.dart';
import 'package:get/get.dart';
import '../../../models/profileData/user_data.dart';
import 'all_care_notes_screen.dart';
class ClientProfileScreen extends StatefulWidget {
final UserData userData;
const ClientProfileScreen({Key? key, required this.userData})
: super(key: key);
@override
State<ClientProfileScreen> createState() => _ClientProfileScreenState();
}
class _ClientProfileScreenState extends State<ClientProfileScreen> {
late final ClientProfileScreenController controller;
@override
void initState() {
controller = Get.put(ClientProfileScreenController(data: widget.userData));
super.initState();
}
@override
Widget build(BuildContext context) {
return CustomScaffold(
onBackButton: () => controller.backButtonPressed(context),
backgroundColor: CustomAppColors.kPrimaryColor,
screenKey: controller.screenKey,
onScreenTap: controller.removeFocus,
showAppBar: false,
appBar: CustomAppBar(
leadingButton: Container(),
showBoxShadow: false,
titleWidget: Row(
children: [
InkWell(
onTap: () => controller.backButtonPressed(context),
child: CustomImageWidget(
imagePath: AssetsManager.kBackIcon,
height: 11.53.h,
width: 8.66.w,
),
),
const SizedBox(
width: 15,
),
CustomTextWidget(
text: 'Client: ${controller.serviceUser()?.displayName ?? ""}',
isExpanded: false,
fontSize: 16.sp,
fontWeight: FontWeight.w700,
fontColor: CustomAppColors.kDarkBlueTextColor),
],
),
),
body: Obx(() {
if (controller.serviceUser() == null) {
return FrequentFunctions.centerText(text: "User detail not found");
}
final detail = controller.serviceUser()!;
return SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: 16.h),
MyCircleImage(
imageSize: 80.r,
url: "${WebUrls.baseUrl}${detail.profilePictureUrl ?? ""}",
errorWidget: CustomImageWidget(
imagePath: AssetsManager.kPersonMainIcon,
height: 53.h,
width: 53.w,
),
),
16.verticalSpace,
CustomTextWidget(
text: detail.displayName,
fontSize: 14.sp,
fontWeight: FontWeight.w600),
16.verticalSpace,
BuildDetailRow(
title: 'Contact Number',
value: detail.modelId?.phoneNo ?? "",
),
BuildDetailRow(
title: 'Home Address',
value: detail.modelId?.homeAddress ?? ""),
BuildDetailRow(
title: 'Next of Kin',
value: detail.modelId?.suFamilyHead ?? ""),
const BuildDetailRow(title: 'Diagnosis History', value: ''),
BuildRoundOutlinedBox(
context: context,
child: BuildDiagnosisHistoryList(
history:
(detail.modelId?.diagnosises.isNotNullOrEmpty() == true)
? detail.modelId!.diagnosises.first.diagnosisText
: "",
date: (detail.modelId?.aboutPatient.aboutDate
.isNotNullOrEmpty() ==
true)
? DateFormatter().getAppointmentTime(
detail.modelId!.aboutPatient.aboutDate)
: "",
),
),
const BuildDetailRow(title: 'About the Patient', value: ''),
BuildRoundOutlinedBox(
context: context,
child: BuildDiagnosisHistoryList(
history: detail.modelId?.aboutPatient.aboutText ?? "",
date: (detail.modelId?.aboutPatient.aboutDate
.isNotNullOrEmpty() ==
true)
? DateFormatter().getAppointmentTime(
detail.modelId!.aboutPatient.aboutDate)
: "",
),
),
16.verticalSpace,
BuildIconButton(
iconPath: AssetsManager.kNotesIcon,
text: 'Notes',
route: CustomRouteNames.kAllCareNotesScreenRoute,
arguments: AllCareNotesScreenArgs(
serviceUserId: controller.serviceUser()!.id!),
),
BuildIconButton(
iconPath: AssetsManager.kCarePlanIcon,
text: 'Care Plan',
route: CustomRouteNames.kCarePlanMenuScreenRoute,
arguments: controller.serviceUser()!,
),
BuildIconButton(
iconPath: AssetsManager.kCalendarAppointmentIcon,
text: 'Appointments',
route: CustomRouteNames.kAppointmentsScreenRoute,
arguments: controller.serviceUser()!,
),
BuildIconButton(
iconPath: AssetsManager.kPhotoGalleryIcon,
text: 'Photo Gallery',
route: CustomRouteNames.kPhotoGalleryScreenRoute,
arguments: controller.serviceUser()!,
),
],
),
);
}),
);
}
}
class BuildIconButton extends StatelessWidget {
const BuildIconButton({
super.key,
required this.iconPath,
required this.text,
required this.route,
required this.arguments,
});
final String iconPath;
final String text;
final String route;
final dynamic arguments;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
if (route.isNotEmpty) {
Navigator.pushNamed(context, route, arguments: arguments);
}
},
child: Container(
margin: EdgeInsets.symmetric(vertical: 5.h, horizontal: 25.w),
padding: EdgeInsets.symmetric(horizontal: 10.r, vertical: 8.r),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2.r),
border: Border.all(
color: CustomAppColors.kLightGreyColor.withOpacity(0.5))),
child: Row(
children: [
CustomImageWidget(
imagePath: iconPath,
height: 20.r,
width: 20.r,
),
12.horizontalSpace,
CustomTextWidget(
text: text,
isExpanded: false,
fontWeight: FontWeight.w600,
fontColor: CustomAppColors.kDarkBlueTextColor,
fontSize: 14.sp),
const Spacer(),
Icon(
Icons.arrow_forward_ios_rounded,
size: 12.sp,
)
],
),
),
);
}
}
class BuildDiagnosisHistoryList extends StatelessWidget {
const BuildDiagnosisHistoryList({
super.key,
required this.date,
required this.history,
});
final String date;
final String history;
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomTextWidget(
text: date,
isExpanded: false,
fontWeight: FontWeight.w600,
fontSize: 10.sp,
fontColor: CustomAppColors.kLightGreyColor,
),
CustomTextWidget(
alignment: Alignment.centerLeft,
textAlign: TextAlign.left,
text: history,
isExpanded: false,
fontSize: 10.sp,
fontColor: CustomAppColors.kBlackColor,
),
],
);
}
}
class BuildRoundOutlinedBox extends StatelessWidget {
const BuildRoundOutlinedBox({
super.key,
required this.context,
required this.child,
});
final BuildContext context;
final Widget child;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.centerLeft,
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 22.r),
padding: EdgeInsets.all(10.sp),
decoration: BoxDecoration(
border: Border.all(color: CustomAppColors.kLightGreyColor),
borderRadius: BorderRadius.circular(10.r),
),
child: child,
);
}
}
class BuildDetailRow extends StatelessWidget {
const BuildDetailRow({
super.key,
required this.title,
required this.value,
});
final String title;
final String value;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 20.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 4,
child: CustomTextWidget(
isExpanded: false,
text: '$title: ',
fontWeight: FontWeight.w600,
textAlign: TextAlign.left,
fontColor: CustomAppColors.kDarkBlueTextColor,
fontSize: 14.sp,
),
),
Expanded(
flex: 6,
child: CustomTextWidget(
text: value,
isExpanded: false,
maxLines: 2,
textAlign: TextAlign.right,
fontWeight: FontWeight.w600,
fontColor: CustomAppColors.kLightTextColor,
fontSize: 14.sp),
)
],
),
);
}
}