You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
289 lines
8.7 KiB
Dart
289 lines
8.7 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:hmg_qline/constants/app_constants.dart';
|
|
import 'package:hmg_qline/models/global_config_model.dart';
|
|
import 'package:hmg_qline/models/ticket_model.dart';
|
|
import 'package:hmg_qline/utilities/enums.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
extension ScreenOrientationEnumExt on int {
|
|
ScreenOrientationEnum toScreenOrientationEnum() {
|
|
if (this == 1) {
|
|
return ScreenOrientationEnum.portraitUp;
|
|
} else if (this == 2) {
|
|
return ScreenOrientationEnum.portraitDown;
|
|
} else if (this == 3) {
|
|
return ScreenOrientationEnum.landscapeRight;
|
|
} else if (this == 4) {
|
|
return ScreenOrientationEnum.landscapeLeft;
|
|
} else {
|
|
return ScreenOrientationEnum.portraitUp;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension DateFormatExt on int {
|
|
String toFormattedDateTimeFromInt() {
|
|
return DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(this));
|
|
}
|
|
|
|
DateTime toDateTimeFromInt() {
|
|
return DateTime.fromMillisecondsSinceEpoch(this);
|
|
}
|
|
}
|
|
|
|
extension NavigationExt on BuildContext {
|
|
navigateReplaceTo(String route) {
|
|
Navigator.pushReplacementNamed(this, route);
|
|
}
|
|
|
|
navigateTo(String route) {
|
|
Navigator.pushNamed(this, route);
|
|
}
|
|
|
|
popScreen() => Navigator.of(this).pop();
|
|
}
|
|
|
|
extension ScreenOrientationExt on ScreenOrientationEnum {
|
|
int getTurnsByOrientation() {
|
|
switch (this) {
|
|
case ScreenOrientationEnum.portraitUp:
|
|
return 1;
|
|
case ScreenOrientationEnum.portraitDown:
|
|
return 3;
|
|
case ScreenOrientationEnum.landscapeRight:
|
|
return 2;
|
|
case ScreenOrientationEnum.landscapeLeft:
|
|
return 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension QTypeEnumExtension on int {
|
|
QTypeEnum toQTypeEnum() {
|
|
// return QTypeEnum.lab;
|
|
switch (this) {
|
|
case 1:
|
|
return QTypeEnum.appointment;
|
|
case 2:
|
|
return QTypeEnum.lab;
|
|
case 3:
|
|
return QTypeEnum.rad;
|
|
case 4:
|
|
return QTypeEnum.general;
|
|
default:
|
|
return QTypeEnum.appointment;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension QTypeExtension on QTypeEnum {
|
|
// Convert the QType enum to its corresponding integer ID
|
|
int getQTypeIDFromEnum() {
|
|
return index + 1; // enum index starts from 0, so we add 1 to match your values.
|
|
}
|
|
}
|
|
|
|
extension ScreenTypeExtension on int {
|
|
// Convert int to ScreenType enum
|
|
ScreenTypeEnum toScreenTypeEnum() {
|
|
switch (this) {
|
|
case 1:
|
|
return ScreenTypeEnum.waitingAreaScreen;
|
|
case 2:
|
|
return ScreenTypeEnum.roomLevelScreen;
|
|
case 3:
|
|
return ScreenTypeEnum.receptionScreen;
|
|
case 4:
|
|
return ScreenTypeEnum.dashboardScreen;
|
|
case 5:
|
|
return ScreenTypeEnum.kioskScreen;
|
|
default:
|
|
return ScreenTypeEnum.waitingAreaScreen;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ScreenTypeIDExtension on ScreenTypeEnum {
|
|
// Convert the ScreenType enum to its corresponding integer ID
|
|
int getScreenTypeIDFromEnum() {
|
|
return index + 1; // enum index starts from 0, so we add 1 to match your values.
|
|
}
|
|
}
|
|
|
|
extension IntToLanguageEnum on int {
|
|
LanguageEnum toLanguageEnum() {
|
|
switch (this) {
|
|
case 1:
|
|
return LanguageEnum.english;
|
|
case 2:
|
|
return LanguageEnum.arabic;
|
|
default:
|
|
return LanguageEnum.english;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension LanguageEnumToInt on LanguageEnum {
|
|
int enumToInt() {
|
|
switch (this) {
|
|
case LanguageEnum.english:
|
|
return 1;
|
|
case LanguageEnum.arabic:
|
|
return 2;
|
|
default:
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension LanguageEnumToString on LanguageEnum {
|
|
String enumToString() {
|
|
switch (this) {
|
|
case LanguageEnum.english:
|
|
return "en-US";
|
|
case LanguageEnum.arabic:
|
|
return "ar-SA";
|
|
}
|
|
}
|
|
}
|
|
|
|
extension XCallType on CallTypeEnum {
|
|
Color getColorByCallType() {
|
|
if (this == CallTypeEnum.vitalSign) {
|
|
return AppColors.newVitalSignColor;
|
|
} else if (this == CallTypeEnum.doctor) {
|
|
return AppColors.newDoctorColor;
|
|
} else if (this == CallTypeEnum.procedure) {
|
|
return AppColors.procedureColor;
|
|
} else if (this == CallTypeEnum.vaccination) {
|
|
return AppColors.vaccinationColor;
|
|
} else if (this == CallTypeEnum.nebulization) {
|
|
return AppColors.nebulizationColor;
|
|
} else {
|
|
return Colors.black54;
|
|
}
|
|
}
|
|
|
|
String getMessageByCallTypeForEnglish(GlobalConfigurationsModel globalConfig, {bool isListView = false}) {
|
|
switch (this) {
|
|
case CallTypeEnum.vitalSign:
|
|
return !isListView ? globalConfig.callForVitalSignTextEng : globalConfig.vitalSignTextEng;
|
|
case CallTypeEnum.doctor:
|
|
return !isListView ? globalConfig.callForDoctorTextEng : globalConfig.doctorTextEng;
|
|
case CallTypeEnum.procedure:
|
|
return !isListView ? globalConfig.callForProcedureTextEng : globalConfig.procedureTextEng;
|
|
case CallTypeEnum.vaccination:
|
|
return !isListView ? globalConfig.callForVaccinationTextEng : globalConfig.vaccinationTextEng;
|
|
case CallTypeEnum.nebulization:
|
|
return !isListView ? globalConfig.callForNebulizationTextEng : globalConfig.nebulizationTextEng;
|
|
case CallTypeEnum.none:
|
|
return !isListView ? globalConfig.callForVitalSignTextEng : globalConfig.vitalSignTextEng;
|
|
}
|
|
}
|
|
|
|
String getMessageByCallTypeForArabic(GlobalConfigurationsModel globalConfig, {bool isListView = false}) {
|
|
switch (this) {
|
|
case CallTypeEnum.vitalSign:
|
|
return !isListView ? globalConfig.callForVitalSignTextArb : globalConfig.vitalSignTextArb;
|
|
case CallTypeEnum.doctor:
|
|
return !isListView ? globalConfig.callForDoctorTextArb : globalConfig.doctorTextArb;
|
|
case CallTypeEnum.procedure:
|
|
return !isListView ? globalConfig.callForProcedureTextArb : globalConfig.procedureTextArb;
|
|
case CallTypeEnum.vaccination:
|
|
return !isListView ? globalConfig.callForVaccinationTextArb : globalConfig.vaccinationTextArb;
|
|
case CallTypeEnum.nebulization:
|
|
return !isListView ? globalConfig.callForNebulizationTextArb : globalConfig.nebulizationTextArb;
|
|
case CallTypeEnum.none:
|
|
return !isListView ? globalConfig.callForVitalSignTextArb : globalConfig.vitalSignTextArb;
|
|
}
|
|
}
|
|
|
|
SvgPicture getIconByCallType(double height, {double? width, BoxFit fit = BoxFit.contain}) {
|
|
String iconPath = "";
|
|
if (this == CallTypeEnum.vitalSign) {
|
|
iconPath = AppAssets.newVitalSignIcon;
|
|
} else if (this == CallTypeEnum.doctor) {
|
|
iconPath = AppAssets.newDoctorIcon;
|
|
} else if (this == CallTypeEnum.procedure) {
|
|
iconPath = AppAssets.procedureIcon;
|
|
} else if (this == CallTypeEnum.vaccination) {
|
|
iconPath = AppAssets.vaccinationIcon;
|
|
} else if (this == CallTypeEnum.nebulization) {
|
|
iconPath = AppAssets.nebulizationIcon;
|
|
}
|
|
|
|
return SvgPicture.asset(
|
|
iconPath.isEmpty ? "assets/images/wait.svg" : iconPath,
|
|
height: height,
|
|
width: width,
|
|
color: getColorByCallType(),
|
|
// fit: fit,
|
|
);
|
|
}
|
|
|
|
int getIdFromCallTypeEnum() {
|
|
switch (this) {
|
|
case CallTypeEnum.vitalSign:
|
|
return 1;
|
|
case CallTypeEnum.doctor:
|
|
return 2;
|
|
case CallTypeEnum.procedure:
|
|
return 3;
|
|
case CallTypeEnum.vaccination:
|
|
return 4;
|
|
case CallTypeEnum.nebulization:
|
|
return 5;
|
|
case CallTypeEnum.none:
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
List<Color> getGradientComboByCallType() {
|
|
switch (this) {
|
|
case CallTypeEnum.vitalSign:
|
|
return AppColors.gradientBorderComboForVitalSigns;
|
|
case CallTypeEnum.doctor:
|
|
return AppColors.gradientBorderComboForDoctor;
|
|
case CallTypeEnum.procedure:
|
|
return AppColors.gradientBorderComboForVitalSigns;
|
|
case CallTypeEnum.vaccination:
|
|
return AppColors.gradientBorderComboForVitalSigns;
|
|
case CallTypeEnum.nebulization:
|
|
return AppColors.gradientBorderComboForVitalSigns;
|
|
case CallTypeEnum.none:
|
|
return AppColors.gradientBorderComboForVitalSigns;
|
|
}
|
|
}
|
|
|
|
String getCallTextFromCallType(TicketData ticket) {
|
|
switch (this) {
|
|
case CallTypeEnum.vitalSign:
|
|
return ticket.callForVitalSignText;
|
|
case CallTypeEnum.doctor:
|
|
return ticket.callForDoctorText;
|
|
case CallTypeEnum.procedure:
|
|
return ticket.callForProcedureText;
|
|
case CallTypeEnum.vaccination:
|
|
return ticket.callForVaccinationText;
|
|
case CallTypeEnum.nebulization:
|
|
return ticket.callForNebulizationText;
|
|
default:
|
|
return ticket.callForVitalSignText;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension XCallTypeInt on int {
|
|
CallTypeEnum toCallTypeEnum() {
|
|
if (this == 1) return CallTypeEnum.vitalSign;
|
|
if (this == 2) return CallTypeEnum.doctor;
|
|
if (this == 3) return CallTypeEnum.procedure;
|
|
if (this == 4) return CallTypeEnum.vaccination;
|
|
if (this == 5) return CallTypeEnum.nebulization;
|
|
return CallTypeEnum.vitalSign;
|
|
}
|
|
}
|