add timer

dev_faiz
Elham Rababh 4 years ago
parent 449b0f3014
commit d0f67e88d9

@ -10,50 +10,87 @@ 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 { class MyHomePage extends StatefulWidget {
String title = "MyHomePage";
String title ="MyHomePage";
bool haveOnePatient = false; bool haveOnePatient = false;
bool have3Patient = true; bool have3Patient = true;
bool haveListOfPatient = false; bool haveListOfPatient = false;
@override @override
State<MyHomePage> createState() => _MyHomePageState(); State<MyHomePage> createState() => _MyHomePageState();
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
int remainingTime = 600;
startTimer() {
this.remainingTime--;
if (remainingTime > 400) {
setState(() {
widget.haveOnePatient = true;
widget.have3Patient = false;
widget.haveListOfPatient = false;
});
} else if (remainingTime > 200) {
setState(() {
widget.haveOnePatient = false;
widget.have3Patient = true;
widget.haveListOfPatient = false;
});
} else {
setState(() {
widget.haveOnePatient = false;
widget.have3Patient = true;
widget.haveListOfPatient = true;
});
}
Future.delayed(Duration(seconds: 1), () {
if (this.remainingTime > 0) {
startTimer();
} else {
}
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SignalRHelper signalRHelper= SignalRHelper(); SignalRHelper signalRHelper = SignalRHelper();
startTimer();
return AppScaffold( return AppScaffold(
appBar: AppHeader(), appBar: AppHeader(),
body: Column( body: Column(
children: [ children: [
SizedBox(height: SizeConfig.getHeightMultiplier() * (widget.haveOnePatient?20: 3)), SizedBox(
widget.haveListOfPatient? height: SizeConfig.getHeightMultiplier() *
Row( (widget.haveOnePatient ? 20 : 3)),
children: [ widget.haveListOfPatient
FirstColumn( ? Row(
have3Patient: widget.have3Patient, children: [
), FirstColumn(
const SizedBox( have3Patient: widget.have3Patient,
width: 40, ),
), const SizedBox(
if(widget.haveListOfPatient) width: 40,
Container( ),
width: 10, if (widget.haveListOfPatient)
height:SizeConfig.getHeightMultiplier()*40, Container(
color: Colors.grey, width: 10,
), height: SizeConfig.getHeightMultiplier() * 40,
if(widget.haveListOfPatient) color: Colors.grey,
const SizedBox( ),
width: 40, if (widget.haveListOfPatient)
), const SizedBox(
if(widget.haveListOfPatient) width: 40,
const QueItemList() ),
], if (widget.haveListOfPatient) const QueItemList()
): FirstColumn(have3Patient: widget.have3Patient,), ],
)
: FirstColumn(
have3Patient: widget.have3Patient,
),
], ],
), ),
bottomSheet: Container( bottomSheet: Container(
@ -74,11 +111,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.
); );
} }
} }
@ -92,18 +132,34 @@ class FirstColumn extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
const QueItem(queNo: "OBG-T45", isFirstLine: true, isNurseVisit: true, haveListOfPatient: true,), const QueItem(
queNo: "OBG-T45",
isFirstLine: true,
isNurseVisit: true,
haveListOfPatient: true,
),
SizedBox( SizedBox(
height: SizeConfig.getHeightMultiplier() * 5,), 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,),
],
), ),
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,
),
],
),
], ],
); );
} }

Loading…
Cancel
Save