Fix the timer

merge-requests/3/head
Elham Rababh 3 years ago
parent 761687fe75
commit c83423bbc1

@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/home/que_item/que_item.dart';
class FirstColumn extends StatelessWidget {
final bool have3Patient;
final bool have2Patient;
const FirstColumn({Key key, this.have3Patient = false, this.have2Patient = false}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
const QueItem(queNo: "OBG-T45", isFirstLine: true, isNurseVisit: true, haveListOfPatient: true,),
SizedBox(
height: SizeConfig.getHeightMultiplier() * 5,),
if(have3Patient ||have2Patient )
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
if(have2Patient || have3Patient)
const QueItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: false, haveListOfPatient: true,),
if(have3Patient)
const QueItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: true, haveListOfPatient: true,),
],
),
],
);
}
}

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:queuing_system/core/base/app_scaffold_widget.dart';
import 'package:queuing_system/core/config/config.dart';
@ -9,55 +11,144 @@ 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';
class MyHomePage extends StatefulWidget {
import 'first_column.dart';
String title ="MyHomePage";
bool haveOnePatient = true;
class MyHomePage extends StatefulWidget {
String title = "MyHomePage";
bool have0Patient = true;
bool have1Patient = false;
bool have2Patient = false;
bool have3Patient = false;
bool haveListOfPatient = true;
bool haveListOfPatient = false;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Timer _timer;
int remainingTime = 30;
@override
void dispose() {
_timer.cancel();
super.dispose();
}
startTimer() {
Timer.periodic(Duration(seconds: 1), (timer) {
if (remainingTime == 0) {
setState(() {
remainingTime = 30;
});
} else {
setState(() {
remainingTime--;
if (remainingTime > 25) {
widget.have0Patient = true;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 20) {
widget.have0Patient = false;
widget.have1Patient = true;
widget.have2Patient = false;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 15) {
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = true;
widget.have3Patient = false;
widget.haveListOfPatient = false;
} else if (remainingTime > 10) {
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = true;
widget.haveListOfPatient = false;
} else if (remainingTime > 5) {
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = true;
widget.haveListOfPatient = false;
} else {
widget.have0Patient = false;
widget.have1Patient = false;
widget.have2Patient = false;
widget.have3Patient = true;
widget.haveListOfPatient = true;
}
});
}
});
}
@override
void initState() {
startTimer();
super.initState();
}
@override
Widget build(BuildContext context) {
SignalRHelper signalRHelper= SignalRHelper();
SignalRHelper signalRHelper = SignalRHelper();
return AppScaffold(
appBar: AppHeader(),
body: Column(
children: [
SizedBox(height: SizeConfig.getHeightMultiplier() * (widget.haveOnePatient?20: 2)),
widget.haveListOfPatient?
Row(
children: [
FirstColumn(
have3Patient: widget.have3Patient,
),
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,),
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',
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,
),
],
),
bottomSheet: Container(
color: Colors.transparent,
height: Utils.getHeight()* 0.9,
height: Utils.getHeight() * 0.9,
width: double.infinity,
child: Row(
children: [
@ -73,37 +164,14 @@ class _MyHomePageState extends State<MyHomePage> {
),
Padding(
padding: const EdgeInsets.only(top: 40, left: 18),
child: Image.asset( "assets/images/cloud_logo.png", height: SizeConfig.getHeightMultiplier()*5,),
child: Image.asset(
"assets/images/cloud_logo.png",
height: SizeConfig.getHeightMultiplier() * 5,
),
),
],
),
),// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
class FirstColumn extends StatelessWidget {
final bool have3Patient;
const FirstColumn({Key key, this.have3Patient = false}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
const QueItem(queNo: "OBG-T45", isFirstLine: true, isNurseVisit: true, haveListOfPatient: true,),
SizedBox(
height: SizeConfig.getHeightMultiplier() * 5,),
if(have3Patient)
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const [
QueItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: true, haveListOfPatient: true,),
QueItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: false, haveListOfPatient: true,),
],
),
],
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

@ -7,20 +7,18 @@ class QueItemList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
child: Expanded(
child: Column(
children: const [
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
child: Column(
children: const [
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,),
QueItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,),
],),
),
],),
);
}
}

@ -177,13 +177,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
meta:
dependency: transitive
description:
@ -307,7 +300,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.3"
tuple:
dependency: transitive
description:

Loading…
Cancel
Save