fist commit ftc staff app clone
This commit is contained in:
42
lib/utilities/app_session_manager.dart
Normal file
42
lib/utilities/app_session_manager.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:ftc_mobile_app/dialogs/app_dialogs.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:stop_watch_timer/stop_watch_timer.dart';
|
||||
|
||||
class AppSessionManager extends GetxService {
|
||||
static AppSessionManager instance = Get.find<AppSessionManager>();
|
||||
|
||||
StopWatchTimer? _stopWatchTimer;
|
||||
|
||||
startSessionTimer(int millis) async {
|
||||
await _stopAndInitTimer(millis);
|
||||
_stopWatchTimer?.onStartTimer();
|
||||
}
|
||||
|
||||
_stopTimer() async {
|
||||
_stopWatchTimer?.onStopTimer();
|
||||
await _stopWatchTimer?.dispose();
|
||||
_stopWatchTimer = null;
|
||||
}
|
||||
|
||||
_stopAndInitTimer(int millis) async {
|
||||
_stopTimer();
|
||||
_initTimer(millis);
|
||||
}
|
||||
|
||||
_initTimer(int millis) {
|
||||
_stopWatchTimer = StopWatchTimer(
|
||||
mode: StopWatchMode.countDown,
|
||||
presetMillisecond: millis,
|
||||
onEnded: () {
|
||||
_stopTimer();
|
||||
//Todo: Show session expire dialog and logout from app
|
||||
|
||||
if (Get.isOverlaysOpen) Get.back();
|
||||
AppDialog.showUnauthorizedAlert();
|
||||
});
|
||||
}
|
||||
|
||||
dispose() {
|
||||
_stopWatchTimer?.dispose();
|
||||
}
|
||||
}
|
||||
155
lib/utilities/assets_manager.dart
Normal file
155
lib/utilities/assets_manager.dart
Normal file
@@ -0,0 +1,155 @@
|
||||
class AssetsManager {
|
||||
AssetsManager._();
|
||||
|
||||
static const String kAppIcon = "assets/images/png/app-logo-icon.png";
|
||||
static const String kLockIcon = "assets/images/svg/lock-icon.svg";
|
||||
static const String kCalendarIcon =
|
||||
"assets/images/svg/nav_bar_calendar_icon.svg";
|
||||
static const String kHomeIcon = "assets/images/svg/nav_bar_home_icon.svg";
|
||||
static const String kMessageIcon =
|
||||
"assets/images/svg/nav_bar_message_icon.svg";
|
||||
static const String kPeopleIcon = "assets/images/svg/nav_bar_people_icon.svg";
|
||||
static const String kPersonMainIcon =
|
||||
"assets/images/svg/nav_bar_person_main_icon.svg";
|
||||
static const String kBackIcon = "assets/images/svg/back_icon.svg";
|
||||
static const String kCalendarAppointmentIcon =
|
||||
"assets/images/svg/calendar_appointment_icon.svg";
|
||||
static const String kCarePlanIcon = "assets/images/svg/care_plan_icon.svg";
|
||||
static const String kNotesIcon = "assets/images/svg/notes_icon.svg";
|
||||
static const String kPhotoGalleryIcon =
|
||||
"assets/images/svg/photo_gallery_icon.svg";
|
||||
static const String kGoToArrowIcon =
|
||||
"assets/images/svg/got_to_arrow_button.svg";
|
||||
static const String kUploadIcon = "assets/images/svg/upload_icon.svg";
|
||||
static const String kFlagIcon = "assets/images/svg/flag_icon.svg";
|
||||
static const String kClockIcon = "assets/images/svg/clock_icon.svg";
|
||||
static const String kMicIcon = "assets/images/svg/microphone_mike.svg";
|
||||
static const String kBellIcon = "assets/images/svg/bell_icon.svg";
|
||||
static const String kManImage = "assets/images/svg/man_image.svg";
|
||||
static const String kManImagePng = "assets/images/svg/man_image_png.png";
|
||||
static const String kDrawerIcon = "assets/images/svg/menu_drawer_icon.svg";
|
||||
static const String kPeopleUnselectedIcon =
|
||||
"assets/images/svg/people_unselected.svg";
|
||||
static const String kPoliciesIcon = "assets/images/svg/policies_icon.svg";
|
||||
static const String kSettingsIcon = "assets/images/svg/setting_icon.svg";
|
||||
static const String kSelectedCalendar =
|
||||
"assets/images/svg/selected_calendar.svg";
|
||||
static const String kPlusIcon = "assets/images/svg/plus_icon.svg";
|
||||
static const String kArrowNextIcon = "assets/images/svg/arrow-next-icon.svg";
|
||||
static const String kPencilIcon = "assets/images/svg/pencil-icon.svg";
|
||||
static const String kFolderIcon = "assets/images/svg/folder_icon.svg";
|
||||
static const String kManBodyImage = "assets/images/svg/man_body_image.svg";
|
||||
static const String kPencilOutlineIcon =
|
||||
"assets/images/svg/pencil_outline_icon.svg";
|
||||
static const String kEclipseIcon = "assets/images/svg/eclipse.svg";
|
||||
static const String kTriangleIcon = "assets/images/svg/triangle.svg";
|
||||
static const String kDustBinRedIcon = "assets/images/svg/dustbin_red.svg";
|
||||
|
||||
//care notes categories
|
||||
static const String kIcGeneral =
|
||||
"assets/images/svg/careNotesCategories/ic_general.svg";
|
||||
static const String kIcHealth =
|
||||
"assets/images/svg/careNotesCategories/ic_health.svg";
|
||||
static const String kIcIndependentLiving =
|
||||
"assets/images/svg/careNotesCategories/ic_independent_living.svg";
|
||||
static const String kIcIntractions =
|
||||
"assets/images/svg/careNotesCategories/ic_intractions.svg";
|
||||
static const String kIcMentalWellbeing =
|
||||
"assets/images/svg/careNotesCategories/ic_mental_wellbeing.svg";
|
||||
static const String kIcPersonalCare =
|
||||
"assets/images/svg/careNotesCategories/ic_personal_care.svg";
|
||||
|
||||
//care notes Subcategories
|
||||
static const String kIcAbc =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_abc.svg';
|
||||
static const String kIcActivity =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_activity.svg';
|
||||
static const String kIcAppointment =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_appointment.svg';
|
||||
static const String kIcCleaning =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_cleaning.svg';
|
||||
static const String kIcConsent =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_consent.svg';
|
||||
static const String kIcCooking =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_cooking.svg';
|
||||
static const String kIcEducation =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_education.svg';
|
||||
static const String kIcEmail =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_email.svg';
|
||||
static const String kIcFinance =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_finance.svg';
|
||||
static const String kIcHydration =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_hydration.svg';
|
||||
static const String kIcInjury =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_injury.svg';
|
||||
static const String kIcLaundry =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_laundry.svg';
|
||||
static const String kIcMeeting =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_meeting.svg';
|
||||
static const String kIcMood =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_mood.svg';
|
||||
static const String kIcMouthHygiene =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_mouth_hygiene.svg';
|
||||
static const String kIcNote =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_note.svg';
|
||||
static const String kIcOtherInteractions =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_other_interactions.svg';
|
||||
static const String kIcPhysicalIntervention =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_physical_intervention.svg';
|
||||
static const String kIcPublicInteraction =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_public_interaction.svg';
|
||||
static const String kIcReviews =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_reviews.svg';
|
||||
static const String kIcSafeguarding =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_safeguarding.svg';
|
||||
static const String kIcSearch =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_search.svg';
|
||||
static const String kIcShower =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_shower.svg';
|
||||
static const String kIcSleep =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_sleep.svg';
|
||||
static const String kIcTelephone =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_telephone.svg';
|
||||
static const String kIcToileting =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_toileting.svg';
|
||||
static const String kIcWeightHeight =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_weight_height.svg';
|
||||
static const String kIcOthers =
|
||||
'assets/images/svg/careNotesSubcatgeories/ic_others.svg';
|
||||
|
||||
//rating icons
|
||||
static const String ratingsIcAngry =
|
||||
'assets/images/png/ratings/ic_angry.webp';
|
||||
static const String ratingsIcBored =
|
||||
'assets/images/png/ratings/ic_bored.webp';
|
||||
static const String ratingsIcCalm = 'assets/images/png/ratings/ic_calm.webp';
|
||||
static const String ratingsIcConfident =
|
||||
'assets/images/png/ratings/ic_confident.webp';
|
||||
static const String ratingsIcExcited =
|
||||
'assets/images/png/ratings/ic_excited.webp';
|
||||
static const String ratingsIcHappy =
|
||||
'assets/images/png/ratings/ic_happy.webp';
|
||||
static const String ratingsIcHopeful =
|
||||
'assets/images/png/ratings/ic_hopeful.webp';
|
||||
static const String ratingsIcNervous =
|
||||
'assets/images/png/ratings/ic_nervous.webp';
|
||||
static const String ratingsIcProud =
|
||||
'assets/images/png/ratings/ic_proud.webp';
|
||||
static const String ratingsIcRelaxed =
|
||||
'assets/images/png/ratings/ic_relaxed.webp';
|
||||
static const String ratingsIcSad = 'assets/images/png/ratings/ic_sad.webp';
|
||||
static const String ratingsIcScared =
|
||||
'assets/images/png/ratings/ic_scared.webp';
|
||||
static const String ratingsIcTired =
|
||||
'assets/images/png/ratings/ic_tired.webp';
|
||||
static const String ratingsIcWorried =
|
||||
'assets/images/png/ratings/ic_worried.webp';
|
||||
|
||||
static const String kConsentCapacityFormHtml = 'assets/consent-capacity.html';
|
||||
static const String svgHumanBodyFrontBack = 'assets/images/svg/human_body_front_back.svg';
|
||||
static const String pngHumanBodyFrontBack = 'assets/images/png/human_body_front_back.png';
|
||||
|
||||
static const String svgIcAdd = 'assets/images/svg/ic_add.svg';
|
||||
static const String svgIcAt = 'assets/images/svg/ic_at.svg';
|
||||
|
||||
}
|
||||
38
lib/utilities/constant_text.dart
Normal file
38
lib/utilities/constant_text.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
class ConstantText {
|
||||
ConstantText._();
|
||||
|
||||
static const String kAppName = "FTC App";
|
||||
static const String kWelcomeBack = "Welcome Back!";
|
||||
static const String kPleaseLoginToContinue = "Please login to continue";
|
||||
static const String kPleaseInputEmail = "Please input your email";
|
||||
static const String kPleaseInputOTP = "Please input your otp";
|
||||
static const String kInvalidOTP = "Invalid otp";
|
||||
static const String kEmailHeading = "Email";
|
||||
static const String kPasswordHeading = "Password";
|
||||
static const String kEmailIsRequired = "Email is required";
|
||||
static const String kPasswordIsRequired = "Password is required";
|
||||
static const String kEmailPhoneIsRequired = "Email or Phone is required";
|
||||
static const String kInvalidEmail = "Invalid email";
|
||||
static const String kRememberMe = "Remember me";
|
||||
static const String kForgotPassword = "Forgot Password?";
|
||||
static const String kLogIn = "Log in";
|
||||
static const String kSubmit = "Submit";
|
||||
static const String kSave = "Save";
|
||||
static const String kSendCode = "Send code";
|
||||
static const String kAgencyLogin = "Agency log in";
|
||||
static const String kEmailOrPhoneHeading = "Email or Phone";
|
||||
static const String kInputEmailOrPhone = "Please input email or phone";
|
||||
static const String kOTPScreenMsg = "Enter the 6 digit code we sent to your email to log in. Your code is available for the next 12 hours.";
|
||||
static const String kTwoFactorAuth = "2 Factor Authentication";
|
||||
static const String kTypeTitle = "Type Title";
|
||||
static const String kTitle = "Title";
|
||||
static const String kViewFullBodyMap = "View Full Body Map";
|
||||
static const String kFlagForHandover = "Flag for handover?";
|
||||
static const String kNoteDetails = "Note Details";
|
||||
static const String kNoteDetailsHint = "Enter note details here...";
|
||||
|
||||
|
||||
|
||||
static const String termsUrl = "https://ftcaresoftware.co.uk/terms-and-conditions.html";
|
||||
static const String privacyUrl = "https://ftcaresoftware.co.uk/app-privacy-policy.html";
|
||||
}
|
||||
27
lib/utilities/custom_app_colors.dart
Normal file
27
lib/utilities/custom_app_colors.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomAppColors {
|
||||
CustomAppColors._();
|
||||
|
||||
static const Color kTransparentColor = Colors.transparent;
|
||||
static const Color kPrimaryColor = Color(0xFFFFFFFF);
|
||||
static const Color kSecondaryColor = Color(0xFF278DEC);
|
||||
static const Color kIconColor = Color(0xFF1D3F43);
|
||||
static Color kLightGreyColor = Colors.grey.shade400;
|
||||
static const Color kSmokeColor = Color(0xFFE9EBEC);
|
||||
static const Color kLightTextColor = Color(0xFF9F9FA3);
|
||||
static const Color kRedColor = Colors.red;
|
||||
static const Color kDarkRedColor= Color(0xffDA0B0B);
|
||||
static const Color kBlueColor= Color(0xff00577b);
|
||||
static const Color kSeaGreenColor= Color(0xff00d194);
|
||||
static const Color kLightPinkColor= Color(0xffff5a6b);
|
||||
static const Color kBlackColor= Color(0xff000000);
|
||||
static const Color kWhiteColor= Color(0xffffffff);
|
||||
static const Color kGreenColor = Color(0xFF7dbe20);
|
||||
static const Color kDarkGreenColor = Color(0xFF0AC247);
|
||||
static const Color kDarkestGreenColor = Color(0xFF008000);
|
||||
static const Color kDarkBlueTextColor = Color(0xff1D3F43);
|
||||
static const Color kYellowColor = Color(0xffFFB800);
|
||||
static const Color kDarkYellowColor = Color(0xffF2AE00);
|
||||
|
||||
}
|
||||
555
lib/utilities/custom_router/custom_route_generator.dart
Normal file
555
lib/utilities/custom_router/custom_route_generator.dart
Normal file
@@ -0,0 +1,555 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/controllers/clients/careNoteFormControllers/common_care_note_forms_controller.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
import 'package:ftc_mobile_app/models/profileData/user_data.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/chat/arguments/chat_screen_args.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/addEditMemoryBox/add_edit_memory_box_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/addEditRiskAssessment/add_edit_risk_assessment_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/add_details_to_new_body_point_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/add_new_document_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/add_new_recent_incident_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/all_care_notes_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/careNoteForms/nutrition_hydration_form_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clients/clients_new_view_module/add_new_pbs_plan_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/home/select_user_for_chat_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/settings/settings_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/training/training_detail_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/training/training_screen.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/webview/webview_screen.dart';
|
||||
import '../../models/clients/allCareNotes/CarePlans.dart';
|
||||
import '../../view/screens/clients/careNoteForms/mood_rating_form.dart';
|
||||
import '../../view/screens/clients/care_note_detail_screen.dart';
|
||||
|
||||
class CustomRouteGenerator {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey();
|
||||
|
||||
CustomRouteGenerator._();
|
||||
|
||||
static Object? argument;
|
||||
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
debugPrint("Current Route: ${settings.name}");
|
||||
argument = settings.arguments;
|
||||
switch (settings.name) {
|
||||
// GetPage(
|
||||
// name: CustomRouteNames.webviewScreen,
|
||||
// page: () => WebviewScreen(
|
||||
// args: Get.arguments as WebviewScreenArgument,
|
||||
// ),
|
||||
// binding: BindingsBuilder(
|
||||
// () => Get.lazyPut(() => WebviewScreenController()))),
|
||||
|
||||
case CustomRouteNames.kWebviewScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return WebviewScreen(
|
||||
args: settings.arguments as WebviewScreenArgument,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kInitialRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const SplashScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kLoginScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const SignInScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAgencySignInScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const AgencySignIn();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kOTPScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const OTPScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kRotaDashboardScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const RotaDashboardScreen();
|
||||
},
|
||||
);
|
||||
// case CustomRouteNames.kCalendarScreenRoute:
|
||||
// return MaterialPageRoute(
|
||||
// builder: (context) {
|
||||
// return CalendarScreen(
|
||||
// controller: Get.put(CalendarViewScreenController()),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
case CustomRouteNames.kBookHolidayScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const BookHolidayScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kClientsListScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const ClientsListScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kClientsProfileScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ClientProfileScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAppointmentsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AppointmentScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kNotesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const NotesScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kSelectNoteScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const SelectNoteScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kNewNoteScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const NewNoteScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCarePlanMenuScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CarePlanMenuScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kDashboardScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const DashboardScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kPickUpShiftsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const PickUpShiftsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kChatScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ChatScreen(
|
||||
args: settings.arguments as ChatScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kNotificationListScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const NotificationListScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kViewProfileScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const ViewProfileScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kYourRotaScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const YourRotaScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kInboxScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const InboxScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kDocumentsListScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return DocumentsListScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kDocumentDetailsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const DocumentDetailsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kRecentIncidentsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return RecentIncidentsScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCurrentHealthIssuesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CurrentHealthIssuesScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kConsentAndCapacityQuestionnaireScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsentAndCapacityQuestionnaireScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kConsentAndCapacityAddNewFormScreenRoute:
|
||||
// ConsentDetailsModel consentDetailsModel = ConsentDetailsModel.empty();
|
||||
// if (settings.arguments != null &&
|
||||
// settings.arguments is ConsentDetailsModel &&
|
||||
// consentDetailsModel.description.isNotEmpty) {
|
||||
// consentDetailsModel = settings.arguments as ConsentDetailsModel;
|
||||
// }
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsentAndCapacityAddNewFormScreen(
|
||||
args:
|
||||
settings.arguments as ConsentAndCapacityAddNewFormScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kLifeHistoryAndGoalsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const LifeHistoryAndGoalsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kPBSPlanScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return PBSPlanScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kPhotoGalleryScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return PhotoGalleryScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kRiskAssessmentsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const RiskAssessmentsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kRiskAssessmentsTemplateScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return RiskAssessmentsTemplateScreen(
|
||||
userData: settings.arguments as UserData,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kSupportPlanScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const SupportPlanScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kOverViewScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const OverviewScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCrisisManagementScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const CrisisManagementScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kMentalHealthScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const MentalHealthScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kHealthScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const HealthScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kFuturePlansScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const FuturePlansScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kMyCurrentPlanScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const MyCurrentPlanScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kMyInterestsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const MyInterestsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kThingsIWantYouToHelpScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const ThingsIWantYouToHelpScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kClientsIntroductionScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const ClientIntroductionScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kMedicationScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const MedicationScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kHealthFullBodyMapScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const HealthFullBodyMapScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAddDetailsToNewPointScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddDetailsToNewBodyPointScreen(
|
||||
args: settings.arguments as AddDetailsToNewBodyPointScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAddNewRecentIncidentsScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddNewRecentIncidentsScreen(
|
||||
args: settings.arguments as AddNewRecentIncidentsScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAddNewPBSPlanScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddNewPBSPlanScreen(
|
||||
args: settings.arguments as AddNewPBSPlanScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAddNewDocumentScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const AddNewDocumentScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kSelectUserForChatScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return const SelectUserForChatScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCareNotesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CareNotesScreen(
|
||||
args: settings.arguments as CareNotesScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCareNotesSubcategoriesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CareNotesSubcategoriesScreen(
|
||||
args: settings.arguments as CareNotesSubcategoriesScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kFreeTextEntriesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return FreeTextEntriesFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kWeightHeightFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return WeightHeightFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kHealthAppointmentsFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return HealthAppointmentsFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kShoweringBathFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ShoweringBathFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kToiletingNoteFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ToiletingNoteFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kMoodRatingFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return MoodRatingFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kABCFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ABCFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kConsentCapacityFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsentCapacityFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kInjuryHealthIssueFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return InjuryHealthIssueFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kObservationsFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ObservationsFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kSafeguardingFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return SafeguardingFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kPhysicalInterventionFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return PhysicalInterventionFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kNutritionHydrationFormScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return NutritionHydrationFormScreen(
|
||||
args: settings.arguments as CommonCareNoteFormArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kAllCareNotesScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AllCareNotesScreen(
|
||||
args: settings.arguments as AllCareNotesScreenArgs,
|
||||
);
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kCareNoteDetailScreenRoute:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return CareNoteDetailScreen(data: settings.arguments as CarePlan);
|
||||
},
|
||||
fullscreenDialog: true);
|
||||
case CustomRouteNames.kAddEditMemoryBoxScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return AddEditMemoryBoxScreen(
|
||||
args: settings.arguments as AddEditMemoryBoxScreenArgs);
|
||||
},
|
||||
fullscreenDialog: true);
|
||||
case CustomRouteNames.kAddEditRiskAssessmentScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return AddEditRiskAssessmentScreen(
|
||||
args: settings.arguments as AddEditRiskAssessmentScreenArgs);
|
||||
},
|
||||
fullscreenDialog: true);
|
||||
case CustomRouteNames.kSettingsScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return const SettingsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kTrainingsScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return const TrainingsScreen();
|
||||
},
|
||||
);
|
||||
case CustomRouteNames.kTrainingDetailScreen:
|
||||
return MaterialPageRoute(
|
||||
builder: (_) {
|
||||
return TrainingDetailScreen(
|
||||
args: settings.arguments as TrainingDetailScreenArgs);
|
||||
},
|
||||
fullscreenDialog: true);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
lib/utilities/custom_router/custom_route_names.dart
Normal file
77
lib/utilities/custom_router/custom_route_names.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
class CustomRouteNames {
|
||||
CustomRouteNames._();
|
||||
|
||||
static const String kWebviewScreen = "/WebviewScreen";
|
||||
static const String kInitialRoute = "/";
|
||||
static const String kLoginScreenRoute = "/LoginScreenRoute";
|
||||
static const String kAgencySignInScreenRoute = "/AgencySignInScreenRoute";
|
||||
static const String kOTPScreenRoute = "/OTPScreenRoute";
|
||||
// static const String kCalendarScreenRoute = "/CalendarScreenRoute";
|
||||
static const String kRotaDashboardScreenRoute = "/RotaDashboardScreenRoute";
|
||||
static const String kBookHolidayScreenRoute = "/BookHolidayScreenRoute";
|
||||
static const String kClientsListScreenRoute = "/ClientsListScreenRoute";
|
||||
static const String kClientsProfileScreenRoute = "/ClientsProfileScreenRoute";
|
||||
static const String kAppointmentsScreenRoute = "/AppointmentsScreenRoute";
|
||||
static const String kNotesScreenRoute = "/NotesScreenRoute";
|
||||
static const String kSelectNoteScreenRoute = "/SelectNoteScreenRoute";
|
||||
static const String kNewNoteScreenRoute = "/NewNoteScreenRoute";
|
||||
static const String kCarePlanMenuScreenRoute = "/CarePlanMenuScreenRoute";
|
||||
static const String kDashboardScreenRoute = "/DashboardScreenRoute";
|
||||
static const String kPickUpShiftsScreenRoute = "/PickUpShiftScreenRoute";
|
||||
static const String kChatScreenRoute = "/ChatScreenRoute";
|
||||
static const String kNotificationListScreenRoute = "/NotificationListScreenRoute";
|
||||
static const String kViewProfileScreenRoute = "/ViewProfileScreenRoute";
|
||||
static const String kYourRotaScreenRoute = "/YourRotaScreenRoute";
|
||||
static const String kInboxScreenRoute = "/InboxScreenRoute";
|
||||
static const String kDocumentsListScreenRoute = "/kDocumentsListScreenRoute";
|
||||
static const String kDocumentDetailsScreenRoute = "/kDocumentDetailsScreenRoute";
|
||||
static const String kRecentIncidentsScreenRoute = "/kRecentIncidentsScreenRoute";
|
||||
static const String kCurrentHealthIssuesScreenRoute = "/kCurrentHealthIssuesScreenRoute";
|
||||
static const String kConsentAndCapacityQuestionnaireScreenRoute = "/kConsentAndCapacityQuestionnaireScreenRoute";
|
||||
static const String kConsentAndCapacityAddNewFormScreenRoute = "/kConsentAndCapacityAddNewFormScreenRoute";
|
||||
static const String kLifeHistoryAndGoalsScreenRoute = "/kLifeHistoryAndGoalsScreenRoute";
|
||||
static const String kPBSPlanScreenRoute = "/kPBSPlanScreenRoute";
|
||||
static const String kPhotoGalleryScreenRoute = "/kPhotoGalleryScreenRoute";
|
||||
static const String kRiskAssessmentsScreenRoute = "/kRiskAssessmentsScreenRoute";
|
||||
static const String kRiskAssessmentsTemplateScreenRoute = "/kRiskAssessmentsTemplateScreenRoute";
|
||||
static const String kSupportPlanScreenRoute = "/kSupportPlanScreenRoute";
|
||||
static const String kOverViewScreenRoute = "/kOverViewScreenRoute";
|
||||
static const String kCrisisManagementScreenRoute = "/kCrisisManagementScreenRoute";
|
||||
static const String kMentalHealthScreenRoute = "/kMentalHealthScreenRoute";
|
||||
static const String kHealthScreenRoute = "/kHealthScreenRoute";
|
||||
static const String kFuturePlansScreenRoute = "/kFuturePlansScreenRoute";
|
||||
static const String kMyCurrentPlanScreenRoute = "/kMyCurrentPlanScreenRoute";
|
||||
static const String kMyInterestsScreenRoute = "/kMyInterestsScreenRoute";
|
||||
static const String kThingsIWantYouToHelpScreenRoute = "/kThingsIWantYouToHelpScreenRoute";
|
||||
static const String kClientsIntroductionScreenRoute = "/kClientsIntroductionScreenRoute";
|
||||
static const String kMedicationScreenRoute = "/kMedicationScreenRoute";
|
||||
static const String kHealthFullBodyMapScreenRoute = "/kHealthFullBodyMapScreenRoute";
|
||||
static const String kAddDetailsToNewPointScreenRoute = "/kAddDetailsToNewPoint";
|
||||
static const String kAddNewRecentIncidentsScreenRoute = "/kAddNewRecentIncidentsScreenRoute";
|
||||
static const String kAddNewPBSPlanScreenRoute = "/kAddNewPBSPlanScreenRoute";
|
||||
static const String kAddNewDocumentScreenRoute = "/kAddNewDocumentScreenRoute";
|
||||
static const String kSelectUserForChatScreenRoute = "/kSelectUserForChatScreenRoute";
|
||||
|
||||
static const String kCareNotesScreenRoute = "/kCareNotesScreenRoute";
|
||||
static const String kCareNotesSubcategoriesScreenRoute = "/kCareNotesSubcategoriesScreenRoute";
|
||||
static const String kFreeTextEntriesScreenRoute = "/kFreeTextEntriesScreenRoute";
|
||||
static const String kWeightHeightFormScreenRoute = "/kWeightHeightFormScreenRoute";
|
||||
static const String kHealthAppointmentsFormScreenRoute = "/kHealthAppointmentsFormScreenRoute";
|
||||
static const String kShoweringBathFormScreenRoute = "/kShoweringBathFormScreenRoute";
|
||||
static const String kToiletingNoteFormScreenRoute = "/kToiletingNoteFormScreenRoute";
|
||||
static const String kMoodRatingFormScreenRoute = "/kMoodRatingFormScreenRoute";
|
||||
static const String kABCFormScreenRoute = "/kABCFormScreenRoute";
|
||||
static const String kConsentCapacityFormScreenRoute = "/kConsentCapacityFormScreenRoute";
|
||||
static const String kInjuryHealthIssueFormScreenRoute = "/kInjuryHealthIssueFormScreenRoute";
|
||||
static const String kObservationsFormScreenRoute = "/kObservationsFormScreenRoute";
|
||||
static const String kSafeguardingFormScreenRoute = "/kSafeguardingFormScreenRoute";
|
||||
static const String kPhysicalInterventionFormScreenRoute = "/kPhysicalInterventionFormScreenRoute";
|
||||
static const String kNutritionHydrationFormScreenRoute = "/kNutritionHydrationFormScreenRoute";
|
||||
static const String kAllCareNotesScreenRoute = "/kAllCareNotesScreenRoute";
|
||||
static const String kCareNoteDetailScreenRoute = "/kCareNoteDetailScreenRoute";
|
||||
static const String kAddEditMemoryBoxScreen = "/kAddEditMemoryBoxScreen";
|
||||
static const String kAddEditRiskAssessmentScreen = "/kAddEditRiskAssessmentScreen";
|
||||
static const String kSettingsScreen = "/kSettingsScreen";
|
||||
static const String kTrainingsScreen = "/kTrainingsScreen";
|
||||
static const String kTrainingDetailScreen = "/kTrainingDetailScreen";
|
||||
}
|
||||
2
lib/utilities/custom_router/export_custom_router.dart
Normal file
2
lib/utilities/custom_router/export_custom_router.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'custom_route_names.dart';
|
||||
export 'custom_route_generator.dart';
|
||||
38
lib/utilities/custom_theme.dart
Normal file
38
lib/utilities/custom_theme.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
|
||||
class CustomTheme {
|
||||
CustomTheme._();
|
||||
|
||||
static ThemeData defaultTheme() {
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
fontFamily: "Roboto",
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: CustomAppColors.kSecondaryColor
|
||||
),
|
||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||
color: CustomAppColors.kSecondaryColor),
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: const BorderSide(
|
||||
color: CustomAppColors.kSmokeColor,
|
||||
width: 0.6,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
5.r,
|
||||
),
|
||||
),
|
||||
),
|
||||
// radioTheme: RadioThemeData(
|
||||
// fillColor: MaterialStateProperty.resolveWith((states) {
|
||||
// if (states.contains(MaterialState.pressed)) {
|
||||
// return CustomAppColors.kSecondaryColor;
|
||||
// }
|
||||
// return Colors.white;
|
||||
// }),
|
||||
// ),
|
||||
splashColor: CustomAppColors.kTransparentColor,
|
||||
);
|
||||
}
|
||||
}
|
||||
33
lib/utilities/custom_timeago_messages.dart
Normal file
33
lib/utilities/custom_timeago_messages.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:get_time_ago/get_time_ago.dart';
|
||||
|
||||
class CustomTimeAgoMessages implements Messages {
|
||||
@override
|
||||
String prefixAgo() => '';
|
||||
|
||||
@override
|
||||
String suffixAgo() => '';
|
||||
|
||||
@override
|
||||
String secsAgo(int seconds) => 'a moment ago';
|
||||
|
||||
@override
|
||||
String minAgo(int minutes) => 'a minute ago';
|
||||
|
||||
@override
|
||||
String minsAgo(int minutes) => '$minutes minutes ago';
|
||||
|
||||
@override
|
||||
String hourAgo(int minutes) => 'an hour ago';
|
||||
|
||||
@override
|
||||
String hoursAgo(int hours) => '$hours hours ago';
|
||||
|
||||
@override
|
||||
String dayAgo(int hours) => 'yesterday';
|
||||
|
||||
@override
|
||||
String daysAgo(int days) => '$days days ago';
|
||||
|
||||
@override
|
||||
String wordSeparator() => ' ';
|
||||
}
|
||||
31
lib/utilities/custom_ui_over_lay.dart
Normal file
31
lib/utilities/custom_ui_over_lay.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
|
||||
class CustomUIOverLay {
|
||||
CustomUIOverLay._();
|
||||
|
||||
static Future<void> initialize() async {
|
||||
_appStatusBarNavBarTheme();
|
||||
_setSystemOrientation();
|
||||
}
|
||||
|
||||
static void _appStatusBarNavBarTheme() {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
systemNavigationBarColor: CustomAppColors.kTransparentColor,
|
||||
systemNavigationBarDividerColor: CustomAppColors.kPrimaryColor,
|
||||
systemNavigationBarIconBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarColor: CustomAppColors.kTransparentColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static void _setSystemOrientation() {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
// DeviceOrientation.portraitDown,
|
||||
]);
|
||||
}
|
||||
}
|
||||
108
lib/utilities/date_formatter.dart
Normal file
108
lib/utilities/date_formatter.dart
Normal file
@@ -0,0 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DateFormatter {
|
||||
static final dateFormatter = DateFormat("dd-MM-yyyy");
|
||||
static final dateFormatter2 = DateFormat("dd/MM/yyyy");
|
||||
|
||||
String todayTomorrowYesterday(DateTime dateToCheck) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
final tomorrow = DateTime(now.year, now.month, now.day + 1);
|
||||
|
||||
final aDate =
|
||||
DateTime(dateToCheck.year, dateToCheck.month, dateToCheck.day);
|
||||
if (aDate == today) {
|
||||
return 'Today';
|
||||
} else if (aDate == yesterday) {
|
||||
return 'Yesterday';
|
||||
} else if (aDate == tomorrow) {
|
||||
return 'Tomorrow';
|
||||
} else {
|
||||
return 'nothing';
|
||||
}
|
||||
}
|
||||
|
||||
// String getRotaHeadingDate(DateTime dateTime) {
|
||||
// String wordDate = todayTomorrowYesterday(dateTime);
|
||||
// String date = DateFormat("yMMMMd").format(dateTime);
|
||||
// return wordDate != 'nothing'
|
||||
// ? "$wordDate, ${date.split(" ").first.substring(0, 3)} ${dateTime.day}"
|
||||
// : "${date.split(" ").first.substring(0, 3)} ${dateTime.day}";
|
||||
// }
|
||||
|
||||
String getRotaDate(DateTime dateTime) {
|
||||
//Nov 1, 5AM-0PM
|
||||
String date = DateFormat("yMMMMd").format(dateTime);
|
||||
return "${date.split(" ").first.substring(0, 3)} ${dateTime.day}, ${dateTime.hour}AM-${dateTime.minute}PM";
|
||||
}
|
||||
|
||||
DateTime? time24to12formatDate({required String time}) {
|
||||
try {
|
||||
if (time.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final f = DateFormat("HH:mm");
|
||||
return f.parse(time);
|
||||
} catch (e) {
|
||||
debugPrint(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
TimeOfDay? time24to12format({required String time}) {
|
||||
final dateTime = time24to12formatDate(time: time);
|
||||
return (dateTime == null) ? null : TimeOfDay.fromDateTime(dateTime);
|
||||
}
|
||||
|
||||
String roasterShiftFormattedTime({required String time}) {
|
||||
final dateTime = time24to12formatDate(time: time);
|
||||
return (dateTime == null) ? "" : DateFormat("hh:mm aa").format(dateTime);
|
||||
}
|
||||
|
||||
String getRotaNewDate(
|
||||
{required int shiftDate,
|
||||
required String startShiftTime,
|
||||
required String endShiftTime}) {
|
||||
if (shiftDate == 0 || startShiftTime.isEmpty || endShiftTime.isEmpty) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final f = DateFormat("HH:mm");
|
||||
final sd = f.parse(startShiftTime);
|
||||
final ed = f.parse(endShiftTime);
|
||||
final date = DateTime.fromMillisecondsSinceEpoch(shiftDate);
|
||||
|
||||
return "${DateFormat("MMM dd").format(date)}, ${DateFormat("hha").format(sd)} - ${DateFormat("hha").format(ed)}";
|
||||
}
|
||||
|
||||
String getAppointmentTime(DateTime dateTime) {
|
||||
//Nov 1
|
||||
String date = DateFormat("yMMMMd").format(dateTime);
|
||||
return "${date.split(" ").first.substring(0, 3)} ${dateTime.day}";
|
||||
}
|
||||
|
||||
String getHolidayDate(DateTime dateTime) {
|
||||
//jan 2, 2024
|
||||
String date = DateFormat("MMM dd, yyyy").format(dateTime);
|
||||
return "${date.split(" ").first.substring(0, 3)} ${dateTime.day}, ${dateTime.year}";
|
||||
}
|
||||
|
||||
String getFormattedDateFromUtc(String utcTime) {
|
||||
try {
|
||||
return DateFormat("yyyy-MM-dd")
|
||||
.parse(utcTime, true)
|
||||
.toLocal()
|
||||
.toString()
|
||||
.split(" ")
|
||||
.first; //String 2024-02-22
|
||||
} catch (e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
static String ddMMyyyyhhmmFormat(DateTime date) {
|
||||
return DateFormat("dd/MM/yyyy hh:mm aa").format(date);
|
||||
}
|
||||
}
|
||||
9
lib/utilities/enums/api_method.dart
Normal file
9
lib/utilities/enums/api_method.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
enum ApiMethod {
|
||||
get,
|
||||
post,
|
||||
put,
|
||||
patch,
|
||||
delete;
|
||||
|
||||
String get value => name;
|
||||
}
|
||||
54
lib/utilities/enums/body_parts.dart
Normal file
54
lib/utilities/enums/body_parts.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
enum BodyPart {
|
||||
fronthead(topPercent: 11, leftPercent: 19.5, apiValue: 'fronthead'),
|
||||
backhead(topPercent: 11, leftPercent: 77.5, apiValue: 'backhead'),
|
||||
righteye(topPercent: 14, leftPercent: 17, apiValue: 'righteye'),
|
||||
lefteye(topPercent: 14, leftPercent: 22, apiValue: 'lefteye'),
|
||||
rightear(topPercent: 15, leftPercent: 14, apiValue: 'rightear'),
|
||||
leftear(topPercent: 15, leftPercent: 25.5, apiValue: 'leftear'),
|
||||
nose(topPercent: 16, leftPercent: 19.5, apiValue: 'nose'),
|
||||
mouth(topPercent: 18, leftPercent: 19.5, apiValue: 'mouth'),
|
||||
neck(topPercent: 21, leftPercent: 19.5, apiValue: 'neck'),
|
||||
nape(topPercent: 20, leftPercent: 77.5, apiValue: 'nape'),
|
||||
rightshoulder(topPercent: 26, leftPercent: 7.5, apiValue: 'rightshoulder'),
|
||||
leftshoulder(topPercent: 26, leftPercent: 31.5, apiValue: 'leftshoulder'),
|
||||
rightshoulderblade(topPercent: 26, leftPercent: 88.5, apiValue: 'rightshoulderblade'),
|
||||
leftshoulderblade(topPercent: 26, leftPercent: 66.5, apiValue: 'leftshoulderblade'),
|
||||
rightArm(topPercent: 35, leftPercent: 5.5, apiValue: 'rightArm'),
|
||||
leftArm(topPercent: 35, leftPercent: 33.5, apiValue: 'leftArm'),
|
||||
rightforearm(topPercent: 46, leftPercent: 4.5, apiValue: 'rightforearm'),
|
||||
leftforearm(topPercent: 46, leftPercent: 34.5, apiValue: 'leftforearm'),
|
||||
rightelbow(topPercent: 41, leftPercent: 93, apiValue: 'rightelbow'),
|
||||
leftelbow(topPercent: 41, leftPercent: 62, apiValue: 'leftelbow'),
|
||||
rightwrist(topPercent: 51, leftPercent: 3, apiValue: 'rightwrist'),
|
||||
leftwrist(topPercent: 51, leftPercent: 36, apiValue: 'leftwrist'),
|
||||
righthand(topPercent: 55, leftPercent: 3, apiValue: 'righthand'),
|
||||
lefthand(topPercent: 55, leftPercent: 36, apiValue: 'lefthand'),
|
||||
chest(topPercent: 30, leftPercent: 19.5, apiValue: 'chest'),
|
||||
topback(topPercent: 30, leftPercent: 77.5, apiValue: 'topback'),
|
||||
middleback(topPercent: 38, leftPercent: 77.5, apiValue: 'middleback'),
|
||||
bottomback(topPercent: 47, leftPercent: 77.5, apiValue: 'bottomback'),
|
||||
abdomen(topPercent: 40, leftPercent: 19.5, apiValue: 'abdomen'),
|
||||
lefthip(topPercent: 54, leftPercent: 67, apiValue: 'lefthip'),
|
||||
righthip(topPercent: 54, leftPercent: 88.3, apiValue: 'righthip'),
|
||||
rightbuttock(topPercent: 52, leftPercent: 83, apiValue: 'rightbuttock'),
|
||||
leftbuttock(topPercent: 52, leftPercent: 72, apiValue: 'leftbuttock'),
|
||||
groin(topPercent: 54, leftPercent: 19.5, apiValue: 'groin'),
|
||||
rightthigh(topPercent: 61, leftPercent: 13.5, apiValue: 'rightthigh'),
|
||||
leftthigh(topPercent: 61, leftPercent: 25.5, apiValue: 'leftthigh'),
|
||||
rightknee(topPercent: 73, leftPercent: 13.5, apiValue: 'rightknee'),
|
||||
leftknee(topPercent: 73, leftPercent: 25.5, apiValue: 'leftknee'),
|
||||
rightcalf(topPercent: 81, leftPercent: 84, apiValue: 'rightcalf'),
|
||||
leftcalf(topPercent: 81, leftPercent: 71.5, apiValue: 'leftcalf'),
|
||||
leftankle(topPercent: 93, leftPercent: 25, apiValue: 'leftankle'),
|
||||
rightankle(topPercent: 93, leftPercent: 14.5, apiValue: 'rightankle'),
|
||||
leftfoot(topPercent: 96, leftPercent: 25, apiValue: 'leftfoot'),
|
||||
rightfoot(topPercent: 96, leftPercent: 14.5, apiValue: 'rightfoot'),
|
||||
leftheel(topPercent: 94, leftPercent: 72.5, apiValue: 'leftheel'),
|
||||
rightheel(topPercent: 94, leftPercent: 83, apiValue: 'rightheel');
|
||||
|
||||
final double topPercent;
|
||||
final double leftPercent;
|
||||
final String apiValue;
|
||||
|
||||
const BodyPart({required this.topPercent, required this.leftPercent, required this.apiValue});
|
||||
}
|
||||
120
lib/utilities/enums/care_note_form_type.dart
Normal file
120
lib/utilities/enums/care_note_form_type.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
///Note: when adding new type, make sure to add condition in [CareNotesFormType.fromText] also
|
||||
enum CareNotesFormType {
|
||||
injuryHealthIssueForm("injuryHealthIssueForm", "InjuryHealthIssue"),
|
||||
weightHeightForm("weightHeightForm", "WeightHeight"),
|
||||
healthAppointmentForm("healthAppointmentForm", "HealthAppointments"),
|
||||
observationsForm("observationsForm", "Observations"),
|
||||
healthOtherForm("healthOtherForm", 'HealthOther'),
|
||||
generalNoteForm("generalNoteForm", "GeneralNote"),
|
||||
activitiesForm("activitiesForm", "Activities"),
|
||||
sleepForm("sleepForm", "Sleep"),
|
||||
safeguardingForm("safeguardingForm", "Safeguarding"),
|
||||
generalOtherForm("generalOtherForm", "GeneralOther"),
|
||||
toiletingNoteForm("toiletingNoteForm", "Toileting"),
|
||||
showeringBathForm("showeringBathForm", "ShoweringBath"),
|
||||
mouthHygieneForm("mouthHygieneForm", "MouthHygiene"),
|
||||
personalCareOtherForm("personalCareOtherForm", "PersonalCareOther"),
|
||||
moodRatingForm("moodRatingForm", "MoodRating"),
|
||||
ABCForm("ABCForm", "ABC"),
|
||||
physicalInterventionForm("physicalInterventionForm", "PhysicalIntervention"),
|
||||
consentCapacityForm("consentCapacityForm", "ConsentCapacityMCADOLS"),
|
||||
mentalWellbeingOtherForm("mentalWellbeingOtherForm", "MentalWellbeingOther"),
|
||||
meetingsForm("meetingsForm", "Meetings"),
|
||||
telephoneCallsForm("telephoneCallsForm", "TelephoneCalls"),
|
||||
reviewsForm("reviewsForm", "Reviews"),
|
||||
emailsForm("emailsForm", "Emails"),
|
||||
allOtherInteractionsForm("allOtherInteractionsForm", "AllOtherInteractions"),
|
||||
professionalFamilyInteractionsOtherForm(
|
||||
"professionalFamilyInteractionsOtherForm",
|
||||
"ProfessionalFamilyInteractionsOther"),
|
||||
laundryForm("laundryForm", "Laundry"),
|
||||
cookingForm("cookingForm", "Cooking"),
|
||||
nutritionHydrationForm("nutritionHydrationForm", "NutritionHydration"),
|
||||
cleaningForm("cleaningForm", "Cleaning"),
|
||||
financeForm("financeForm", "Finance"),
|
||||
publicInteractionForm("publicInteractionForm", "PublicInteraction"),
|
||||
educationForm("educationForm", "Education"),
|
||||
independentLivingOtherForm(
|
||||
"independentLivingOtherForm", "IndependentLivingOther"),
|
||||
;
|
||||
|
||||
final String text;
|
||||
final String apiValue;
|
||||
|
||||
const CareNotesFormType(this.text, this.apiValue);
|
||||
|
||||
factory CareNotesFormType.fromText(String text) {
|
||||
if (text == CareNotesFormType.injuryHealthIssueForm.text) {
|
||||
return CareNotesFormType.injuryHealthIssueForm;
|
||||
} else if (text == CareNotesFormType.weightHeightForm.text) {
|
||||
return CareNotesFormType.weightHeightForm;
|
||||
} else if (text == CareNotesFormType.healthAppointmentForm.text) {
|
||||
return CareNotesFormType.healthAppointmentForm;
|
||||
} else if (text == CareNotesFormType.observationsForm.text) {
|
||||
return CareNotesFormType.observationsForm;
|
||||
} else if (text == CareNotesFormType.healthOtherForm.text) {
|
||||
return CareNotesFormType.healthOtherForm;
|
||||
} else if (text == CareNotesFormType.generalNoteForm.text) {
|
||||
return CareNotesFormType.generalNoteForm;
|
||||
} else if (text == CareNotesFormType.activitiesForm.text) {
|
||||
return CareNotesFormType.activitiesForm;
|
||||
} else if (text == CareNotesFormType.sleepForm.text) {
|
||||
return CareNotesFormType.sleepForm;
|
||||
} else if (text == CareNotesFormType.safeguardingForm.text) {
|
||||
return CareNotesFormType.safeguardingForm;
|
||||
} else if (text == CareNotesFormType.generalOtherForm.text) {
|
||||
return CareNotesFormType.generalOtherForm;
|
||||
} else if (text == CareNotesFormType.showeringBathForm.text) {
|
||||
return CareNotesFormType.showeringBathForm;
|
||||
} else if (text == CareNotesFormType.mouthHygieneForm.text) {
|
||||
return CareNotesFormType.mouthHygieneForm;
|
||||
} else if (text == CareNotesFormType.personalCareOtherForm.text) {
|
||||
return CareNotesFormType.personalCareOtherForm;
|
||||
} else if (text == CareNotesFormType.moodRatingForm.text) {
|
||||
return CareNotesFormType.moodRatingForm;
|
||||
} else if (text == CareNotesFormType.toiletingNoteForm.text) {
|
||||
return CareNotesFormType.toiletingNoteForm;
|
||||
} else if (text == CareNotesFormType.ABCForm.text) {
|
||||
return CareNotesFormType.ABCForm;
|
||||
} else if (text == CareNotesFormType.physicalInterventionForm.text) {
|
||||
return CareNotesFormType.physicalInterventionForm;
|
||||
} else if (text == CareNotesFormType.consentCapacityForm.text) {
|
||||
return CareNotesFormType.consentCapacityForm;
|
||||
} else if (text == CareNotesFormType.mentalWellbeingOtherForm.text) {
|
||||
return CareNotesFormType.mentalWellbeingOtherForm;
|
||||
} else if (text == CareNotesFormType.meetingsForm.text) {
|
||||
return CareNotesFormType.meetingsForm;
|
||||
} else if (text == CareNotesFormType.telephoneCallsForm.text) {
|
||||
return CareNotesFormType.telephoneCallsForm;
|
||||
} else if (text == CareNotesFormType.reviewsForm.text) {
|
||||
return CareNotesFormType.reviewsForm;
|
||||
} else if (text == CareNotesFormType.emailsForm.text) {
|
||||
return CareNotesFormType.emailsForm;
|
||||
} else if (text == CareNotesFormType.allOtherInteractionsForm.text) {
|
||||
return CareNotesFormType.allOtherInteractionsForm;
|
||||
} else if (text ==
|
||||
CareNotesFormType.professionalFamilyInteractionsOtherForm.text) {
|
||||
return CareNotesFormType.professionalFamilyInteractionsOtherForm;
|
||||
} else if (text == CareNotesFormType.laundryForm.text) {
|
||||
return CareNotesFormType.laundryForm;
|
||||
} else if (text == CareNotesFormType.cookingForm.text) {
|
||||
return CareNotesFormType.cookingForm;
|
||||
} else if (text == CareNotesFormType.nutritionHydrationForm.text) {
|
||||
return CareNotesFormType.nutritionHydrationForm;
|
||||
} else if (text == CareNotesFormType.cleaningForm.text) {
|
||||
return CareNotesFormType.cleaningForm;
|
||||
} else if (text == CareNotesFormType.financeForm.text) {
|
||||
return CareNotesFormType.financeForm;
|
||||
} else if (text == CareNotesFormType.publicInteractionForm.text) {
|
||||
return CareNotesFormType.publicInteractionForm;
|
||||
} else if (text == CareNotesFormType.educationForm.text) {
|
||||
return CareNotesFormType.educationForm;
|
||||
} else if (text == CareNotesFormType.independentLivingOtherForm.text) {
|
||||
return CareNotesFormType.independentLivingOtherForm;
|
||||
} else {
|
||||
throw ArgumentError(
|
||||
'$text doesn\'t match any CareNotesFormTypes. Add following condition in CareNotesFormType.fromText factory constructor: \nelse if (text == CareNotesFormType.$text.text) {return CareNotesFormType.$text;}',
|
||||
"text");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
lib/utilities/export_utilities.dart
Normal file
11
lib/utilities/export_utilities.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
export 'custom_router/export_custom_router.dart';
|
||||
export 'mixins/export_mixins.dart';
|
||||
export 'extensions/export_extensions.dart';
|
||||
export 'local_storage_manager/export_local_storage.dart';
|
||||
export 'constant_text.dart';
|
||||
export 'custom_theme.dart';
|
||||
export 'custom_app_colors.dart';
|
||||
export 'custom_ui_over_lay.dart';
|
||||
export 'assets_manager.dart';
|
||||
export 'frequent_functions.dart';
|
||||
export 'date_formatter.dart';
|
||||
200
lib/utilities/extensions/custom_extensions.dart
Normal file
200
lib/utilities/extensions/custom_extensions.dart
Normal file
@@ -0,0 +1,200 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:ftc_mobile_app/view/custom_widgets/loading_widget.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
//BuildContext
|
||||
extension BuildContextExtensions on BuildContext {
|
||||
showErrorSnackBar({required String message, Duration? duration}) {
|
||||
try {
|
||||
ScaffoldMessenger.of(this).showSnackBar(SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
duration: duration ?? const Duration(seconds: 4),
|
||||
));
|
||||
} catch (e) {
|
||||
debugPrint(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// num
|
||||
extension NumExtensions on num {
|
||||
BorderRadius toRadius() {
|
||||
return BorderRadius.circular(toDouble().r);
|
||||
}
|
||||
|
||||
RoundedRectangleBorder toRoundedRectRadius() {
|
||||
return RoundedRectangleBorder(borderRadius: toRadius());
|
||||
}
|
||||
|
||||
num percentOf(num value) {
|
||||
return value * (this / 100.0);
|
||||
}
|
||||
|
||||
double toRadian() {
|
||||
return this * pi / 180;
|
||||
}
|
||||
|
||||
double toDegree() {
|
||||
return this * 180 / pi;
|
||||
}
|
||||
|
||||
double get milesToMeters => this * 1609.344;
|
||||
|
||||
double get metersToMiles => this / 1609.344;
|
||||
}
|
||||
|
||||
// string
|
||||
extension StringExtensions on String? {
|
||||
bool isNullOrEmpty() {
|
||||
return (this == null || this!.isEmpty);
|
||||
}
|
||||
|
||||
bool isNullOrEmptyNot() {
|
||||
return (this != null && this!.isNotEmpty);
|
||||
}
|
||||
|
||||
String removeSpaces() {
|
||||
return this?.replaceAll(RegExp(r"\s\b|\b\s"), "") ?? "";
|
||||
}
|
||||
|
||||
bool get hasDigitsOnly {
|
||||
return isNotNullOrEmpty() && RegExp(r'^[0-9]+$').hasMatch(this!);
|
||||
}
|
||||
}
|
||||
|
||||
// widgets
|
||||
extension WidgetsExtension on Widget {
|
||||
// add click
|
||||
Widget addInkwell({required Function onClick}) {
|
||||
return InkWell(
|
||||
child: this,
|
||||
onTap: () => onClick(),
|
||||
);
|
||||
}
|
||||
|
||||
// add padding
|
||||
Widget addPaddingAll(num value) {
|
||||
return Padding(
|
||||
padding: REdgeInsets.all(value.toDouble()),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
// add horizontal padding
|
||||
Widget addPaddingHorizontal(num value) {
|
||||
return Padding(
|
||||
padding: REdgeInsets.symmetric(horizontal: value.toDouble()),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
// add vertical padding
|
||||
Widget addPaddingVertical(num value) {
|
||||
return Padding(
|
||||
padding: REdgeInsets.symmetric(vertical: value.toDouble()),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget alignCenterLeft() {
|
||||
return Align(alignment: Alignment.centerLeft, child: this);
|
||||
}
|
||||
|
||||
Widget alignCenterRight() {
|
||||
return Align(alignment: Alignment.centerRight, child: this);
|
||||
}
|
||||
|
||||
Widget alignCenter() {
|
||||
return Align(alignment: Alignment.center, child: this);
|
||||
}
|
||||
}
|
||||
|
||||
//bool
|
||||
extension BoolExtensions on bool {
|
||||
bool get not => !this;
|
||||
}
|
||||
|
||||
//object
|
||||
extension ObjectExtension on Object? {
|
||||
bool isNullObject() => this == null;
|
||||
|
||||
bool isNotNull() => isNullObject().not;
|
||||
|
||||
bool isNullOrEmpty() {
|
||||
if (this is String) {
|
||||
return (isNullObject() || (this as String).isEmpty);
|
||||
} else if (this is List) {
|
||||
return (isNullObject() || (this as List).isEmpty);
|
||||
} else {
|
||||
return isNullObject();
|
||||
}
|
||||
}
|
||||
|
||||
bool isNotNullOrEmpty() => isNullOrEmpty().not;
|
||||
}
|
||||
|
||||
extension HexColor on Color {
|
||||
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
|
||||
static Color fromHex(String hexString) {
|
||||
final buffer = StringBuffer();
|
||||
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
|
||||
buffer.write(hexString.replaceFirst('#', ''));
|
||||
return Color(int.parse(buffer.toString(), radix: 16));
|
||||
}
|
||||
|
||||
/// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`).
|
||||
String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
|
||||
'${alpha.toRadixString(16).padLeft(2, '0')}'
|
||||
'${red.toRadixString(16).padLeft(2, '0')}'
|
||||
'${green.toRadixString(16).padLeft(2, '0')}'
|
||||
'${blue.toRadixString(16).padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
extension TimeOfDayChecker on TimeOfDay {
|
||||
bool isBefore(TimeOfDay other) {
|
||||
// print("now: $hour:$minute");
|
||||
// print("other: ${other.hour}:${other.minute}");
|
||||
// final int minutes1 = hour * 60 + minute;
|
||||
// final int minutes2 = other.hour * 60 + other.minute;
|
||||
//
|
||||
// return minutes1 < minutes2;
|
||||
|
||||
print("isBefore");
|
||||
print("now: $hour:$minute");
|
||||
print("other: ${other.hour}:${other.minute}");
|
||||
final n = DateTime.now();
|
||||
final d1 = DateTime(n.year, n.month, n.day, hour, minute);
|
||||
final d2 = DateTime(n.year, n.month, n.day, other.hour, other.minute);
|
||||
// final int minutes1 = hour * 60 + minute;
|
||||
// final int minutes2 = other.hour * 60 + other.minute;
|
||||
|
||||
return d1.isBefore(d2);
|
||||
}
|
||||
|
||||
bool isAfter(TimeOfDay other) {
|
||||
print("isAfter");
|
||||
print("now: $hour:$minute");
|
||||
print("other: ${other.hour}:${other.minute}");
|
||||
final n = DateTime.now();
|
||||
final d1 = DateTime(n.year, n.month, n.day, hour, minute);
|
||||
final d2 = DateTime(n.year, n.month, n.day, other.hour, other.minute);
|
||||
// final int minutes1 = hour * 60 + minute;
|
||||
// final int minutes2 = other.hour * 60 + other.minute;
|
||||
|
||||
return d1.isAfter(d2);
|
||||
}
|
||||
}
|
||||
|
||||
extension FutureExt<T> on Future<T> {
|
||||
Future<T> showLoader() {
|
||||
return Get.showOverlay(
|
||||
asyncFunction: () async => this,
|
||||
opacity: 1,
|
||||
opacityColor: Colors.black.withOpacity(0.5),
|
||||
loadingWidget: const LoadingWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
0
lib/utilities/extensions/export_extensions.dart
Normal file
0
lib/utilities/extensions/export_extensions.dart
Normal file
150
lib/utilities/fcm_notifications.dart
Normal file
150
lib/utilities/fcm_notifications.dart
Normal file
@@ -0,0 +1,150 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
||||
import 'notification_util.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'extensions/custom_extensions.dart';
|
||||
|
||||
class FcmNotification {
|
||||
static FcmNotification? _instance;
|
||||
|
||||
static FcmNotification getInstance() {
|
||||
_instance ??= FcmNotification();
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
init() async {
|
||||
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
|
||||
await Firebase.initializeApp();
|
||||
_firebaseCloudMessagingListeners();
|
||||
}
|
||||
|
||||
Future<void> _firebaseCloudMessagingListeners() async {
|
||||
// ios permission
|
||||
if (Platform.isIOS) iOSPermission();
|
||||
await FirebaseMessaging.instance
|
||||
.setForegroundNotificationPresentationOptions(
|
||||
alert: false, // Required to display a heads up notification
|
||||
badge: true,
|
||||
sound: true,
|
||||
);
|
||||
//foreground message
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage remoteMessage) async {
|
||||
// RemoteNotification notificationData = remoteMessage.notification;
|
||||
|
||||
if (kDebugMode) log("new message received: ${remoteMessage.data}");
|
||||
|
||||
incrementNotificationCount();
|
||||
|
||||
// final data = Notifications.fromJson(remoteMessage.data);
|
||||
|
||||
// if (Get.currentRoute == AppRoute.individualChatScreen &&
|
||||
// data.contentType == notificationContentTypeMessage) return;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
NotificationUtils.showDefaultNotification(
|
||||
title: "${remoteMessage.notification?.title}",
|
||||
body: '${remoteMessage.notification?.body}',
|
||||
payload: remoteMessage.data,
|
||||
);
|
||||
}
|
||||
});
|
||||
// Also handle any interaction when the app is in the background via a
|
||||
// Stream listener
|
||||
FirebaseMessaging.onMessageOpenedApp.listen(
|
||||
(RemoteMessage? remoteMessage) async {
|
||||
if (remoteMessage != null) {
|
||||
handleAppNotification(remoteMessage.data);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> iOSPermission() async {
|
||||
NotificationSettings settings =
|
||||
await FirebaseMessaging.instance.requestPermission(
|
||||
alert: true,
|
||||
announcement: false,
|
||||
badge: true,
|
||||
carPlay: false,
|
||||
criticalAlert: false,
|
||||
provisional: false,
|
||||
sound: true,
|
||||
);
|
||||
debugPrint('User granted permission: ${settings.authorizationStatus}');
|
||||
}
|
||||
|
||||
void selectNotification(String? payload) async {
|
||||
debugPrint('selected notification payload: $payload');
|
||||
|
||||
if (payload != null) {
|
||||
var messageData = jsonDecode(payload);
|
||||
handleAppNotification(messageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleAppNotification(Map<String, dynamic> payload) {
|
||||
if (kDebugMode) {
|
||||
log("Handle App Notification: $payload");
|
||||
}
|
||||
// onNotificationTap(Notifications.fromJson(payload));
|
||||
}
|
||||
|
||||
// onNotificationTap(Notifications notification) {
|
||||
// if (TradePersonNotificationContentTypes.toOpenJobDetailPage
|
||||
// .contains(notification.contentType)) {
|
||||
// _gotoJobDetailScreen(notification.content);
|
||||
// } else if (ClientNotificationContentTypes.toOpenJobDetailPage
|
||||
// .contains(notification.contentType)) {
|
||||
// if (notification.content == null) {
|
||||
// debugPrint("content null");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final id = JobDetail.fromJson(notification.content!).id;
|
||||
// if (id.isNullOrEmpty()) {
|
||||
// debugPrint("job id missing");
|
||||
// return;
|
||||
// }
|
||||
// AppRoute.toJobDetailScreen(args: JobDetailScreenArgs(jobId: id));
|
||||
// } else if (notification.contentType == notificationContentTypeMessage) {
|
||||
// if (notification.content == null) {
|
||||
// debugPrint("content null");
|
||||
// return;
|
||||
// }
|
||||
// final message = ChatModel.fromJson(notification.content);
|
||||
// AppRoute.toIndividualChatScreen(
|
||||
// arguments: IndividualChatScreenArgs(
|
||||
// otherUserId: message.sentBy!.id!,
|
||||
// name: message.sentBy!.fullname ?? emptyString,
|
||||
// profilePicPath: message.sentBy!.profilePic ?? emptyString,
|
||||
// otherUserType: message.sentBy!.userType!,
|
||||
// onLastMessageUpdate: (ChatModel message) {},
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
incrementNotificationCount() async {
|
||||
//Todo
|
||||
// try {
|
||||
// final appProviderController = AppProviderController.instance;
|
||||
// appProviderController.notiCountUp();
|
||||
// if (await FlutterAppBadger.isAppBadgeSupported()) {
|
||||
// FlutterAppBadger.updateBadgeCount(
|
||||
// appProviderController.notificationCount());
|
||||
// }
|
||||
// } catch (e) {
|
||||
// debugPrint(e.toString());
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
debugPrint("Handling a background message: ${message.data}, ${message.ttl}");
|
||||
incrementNotificationCount();
|
||||
}
|
||||
221
lib/utilities/frequent_functions.dart
Normal file
221
lib/utilities/frequent_functions.dart
Normal file
@@ -0,0 +1,221 @@
|
||||
import 'package:get_time_ago/get_time_ago.dart';
|
||||
import 'extensions/custom_extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';
|
||||
|
||||
class FrequentFunctions {
|
||||
FrequentFunctions._();
|
||||
|
||||
static final _instance = FrequentFunctions._();
|
||||
// static Rx<UserModel> userModel = UserModel.empty().obs;
|
||||
// static ProfileDataModel profileDataModelNew = ProfileDataModel.fromJson(
|
||||
// json.decode(LocalStorageManager.getSessionToken(
|
||||
// tokenKey: LocalStorageKeys.kProfileModelKey)));
|
||||
|
||||
factory FrequentFunctions() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
static const noWidget = SizedBox.shrink();
|
||||
|
||||
static const waterDropHeader = WaterDropHeader(
|
||||
waterDropColor: CustomAppColors.kSecondaryColor,
|
||||
complete: FrequentFunctions.noWidget,
|
||||
failed: FrequentFunctions.noWidget,
|
||||
completeDuration: Duration.zero,
|
||||
);
|
||||
|
||||
static DateFormat careNoteDateFormatter = DateFormat("dd/MM/yyyy, hh:mm aa");
|
||||
|
||||
void logoutButtonPressed(BuildContext context) {
|
||||
// LocalStorageManager.removeSession(token: LocalStorageKeys.kUserModelKey);
|
||||
// LocalStorageManager.removeSession(token: LocalStorageKeys.kProfileModelKey);
|
||||
LocalStorageManager.clear();
|
||||
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, CustomRouteNames.kLoginScreenRoute, (route) => false);
|
||||
}
|
||||
|
||||
static void showToast(
|
||||
{required String message, Toast toast = Toast.LENGTH_SHORT}) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
toastLength: toast,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
timeInSecForIosWeb: 1,
|
||||
backgroundColor: CustomAppColors.kBlackColor,
|
||||
textColor: CustomAppColors.kPrimaryColor,
|
||||
fontSize: 13.0,
|
||||
);
|
||||
}
|
||||
|
||||
// static void showDialog(
|
||||
// {required BuildContext context,
|
||||
// required String title,
|
||||
// required String description,
|
||||
// required DialogType type,
|
||||
// Color btnOkColor = CustomAppColors.kSecondaryColor,
|
||||
// Function? onOkBtnPressed}) {
|
||||
// AwesomeDialog(
|
||||
// customHeader: Image.asset(AssetsManager.kAppIcon),
|
||||
// dismissOnBackKeyPress: true,
|
||||
// context: context,
|
||||
// dialogType: type,
|
||||
// headerAnimationLoop: false,
|
||||
// animType: AnimType.scale,
|
||||
// btnOkColor: btnOkColor,
|
||||
// title: title,
|
||||
// dismissOnTouchOutside: true,
|
||||
// desc: description,
|
||||
// btnOkOnPress: () {
|
||||
// if (onOkBtnPressed != null) {
|
||||
// onOkBtnPressed();
|
||||
// }
|
||||
// },
|
||||
// ).show();
|
||||
// }
|
||||
|
||||
List<RotaShift> findDaysWithData(MonthWiseRecord monthWiseRecord) {
|
||||
// print('Month: ${monthWiseRecord.id}');
|
||||
List<RotaShift> rotaShiftListReturning = [];
|
||||
|
||||
for (var weekRecord in [
|
||||
monthWiseRecord.week1,
|
||||
monthWiseRecord.week2,
|
||||
monthWiseRecord.week3,
|
||||
monthWiseRecord.week4,
|
||||
]) {
|
||||
for (var day in [
|
||||
weekRecord.mondayRecord,
|
||||
weekRecord.tuesdayRecord,
|
||||
weekRecord.wednesdayRecord,
|
||||
weekRecord.thursdayRecord,
|
||||
weekRecord.fridayRecord,
|
||||
weekRecord.saturdayRecord,
|
||||
weekRecord.sundayRecord
|
||||
]) {
|
||||
if (day.rotaShift.havingShift &&
|
||||
day.rotaShift.shiftTime.isAfter(DateTime.now())) {
|
||||
rotaShiftListReturning.add(day.rotaShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rotaShiftListReturning;
|
||||
}
|
||||
|
||||
static Future<DateTime?> datePicker(BuildContext context) async {
|
||||
return await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime.now(),
|
||||
lastDate: DateTime.now().add(const Duration(days: 365)),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<TimeOfDay?> selectTime(BuildContext context,
|
||||
{required TimeOfDay selectedTime, required Color themeColor}) =>
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: selectedTime,
|
||||
initialEntryMode: TimePickerEntryMode.dialOnly,
|
||||
confirmText: "CONFIRM",
|
||||
helpText: "Select Time",
|
||||
builder: (context, child) {
|
||||
return MediaQuery(
|
||||
data:
|
||||
MediaQuery.of(context).copyWith(alwaysUse24HourFormat: false),
|
||||
child: Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
timePickerTheme: TimePickerThemeData(
|
||||
backgroundColor: Colors.white,
|
||||
// hourMinuteShape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
// side: BorderSide(color: Colors.orange, width: 4),
|
||||
// ),
|
||||
dayPeriodBorderSide:
|
||||
const BorderSide(color: Colors.black, width: 1),
|
||||
dayPeriodColor: MaterialStateColor.resolveWith((states) =>
|
||||
states.contains(MaterialState.selected)
|
||||
? themeColor
|
||||
: CustomAppColors.kSmokeColor),
|
||||
// shape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
// side: BorderSide(color: Colors.orange, width: 4),
|
||||
// ),
|
||||
dayPeriodTextColor: Colors.black,
|
||||
// dayPeriodTextStyle:
|
||||
// textStyle12w500.copyWith(fontWeight: FontWeight.bold),
|
||||
// dayPeriodShape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
// side: BorderSide(color: Colors.orange, width: 4),
|
||||
// ),
|
||||
hourMinuteColor: MaterialStateColor.resolveWith((states) =>
|
||||
states.contains(MaterialState.selected)
|
||||
? themeColor
|
||||
: CustomAppColors.kSmokeColor),
|
||||
hourMinuteTextColor: MaterialStateColor.resolveWith(
|
||||
(states) => states.contains(MaterialState.selected)
|
||||
? Colors.black
|
||||
: Colors.black),
|
||||
// hourMinuteTextStyle: const TextStyle(
|
||||
// fontSize: 32, fontWeight: FontWeight.bold),
|
||||
|
||||
dialHandColor: themeColor,
|
||||
dialBackgroundColor: CustomAppColors.kSmokeColor,
|
||||
dialTextColor: MaterialStateColor.resolveWith((states) =>
|
||||
states.contains(MaterialState.selected)
|
||||
? Colors.black
|
||||
: Colors.black),
|
||||
|
||||
// helpTextStyle: textStyle14w600,
|
||||
inputDecorationTheme: const InputDecorationTheme(
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
|
||||
entryModeIconColor: themeColor,
|
||||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
// backgroundColor: MaterialStateColor.resolveWith((states) => Colors.orange),
|
||||
foregroundColor: MaterialStateColor.resolveWith(
|
||||
(states) => Colors.black),
|
||||
// overlayColor: MaterialStateColor.resolveWith((states) => Colors.deepOrange),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: child!,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
//eg: a = ["A", "B", "C"], b = ["1", "2"]
|
||||
// zip(a, b) => ["A", "1", "B", "2", "C"]
|
||||
static Iterable<T> zip<T>(Iterable<T> a, Iterable<T> b) sync* {
|
||||
final ita = a.iterator;
|
||||
final itb = b.iterator;
|
||||
bool hasa, hasb;
|
||||
while ((hasa = ita.moveNext()) | (hasb = itb.moveNext())) {
|
||||
if (hasa) yield ita.current;
|
||||
if (hasb) yield itb.current;
|
||||
}
|
||||
}
|
||||
|
||||
static Widget centerText({required String text}) {
|
||||
return Center(
|
||||
child: CustomTextWidget(
|
||||
text: text,
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
));
|
||||
}
|
||||
|
||||
static String toTimesAgo(String? dateTime) {
|
||||
return (dateTime.isNullOrEmpty())
|
||||
? ""
|
||||
: GetTimeAgo.parse(DateTime.parse(dateTime!).toLocal());
|
||||
}
|
||||
}
|
||||
216
lib/utilities/image_picker_popup.dart
Normal file
216
lib/utilities/image_picker_popup.dart
Normal file
@@ -0,0 +1,216 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class ImagePickerPopup {
|
||||
ImagePickerPopup._();
|
||||
|
||||
static final _picker = ImagePicker();
|
||||
|
||||
static void showImagePickerDialog(
|
||||
// BuildContext context,
|
||||
Function(File? file) onFetchImage, {
|
||||
double? maxWidth,
|
||||
double? maxHeight,
|
||||
}) {
|
||||
_checkCameraPermission().then((permissionGranted) {
|
||||
debugPrint("permission status: $permissionGranted");
|
||||
if (permissionGranted) {
|
||||
_showImageUploadBottomSheet(
|
||||
onFetchImage,
|
||||
maxWidth: maxWidth,
|
||||
maxHeight: maxHeight,
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(Get.context!).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please allow permission to access Camera and photos.',
|
||||
// style: textStyle16w400.copyWith(color: Colors.white),
|
||||
),
|
||||
duration: const Duration(seconds: 5),
|
||||
backgroundColor: Colors.black,
|
||||
action: SnackBarAction(
|
||||
label: 'Setting', onPressed: () => openAppSettings()),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Future<bool> _checkCameraPermission() async {
|
||||
// 1. Checking Initial Permission Status:
|
||||
const cameraPermission = Permission.camera;
|
||||
|
||||
final cameraPermissionStatus = await cameraPermission.status;
|
||||
|
||||
if (cameraPermissionStatus.isGranted) {
|
||||
debugPrint("status: true");
|
||||
return true;
|
||||
} else {
|
||||
Map permissionsResult = await [cameraPermission].request();
|
||||
if (permissionsResult.values.isNotEmpty &&
|
||||
permissionsResult[cameraPermission] == PermissionStatus.granted) {
|
||||
debugPrint("status2: true");
|
||||
return true;
|
||||
} else {
|
||||
debugPrint("status3: false");
|
||||
return await cameraPermission.shouldShowRequestRationale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _showImageUploadBottomSheet(
|
||||
// BuildContext context,
|
||||
Function(File) onFetchImage, {
|
||||
double? maxWidth,
|
||||
double? maxHeight,
|
||||
}) {
|
||||
Get.bottomSheet(
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
"Upload Image",
|
||||
// style: textStyle16w700.copyWith(color: Colors.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
"Click a Photo or upload your image from saved photos.",
|
||||
// style: textStyle12w500.copyWith(color: Colors.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
const SizedBox(width: 30),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
// Navigator.of(context).pop();
|
||||
getImageFromSource(
|
||||
fromCamera: true,
|
||||
onFetchImage: onFetchImage,
|
||||
maxWidth: maxWidth,
|
||||
maxHeight: maxHeight,
|
||||
);
|
||||
},
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(20.0)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
CupertinoIcons.camera,
|
||||
size: 50.r,
|
||||
color: Get.theme.primaryColor,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
"Camera",
|
||||
// style: textStyle16w700.copyWith(
|
||||
// color: Colors.black)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 40.r,
|
||||
height: 64.r,
|
||||
child: const Center(
|
||||
child: VerticalDivider(color: Colors.grey, width: 2),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
Get.back();
|
||||
getImageFromSource(
|
||||
fromCamera: false, onFetchImage: onFetchImage);
|
||||
},
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(20.0)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
// SvgPicture.asset(
|
||||
// Assets.svgPlaceholderImg2,
|
||||
// width: 50,
|
||||
// height: 50,
|
||||
// ),
|
||||
Icon(
|
||||
CupertinoIcons.photo,
|
||||
size: 50.r,
|
||||
color: Get.theme.primaryColor,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
"Gallery",
|
||||
// style: textStyle16w700.copyWith(
|
||||
// color: Colors.black)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.white);
|
||||
}
|
||||
|
||||
static void getImageFromSource({
|
||||
required bool fromCamera,
|
||||
required Function(File) onFetchImage,
|
||||
double? maxWidth,
|
||||
double? maxHeight,
|
||||
}) async {
|
||||
final permissionGranted = await _checkCameraPermission();
|
||||
debugPrint("permission status: $permissionGranted");
|
||||
|
||||
if (permissionGranted) {
|
||||
final pickedFile = await _picker.pickImage(
|
||||
source: fromCamera ? ImageSource.camera : ImageSource.gallery,
|
||||
imageQuality: 80,
|
||||
maxWidth: maxWidth,
|
||||
maxHeight: maxHeight,
|
||||
);
|
||||
if (pickedFile != null) {
|
||||
final picture = File(pickedFile.path);
|
||||
onFetchImage(picture);
|
||||
}
|
||||
} else {
|
||||
ScaffoldMessenger.of(Get.context!).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text(
|
||||
'Please allow permission to access Camera and photos.',
|
||||
),
|
||||
duration: const Duration(seconds: 5),
|
||||
backgroundColor: Colors.black,
|
||||
action: SnackBarAction(
|
||||
label: 'Setting', onPressed: () => openAppSettings()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export 'local_storage_keys.dart';
|
||||
export 'local_storage_manager.dart';
|
||||
13
lib/utilities/local_storage_manager/local_storage_keys.dart
Normal file
13
lib/utilities/local_storage_manager/local_storage_keys.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
class LocalStorageKeys {
|
||||
LocalStorageKeys._();
|
||||
|
||||
static const String kUserTokenKey = "UserTokenKey";
|
||||
static const String kUserIdKey = "UserIdKey";
|
||||
// static const String kRememberMeKey = "RememberMeKey";
|
||||
static const String kSaveEmailKey = "SaveEmailKey";
|
||||
// static const String kUserModelKey = "UserModelKey";
|
||||
// static const String kProfileModelKey = "ProfileModelKey";
|
||||
// static const String kIsUserLoggedInKey = "IsUserLoggedInKey ";
|
||||
|
||||
static const String kCurrentOngoingShift = "CurrentOngoingShift ";
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:ftc_mobile_app/models/rota/WeekArrayData.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import 'local_storage_keys.dart';
|
||||
|
||||
abstract class LocalStorageManager {
|
||||
// LocalStorageManager._();
|
||||
//
|
||||
// static final LocalStorageManager _instance = LocalStorageManager._();
|
||||
//
|
||||
// factory LocalStorageManager() {
|
||||
// return _instance;
|
||||
// }
|
||||
|
||||
static final GetStorage _box = GetStorage();
|
||||
|
||||
static Future init() => GetStorage.init();
|
||||
|
||||
static Future<void> saveSession({
|
||||
required String tokenKey,
|
||||
required String tokenValue,
|
||||
}) async {
|
||||
await _box.write(tokenKey, tokenValue);
|
||||
}
|
||||
|
||||
static Future<void> removeSession({required String token}) async {
|
||||
await _box.remove(token);
|
||||
}
|
||||
|
||||
static String getSessionToken({required String tokenKey}) {
|
||||
return _box.read(tokenKey) ?? '';
|
||||
}
|
||||
|
||||
static Future setLoginToken(String token) async {
|
||||
await _box.write(LocalStorageKeys.kUserTokenKey, token);
|
||||
}
|
||||
|
||||
static String getLoginToken() {
|
||||
return _box.read(LocalStorageKeys.kUserTokenKey) ?? '';
|
||||
}
|
||||
|
||||
static Future setUserId(String id) async {
|
||||
await _box.write(LocalStorageKeys.kUserIdKey, id);
|
||||
}
|
||||
|
||||
static String get userId {
|
||||
return _box.read(LocalStorageKeys.kUserIdKey) ?? '';
|
||||
}
|
||||
|
||||
static void saveShiftData({required DaysArrayData data}) {
|
||||
_box.write(LocalStorageKeys.kCurrentOngoingShift, data.toJson());
|
||||
}
|
||||
|
||||
static DaysArrayData? getOngoingShift() {
|
||||
try {
|
||||
return DaysArrayData.fromJson(
|
||||
_box.read(LocalStorageKeys.kCurrentOngoingShift));
|
||||
} catch (e) {
|
||||
debugPrint(
|
||||
"LocalStorageManager.getCurrentShiftData err: ${e.toString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> removeOngoingShift() async {
|
||||
await _box.remove(LocalStorageKeys.kCurrentOngoingShift);
|
||||
}
|
||||
|
||||
static Future clear() {
|
||||
return _box.erase();
|
||||
}
|
||||
}
|
||||
0
lib/utilities/mixins/export_mixins.dart
Normal file
0
lib/utilities/mixins/export_mixins.dart
Normal file
183
lib/utilities/notification_util.dart
Normal file
183
lib/utilities/notification_util.dart
Normal file
@@ -0,0 +1,183 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'fcm_notifications.dart';
|
||||
import 'extensions/custom_extensions.dart';
|
||||
|
||||
const String packageName = "com.inajam.app";
|
||||
const notificationChannelId = packageName;
|
||||
const notificationChannelName = "inajam";
|
||||
const notificationChannelDescription = "In A Jam";
|
||||
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
//for SDK version 33
|
||||
Future<void> requestNotificationPermissions() async {
|
||||
if (Platform.isIOS || Platform.isMacOS) {
|
||||
await flutterLocalNotificationsPlugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
IOSFlutterLocalNotificationsPlugin>()
|
||||
?.requestPermissions(
|
||||
alert: true,
|
||||
badge: true,
|
||||
sound: true,
|
||||
critical: true,
|
||||
);
|
||||
} else if (Platform.isAndroid) {
|
||||
final AndroidFlutterLocalNotificationsPlugin? androidImplementation =
|
||||
flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin>();
|
||||
|
||||
await androidImplementation?.requestNotificationsPermission();
|
||||
}
|
||||
}
|
||||
|
||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('@drawable/notification_icon');
|
||||
|
||||
const DarwinInitializationSettings initializationSettingsDarwin =
|
||||
DarwinInitializationSettings(
|
||||
// requestAlertPermission: true,
|
||||
// requestBadgePermission: true,
|
||||
// requestSoundPermission: true,
|
||||
// onDidReceiveLocalNotification:
|
||||
// (int id, String? title, String? body, String? payload) async {
|
||||
// didReceiveLocalNotificationStream.add(
|
||||
// ReceivedNotification(
|
||||
// id: id,
|
||||
// title: title,
|
||||
// body: body,
|
||||
// payload: payload,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// notificationCategories: darwinNotificationCategories,
|
||||
);
|
||||
|
||||
const InitializationSettings initializationSettings = InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsDarwin,
|
||||
macOS: initializationSettingsDarwin,
|
||||
);
|
||||
|
||||
void selectNotification(String? payload) async {
|
||||
debugPrint('selected notification payload: $payload');
|
||||
debugPrint(
|
||||
'is selected notification payload null or empty: ${payload.isNotNullOrEmpty()}');
|
||||
|
||||
if (payload.isNotNullOrEmpty()) {
|
||||
var messageData = jsonDecode(payload!);
|
||||
handleAppNotification(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
//-----------------------
|
||||
//-----------------------
|
||||
class NotificationUtils {
|
||||
NotificationUtils._();
|
||||
|
||||
static NotificationDetails? platformChannelSpecifics;
|
||||
static AndroidNotificationChannel? channel;
|
||||
static AndroidNotificationDetails? androidPlatformChannelSpecifics;
|
||||
|
||||
static Future init() async {
|
||||
try {
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
|
||||
onDidReceiveNotificationResponse: (response) =>
|
||||
selectNotification(response.payload)
|
||||
|
||||
// onDidReceiveNotificationResponse:
|
||||
// (NotificationResponse notificationResponse) {
|
||||
// switch (notificationResponse.notificationResponseType) {
|
||||
// case NotificationResponseType.selectedNotification:
|
||||
// selectNotificationStream.add(notificationResponse.payload);
|
||||
// break;
|
||||
// case NotificationResponseType.selectedNotificationAction:
|
||||
// if (notificationResponse.actionId == navigationActionId) {
|
||||
// selectNotificationStream.add(notificationResponse.payload);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// },
|
||||
// onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
|
||||
);
|
||||
|
||||
platformChannelSpecifics = await getChannelSpecifics();
|
||||
} catch (e) {
|
||||
debugPrint("NotificationUtils: ${e.toString()}");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<NotificationDetails> getChannelSpecifics(
|
||||
[int? badgeNumber]) async {
|
||||
if (Platform.isAndroid) {
|
||||
channel = await _getAndroidDefaultChannel(notificationChannelId,
|
||||
notificationChannelName, notificationChannelDescription);
|
||||
}
|
||||
androidPlatformChannelSpecifics ??= AndroidNotificationDetails(
|
||||
notificationChannelId, notificationChannelName,
|
||||
channelDescription: notificationChannelDescription,
|
||||
importance: channel?.importance ?? Importance.max,
|
||||
priority: Priority.high,
|
||||
enableVibration: true,
|
||||
playSound: false);
|
||||
|
||||
int badgeNum = 0;
|
||||
|
||||
//Todo
|
||||
// try {
|
||||
// badgeNum =
|
||||
// badgeNumber ?? AppProviderController.instance.notificationCount();
|
||||
// print("badgeNum: $badgeNum");
|
||||
// } catch (e) {}
|
||||
|
||||
var iOSPlatformChannelSpecifics = DarwinNotificationDetails(
|
||||
presentSound: true,
|
||||
presentBadge: true,
|
||||
presentAlert: true,
|
||||
badgeNumber: badgeNum,
|
||||
);
|
||||
return NotificationDetails(
|
||||
android: androidPlatformChannelSpecifics,
|
||||
iOS: iOSPlatformChannelSpecifics,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> showDefaultNotification(
|
||||
{required String title,
|
||||
required String body,
|
||||
Map<String, dynamic>? payload,
|
||||
int? badgeNumber}) async {
|
||||
platformChannelSpecifics = await getChannelSpecifics(badgeNumber);
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
10,
|
||||
title,
|
||||
body,
|
||||
platformChannelSpecifics,
|
||||
payload: (payload.isNullOrEmpty()) ? null : jsonEncode(payload!),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<AndroidNotificationChannel> _getAndroidDefaultChannel(
|
||||
String channelId,
|
||||
String channelName,
|
||||
String? channelDescription,
|
||||
) async {
|
||||
AndroidNotificationChannel channel = AndroidNotificationChannel(
|
||||
channelId,
|
||||
channelName,
|
||||
description: channelDescription,
|
||||
importance: Importance.max,
|
||||
enableVibration: true,
|
||||
playSound: false,
|
||||
);
|
||||
await flutterLocalNotificationsPlugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin>()
|
||||
?.createNotificationChannel(channel);
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user