193 lines
6.2 KiB
Dart
193 lines
6.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:ftc_mobile_app/models/clients/PBSPlanModel.dart';
|
|
import 'package:ftc_mobile_app/models/profileData/user_data.dart';
|
|
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
|
|
import 'package:ftc_mobile_app/view/custom_widgets/custom_app_bar_with_action.dart';
|
|
import 'package:ftc_mobile_app/view/custom_widgets/my_circle_image.dart';
|
|
import 'package:ftc_mobile_app/view/screens/clients/clients_new_view_module/add_new_pbs_plan_screen.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../../ftc_mobile_app.dart';
|
|
|
|
class PBSPlanScreen extends StatefulWidget {
|
|
final UserData userData;
|
|
|
|
const PBSPlanScreen({Key? key, required this.userData}) : super(key: key);
|
|
|
|
@override
|
|
State<PBSPlanScreen> createState() => _PBSPlanScreenState();
|
|
}
|
|
|
|
class _PBSPlanScreenState extends State<PBSPlanScreen> {
|
|
final controller = Get.put(PBSPlanScreenController());
|
|
|
|
@override
|
|
void initState() {
|
|
controller.serviceUser.value = widget.userData;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomScaffold(
|
|
// onBackButton: () => controller.onBackPress(context),
|
|
backgroundColor: CustomAppColors.kPrimaryColor,
|
|
screenKey: controller.screenKey,
|
|
onScreenTap: controller.removeFocus,
|
|
// sideDrawer: const CustomDrawer(),
|
|
showAppBar: true,
|
|
appBar: _appBar(context),
|
|
body: Column(
|
|
children: [
|
|
// SearchBarWidget(onSearchTextChange: (_) {}),
|
|
Expanded(child: Obx(() {
|
|
if (controller.pbsList.isEmpty) {
|
|
return FrequentFunctions.centerText(text: "No data found");
|
|
}
|
|
|
|
return listView(controller.pbsList());
|
|
})),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
AppBar _appBar(BuildContext context) {
|
|
return CustomAppBarWithAction(
|
|
context,
|
|
titleText: "PBS Plan",
|
|
actionText: '+ Add Form',
|
|
onActionTap: _onAddNewTap,
|
|
);
|
|
}
|
|
|
|
Widget listView(List<PbsList> list) {
|
|
return DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: CustomAppColors.kLightGreyColor)),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: REdgeInsets.symmetric(horizontal: 16.0, vertical: 12),
|
|
child: Text(
|
|
"Staff Member",
|
|
style: TextStyle(
|
|
color: CustomAppColors.kBlackColor,
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.separated(
|
|
itemCount: list.length,
|
|
separatorBuilder: (_, index) => Divider(
|
|
color: CustomAppColors.kLightGreyColor,
|
|
height: 1,
|
|
),
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return InkWell(
|
|
onTap: () {
|
|
// listItemTap(index, list[index]);
|
|
},
|
|
child: listItem(index: index, data: list[index]),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget listItem({required int index, required PbsList data}) {
|
|
return InkWell(
|
|
onTap: () async {
|
|
Navigator.pushNamed(
|
|
context,
|
|
CustomRouteNames.kAddNewPBSPlanScreenRoute,
|
|
arguments: AddNewPBSPlanScreenArgs(
|
|
userData: widget.userData, pbsData: data, viewOnly: true),
|
|
);
|
|
},
|
|
child: Container(
|
|
padding: REdgeInsets.symmetric(vertical: 9, horizontal: 16),
|
|
color: index % 2 == 0
|
|
? CustomAppColors.kLightGreyColor.withOpacity(0.1)
|
|
: Colors.white,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
MyCircleImage(
|
|
imageSize: 53.r,
|
|
url: "${WebUrls.baseUrl}${data.staffId?.profilePictureUrl ?? ""}",
|
|
errorWidget: CustomImageWidget(
|
|
imagePath: AssetsManager.kPersonMainIcon,
|
|
imageColor: CustomAppColors.kDarkBlueTextColor,
|
|
height: 53.r,
|
|
width: 53.r,
|
|
),
|
|
),
|
|
12.horizontalSpace,
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
data.staffId?.name ?? "",
|
|
style: TextStyle(
|
|
color: CustomAppColors.kDarkBlueTextColor,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
(data.createdAt.isNullOrEmpty())
|
|
? FrequentFunctions.noWidget
|
|
: Text(
|
|
DateFormatter.ddMMyyyyhhmmFormat(
|
|
DateTime.parse(data.createdAt).toLocal()),
|
|
style: TextStyle(
|
|
color: CustomAppColors.kLightGreyColor,
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// EditIcon(onTap: () async {
|
|
// dynamic res = await Navigator.pushNamed(
|
|
// context, CustomRouteNames.kAddNewPBSPlanScreenRoute,
|
|
// arguments: AddNewPBSPlanScreenArgs(
|
|
// userData: widget.userData, pbsData: data));
|
|
// if (res == true) {
|
|
// controller.fetchPBSPlanList();
|
|
// }
|
|
// }),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_onAddNewTap() async {
|
|
dynamic res = await Navigator.pushNamed(
|
|
controller.screenKey.currentContext!,
|
|
CustomRouteNames.kAddNewPBSPlanScreenRoute,
|
|
arguments: AddNewPBSPlanScreenArgs(
|
|
userData: widget.userData,
|
|
));
|
|
if (res == true) {
|
|
controller.fetchPBSPlanList();
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
controller.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|