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.
mohemm-flutter-app/lib/home/home_screen.dart

182 lines
5.8 KiB
Dart

4 years ago
import 'dart:async';
4 years ago
import 'package:flutter/material.dart';
import 'package:queuing_system/core/base/app_scaffold_widget.dart';
4 years ago
import 'package:queuing_system/core/config/config.dart';
import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/header/app_header.dart';
import 'package:queuing_system/home/que_item_list.dart';
4 years ago
import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
4 years ago
import 'first_column.dart';
4 years ago
4 years ago
class MyHomePage extends StatefulWidget {
String title = "MyHomePage";
4 years ago
bool have0Patient = true;
4 years ago
bool have1Patient = false;
bool have2Patient = false;
4 years ago
bool have3Patient = false;
bool haveListOfPatient = false;
4 years ago
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
4 years ago
Timer _timer;
int remainingTime = 30;
@override
void dispose() {
_timer.cancel();
super.dispose();
}
startTimer() {
Timer.periodic(const Duration(seconds: 1), (timer) {
4 years ago
if (remainingTime == 0) {
setState(() {
remainingTime = 30;
});
} else {
setState(() {
remainingTime--;
if (remainingTime > 25) {
/// for 0 patinet
4 years ago
widget.have0Patient = true;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 20) {
/// for 1 patinet
4 years ago
widget.have0Patient = false;
widget.have1Patient = true;
widget.have2Patient = false;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 15) {
/// for 2 patinet
4 years ago
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = true;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 10) {
/// for 3 only patinet
4 years ago
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = true;
widget.haveListOfPatient = false;
} else {
/// for 3+ only patinet
4 years ago
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = true;
widget.haveListOfPatient = true;
}
});
}
});
}
@override
void initState() {
4 years ago
startTimer();
SignalRHelper signalRHelper = new SignalRHelper();
if (!signalRHelper.getConnectionState()) signalRHelper.startSignalRConnection();
4 years ago
super.initState();
}
4 years ago
@override
Widget build(BuildContext context) {
4 years ago
return AppScaffold(
appBar: AppHeader(),
4 years ago
body: Column(
children: [
4 years ago
SizedBox(
height: SizeConfig.getHeightMultiplier() *
(widget.haveListOfPatient
? 2
: widget.have1Patient || widget.have0Patient
? 20
: 10)),
widget.have0Patient
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: AppText("Awaiting Patients Arrival",
fontFamily: 'Poppins-SemiBold.ttf',
letterSpacing: -1.56,
4 years ago
fontSize: SizeConfig.getWidthMultiplier() * 9),
),
],
)
: widget.haveListOfPatient
? Row(
children: [
FirstColumn(
have3Patient: widget.have3Patient,
have2Patient: widget.have2Patient,
),
const SizedBox(
width: 40,
),
if (widget.haveListOfPatient)
Container(
width: 10,
height: SizeConfig.getHeightMultiplier() * 40,
color: AppGlobal.appLightGreyColor,
),
if (widget.haveListOfPatient)
const SizedBox(
width: 40,
),
if (widget.haveListOfPatient) const QueItemList()
],
)
: FirstColumn(
have3Patient: widget.have3Patient,
have2Patient: widget.have2Patient,
),
4 years ago
],
),
bottomSheet: Container(
color: Colors.transparent,
4 years ago
height: Utils.getHeight(),
4 years ago
width: double.infinity,
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(top: 30, left: 30),
child: AppText(
"Powered By",
letterSpacing: -1.56,
fontSize: SizeConfig.getWidthMultiplier() * 2.6,
fontFamily: 'Poppins-Medium.ttf',
),
),
Padding(
padding: const EdgeInsets.only(top: 40, left: 18),
4 years ago
child: Image.asset(
"assets/images/cloud_logo.png",
height: SizeConfig.getHeightMultiplier() * 6,
4 years ago
),
4 years ago
),
],
),
4 years ago
), // This trailing comma makes auto-formatting nicer for build methods.
4 years ago
);
}
}