rota module added.

design_3.0_rota_module
Sikander Saleem 3 weeks ago
parent 6f43fd777a
commit c377c67f40

@ -446,17 +446,17 @@ class UserProvider extends ChangeNotifier {
}
}
Future<List<UserRotaModel>> getUserRota() async {
Future<UserRotaModel?> getUserRota() async {
Response response;
try {
response = await ApiManager.instance.get(URLs.getUserRota);
if (response.statusCode >= 200 && response.statusCode < 300) {
List dataList = json.decode(response.body);
return List.generate(dataList.length, (index) => UserRotaModel.fromJson(dataList[index]));
return UserRotaModel.fromJson(dataList.first);
}
return [];
return null;
} catch (error) {
return [];
return null ;
}
}

@ -219,12 +219,11 @@ class _ProfilePageState extends State<ProfilePage> {
],
).toShadowContainer(context),
if (context.settingProvider.isUserFlowMedical)
FutureBuilder<List<UserRotaModel>>(
FutureBuilder<UserRotaModel?>(
future: _userProvider.getUserRota(),
builder: (cxt, snapshot) {
bool isLoading = snapshot.connectionState == ConnectionState.waiting;
if ((!isLoading && (snapshot.hasError || (snapshot.data?.isEmpty ?? true)))) {
if ((!isLoading && (snapshot.hasError || !snapshot.hasData))) {
return const SizedBox();
}
@ -238,56 +237,6 @@ class _ProfilePageState extends State<ProfilePage> {
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
),
8.height,
if (!isLoading)
ListView.separated(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (cxt, index) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Text(
// 'Site: ${_user.clientName ?? "-"}',
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
// ),
Text(
'Shift Name: ${snapshot.data![index].shiftName ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Break: ${snapshot.data![index].breakTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
if (snapshot.data![index].leaveTypeCode?.isNotEmpty ?? false)
SizedBox(
width: double.infinity,
child: Column(children: [
8.height,
Text(
snapshot.data![index].leaveTypeCode ?? "",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120, fontWeight: FontWeight.w600),
),
Text(
snapshot.data![index].leaveDescription ?? "",
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
]),
)
else ...[
Text(
'Shift Start Time: ${snapshot.data![index].shTActualStartTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Shift Start Time: ${snapshot.data![index].shTActualEndTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
],
],
),
separatorBuilder: (cxt, index) => const Divider().defaultStyle(context),
itemCount: snapshot.data!.length),
if (isLoading) ...[
Text(
'Shift Start Time Time',
@ -297,8 +246,60 @@ class _ProfilePageState extends State<ProfilePage> {
Text(
'Shift Actual Actual Start Time',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
).toShimmer(context: context, isShow: isLoading),
]
).toShimmer(context: context, isShow: isLoading)
] else
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Text(
// 'Site: ${_user.clientName ?? "-"}',
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
// ),
Text(
'Shift Name: ${snapshot.data!.shiftName ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Break: ${snapshot.data!.breakTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
if (snapshot.data!.leaveTypeCode?.isNotEmpty ?? false)
SizedBox(
width: double.infinity,
child: Column(children: [
8.height,
Text(
snapshot.data!.leaveTypeCode ?? "",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120, fontWeight: FontWeight.w600),
),
Text(
snapshot.data!.leaveDescription ?? "",
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
]),
)
else ...[
Text(
'Shift Start Time: ${snapshot.data!.shiftActualStartDatetime?.chatMsgTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Shift Start Time: ${snapshot.data!.shiftActualEndDateTime?.chatMsgTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
const Divider().defaultStyle(context),
Text(
'Swipe In: ${snapshot.data!.shTActualStartTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
Text(
'Swipe Out: ${snapshot.data!.shTActualEndTime?.toTime ?? "-"}',
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
),
],
],
),
],
).toShadowContainer(context),
);

Loading…
Cancel
Save