Added Screen orientation

master
Faiz Hashmi 2 years ago
parent 3b1966f819
commit 867e2779e3

@ -9,6 +9,7 @@ import 'package:queuing_system/core/response_models/prayers_widget_model.dart';
import 'package:queuing_system/core/response_models/rss_feed_model.dart'; import 'package:queuing_system/core/response_models/rss_feed_model.dart';
import 'package:queuing_system/core/response_models/weathers_widget_model.dart'; import 'package:queuing_system/core/response_models/weathers_widget_model.dart';
import 'package:queuing_system/core/response_models/widgets_config_model.dart'; import 'package:queuing_system/core/response_models/widgets_config_model.dart';
import 'package:queuing_system/core/response_models/test_patients.dart';
const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP"; const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP";
const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate"; const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate";
@ -28,12 +29,15 @@ class API {
static getCallRequestInfoByClinicInfo(String deviceIp, static getCallRequestInfoByClinicInfo(String deviceIp,
{required Function(List<PatientTicketModel>, List<PatientTicketModel>, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async { {required Function(List<PatientTicketModel>, List<PatientTicketModel>, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async {
final body = {"ipAdress": deviceIp, "apiKey": apiKey}; final body = {"ipAdress": deviceIp, "apiKey": apiKey};
bool isDevMode = false; bool isDevMode = true;
if (isDevMode) { if (isDevMode) {
var callPatients = PatientTicketModel.testCallPatients; final Map<String, dynamic> response = testPatientsData["data"] as Map<String, dynamic>;
CallConfig callConfig = CallConfig.testCallConfig;
var isQueuePatients = callPatients.where((element) => (element.isQueue == false)).toList(); CallConfig callConfig = CallConfig.fromJson(response["callConfig"]);
var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList();
var isQueuePatients = callPatients.where((element) => (element.isQueue == false && element.callType != 0)).toList();
log("callPatients: ${callPatients.toString()}");
log("isQueuePatients: ${isQueuePatients.toString()}");
onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig);
return; return;
} }

@ -53,6 +53,7 @@ class CallConfig {
late String callTypeVaccinationText; late String callTypeVaccinationText;
late String callTypeNebulizationText; late String callTypeNebulizationText;
late TextDirection textDirection; late TextDirection textDirection;
late ScreenOrientationEnum screenRotationEnum;
CallConfig({ CallConfig({
this.id = 0, this.id = 0,
@ -94,6 +95,7 @@ class CallConfig {
this.callTypeVaccinationText = "", this.callTypeVaccinationText = "",
this.callTypeNebulizationText = "", this.callTypeNebulizationText = "",
this.textDirection = TextDirection.ltr, this.textDirection = TextDirection.ltr,
this.screenRotationEnum = ScreenOrientationEnum.portraitUp,
}); });
CallConfig.fromJson(Map<String, dynamic> json) { CallConfig.fromJson(Map<String, dynamic> json) {
@ -137,7 +139,8 @@ class CallConfig {
callTypeVaccinationText = json['vaccinationText']; callTypeVaccinationText = json['vaccinationText'];
callTypeNebulizationText = json['nebulizationText']; callTypeNebulizationText = json['nebulizationText'];
textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr;
// textDirection = TextDirection.ltr; screenRotationEnum = (json['orientationType'] as int).toScreenOrientationEnum();
// screenRotationEnum = (json['screenRotationId'] as int).toScreenOrientationEnum();
} }
static var data = { static var data = {
@ -187,3 +190,26 @@ class CallConfig {
static CallConfig testCallConfig = CallConfig.fromJson(data); static CallConfig testCallConfig = CallConfig.fromJson(data);
} }
enum ScreenOrientationEnum {
landscapeRight,
landscapeLeft,
portraitUp,
portraitDown,
}
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;
}
}
}

@ -1,5 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:queuing_system/core/response_models/call_config_model.dart';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
class PatientTicketModel { class PatientTicketModel {
@ -36,6 +37,9 @@ class PatientTicketModel {
late String roomText; late String roomText;
late String queueNoText; late String queueNoText;
late String callForText; late String callForText;
late int orientationType;
late ScreenOrientationEnum screenRotationEnum;
late bool callUpdated = false; late bool callUpdated = false;
PatientTicketModel({ PatientTicketModel({
@ -72,6 +76,8 @@ class PatientTicketModel {
this.roomText = "Room", this.roomText = "Room",
this.queueNoText = "Queue No", this.queueNoText = "Queue No",
this.callForText = "Call For", this.callForText = "Call For",
this.orientationType = 1,
this.screenRotationEnum = ScreenOrientationEnum.portraitUp,
}); });
int getRandomNum() { int getRandomNum() {
@ -111,6 +117,8 @@ class PatientTicketModel {
roomText = json['roomText']; roomText = json['roomText'];
queueNoText = json['queueNoText']; queueNoText = json['queueNoText'];
callForText = json['callForText']; callForText = json['callForText'];
orientationType = json['orientationType'];
screenRotationEnum = (json['orientationType'] as int).toScreenOrientationEnum();
} }
// "voiceLanguage": 1, // "voiceLanguage": 1,
@ -130,27 +138,6 @@ class PatientTicketModel {
// "queueNoText": "Queue No", // "queueNoText": "Queue No",
// "callForText": "Call For" // "callForText": "Call For"
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['patientID'] = patientID;
data['mobileNo'] = mobileNo;
data['doctorName'] = doctorName;
data['doctorNameN'] = doctorNameN;
data['patientGender'] = patientGender;
data['callType'] = callType;
data['roomNo'] = roomNo;
data['createdOn'] = createdOn;
data['editedOn'] = editedOn;
data['queueNo'] = queueNo;
data['callNoStr'] = callNoStr;
data['isQueue'] = isQueue;
data['isToneReq'] = isToneReq;
data['isVoiceReq'] = isVoiceReq;
data['concurrentCallDelaySec'] = concurrentCallDelaySec;
return data;
}
@override @override
String toString() { String toString() {
return (queueNo).toString(); return (queueNo).toString();
@ -164,98 +151,98 @@ class PatientTicketModel {
if (callType == 5) return CallType.nebulization; if (callType == 5) return CallType.nebulization;
return CallType.vitalSign; return CallType.vitalSign;
} }
//
static List<PatientTicketModel> testCallPatients = [ // static List<PatientTicketModel> testCallPatients = [
PatientTicketModel( // PatientTicketModel(
id: 1, // id: 1,
patientID: 112, // patientID: 112,
mobileNo: "112", // mobileNo: "112",
doctorName: "name", // doctorName: "name",
doctorNameN: "nameN", // doctorNameN: "nameN",
patientGender: 1, // patientGender: 1,
callType: 1, // callType: 1,
roomNo: "617", // roomNo: "617",
createdOn: DateTime.now().millisecondsSinceEpoch.toString(), // createdOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOn: DateTime.now().millisecondsSinceEpoch.toString(), // editedOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOnTimeStamp: DateTime.now().millisecondsSinceEpoch, // editedOnTimeStamp: DateTime.now().millisecondsSinceEpoch,
queueNo: "B-89", // queueNo: "B-89",
callNoStr: "B-89", // callNoStr: "B-89",
isQueue: true, // isQueue: true,
isToneReq: true, // isToneReq: true,
isVoiceReq: true, // isVoiceReq: true,
concurrentCallDelaySec: 8, // concurrentCallDelaySec: 8,
), // ),
PatientTicketModel( // PatientTicketModel(
id: 1, // id: 1,
patientID: 112, // patientID: 112,
mobileNo: "112", // mobileNo: "112",
doctorName: "name", // doctorName: "name",
doctorNameN: "nameN", // doctorNameN: "nameN",
patientGender: 1, // patientGender: 1,
callType: 1, // callType: 1,
roomNo: "617", // roomNo: "617",
createdOn: DateTime.now().millisecondsSinceEpoch.toString(), // createdOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOn: DateTime.now().millisecondsSinceEpoch.toString(), // editedOn: DateTime.now().millisecondsSinceEpoch.toString(),
queueNo: "B-89", // queueNo: "B-89",
callNoStr: "B-89", // callNoStr: "B-89",
isQueue: true, // isQueue: true,
isToneReq: true, // isToneReq: true,
isVoiceReq: true, // isVoiceReq: true,
concurrentCallDelaySec: 8, // concurrentCallDelaySec: 8,
), // ),
PatientTicketModel( // PatientTicketModel(
id: 1, // id: 1,
patientID: 112, // patientID: 112,
mobileNo: "112", // mobileNo: "112",
doctorName: "name", // doctorName: "name",
doctorNameN: "nameN", // doctorNameN: "nameN",
patientGender: 1, // patientGender: 1,
callType: 1, // callType: 1,
roomNo: "617", // roomNo: "617",
createdOn: DateTime.now().millisecondsSinceEpoch.toString(), // createdOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOn: DateTime.now().millisecondsSinceEpoch.toString(), // editedOn: DateTime.now().millisecondsSinceEpoch.toString(),
queueNo: "B-89", // queueNo: "B-89",
callNoStr: "B-89", // callNoStr: "B-89",
isQueue: true, // isQueue: true,
isToneReq: true, // isToneReq: true,
isVoiceReq: true, // isVoiceReq: true,
concurrentCallDelaySec: 8, // concurrentCallDelaySec: 8,
), // ),
PatientTicketModel( // PatientTicketModel(
id: 1, // id: 1,
patientID: 112, // patientID: 112,
mobileNo: "112", // mobileNo: "112",
doctorName: "name", // doctorName: "name",
doctorNameN: "nameN", // doctorNameN: "nameN",
patientGender: 1, // patientGender: 1,
callType: 1, // callType: 1,
roomNo: "617", // roomNo: "617",
createdOn: DateTime.now().millisecondsSinceEpoch.toString(), // createdOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOn: DateTime.now().millisecondsSinceEpoch.toString(), // editedOn: DateTime.now().millisecondsSinceEpoch.toString(),
queueNo: "B-89", // queueNo: "B-89",
callNoStr: "B-89", // callNoStr: "B-89",
isQueue: true, // isQueue: true,
isToneReq: true, // isToneReq: true,
isVoiceReq: true, // isVoiceReq: true,
concurrentCallDelaySec: 8, // concurrentCallDelaySec: 8,
), // ),
PatientTicketModel( // PatientTicketModel(
id: 1, // id: 1,
patientID: 112, // patientID: 112,
mobileNo: "112", // mobileNo: "112",
doctorName: "name", // doctorName: "name",
doctorNameN: "nameN", // doctorNameN: "nameN",
patientGender: 1, // patientGender: 1,
callType: 1, // callType: 1,
roomNo: "617", // roomNo: "617",
createdOn: DateTime.now().millisecondsSinceEpoch.toString(), // createdOn: DateTime.now().millisecondsSinceEpoch.toString(),
editedOn: DateTime.now().millisecondsSinceEpoch.toString(), // editedOn: DateTime.now().millisecondsSinceEpoch.toString(),
queueNo: "B-89", // queueNo: "B-89",
callNoStr: "B-89", // callNoStr: "B-89",
isQueue: true, // isQueue: true,
isToneReq: true, // isToneReq: true,
isVoiceReq: true, // isVoiceReq: true,
concurrentCallDelaySec: 8, // concurrentCallDelaySec: 8,
), // ),
]; // ];
} }

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:marquee/marquee.dart'; import 'package:marquee/marquee.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:queuing_system/core/config/size_config.dart'; import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/core/response_models/call_config_model.dart';
import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/home/app_provider.dart';
import 'package:queuing_system/utils/Utils.dart'; import 'package:queuing_system/utils/Utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
@ -28,7 +29,7 @@ class AppFooter extends StatelessWidget {
children: [ children: [
InkWell( InkWell(
onTap: () async { onTap: () async {
await context.read<AppProvider>().callPatientsAPI(); // await context.read<AppProvider>().callPatientsAPI();
}, },
child: AppText( child: AppText(
"Powered By", "Powered By",
@ -37,6 +38,34 @@ class AppFooter extends StatelessWidget {
), ),
), ),
Text(appProvider.currentDeviceIp, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)), Text(appProvider.currentDeviceIp, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)),
Row(
children: [
InkWell(
onTap: () {
appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.portraitUp);
},
child: const Icon(Icons.arrow_upward),
),
InkWell(
onTap: () {
appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeRight);
},
child: const Icon(Icons.arrow_forward),
),
InkWell(
onTap: () {
appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.portraitDown);
},
child: const Icon(Icons.arrow_downward),
),
InkWell(
onTap: () {
appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeLeft);
},
child: const Icon(Icons.arrow_back),
),
],
),
], ],
), ),
const SizedBox(width: 10), const SizedBox(width: 10),

@ -1,9 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:marquee/marquee.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:queuing_system/core/config/config.dart'; import 'package:queuing_system/core/config/config.dart';
import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/home/app_provider.dart';
import 'package:queuing_system/utils/utils.dart'; import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
@ -11,7 +9,6 @@ import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
class AppHeader extends StatelessWidget with PreferredSizeWidget { class AppHeader extends StatelessWidget with PreferredSizeWidget {
const AppHeader({Key? key}) : super(key: key); const AppHeader({Key? key}) : super(key: key);
//
// Widget getWeatherWidget() { // Widget getWeatherWidget() {
// return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) { // return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) {
// if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) { // if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) {
@ -71,37 +68,41 @@ class AppHeader extends StatelessWidget with PreferredSizeWidget {
// }); // });
// } // }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppProvider appProvider = context.read<AppProvider>();
// return SizedBox(); // return SizedBox();
return Container( return Consumer(
height: 100, builder: (BuildContext context, AppProvider appProvider, Widget? child) {
padding: const EdgeInsets.only(left: 20, right: 20), return Container(
decoration: BoxDecoration(color: AppGlobal.vitalSignColor), height: 100,
child: Directionality( padding: const EdgeInsets.only(left: 20, right: 20),
textDirection: appProvider.patientCallConfigurations.textDirection, decoration: BoxDecoration(color: AppGlobal.vitalSignColor),
child: Row( child: Directionality(
mainAxisAlignment: MainAxisAlignment.spaceBetween, textDirection: appProvider.patientCallConfigurations.textDirection,
crossAxisAlignment: CrossAxisAlignment.center, child: Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
InkWell( crossAxisAlignment: CrossAxisAlignment.center,
onTap: () {}, children: [
child: AppText( InkWell(
appProvider.patientCallConfigurations.currentServeText, onTap: () async {
color: Colors.white, await appProvider.callPatientsAPI();
), },
), child: AppText(
// getPrayerWidget(), appProvider.patientCallConfigurations.currentServeText,
// getWeatherWidget(), color: Colors.white,
SvgPicture.asset( ),
"assets/images/hmglogo.svg", ),
height: Utils.getHeight() * 0.5, // getPrayerWidget(),
// getWeatherWidget(),
SvgPicture.asset(
"assets/images/hmglogo.svg",
height: Utils.getHeight() * 0.5,
),
],
), ),
], ),
), );
), },
); );
} }

@ -19,6 +19,8 @@ import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/utils/signalR_utils.dart'; import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
bool isVoiceActualCompletedGlobally = false;
class AppProvider extends ChangeNotifier { class AppProvider extends ChangeNotifier {
AppProvider() { AppProvider() {
callInitializations(); callInitializations();
@ -52,6 +54,13 @@ class AppProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
ScreenOrientationEnum currentScreenRotation = ScreenOrientationEnum.portraitUp;
updateCurrentScreenRotation(ScreenOrientationEnum value) {
currentScreenRotation = value;
notifyListeners();
}
Future<void> getCurrentIP() async { Future<void> getCurrentIP() async {
final ips = await NetworkInterface.list(type: InternetAddressType.IPv4); final ips = await NetworkInterface.list(type: InternetAddressType.IPv4);
for (var interface in ips) { for (var interface in ips) {
@ -100,8 +109,9 @@ class AppProvider extends ChangeNotifier {
String nextPrayerToShowWithTime = ''; String nextPrayerToShowWithTime = '';
void getNextPrayerToShow() { void getNextPrayerToShow() {
log("Checking Namaz time Locally!");
final current = DateTime.now(); final current = DateTime.now();
log("Checking Namaz time Locally at ${current.toString()} and ${current.timeZoneName} ");
if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!).isAfter(current)) { if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!).isAfter(current)) {
final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!)); final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!));
nextPrayerToShowWithTime = "${patientCallConfigurations.fajrText} at $namazTime"; nextPrayerToShowWithTime = "${patientCallConfigurations.fajrText} at $namazTime";
@ -252,6 +262,7 @@ class AppProvider extends ChangeNotifier {
isQueuePatients = isQueuePatientsCalls; isQueuePatients = isQueuePatientsCalls;
notifyListeners(); notifyListeners();
if (patientTickets.isNotEmpty) { if (patientTickets.isNotEmpty) {
updateCurrentScreenRotation(patientTickets.first.screenRotationEnum);
voiceCallPatientTicket(patientTickets.first); voiceCallPatientTicket(patientTickets.first);
updatePatientTicket(patientTickets.first); updatePatientTicket(patientTickets.first);
} }
@ -317,6 +328,7 @@ class AppProvider extends ChangeNotifier {
} }
if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) { if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) {
log("patientTicket.voiceLanguage: ${patientTicket.voiceLanguage}");
final postVoice = getCallTypeText(patientTicket); final postVoice = getCallTypeText(patientTicket);
voiceCaller = CallByVoice( voiceCaller = CallByVoice(
preVoice: patientTicket.ticketNoText, preVoice: patientTicket.ticketNoText,
@ -332,7 +344,6 @@ class AppProvider extends ChangeNotifier {
} }
} else { } else {
isCallingInProgress = false; isCallingInProgress = false;
if (isApiCallNeeded) { if (isApiCallNeeded) {
Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async {
await callPatientsAPI(); await callPatientsAPI();
@ -345,9 +356,10 @@ class AppProvider extends ChangeNotifier {
Future<void> listenAudioPlayerEvents() async { Future<void> listenAudioPlayerEvents() async {
audioPlayer.playerStateStream.listen((playerState) async { audioPlayer.playerStateStream.listen((playerState) async {
if (playerState.processingState == ProcessingState.completed) { if (playerState.processingState == ProcessingState.completed) {
// isCallingInProgress = false; if (currentPatient.isVoiceReq) {
isCallingInProgress = true;
if (currentPatient.isVoiceReq) return; return;
}
if (isQueuePatients.isNotEmpty) { if (isQueuePatients.isNotEmpty) {
final length = isQueuePatients.length; final length = isQueuePatients.length;
@ -377,11 +389,10 @@ class AppProvider extends ChangeNotifier {
} }
}); });
flutterTts.setStartHandler(() {
// isCallingInProgress = true;
});
flutterTts.setCompletionHandler(() async { flutterTts.setCompletionHandler(() async {
log("My Value is in setCompletionHandler: $isVoiceActualCompletedGlobally");
if (!isVoiceActualCompletedGlobally) {}
;
if (isQueuePatients.isNotEmpty) { if (isQueuePatients.isNotEmpty) {
final length = isQueuePatients.length; final length = isQueuePatients.length;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
@ -401,7 +412,6 @@ class AppProvider extends ChangeNotifier {
} }
} }
isCallingInProgress = false; isCallingInProgress = false;
print("I am gere with: $isCallingInProgress");
if (isApiCallNeeded) { if (isApiCallNeeded) {
Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async {
await callPatientsAPI(); await callPatientsAPI();

@ -1,9 +1,12 @@
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:queuing_system/core/base/app_scaffold_widget.dart'; import 'package:queuing_system/core/base/app_scaffold_widget.dart';
import 'package:queuing_system/core/config/config.dart'; import 'package:queuing_system/core/config/config.dart';
import 'package:queuing_system/core/config/size_config.dart'; import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/core/response_models/call_config_model.dart';
import 'package:queuing_system/footer/app_footer.dart'; import 'package:queuing_system/footer/app_footer.dart';
import 'package:queuing_system/header/app_header.dart'; import 'package:queuing_system/header/app_header.dart';
import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/home/app_provider.dart';
@ -19,10 +22,9 @@ class MyHomePage extends StatelessWidget {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Container( return Container(
constraints: BoxConstraints( height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown)
minWidth: SizeConfig.getWidthMultiplier() * 30, ? SizeConfig.getHeightMultiplier() * 8
minHeight: SizeConfig.getHeightMultiplier() * 5.5, : SizeConfig.getHeightMultiplier() * 5,
),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: AppGlobal.configWidgetDecoration, decoration: AppGlobal.configWidgetDecoration,
child: Directionality( child: Directionality(
@ -64,10 +66,9 @@ class MyHomePage extends StatelessWidget {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Container( return Container(
constraints: BoxConstraints( height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown)
minWidth: SizeConfig.getWidthMultiplier() * 25, ? SizeConfig.getHeightMultiplier() * 8
minHeight: SizeConfig.getHeightMultiplier() * 5, : SizeConfig.getHeightMultiplier() * 5,
),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: AppGlobal.configWidgetDecoration, decoration: AppGlobal.configWidgetDecoration,
child: Directionality( child: Directionality(
@ -102,7 +103,7 @@ class MyHomePage extends StatelessWidget {
}); });
} }
getBody(AppProvider appProvider) { getBody(AppProvider appProvider, context) {
return Column( return Column(
children: [ children: [
const SizedBox(height: 12), const SizedBox(height: 12),
@ -121,32 +122,52 @@ class MyHomePage extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
Expanded( Expanded(
flex: 9, flex: 9,
child: dataContent(appProvider: appProvider), child: dataContent(appProvider: appProvider, context: context),
), ),
], ],
); );
} }
int getTurnsByOrientation(ScreenOrientationEnum screenOrientationEnum) {
switch (screenOrientationEnum) {
case ScreenOrientationEnum.portraitUp:
return 0;
case ScreenOrientationEnum.portraitDown:
return 2;
case ScreenOrientationEnum.landscapeRight:
return 1;
case ScreenOrientationEnum.landscapeLeft:
return 3;
default:
return 0;
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = context.watch<AppProvider>(); final appProvider = context.watch<AppProvider>();
return AppScaffold( log(appProvider.currentScreenRotation.toString());
appProvider: appProvider,
appBar: const AppHeader(), return RotatedBox(
body: getBody(appProvider), // quarterTurns: 3,
bottomNavigationBar: const AppFooter(), quarterTurns: getTurnsByOrientation(appProvider.currentScreenRotation),
child: AppScaffold(
appProvider: appProvider,
appBar: const AppHeader(),
body: getBody(appProvider, context),
bottomNavigationBar: const AppFooter(),
),
); );
} }
Widget dataContent({required AppProvider appProvider}) { Widget dataContent({required AppProvider appProvider, required BuildContext context}) {
// appProvider.testCalling(); // appProvider.testCalling();
if (appProvider.patientTickets.isEmpty) { if (appProvider.patientTickets.isEmpty) {
// No Patient in Queue // No Patient in Queue
return noPatientInQueue(); return noPatientInQueue(screenOrientationEnum: appProvider.currentScreenRotation);
} else if (appProvider.patientTickets.length > 3) { } else if (appProvider.patientTickets.length > 3) {
// Return Content With Side List // Return Content With Side List
return priorityTicketsWithSideList(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations); return priorityTicketsWithSideList(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations, context: context);
} else { } else {
// Return Content In Center Aligned // Return Content In Center Aligned
return PriorityTickets(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations); return PriorityTickets(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations);

@ -1,8 +1,12 @@
import 'dart:developer';
import 'package:blinking_text/blinking_text.dart'; import 'package:blinking_text/blinking_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:queuing_system/core/config/size_config.dart'; import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/core/response_models/call_config_model.dart'; import 'package:queuing_system/core/response_models/call_config_model.dart';
import 'package:queuing_system/core/response_models/patient_ticket_model.dart'; import 'package:queuing_system/core/response_models/patient_ticket_model.dart';
import 'package:queuing_system/home/app_provider.dart';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
@ -148,12 +152,18 @@ class TicketItem extends StatelessWidget {
} }
} }
Widget noPatientInQueue() { Widget noPatientInQueue({required ScreenOrientationEnum screenOrientationEnum}) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Center( Center(
child: AppText("Awaiting Patients Arrival", fontFamily: 'Poppins-SemiBold.ttf', fontSize: SizeConfig.getWidthMultiplier() * 9), child: AppText(
"Awaiting Patients Arrival",
fontFamily: 'Poppins-SemiBold.ttf',
fontSize: (screenOrientationEnum == ScreenOrientationEnum.portraitDown || screenOrientationEnum == ScreenOrientationEnum.portraitUp)
? SizeConfig.getWidthMultiplier() * 9
: SizeConfig.getWidthMultiplier() * 7,
),
), ),
], ],
); );
@ -171,179 +181,183 @@ Widget qamarsBirthdayWidget() {
); );
} }
Widget priorityTicketsWithSideList({required List<PatientTicketModel> tickets, required CallConfig callConfig}) { Widget priorityTicketsWithSideList({required List<PatientTicketModel> tickets, required CallConfig callConfig, required BuildContext context}) {
final priorityTickets = tickets.sublist(0, 3); final priorityTickets = tickets.sublist(0, 3);
final otherTickets = tickets.sublist(3, tickets.length); final otherTickets = tickets.sublist(3, tickets.length);
return Row( final AppProvider appProvider = context.watch<AppProvider>();
children: [ log("appProvider.currentScreenRotation: ${appProvider.currentScreenRotation}");
Expanded(flex: 7, child: PriorityTickets(callConfig: callConfig, tickets: priorityTickets)),
Container(color: Colors.grey.withOpacity(0.1), width: 10, margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 50)), final List<Widget> children = [
Expanded( Expanded(flex: 7, child: PriorityTickets(callConfig: callConfig, tickets: priorityTickets)),
flex: 6, Container(color: Colors.grey.withOpacity(0.1), width: 10, margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 50)),
child: ListView( Expanded(
children: [ flex: 6,
Padding( child: ListView(
padding: EdgeInsets.fromLTRB(10, SizeConfig.getHeightMultiplier() * 3.3, 10, 10), children: [
child: Directionality( Padding(
textDirection: callConfig.textDirection, padding: EdgeInsets.fromLTRB(10, SizeConfig.getHeightMultiplier() * 3.3, 10, 10),
child: Row( child: Directionality(
crossAxisAlignment: CrossAxisAlignment.end, textDirection: callConfig.textDirection,
mainAxisAlignment: MainAxisAlignment.spaceAround, child: Row(
children: [ crossAxisAlignment: CrossAxisAlignment.end,
Expanded( mainAxisAlignment: MainAxisAlignment.spaceAround,
flex: 3, children: [
child: Row( Expanded(
mainAxisAlignment: MainAxisAlignment.center, flex: 3,
children: [ child: Row(
AppText( mainAxisAlignment: MainAxisAlignment.center,
callConfig.queueNoText, children: [
letterSpacing: -2, AppText(
fontHeight: 0.5, callConfig.queueNoText,
fontWeight: FontWeight.bold, letterSpacing: -2,
fontSize: SizeConfig.getWidthMultiplier() * 3.8, fontHeight: 0.5,
textAlign: TextAlign.center, fontWeight: FontWeight.bold,
), fontSize: SizeConfig.getWidthMultiplier() * 3.8,
], textAlign: TextAlign.center,
), ),
), ],
Container(
color: Colors.grey.withOpacity(0.5),
width: 5,
height: SizeConfig.getHeightMultiplier() * 2,
margin: const EdgeInsets.symmetric(horizontal: 15),
),
Expanded(
flex: 5,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
callConfig.callForText,
letterSpacing: -2,
fontHeight: 0.5,
fontWeight: FontWeight.bold,
fontSize: SizeConfig.getWidthMultiplier() * 3.8,
textAlign: TextAlign.center,
),
],
),
),
Container(
color: Colors.grey.withOpacity(0.5),
width: 5,
height: SizeConfig.getHeightMultiplier() * 2,
margin: const EdgeInsets.symmetric(horizontal: 15),
), ),
Expanded( ),
flex: 3, Container(
child: Row( color: Colors.grey.withOpacity(0.5),
mainAxisAlignment: MainAxisAlignment.center, width: 5,
children: [ height: SizeConfig.getHeightMultiplier() * 2,
AppText( margin: const EdgeInsets.symmetric(horizontal: 15),
callConfig.roomText, ),
letterSpacing: -2, Expanded(
fontHeight: 0.5, flex: 5,
fontWeight: FontWeight.bold, child: Row(
fontSize: SizeConfig.getWidthMultiplier() * 3.8, mainAxisAlignment: MainAxisAlignment.center,
textAlign: TextAlign.center, children: [
), AppText(
], callConfig.callForText,
), letterSpacing: -2,
fontHeight: 0.5,
fontWeight: FontWeight.bold,
fontSize: SizeConfig.getWidthMultiplier() * 3.8,
textAlign: TextAlign.center,
),
],
), ),
], ),
), Container(
), color: Colors.grey.withOpacity(0.5),
), width: 5,
ListView.builder( height: SizeConfig.getHeightMultiplier() * 2,
shrinkWrap: true, margin: const EdgeInsets.symmetric(horizontal: 15),
itemCount: otherTickets.length, ),
itemBuilder: (ctx, idx) { Expanded(
final itm = otherTickets[idx]; flex: 3,
return Padding(
padding: const EdgeInsets.all(8),
child: Directionality(
textDirection: callConfig.textDirection,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Expanded( AppText(
flex: 3, callConfig.roomText,
child: Row( letterSpacing: -2,
mainAxisAlignment: MainAxisAlignment.center, fontHeight: 0.5,
children: [ fontWeight: FontWeight.bold,
AppText( fontSize: SizeConfig.getWidthMultiplier() * 3.8,
itm.queueNo.toString(), textAlign: TextAlign.center,
letterSpacing: -1,
fontHeight: 0.5,
fontWeight: FontWeight.bold,
fontSize: SizeConfig.getWidthMultiplier() * 4,
textAlign: TextAlign.center,
),
],
),
), ),
Container( ],
color: Colors.grey.withOpacity(0.5), ),
width: 5, ),
height: SizeConfig.getHeightMultiplier() * 2, ],
margin: const EdgeInsets.symmetric(horizontal: 15), ),
),
),
ListView.builder(
shrinkWrap: true,
itemCount: otherTickets.length,
itemBuilder: (ctx, idx) {
final itm = otherTickets[idx];
return Padding(
padding: const EdgeInsets.all(8),
child: Directionality(
textDirection: callConfig.textDirection,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
itm.queueNo.toString(),
letterSpacing: -1,
fontHeight: 0.5,
fontWeight: FontWeight.bold,
fontSize: SizeConfig.getWidthMultiplier() * 4,
textAlign: TextAlign.center,
),
],
), ),
Expanded( ),
flex: 5, Container(
child: Row( color: Colors.grey.withOpacity(0.5),
mainAxisAlignment: MainAxisAlignment.center, width: 5,
crossAxisAlignment: CrossAxisAlignment.center, height: SizeConfig.getHeightMultiplier() * 2,
children: [ margin: const EdgeInsets.symmetric(horizontal: 15),
Padding( ),
padding: const EdgeInsets.only(bottom: 10), Expanded(
child: SizedBox( flex: 5,
width: SizeConfig.getWidthMultiplier() * 3.5, child: Row(
child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5), mainAxisAlignment: MainAxisAlignment.center,
), crossAxisAlignment: CrossAxisAlignment.center,
), children: [
const SizedBox(width: 15), Padding(
AppText( padding: const EdgeInsets.only(bottom: 10),
itm.getCallType().message(callConfig, isListView: true), child: SizedBox(
color: itm.getCallType().color(), width: SizeConfig.getWidthMultiplier() * 3.5,
letterSpacing: -1, child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5),
fontSize: SizeConfig.getWidthMultiplier() * 3,
fontWeight: FontWeight.w600,
fontHeight: 0.5,
), ),
], ),
), const SizedBox(width: 15),
AppText(
itm.getCallType().message(callConfig, isListView: true),
color: itm.getCallType().color(),
letterSpacing: -1,
fontSize: SizeConfig.getWidthMultiplier() * 3,
fontWeight: FontWeight.w600,
fontHeight: 0.5,
),
],
), ),
Container( ),
color: Colors.grey.withOpacity(0.5), Container(
width: 5, color: Colors.grey.withOpacity(0.5),
height: SizeConfig.getHeightMultiplier() * 2, width: 5,
margin: const EdgeInsets.symmetric(horizontal: 15), height: SizeConfig.getHeightMultiplier() * 2,
margin: const EdgeInsets.symmetric(horizontal: 15),
),
Expanded(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
itm.roomNo, // callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: ${itm.roomNo}" : " ${itm.roomNo} ${callConfig.roomText}: ",
color: itm.getCallType().color(),
letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3.3,
fontWeight: FontWeight.w600,
fontHeight: 0.5,
),
],
), ),
Expanded( )
flex: 3, ],
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
itm.roomNo, // callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: ${itm.roomNo}" : " ${itm.roomNo} ${callConfig.roomText}: ",
color: itm.getCallType().color(),
letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3.3,
fontWeight: FontWeight.w600,
fontHeight: 0.5,
),
],
),
)
],
),
), ),
); ),
}, );
), },
], ),
), ],
) ),
], )
); ];
return (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown)
? Row(children: children)
: Column(children: children);
} }

@ -1,6 +1,8 @@
import 'dart:developer';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:queuing_system/core/api.dart'; import 'package:queuing_system/core/api.dart';
import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/home/app_provider.dart';
@ -32,6 +34,13 @@ class MyApp extends StatelessWidget {
builder: (context, constraints) { builder: (context, constraints) {
return OrientationBuilder(builder: (context, orientation) { return OrientationBuilder(builder: (context, orientation) {
SizeConfig().init(constraints, orientation); SizeConfig().init(constraints, orientation);
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
// DeviceOrientation.portraitDown,
// DeviceOrientation.landscapeLeft,
// DeviceOrientation.landscapeRight,
]);
return MultiProvider( return MultiProvider(
providers: [ providers: [
ChangeNotifierProvider<AppProvider>(create: (context) => AppProvider()), ChangeNotifierProvider<AppProvider>(create: (context) => AppProvider()),

@ -1,4 +1,5 @@
import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_tts/flutter_tts.dart';
import 'package:queuing_system/home/app_provider.dart';
class CallByVoice { class CallByVoice {
final String lang; final String lang;
@ -42,20 +43,27 @@ class CallByVoice {
// Create Pre Voice Players // Create Pre Voice Players
if (postVoice != null && postVoice.isNotEmpty) { if (postVoice != null && postVoice.isNotEmpty) {
flutterTts.setSpeechRate(0.45); flutterTts.setSpeechRate(0.45);
if (lang == "ar") { if (lang != "ar") {
flutterTts.setPitch(1.1); await flutterTts.setLanguage(lang);
} else {
flutterTts.setPitch(0.9); flutterTts.setPitch(0.9);
flutterTts.setVolume(1.0);
isVoiceActualCompletedGlobally = true;
await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
return;
} }
flutterTts.setPitch(1.1);
flutterTts.setVolume(1.0); flutterTts.setVolume(1.0);
await flutterTts.setLanguage(lang); await flutterTts.setLanguage(lang);
await flutterTts.awaitSpeakCompletion(true); isVoiceActualCompletedGlobally = false;
await flutterTts.awaitSpeakCompletion(true); // TODO : BUG HERE
// await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); // await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
await flutterTts.speak(preVoice + " .. "); await flutterTts.speak(preVoice + " .. ");
await flutterTts.setLanguage("en"); await flutterTts.setLanguage("en");
await flutterTts.speak(clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. "); await flutterTts.speak(clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. ");
await flutterTts.setLanguage(lang); await flutterTts.setLanguage(lang);
isVoiceActualCompletedGlobally = true;
await flutterTts.speak(postVoice); await flutterTts.speak(postVoice);
} }

@ -296,6 +296,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
native_device_orientation:
dependency: "direct main"
description:
name: native_device_orientation
sha256: "744a03030fad5a332a54833cd34f1e2ee51ae9acf477b4ef85bacc8823af9937"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
nested: nested:
dependency: transitive dependency: transitive
description: description:

@ -47,6 +47,7 @@ dependencies:
signalr_core: ^1.1.1 signalr_core: ^1.1.1
intl: ^0.18.1 intl: ^0.18.1
marquee: ^2.2.3 marquee: ^2.2.3
native_device_orientation: ^1.2.1

Loading…
Cancel
Save