From 44f919335b9386d899ed000ff1904e57696598f0 Mon Sep 17 00:00:00 2001 From: Aman Date: Fri, 25 Aug 2023 06:29:36 +0530 Subject: [PATCH] fix: linter issues Signed-off-by: Aman --- .../repositories/coupon_repository.dart | 9 +- .../repositories/feedback_repository.dart | 7 +- lib/domain/repositories/leave_repository.dart | 11 +- lib/domain/repositories/menu_repository.dart | 13 +- .../repositories/transaction_repositroy.dart | 9 +- lib/domain/repositories/user_repository.dart | 23 +- lib/presentation/app/app.dart | 2 +- lib/presentation/components/black_button.dart | 2 +- .../components/no_data_found_container.dart | 1 - .../coupons/components/coupon_card.dart | 2 +- .../FeedbackTile/bloc/feedback_tile_bloc.dart | 1 - .../bloc/feedback_tile_event.dart | 1 - .../FeedbackTile/feedback_tile.dart | 2 +- lib/presentation/feedback/feedback_view.dart | 8 +- .../components/leave_history.dart | 4 +- .../bloc/notification_page_bloc.dart | 12 +- .../components/no_notification_widget.dart | 2 +- .../components/notification_card.dart | 6 +- .../profile/components/profile_button.dart | 6 +- .../profile/components/profile_card.dart | 4 +- .../profile/components/profile_photo.dart | 2 +- lib/presentation/profile/profile_view.dart | 6 +- .../yourMealDailyCardsCombined/menu_card.dart | 285 +++++++++--------- lib/utils/api_utils.dart | 157 ---------- lib/utils/app_exceptions.dart | 52 ---- 25 files changed, 208 insertions(+), 419 deletions(-) delete mode 100644 lib/utils/api_utils.dart delete mode 100644 lib/utils/app_exceptions.dart diff --git a/lib/domain/repositories/coupon_repository.dart b/lib/domain/repositories/coupon_repository.dart index 0b819026..86b91e53 100644 --- a/lib/domain/repositories/coupon_repository.dart +++ b/lib/domain/repositories/coupon_repository.dart @@ -3,11 +3,12 @@ import 'package:appetizer/data/services/remote/api_service.dart'; import 'package:appetizer/domain/models/coupon/coupon.dart'; import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/menu/week_menu.dart'; +import 'package:flutter/foundation.dart'; -class CouponRepositroy { +class CouponRepository { final ApiService _apiService; - CouponRepositroy(this._apiService); + CouponRepository(this._apiService); Future applyForCoupon(Coupon coupon) async { Map map = { @@ -17,7 +18,7 @@ class CouponRepositroy { try { return await _apiService.applyForCoupon(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -29,7 +30,7 @@ class CouponRepositroy { try { return await _apiService.cancelCoupon(coupon.meal, map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/domain/repositories/feedback_repository.dart b/lib/domain/repositories/feedback_repository.dart index 03b3eb44..64dad343 100644 --- a/lib/domain/repositories/feedback_repository.dart +++ b/lib/domain/repositories/feedback_repository.dart @@ -3,6 +3,7 @@ import 'package:appetizer/data/services/remote/api_service.dart'; import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/feedback/appetizer_feedback.dart'; import 'package:appetizer/domain/models/feedback/feedback_response.dart'; +import 'package:flutter/foundation.dart'; class FeedbackRepository { final ApiService _apiService; @@ -13,7 +14,7 @@ class FeedbackRepository { try { return await _apiService.submittedFeedbacks(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -22,7 +23,7 @@ class FeedbackRepository { try { return await _apiService.responseOfFeedbacks(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -37,7 +38,7 @@ class FeedbackRepository { try { return await _apiService.newFeedback(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/domain/repositories/leave_repository.dart b/lib/domain/repositories/leave_repository.dart index bc6eb919..0b7a7dda 100644 --- a/lib/domain/repositories/leave_repository.dart +++ b/lib/domain/repositories/leave_repository.dart @@ -3,9 +3,10 @@ import 'package:appetizer/data/services/remote/api_service.dart'; import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/leaves/paginated_leaves.dart'; import 'package:appetizer/domain/models/menu/week_menu.dart'; +import 'package:flutter/foundation.dart'; class LeaveRepository { - ApiService _apiService; + final ApiService _apiService; LeaveRepository(this._apiService); @@ -40,7 +41,7 @@ class LeaveRepository { try { return await _apiService.check(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -52,7 +53,7 @@ class LeaveRepository { try { return await _apiService.check(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -66,7 +67,7 @@ class LeaveRepository { try { return await _apiService.leave(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -77,7 +78,7 @@ class LeaveRepository { try { return await _apiService.cancelLeave(meal.id); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/domain/repositories/menu_repository.dart b/lib/domain/repositories/menu_repository.dart index 6be211f4..f33173ea 100644 --- a/lib/domain/repositories/menu_repository.dart +++ b/lib/domain/repositories/menu_repository.dart @@ -2,9 +2,10 @@ import 'package:appetizer/data/constants/constants.dart'; import 'package:appetizer/data/services/remote/api_service.dart'; import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/menu/week_menu.dart'; +import 'package:flutter/foundation.dart'; class MenuRepository { - ApiService _apiService; + final ApiService _apiService; MenuRepository(this._apiService); @@ -14,7 +15,7 @@ class MenuRepository { try { return await _apiService.weekMenuMultimessing(hostelCode, id); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -23,7 +24,7 @@ class MenuRepository { try { return await _apiService.weekMenuForYourMeals(weekId); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -34,7 +35,7 @@ class MenuRepository { try { return await _apiService.weekMenuByWeekId(weekId); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -43,7 +44,7 @@ class MenuRepository { try { return await _apiService.currentWeekMenu(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -52,7 +53,7 @@ class MenuRepository { try { return await _apiService.dayMenu(week, dayOfWeek); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/domain/repositories/transaction_repositroy.dart b/lib/domain/repositories/transaction_repositroy.dart index cb74919a..76432cd1 100644 --- a/lib/domain/repositories/transaction_repositroy.dart +++ b/lib/domain/repositories/transaction_repositroy.dart @@ -3,9 +3,10 @@ import 'package:appetizer/data/services/remote/api_service.dart'; import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/transaction/faq.dart'; import 'package:appetizer/domain/models/transaction/paginated_yearly_rebate.dart'; +import 'package:flutter/foundation.dart'; class TransactionRepository { - ApiService _apiService; + final ApiService _apiService; TransactionRepository(this._apiService); @@ -15,7 +16,7 @@ class TransactionRepository { try { return await _apiService.getMonthlyRebate(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -24,7 +25,7 @@ class TransactionRepository { try { return await _apiService.getYearlyRebate(year); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -33,7 +34,7 @@ class TransactionRepository { try { return await _apiService.getFAQs(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/domain/repositories/user_repository.dart b/lib/domain/repositories/user_repository.dart index e0ca427b..5caf14bd 100644 --- a/lib/domain/repositories/user_repository.dart +++ b/lib/domain/repositories/user_repository.dart @@ -4,9 +4,10 @@ import 'package:appetizer/domain/models/failure_model.dart'; import 'package:appetizer/domain/models/user/notification.dart'; import 'package:appetizer/domain/models/user/oauth_user.dart'; import 'package:appetizer/domain/models/user/user.dart'; +import 'package:flutter/foundation.dart'; class UserRepository { - ApiService _apiService; + final ApiService _apiService; UserRepository(this._apiService); @@ -20,7 +21,7 @@ class UserRepository { try { return await _apiService.login(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -29,7 +30,7 @@ class UserRepository { try { return await _apiService.logout(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -38,7 +39,7 @@ class UserRepository { try { return await _apiService.getCurrentUser(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -47,7 +48,7 @@ class UserRepository { try { return await _apiService.updateUser(user); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -60,7 +61,7 @@ class UserRepository { try { return await _apiService.updateFcmTokenForUser(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -73,7 +74,7 @@ class UserRepository { try { return await _apiService.changePassword(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -85,7 +86,7 @@ class UserRepository { try { return await _apiService.resetPassword(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -94,7 +95,7 @@ class UserRepository { try { return await _apiService.oAuthRedirect(code); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -109,7 +110,7 @@ class UserRepository { try { return await _apiService.oAuthComplete(map); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } @@ -118,7 +119,7 @@ class UserRepository { try { return await _apiService.getNotifications(); } catch (e) { - print(e); + debugPrint(e.toString()); throw Failure(AppConstants.GENERIC_FAILURE); } } diff --git a/lib/presentation/app/app.dart b/lib/presentation/app/app.dart index 13ebc8d9..09489701 100644 --- a/lib/presentation/app/app.dart +++ b/lib/presentation/app/app.dart @@ -29,7 +29,7 @@ class _AppetizerAppState extends State { @override Widget build(BuildContext context) { return MultiRepositoryProvider( - providers: [], + providers: const [], child: BlocBuilder( builder: (context, state) { return MaterialApp.router( diff --git a/lib/presentation/components/black_button.dart b/lib/presentation/components/black_button.dart index fe8051e0..3dab8cbc 100644 --- a/lib/presentation/components/black_button.dart +++ b/lib/presentation/components/black_button.dart @@ -31,7 +31,7 @@ class BlackButton extends StatelessWidget { title, textAlign: TextAlign.center, style: TextStyle( - color: Color(0xFFF6F6F6), + color: const Color(0xFFF6F6F6), fontSize: 12.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w700, diff --git a/lib/presentation/components/no_data_found_container.dart b/lib/presentation/components/no_data_found_container.dart index 00b2d92c..fb847785 100644 --- a/lib/presentation/components/no_data_found_container.dart +++ b/lib/presentation/components/no_data_found_container.dart @@ -1,7 +1,6 @@ import 'package:appetizer/data/core/theme/dimensional/dimensional.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:flutter_svg_provider/flutter_svg_provider.dart'; class NoDataFoundContainer extends StatelessWidget { const NoDataFoundContainer({ diff --git a/lib/presentation/coupons/components/coupon_card.dart b/lib/presentation/coupons/components/coupon_card.dart index c929b6c1..cf35ff78 100644 --- a/lib/presentation/coupons/components/coupon_card.dart +++ b/lib/presentation/coupons/components/coupon_card.dart @@ -63,7 +63,7 @@ class CouponCard extends StatelessWidget { Text( coupon.meal, style: TextStyle( - color: Color(0xFF2E2E2E), + color: const Color(0xFF2E2E2E), fontSize: 10.toAutoScaledFont, fontFamily: 'Noto Sans', fontWeight: FontWeight.w400, diff --git a/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_bloc.dart b/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_bloc.dart index 18de2eb0..9aedaab9 100644 --- a/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_bloc.dart +++ b/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_bloc.dart @@ -1,6 +1,5 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; -import 'package:meta/meta.dart'; part 'feedback_tile_event.dart'; part 'feedback_tile_state.dart'; diff --git a/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_event.dart b/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_event.dart index 8779e1f4..91a76417 100644 --- a/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_event.dart +++ b/lib/presentation/feedback/components/FeedbackTile/bloc/feedback_tile_event.dart @@ -1,6 +1,5 @@ part of 'feedback_tile_bloc.dart'; -@immutable abstract class FeedbackTileEvent extends Equatable { const FeedbackTileEvent(); diff --git a/lib/presentation/feedback/components/FeedbackTile/feedback_tile.dart b/lib/presentation/feedback/components/FeedbackTile/feedback_tile.dart index 9b4e01c4..0dde8a19 100644 --- a/lib/presentation/feedback/components/FeedbackTile/feedback_tile.dart +++ b/lib/presentation/feedback/components/FeedbackTile/feedback_tile.dart @@ -26,7 +26,7 @@ class FeedbackTile extends StatelessWidget { title, textAlign: TextAlign.left, style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 20.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, diff --git a/lib/presentation/feedback/feedback_view.dart b/lib/presentation/feedback/feedback_view.dart index cfcc5c67..4dd5b041 100644 --- a/lib/presentation/feedback/feedback_view.dart +++ b/lib/presentation/feedback/feedback_view.dart @@ -54,7 +54,7 @@ class FeedbackPage extends StatelessWidget { Text( 'Kindly provide us with your feedback to improve your mess experienWeekly Menuce.', style: TextStyle( - color: Color(0xFF5A5A5A), + color: const Color(0xFF5A5A5A), fontSize: 14.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, @@ -72,13 +72,13 @@ class FeedbackPage extends StatelessWidget { ), ); }), - SizedBox( + const SizedBox( height: 2, ), Text( 'If any other feeback, please describe below', style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 16.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, @@ -103,7 +103,7 @@ class FeedbackPage extends StatelessWidget { border: OutlineInputBorder( borderSide: BorderSide( width: 0.5.toAutoScaledWidth, - color: Color.fromARGB(37, 0, 0, 0), + color: const Color.fromARGB(37, 0, 0, 0), ), ), ), diff --git a/lib/presentation/leaves_and_rebate/components/leave_history.dart b/lib/presentation/leaves_and_rebate/components/leave_history.dart index 800c5bc6..862fbb5d 100644 --- a/lib/presentation/leaves_and_rebate/components/leave_history.dart +++ b/lib/presentation/leaves_and_rebate/components/leave_history.dart @@ -20,9 +20,9 @@ class LeaveHistory extends StatelessWidget { ), shadows: [ BoxShadow( - color: Color(0x19000000), + color: const Color(0x19000000), blurRadius: 7.toAutoScaledWidth, - offset: Offset(2, 2), + offset: const Offset(2, 2), spreadRadius: 1, ) ]), diff --git a/lib/presentation/notifications/bloc/notification_page_bloc.dart b/lib/presentation/notifications/bloc/notification_page_bloc.dart index 5df62298..5c5db942 100644 --- a/lib/presentation/notifications/bloc/notification_page_bloc.dart +++ b/lib/presentation/notifications/bloc/notification_page_bloc.dart @@ -13,17 +13,17 @@ class NotificationPageBloc // TODO: implement repository call bool submissionSuccessful = true; List notifications = [ - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", message: "fasfafafassfadasdadsafafasfsdfafasfasfasfasfasfas"), - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", message: "fasfafafassfadasdadsafafasfsdfafasfasfasfasfasfas"), - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", @@ -50,17 +50,17 @@ class NotificationPageBloc (NotificationPageSwitchChangedEvent event, Emitter emit) { List notifications = [ - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", message: "fasfafafassfadasdadsafafasfsdfafasfasfasfasfasfas"), - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", message: "fasfafafassfadasdadsafafasfsdfafasfasfasfasfasfas"), - Notification( + const Notification( id: 123, dateCreated: 532523, title: "Yesssir", diff --git a/lib/presentation/notifications/components/no_notification_widget.dart b/lib/presentation/notifications/components/no_notification_widget.dart index 0d2da142..fa6a1c33 100644 --- a/lib/presentation/notifications/components/no_notification_widget.dart +++ b/lib/presentation/notifications/components/no_notification_widget.dart @@ -12,7 +12,7 @@ class NoNotificationsWidget extends StatelessWidget { child: Text( 'No new notifications !', style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 18.toAutoScaledFont, fontFamily: 'Noto Sans', fontWeight: FontWeight.w400, diff --git a/lib/presentation/notifications/components/notification_card.dart b/lib/presentation/notifications/components/notification_card.dart index f856bd55..bbfd4f63 100644 --- a/lib/presentation/notifications/components/notification_card.dart +++ b/lib/presentation/notifications/components/notification_card.dart @@ -46,7 +46,7 @@ class NotificationCard extends StatelessWidget { child: Text( data.title, style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 18.toAutoScaledFont, fontFamily: 'Noto Sans', fontWeight: FontWeight.w500, @@ -58,7 +58,7 @@ class NotificationCard extends StatelessWidget { child: Text( '${data.dateCreated}', style: TextStyle( - color: Color(0xFF2E2E2E), + color: const Color(0xFF2E2E2E), fontSize: 10.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, @@ -74,7 +74,7 @@ class NotificationCard extends StatelessWidget { Text( data.message, style: TextStyle( - color: Color(0xFF2E2E2E), + color: const Color(0xFF2E2E2E), fontSize: 14.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, diff --git a/lib/presentation/profile/components/profile_button.dart b/lib/presentation/profile/components/profile_button.dart index 16232484..41160269 100644 --- a/lib/presentation/profile/components/profile_button.dart +++ b/lib/presentation/profile/components/profile_button.dart @@ -29,7 +29,7 @@ class ProfileTextButton extends StatelessWidget { title, textAlign: TextAlign.center, style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 13.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w400, @@ -82,7 +82,7 @@ class ProfileIconButton extends StatelessWidget { SizedBox( width: 20.toAutoScaledWidth, height: 20.toAutoScaledHeight, - child: Icon( + child: const Icon( Icons.bookmark_border_outlined, color: Color.fromARGB(255, 255, 203, 116), ), @@ -92,7 +92,7 @@ class ProfileIconButton extends StatelessWidget { title, textAlign: TextAlign.center, style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 14.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w500, diff --git a/lib/presentation/profile/components/profile_card.dart b/lib/presentation/profile/components/profile_card.dart index 1cb25794..92bf1e47 100644 --- a/lib/presentation/profile/components/profile_card.dart +++ b/lib/presentation/profile/components/profile_card.dart @@ -19,7 +19,7 @@ class Fields extends StatelessWidget { Text( '$title ', style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 16.toAutoScaledFont, fontFamily: 'Lato', fontWeight: FontWeight.w500, @@ -28,7 +28,7 @@ class Fields extends StatelessWidget { Text( data, style: TextStyle( - color: Color(0xFF2E2E2E), + color: const Color(0xFF2E2E2E), fontSize: 16.toAutoScaledFont, fontFamily: 'Inter', fontWeight: FontWeight.w400, diff --git a/lib/presentation/profile/components/profile_photo.dart b/lib/presentation/profile/components/profile_photo.dart index 52ebe3e3..b5ddde21 100644 --- a/lib/presentation/profile/components/profile_photo.dart +++ b/lib/presentation/profile/components/profile_photo.dart @@ -18,7 +18,7 @@ class ProfilePhoto extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(62.toAutoScaledWidth), side: BorderSide( - color: Color.fromARGB(255, 255, 255, 255), + color: const Color.fromARGB(255, 255, 255, 255), width: 12.4.toAutoScaledWidth, )), ), diff --git a/lib/presentation/profile/profile_view.dart b/lib/presentation/profile/profile_view.dart index 05d85416..ab01afe9 100644 --- a/lib/presentation/profile/profile_view.dart +++ b/lib/presentation/profile/profile_view.dart @@ -49,7 +49,7 @@ class ProfileScreen extends StatelessWidget { Text( data.name, style: TextStyle( - color: Color(0xFF111111), + color: const Color(0xFF111111), fontSize: 25.toAutoScaledFont, fontFamily: 'Noto Sans', fontWeight: FontWeight.w600, @@ -84,7 +84,7 @@ class ProfileScreen extends StatelessWidget { ], ), ), - Divider( + const Divider( height: 2, thickness: 2, color: Color.fromARGB(255, 189, 189, 189), @@ -131,7 +131,7 @@ class ProfileScreen extends StatelessWidget { child: Text( 'Raise a Query', style: TextStyle( - color: Color(0xFF008BFF), + color: const Color(0xFF008BFF), fontSize: 12.toAutoScaledFont, fontFamily: 'Inter', fontWeight: FontWeight.w400, diff --git a/lib/presentation/week_menu/components/yourMealDailyCardsCombined/menu_card.dart b/lib/presentation/week_menu/components/yourMealDailyCardsCombined/menu_card.dart index 1b8b056a..f0a3153b 100644 --- a/lib/presentation/week_menu/components/yourMealDailyCardsCombined/menu_card.dart +++ b/lib/presentation/week_menu/components/yourMealDailyCardsCombined/menu_card.dart @@ -119,164 +119,159 @@ class MealCard extends StatelessWidget { offset: 2, width: 312.toAutoScaledWidth, height: 168.toAutoScaledHeight, - child: Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 125.toAutoScaledWidth, - height: 168.toAutoScaledHeight, - decoration: BoxDecoration( - image: DecorationImage( - image: svg.Svg( - 'assets/images/meal_card/${meal.title}.svg', - ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 125.toAutoScaledWidth, + height: 168.toAutoScaledHeight, + decoration: BoxDecoration( + image: DecorationImage( + image: svg.Svg( + 'assets/images/meal_card/${meal.title}.svg', ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox(height: 15.toAutoScaledHeight), - Container( - height: 28.toAutoScaledHeight, - padding: EdgeInsets.only(left: 12), - child: Text( - meal.title, - style: AppTheme.headline1.copyWith( - fontSize: 20.toAutoScaledFont, - color: AppTheme.black11), - ), - ), - Container( - height: 17.toAutoScaledHeight, - padding: EdgeInsets.only(left: 12.toAutoScaledWidth), - child: Text( - '${DateFormat.jm().format(meal.startTime)} - ${DateFormat.jm().format(meal.endTime)}', - style: AppTheme.headline3.copyWith( - fontWeight: FontWeight.w600, - fontSize: 12.toAutoScaledFont, - color: AppTheme.grey2f), - ), - ), - SizedBox(height: 9.toAutoScaledHeight), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only(left: 12.toAutoScaledWidth), - child: FittedBox( - fit: BoxFit.contain, - child: FSwitch( - enable: !meal.isLeaveToggleOutdated, - open: meal.leaveStatus.status != LeaveStatusEnum.A, - sliderColor: AppTheme.customWhite, - openColor: AppTheme.black2e, - height: 20.toAutoScaledHeight, - width: 44.toAutoScaledWidth, - onChanged: (value) async { - context - .read() - .add(ToggleMealLeaveEvent( - mealId: meal.id, - leaveAppliedAlready: - meal.leaveStatus.status == - LeaveStatusEnum.A)); - }, - ), - ), - ), - ], - ), - SizedBox(height: 45.toAutoScaledHeight), - ...[ - meal.isOutdated - ? GestureDetector( - onTap: () { - //TODO: lead to feedback page - }, - child: const FeedbackAndCouponWidget( - taken: false, coupon: false), - ) - : (_isMealValidForCoupon(meal) - ? GestureDetector( - onTap: () { - if (!meal.isCouponOutdated) { - context - .read() - .add(ToggleMealCouponEvent( - couponId: - meal.couponStatus.status == - CouponStatusEnum.A - ? meal.couponStatus.id! - : -1, - couponAppliedAlready: - meal.couponStatus.status == - CouponStatusEnum.A, - mealId: meal.id)); - } else if (meal.couponStatus.status == - CouponStatusEnum.A) { - showCouponDialog( - "Coupon no: ${meal.couponStatus.id!}", - context); - } else { - showCouponDialog( - "You can not apply for coupon now", - context); - } - }, - child: FeedbackAndCouponWidget( - taken: meal.couponStatus.status == - CouponStatusEnum.A, - coupon: true), - ) - : const SizedBox.shrink()), - ], - SizedBox(height: 10.toAutoScaledHeight) - ], - ), ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, + child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - SizedBox(height: 18.toAutoScaledHeight), - for (var item in meal.items) Text(" \u2022 ${item.name}"), - const Spacer(), + SizedBox(height: 15.toAutoScaledHeight), Container( - margin: EdgeInsets.symmetric( - horizontal: 22.toAutoScaledWidth, + height: 28.toAutoScaledHeight, + padding: const EdgeInsets.only(left: 12), + child: Text( + meal.title, + style: AppTheme.headline1.copyWith( + fontSize: 20.toAutoScaledFont, color: AppTheme.black11), ), - height: 0.5, - width: 145, - color: AppTheme.rulerColor, ), - SizedBox(height: 8.toAutoScaledHeight), Container( - width: 187.toAutoScaledWidth, - padding: EdgeInsets.only( - left: 12.toAutoScaledWidth, - right: 19.toAutoScaledWidth, + height: 17.toAutoScaledHeight, + padding: EdgeInsets.only(left: 12.toAutoScaledWidth), + child: Text( + '${DateFormat.jm().format(meal.startTime)} - ${DateFormat.jm().format(meal.endTime)}', + style: AppTheme.headline3.copyWith( + fontWeight: FontWeight.w600, + fontSize: 12.toAutoScaledFont, + color: AppTheme.grey2f), ), - child: RichText( - text: TextSpan( - text: 'Daily Items: ', - style: AppTheme.bodyText2.copyWith( - fontWeight: FontWeight.w600, - color: const Color(0xFFB51111)), - children: [ - TextSpan( - text: dailyItemsParsed, style: AppTheme.bodyText2) - ], + ), + SizedBox(height: 9.toAutoScaledHeight), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only(left: 12.toAutoScaledWidth), + child: FittedBox( + fit: BoxFit.contain, + child: FSwitch( + enable: !meal.isLeaveToggleOutdated, + open: meal.leaveStatus.status != LeaveStatusEnum.A, + sliderColor: AppTheme.customWhite, + openColor: AppTheme.black2e, + height: 20.toAutoScaledHeight, + width: 44.toAutoScaledWidth, + onChanged: (value) async { + context.read().add( + ToggleMealLeaveEvent( + mealId: meal.id, + leaveAppliedAlready: + meal.leaveStatus.status == + LeaveStatusEnum.A)); + }, + ), + ), ), - ), + ], ), - SizedBox(height: 17.toAutoScaledHeight) + SizedBox(height: 45.toAutoScaledHeight), + ...[ + meal.isOutdated + ? GestureDetector( + onTap: () { + //TODO: lead to feedback page + }, + child: const FeedbackAndCouponWidget( + taken: false, coupon: false), + ) + : (_isMealValidForCoupon(meal) + ? GestureDetector( + onTap: () { + if (!meal.isCouponOutdated) { + context + .read() + .add(ToggleMealCouponEvent( + couponId: meal.couponStatus.status == + CouponStatusEnum.A + ? meal.couponStatus.id! + : -1, + couponAppliedAlready: + meal.couponStatus.status == + CouponStatusEnum.A, + mealId: meal.id)); + } else if (meal.couponStatus.status == + CouponStatusEnum.A) { + showCouponDialog( + "Coupon no: ${meal.couponStatus.id!}", + context); + } else { + showCouponDialog( + "You can not apply for coupon now", + context); + } + }, + child: FeedbackAndCouponWidget( + taken: meal.couponStatus.status == + CouponStatusEnum.A, + coupon: true), + ) + : const SizedBox.shrink()), + ], + SizedBox(height: 10.toAutoScaledHeight) ], - ) - ], - ), + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 18.toAutoScaledHeight), + for (var item in meal.items) Text(" \u2022 ${item.name}"), + const Spacer(), + Container( + margin: EdgeInsets.symmetric( + horizontal: 22.toAutoScaledWidth, + ), + height: 0.5, + width: 145, + color: AppTheme.rulerColor, + ), + SizedBox(height: 8.toAutoScaledHeight), + Container( + width: 187.toAutoScaledWidth, + padding: EdgeInsets.only( + left: 12.toAutoScaledWidth, + right: 19.toAutoScaledWidth, + ), + child: RichText( + text: TextSpan( + text: 'Daily Items: ', + style: AppTheme.bodyText2.copyWith( + fontWeight: FontWeight.w600, + color: const Color(0xFFB51111)), + children: [ + TextSpan( + text: dailyItemsParsed, style: AppTheme.bodyText2) + ], + ), + ), + ), + SizedBox(height: 17.toAutoScaledHeight) + ], + ) + ], ), ); } diff --git a/lib/utils/api_utils.dart b/lib/utils/api_utils.dart deleted file mode 100644 index 593dc750..00000000 --- a/lib/utils/api_utils.dart +++ /dev/null @@ -1,157 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; -import 'package:appetizer/data/constants/constants.dart'; -import 'package:appetizer/domain/models/failure_model.dart'; -import 'package:appetizer/utils/app_exceptions.dart'; -import 'package:flutter/foundation.dart'; -import 'package:http/http.dart' as http; -import 'package:shared_preferences/shared_preferences.dart'; - -class ApiUtils { - static http.Client client = http.Client(); - - /// Returns JSON GET response - static Future get(String uri, {Map? headers}) async { - try { - final response = await client.get(Uri.parse(uri), headers: headers); - final jsonResponse = ApiUtils.jsonResponse(response); - return jsonResponse; - } on UnauthorizedException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.UNAUTHORIZED_EXCEPTION); - } on SocketException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.NO_INTERNET_CONNECTION); - } on HttpException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.HTTP_EXCEPTION); - } - } - - /// Returns JSON POST response - static Future post(String uri, - {required Map headers, dynamic body}) async { - try { - final response = await client.post(Uri.parse(uri), - headers: headers, body: jsonEncode(body)); - final jsonResponse = ApiUtils.jsonResponse(response); - return jsonResponse; - } on UnauthorizedException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.UNAUTHORIZED_EXCEPTION); - } on SocketException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.NO_INTERNET_CONNECTION); - } on HttpException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.HTTP_EXCEPTION); - } - } - - /// Returns JSON PUT response - static Future put(String uri, - {required Map headers, dynamic body}) async { - try { - final response = await client.put( - Uri.parse(uri), - headers: headers, - body: jsonEncode(body), - ); - final jsonResponse = ApiUtils.jsonResponse(response); - return jsonResponse; - } on UnauthorizedException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.UNAUTHORIZED_EXCEPTION); - } on SocketException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.NO_INTERNET_CONNECTION); - } on HttpException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.HTTP_EXCEPTION); - } - } - - /// Returns JSON PATCH response - static Future patch(String uri, - {required Map headers, dynamic body}) async { - try { - final response = await client.patch(Uri.parse(uri), - headers: headers, body: jsonEncode(body)); - final jsonResponse = ApiUtils.jsonResponse(response); - return jsonResponse; - } on UnauthorizedException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.UNAUTHORIZED_EXCEPTION); - } on SocketException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.NO_INTERNET_CONNECTION); - } on HttpException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.HTTP_EXCEPTION); - } - } - - /// Returns JSON DELETE response - static Future delete(String uri, - {required Map headers}) async { - try { - final response = await http.delete(Uri.parse(uri), headers: headers); - final jsonResponse = ApiUtils.jsonResponse(response); - return jsonResponse; - } on UnauthorizedException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.UNAUTHORIZED_EXCEPTION); - } on SocketException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.NO_INTERNET_CONNECTION); - } on HttpException catch (e) { - debugPrint(e.message); - throw Failure(AppConstants.HTTP_EXCEPTION); - } - } - - static dynamic jsonResponse(http.Response response) { - switch (response.statusCode) { - case 200: - case 201: - case 202: - case 204: - if (response.body == '') return; - var responseJson = json.decode(response.body); - debugPrint(responseJson); - return responseJson; - case 400: - debugPrint(response.body); - throw BadRequestException(response.body); - case 401: - debugPrint(response.body); - throw UnauthorizedException(response.body); - case 403: - debugPrint(response.body); - throw ForbiddenException(response.body); - case 404: - debugPrint(response.body); - throw NotFoundException(response.body); - case 409: - debugPrint(response.body); - throw ConflictException(response.body); - case 500: - debugPrint(response.body); - throw InternalServerErrorException(response.body); - case 503: - debugPrint(response.body); - throw ServiceUnavailableException(response.body); - default: - debugPrint(response.body); - throw FetchDataException( - 'Error occured while Communication with Server with StatusCode : ${response.statusCode}', - ); - } - } - - static Future addTokenToHeaders(Map headers) async { - var prefs = await SharedPreferences.getInstance(); - var token = prefs.getString('token'); - headers.addAll({'Authorization': 'Token $token'}); - } -} diff --git a/lib/utils/app_exceptions.dart b/lib/utils/app_exceptions.dart deleted file mode 100644 index 658796f5..00000000 --- a/lib/utils/app_exceptions.dart +++ /dev/null @@ -1,52 +0,0 @@ -class AppException implements Exception { - final _message; - final _prefix; - - AppException([this._message, this._prefix]); - - String get message => _message; - - String get pefix => _prefix; - - @override - String toString() => '$_prefix : $_message'; -} - -class BadRequestException extends AppException { - BadRequestException([message]) : super(message, 'Invalid Request'); -} - -class UnauthorizedException extends AppException { - UnauthorizedException([message]) : super(message, 'Unauthorized'); -} - -class ForbiddenException extends AppException { - ForbiddenException([String? message]) : super(message, 'Forbidden'); -} - -class NotFoundException extends AppException { - NotFoundException([String? message]) : super(message, 'Not Found'); -} - -class ConflictException extends AppException { - ConflictException([String? message]) : super(message, 'Conflict'); -} - -class InternalServerErrorException extends AppException { - InternalServerErrorException([String? message]) - : super(message, 'Internal Server Error'); -} - -class ServiceUnavailableException extends AppException { - ServiceUnavailableException([String? message]) - : super(message, 'Service Unavailable'); -} - -class InvalidInputException extends AppException { - InvalidInputException([String? message]) : super(message, 'Invalid Input'); -} - -class FetchDataException extends AppException { - FetchDataException([String? message]) - : super(message, 'Error During Communication'); -}