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.
235 lines
9.8 KiB
Dart
235 lines
9.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:hmg_qline/constants/app_constants.dart';
|
|
import 'package:hmg_qline/utilities/enums.dart';
|
|
import 'package:hmg_qline/utilities/extensions.dart';
|
|
import 'package:hmg_qline/view_models/queuing_view_model.dart';
|
|
import 'package:hmg_qline/view_models/screen_config_view_model.dart';
|
|
import 'package:hmg_qline/views/common_widgets/app_footer.dart';
|
|
import 'package:hmg_qline/views/common_widgets/app_header.dart';
|
|
import 'package:hmg_qline/views/common_widgets/app_scaffold.dart';
|
|
import 'package:hmg_qline/views/common_widgets/app_texts_widget.dart';
|
|
import 'package:hmg_qline/views/main_queue_screen/components/priority_tickets.dart';
|
|
import 'package:hmg_qline/views/main_queue_screen/components/priority_tickets_sidelist.dart';
|
|
import 'package:hmg_qline/views/view_helpers/size_config.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class MainQueueScreen extends StatelessWidget {
|
|
const MainQueueScreen({super.key});
|
|
|
|
Widget getWeatherWidget(ScreenConfigViewModel screenConfigViewModel) {
|
|
if (screenConfigViewModel.weathersWidgetModel.maxTemp == null || screenConfigViewModel.weathersWidgetModel.minTemp == null || screenConfigViewModel.weathersWidgetModel.iconPhrase == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return Container(
|
|
height: (screenConfigViewModel.currentScreenRotation == ScreenOrientationEnum.portraitUp || screenConfigViewModel.currentScreenRotation == ScreenOrientationEnum.portraitDown)
|
|
? SizeConfig.getHeightMultiplier() * 2
|
|
: SizeConfig.getHeightMultiplier() * 0.9,
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
decoration: AppColors.configWidgetDecoration,
|
|
child: Directionality(
|
|
textDirection: screenConfigViewModel.globalConfigurationsModel.textDirection,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
AppText(
|
|
screenConfigViewModel.globalConfigurationsModel.weatherText,
|
|
color: Colors.grey,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 2,
|
|
),
|
|
AppText(
|
|
"${screenConfigViewModel.globalConfigurationsModel.maxText}: ${screenConfigViewModel.weathersWidgetModel.maxTemp}°C , ${screenConfigViewModel.globalConfigurationsModel.minText}: ${screenConfigViewModel.weathersWidgetModel.minTemp}°C",
|
|
fontSize: SizeConfig.getWidthMultiplier() * 3,
|
|
fontHeight: 1,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 15),
|
|
SvgPicture.asset(
|
|
screenConfigViewModel.weathersWidgetModel.weatherIconPath ?? AppAssets.weatherIcon,
|
|
height: SizeConfig.getHeightMultiplier() * 0.5,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget getPrayerWidget(ScreenConfigViewModel screenConfigViewModel) {
|
|
if (screenConfigViewModel.nextPrayerToShowWithTime.isEmpty) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return SizedBox(
|
|
child: Container(
|
|
height: (screenConfigViewModel.currentScreenRotation == ScreenOrientationEnum.portraitUp || screenConfigViewModel.currentScreenRotation == ScreenOrientationEnum.portraitDown)
|
|
? SizeConfig.getHeightMultiplier() * 2
|
|
: SizeConfig.getHeightMultiplier() * 0.9,
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
decoration: AppColors.configWidgetDecoration,
|
|
child: Directionality(
|
|
textDirection: screenConfigViewModel.globalConfigurationsModel.textDirection,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
AppText(
|
|
screenConfigViewModel.globalConfigurationsModel.nextPrayerText,
|
|
color: Colors.grey,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 1.5,
|
|
),
|
|
AppText(
|
|
screenConfigViewModel.nextPrayerToShowWithTime,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 3,
|
|
fontHeight: 1,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 15),
|
|
SvgPicture.asset(
|
|
AppAssets.mosqueIcon,
|
|
height: SizeConfig.getWidthMultiplier() * 7,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget noPatientInQueue(String text) {
|
|
return Center(
|
|
child: AppText(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 9,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget qamarsBirthdayWidget() {
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
AppText("Good Bye", fontFamily: 'Poppins-SemiBold.ttf', fontSize: SizeConfig.getWidthMultiplier() * 15),
|
|
Center(
|
|
child: AppText("Syed Qamar :(", fontFamily: 'Poppins-SemiBold.ttf', fontSize: SizeConfig.getWidthMultiplier() * 11),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget dataContent({required BuildContext context}) {
|
|
return Consumer2(
|
|
builder: (BuildContext context, ScreenConfigViewModel screenConfigViewModel, QueuingViewModel queuingViewModel, Widget? child) {
|
|
Widget widget = const SizedBox();
|
|
String text = AppStrings.awaitingArrivalEng;
|
|
// queuingViewModel.voiceCallTicket(ticketData: queuingViewModel.currentTickets.first.ticketModel);
|
|
if (screenConfigViewModel.globalConfigurationsModel.screenLanguageEnum == LanguageEnum.arabic) {
|
|
text = AppStrings.awaitingArrivalAr;
|
|
}
|
|
if (queuingViewModel.currentTickets.isEmpty) {
|
|
widget = noPatientInQueue(text);
|
|
} else if (screenConfigViewModel.globalConfigurationsModel.screenTypeEnum == ScreenTypeEnum.roomLevelScreen) {
|
|
widget = PriorityTickets(
|
|
tickets: [queuingViewModel.currentTickets.first],
|
|
globalConfigurationsModel: screenConfigViewModel.globalConfigurationsModel,
|
|
);
|
|
} else if (queuingViewModel.currentTickets.length > AppConstants.thresholdForListUI) {
|
|
widget = PriorityTicketsSidelist(
|
|
tickets: queuingViewModel.currentTickets,
|
|
globalConfigurationsModel: screenConfigViewModel.globalConfigurationsModel,
|
|
screenOrientationEnum: screenConfigViewModel.currentScreenRotation,
|
|
);
|
|
} else {
|
|
widget = PriorityTickets(
|
|
tickets: queuingViewModel.currentTickets,
|
|
globalConfigurationsModel: screenConfigViewModel.globalConfigurationsModel,
|
|
);
|
|
}
|
|
|
|
return widget;
|
|
},
|
|
);
|
|
}
|
|
|
|
int getFlexForScreenTypes(ScreenConfigViewModel screenConfigVM) {
|
|
int flex = 1;
|
|
|
|
if (screenConfigVM.currentScreenTypeEnum == ScreenTypeEnum.roomLevelScreen) {
|
|
if (screenConfigVM.currentScreenRotation == ScreenOrientationEnum.portraitUp || screenConfigVM.currentScreenRotation == ScreenOrientationEnum.portraitDown) {
|
|
flex = 2;
|
|
} else {
|
|
flex = 3;
|
|
}
|
|
} else {
|
|
if (screenConfigVM.currentScreenRotation == ScreenOrientationEnum.portraitUp || screenConfigVM.currentScreenRotation == ScreenOrientationEnum.portraitDown) {
|
|
flex = 2;
|
|
} else {
|
|
flex = 1;
|
|
}
|
|
}
|
|
return flex;
|
|
}
|
|
|
|
Widget getBody({required BuildContext context}) {
|
|
return Consumer<ScreenConfigViewModel>(
|
|
builder: (BuildContext context, ScreenConfigViewModel screenConfigVM, Widget? child) {
|
|
return Column(
|
|
children: [
|
|
Expanded(
|
|
flex: getFlexForScreenTypes(screenConfigVM),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
children: [
|
|
if (screenConfigVM.globalConfigurationsModel.isWeatherReq) ...[
|
|
getWeatherWidget(screenConfigVM),
|
|
],
|
|
const SizedBox(width: 20),
|
|
if (screenConfigVM.globalConfigurationsModel.isPrayerTimeReq) ...[
|
|
getPrayerWidget(screenConfigVM),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Expanded(flex: 10, child: dataContent(context: context)),
|
|
if (!screenConfigVM.globalConfigurationsModel.isWeatherReq && !screenConfigVM.globalConfigurationsModel.isPrayerTimeReq) ...[
|
|
const SizedBox(height: 100),
|
|
],
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Selector<ScreenConfigViewModel, ScreenOrientationEnum>(
|
|
selector: (context, screenConfigViewModel) => screenConfigViewModel.currentScreenRotation,
|
|
builder: (BuildContext context, ScreenOrientationEnum screenOrientationEnum, Widget? child) {
|
|
//TODO: For Testing Only
|
|
// context.read<QueuingViewModel>().voiceCallTicket(ticketData: context.read<QueuingViewModel>().currentTickets.first.ticketModel);
|
|
return RotatedBox(
|
|
quarterTurns: screenOrientationEnum.getTurnsByOrientation(),
|
|
child: AppScaffold(
|
|
appBar: const AppHeader(),
|
|
body: getBody(context: context),
|
|
bottomNavigationBar: const AppFooter(),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|