rota module added.

design_3.0_rota_module
Sikander Saleem 2 months ago
parent 6f43fd777a
commit c377c67f40

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

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

Loading…
Cancel
Save