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.
177 lines
6.7 KiB
Dart
177 lines
6.7 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:provider/provider.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/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/header/app_header.dart';
|
|
import 'package:queuing_system/home/app_provider.dart';
|
|
import 'package:queuing_system/home/priority_calls_components.dart';
|
|
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
|
|
|
|
class MyHomePage extends StatelessWidget {
|
|
const MyHomePage({Key? key}) : super(key: key);
|
|
|
|
getWeatherWidget() {
|
|
return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) {
|
|
if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return Container(
|
|
height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown)
|
|
? SizeConfig.getHeightMultiplier() * 8
|
|
: SizeConfig.getHeightMultiplier() * 5,
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
decoration: AppGlobal.configWidgetDecoration,
|
|
child: Directionality(
|
|
textDirection: appProvider.patientCallConfigurations.textDirection,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AppText(
|
|
appProvider.patientCallConfigurations.weatherText,
|
|
color: Colors.grey,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 1.5,
|
|
),
|
|
AppText(
|
|
// "Max: 40C , Min: 38C",
|
|
"${appProvider.patientCallConfigurations.maxText}: ${appProvider.currentWeathersWidgetModel.maxTemp}°C , ${appProvider.patientCallConfigurations.minText}: ${appProvider.currentWeathersWidgetModel.minTemp}°C",
|
|
fontSize: SizeConfig.getHeightMultiplier() * 1.3,
|
|
fontHeight: 1,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 15),
|
|
SvgPicture.asset(
|
|
appProvider.currentWeathersWidgetModel.weatherIconPath ?? AppGlobal.weatherIcon,
|
|
height: SizeConfig.getHeightMultiplier() * 3,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
getPrayerWidget() {
|
|
return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) {
|
|
if (appProvider.nextPrayerToShowWithTime.isEmpty) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return Container(
|
|
height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown)
|
|
? SizeConfig.getHeightMultiplier() * 8
|
|
: SizeConfig.getHeightMultiplier() * 5,
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
decoration: AppGlobal.configWidgetDecoration,
|
|
child: Directionality(
|
|
textDirection: appProvider.patientCallConfigurations.textDirection,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AppText(
|
|
appProvider.patientCallConfigurations.nextPrayerText,
|
|
color: Colors.grey,
|
|
fontSize: SizeConfig.getWidthMultiplier() * 1.5,
|
|
),
|
|
AppText(
|
|
appProvider.nextPrayerToShowWithTime,
|
|
fontSize: SizeConfig.getHeightMultiplier() * 1.3,
|
|
fontHeight: 1,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 15),
|
|
SvgPicture.asset(
|
|
AppGlobal.mosqueIcon,
|
|
height: SizeConfig.getHeightMultiplier() * 3,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
getBody(AppProvider appProvider, context) {
|
|
return Column(
|
|
children: [
|
|
const SizedBox(height: 12),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 40),
|
|
child: Row(
|
|
children: [
|
|
getWeatherWidget(),
|
|
const SizedBox(width: 35),
|
|
getPrayerWidget(),
|
|
],
|
|
),
|
|
)),
|
|
const SizedBox(height: 20),
|
|
Expanded(
|
|
flex: 9,
|
|
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
|
|
Widget build(BuildContext context) {
|
|
final appProvider = context.watch<AppProvider>();
|
|
log(appProvider.currentScreenRotation.toString());
|
|
|
|
return RotatedBox(
|
|
// quarterTurns: 3,
|
|
quarterTurns: getTurnsByOrientation(appProvider.currentScreenRotation),
|
|
child: AppScaffold(
|
|
appProvider: appProvider,
|
|
appBar: const AppHeader(),
|
|
body: getBody(appProvider, context),
|
|
bottomNavigationBar: const AppFooter(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget dataContent({required AppProvider appProvider, required BuildContext context}) {
|
|
// appProvider.testCalling();
|
|
if (appProvider.patientTickets.isEmpty) {
|
|
// No Patient in Queue
|
|
return noPatientInQueue(screenOrientationEnum: appProvider.currentScreenRotation);
|
|
} else if (appProvider.patientTickets.length > 3) {
|
|
// Return Content With Side List
|
|
return priorityTicketsWithSideList(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations, context: context);
|
|
} else {
|
|
// Return Content In Center Aligned
|
|
return PriorityTickets(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations);
|
|
}
|
|
}
|
|
}
|