diff --git a/lib/domain/models/leaves/leave.dart b/lib/domain/models/leaves/leave.dart index 465d6962..d3c0c41f 100644 --- a/lib/domain/models/leaves/leave.dart +++ b/lib/domain/models/leaves/leave.dart @@ -7,11 +7,11 @@ class Leave with _$Leave { @JsonSerializable(fieldRename: FieldRename.snake) const factory Leave({ required int id, - required DateTime dateCreated, + required int dateCreated, required String startMealType, required String endMealType, - required DateTime startDatetime, - required DateTime endDatetime, + required int startDatetime, + required int endDatetime, required int mealCount, required String status, }) = _Leave; diff --git a/lib/domain/repositories/leave/leave_repository.dart b/lib/domain/repositories/leave/leave_repository.dart index d63f16c2..57a0e50b 100644 --- a/lib/domain/repositories/leave/leave_repository.dart +++ b/lib/domain/repositories/leave/leave_repository.dart @@ -29,8 +29,13 @@ class LeaveRepository { Future getLeaves(int year, int month) async { try { - if (month == 0) return await _apiService.getLeavesForYear(year); - return await _apiService.getLeaves(year, month); + dynamic response; + if (month == 0) { + response = await _apiService.getLeavesForYear(year); + } else { + response = await _apiService.getLeaves(year, month); + } + return response; } catch (e) { // TODO: Handle error return const PaginatedLeaves( diff --git a/lib/presentation/leaves_and_rebate/bloc/leaves_and_rebate_bloc.dart b/lib/presentation/leaves_and_rebate/bloc/leaves_and_rebate_bloc.dart index e3fc0d28..a5edab64 100644 --- a/lib/presentation/leaves_and_rebate/bloc/leaves_and_rebate_bloc.dart +++ b/lib/presentation/leaves_and_rebate/bloc/leaves_and_rebate_bloc.dart @@ -26,7 +26,7 @@ class LeavesAndRebateBloc FutureOr _onFetchLeavesAndRebates( FetchLeavesAndRebates event, Emitter emit) async { PaginatedLeaves currYearLeaves = - await leaveRepository.getLeaves(DateTime.now().year, 0); + await leaveRepository.getLeaves(DateTime.now().year.toInt(), 0); int remainingLeaves = await leaveRepository.remainingLeaves(); PaginatedYearlyRebate initialYearlyRebates = await transactionRepository.getYearlyRebates( diff --git a/lib/presentation/leaves_and_rebate/components/leave_history.dart b/lib/presentation/leaves_and_rebate/components/leave_history.dart index c7e27125..fa50446c 100644 --- a/lib/presentation/leaves_and_rebate/components/leave_history.dart +++ b/lib/presentation/leaves_and_rebate/components/leave_history.dart @@ -1,6 +1,7 @@ import 'package:appetizer/app_theme.dart'; import 'package:appetizer/data/core/theme/dimensional/dimensional.dart'; import 'package:appetizer/domain/models/leaves/paginated_leaves.dart'; +import 'package:appetizer/presentation/components/shadow_container.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -11,76 +12,77 @@ class LeaveHistory extends StatelessWidget { @override Widget build(BuildContext context) { //TODO: wrap with Shadow Container - return Container( - margin: const EdgeInsets.symmetric(horizontal: 24), - decoration: ShapeDecoration( - color: AppTheme.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), - shadows: [ - BoxShadow( - color: const Color(0x19000000), - blurRadius: 7.toAutoScaledWidth, - offset: const Offset(2, 2), - spreadRadius: 1, - ) - ]), - child: SingleChildScrollView( - child: ExpansionTile( - expandedCrossAxisAlignment: CrossAxisAlignment.start, - backgroundColor: AppTheme.white, - title: const SizedBox.shrink(), - leading: Text("Leave History", - style: AppTheme.headline3.copyWith( - fontSize: 16.toAutoScaledFont, - color: AppTheme.grey2f, - height: (11.0 / 8.0).toAutoScaledHeight)), - trailing: const Icon(Icons.expand_more, color: AppTheme.grey2f), - children: [ - if (paginatedLeaves.results.isNotEmpty) - Container( - margin: EdgeInsets.only(left: 24.toAutoScaledWidth), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - paginatedLeaves.results[0].startDatetime.year - .toString(), - style: AppTheme.headline2.copyWith( - fontSize: 14.toAutoScaledFont, - color: AppTheme.primary), - ), - 10.toVerticalSizedBox, - ...paginatedLeaves.results - .map((leave) => Padding( - padding: EdgeInsets.only( - bottom: 10.toAutoScaledHeight), - child: Row( - children: [ - RichText( - text: TextSpan( - text: DateFormat('dd MMM -') - .format(leave.startDatetime), - style: AppTheme.bodyText1.copyWith( - height: 1.toAutoScaledHeight), - children: [ - TextSpan( - text: leave.startMealType, - style: const TextStyle( - color: AppTheme.primary), - ) - ]), + return ShadowContainer( + width: 312.toAutoScaledWidth, + offset: 2, + child: ExpansionTile( + expandedCrossAxisAlignment: CrossAxisAlignment.start, + backgroundColor: AppTheme.white, + title: const SizedBox.shrink(), + leading: Text("Leave History", + style: AppTheme.headline3.copyWith( + fontSize: 16.toAutoScaledFont, + color: AppTheme.grey2f, + height: (11.0 / 8.0).toAutoScaledHeight)), + trailing: const Icon(Icons.expand_more, color: AppTheme.grey2f), + children: [ + if (paginatedLeaves.results.isNotEmpty) + Container( + height: 120, + margin: EdgeInsets.only(left: 24.toAutoScaledWidth), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + // convert int to datetime + DateTime.fromMillisecondsSinceEpoch( + paginatedLeaves.results[0].startDatetime) + .year + .toString(), + style: AppTheme.headline2.copyWith( + fontSize: 14.toAutoScaledFont, + color: AppTheme.primary), + ), + 10.toVerticalSizedBox, + Expanded( + child: ListView( + padding: EdgeInsets.zero, + children: [ + ...paginatedLeaves.results + .map((leave) => Padding( + padding: EdgeInsets.only( + bottom: 10.toAutoScaledHeight), + child: Row( + children: [ + RichText( + text: TextSpan( + text: DateFormat('dd MMM -') + .format(DateTime + .fromMillisecondsSinceEpoch( + leave.startDatetime)), + style: AppTheme.bodyText1 + .copyWith( + height: + 1.toAutoScaledHeight), + children: [ + TextSpan( + text: leave.startMealType, + style: const TextStyle( + color: AppTheme.primary), + ) + ]), + ), + // const Text("-"), + ], ), - // const Text("-"), - ], - ), - )) - .toList(), - ]), - ) - ], - ), + )) + .toList(), + ], + ), + ), + ]), + ) + ], ), ); } diff --git a/lib/presentation/week_menu/components/DayMenu/menu_card.dart b/lib/presentation/week_menu/components/DayMenu/menu_card.dart index e35b4de8..1f146147 100644 --- a/lib/presentation/week_menu/components/DayMenu/menu_card.dart +++ b/lib/presentation/week_menu/components/DayMenu/menu_card.dart @@ -204,7 +204,9 @@ class MealCard extends StatelessWidget { decoration: BoxDecoration( image: DecorationImage( image: svg.Svg( - 'assets/images/meal_card/${meal.title}.svg', + meal.type == MealType.S + ? 'assets/images/meal_card/Lunch.svg' + : 'assets/images/meal_card/${meal.title}.svg', ), fit: BoxFit.fill, ), @@ -283,20 +285,22 @@ class MealCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 18.toAutoScaledHeight), - Container( - constraints: BoxConstraints( - maxHeight: 100.toAutoScaledHeight, - maxWidth: 180.toAutoScaledWidth, - ), - padding: EdgeInsets.only(left: 10.toAutoScaledWidth), - child: ListView.builder( - itemCount: meal.items.length, - shrinkWrap: true, - padding: EdgeInsets.zero, - itemBuilder: (context, index) { - final item = meal.items[index]; - return Text("\u2022 ${item.name.titleCase}"); - }, + SingleChildScrollView( + child: Container( + constraints: BoxConstraints( + maxHeight: 100.toAutoScaledHeight, + maxWidth: 180.toAutoScaledWidth, + ), + padding: EdgeInsets.only(left: 10.toAutoScaledWidth), + child: ListView.builder( + itemCount: meal.items.length, + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, index) { + final item = meal.items[index]; + return Text("\u2022 ${item.name.titleCase}"); + }, + ), ), ), const Spacer(),