Fix the timer

merge-requests/3/head
Elham Rababh 4 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:flutter/material.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';
@ -9,55 +11,144 @@ import 'package:queuing_system/utils/signalR_utils.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';
class MyHomePage extends StatefulWidget { import 'first_column.dart';
String title ="MyHomePage"; class MyHomePage extends StatefulWidget {
bool haveOnePatient = true; String title = "MyHomePage";
bool have0Patient = true;
bool have1Patient = false;
bool have2Patient = false;
bool have3Patient = false; bool have3Patient = false;
bool haveListOfPatient = true; bool haveListOfPatient = false;
@override @override
State<MyHomePage> createState() => _MyHomePageState(); State<MyHomePage> createState() => _MyHomePageState();
} }
class _MyHomePageState extends State<MyHomePage> { 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SignalRHelper signalRHelper= SignalRHelper(); SignalRHelper signalRHelper = SignalRHelper();
return AppScaffold( return AppScaffold(
appBar: AppHeader(), appBar: AppHeader(),
body: Column( body: Column(
children: [ children: [
SizedBox(height: SizeConfig.getHeightMultiplier() * (widget.haveOnePatient?20: 2)), SizedBox(
widget.haveListOfPatient? height: SizeConfig.getHeightMultiplier() *
Row( (widget.haveListOfPatient
children: [ ? 2
FirstColumn( : widget.have1Patient || widget.have0Patient
have3Patient: widget.have3Patient, ? 20
), : 10)),
const SizedBox( widget.have0Patient
width: 40, ? Column(
), mainAxisAlignment: MainAxisAlignment.center,
if(widget.haveListOfPatient) children: [
Container( Center(
width: 10, child: AppText("Awaiting Patients Arrival",
height:SizeConfig.getHeightMultiplier()*40, fontFamily: 'Poppins-SemiBold.ttf',
color: AppGlobal.appLightGreyColor, fontSize: SizeConfig.getWidthMultiplier() * 9),
), ),
if(widget.haveListOfPatient) ],
const SizedBox( )
width: 40, : widget.haveListOfPatient
), ? Row(
if(widget.haveListOfPatient) children: [
const QueItemList() FirstColumn(
], have3Patient: widget.have3Patient,
): 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( bottomSheet: Container(
color: Colors.transparent, color: Colors.transparent,
height: Utils.getHeight()* 0.9, height: Utils.getHeight() * 0.9,
width: double.infinity, width: double.infinity,
child: Row( child: Row(
children: [ children: [
@ -73,37 +164,14 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
Padding( Padding(
padding: const EdgeInsets.only(top: 40, left: 18), 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. ), // 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,),
],
),
],
); );
} }
} }

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

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

Loading…
Cancel
Save