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'; 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'; 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'; import 'first_column.dart'; class MyHomePage extends StatefulWidget { String title = "MyHomePage"; bool have0Patient = true; bool have1Patient = false; bool have2Patient = false; bool have3Patient = false; bool haveListOfPatient = false; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { Timer _timer; int remainingTime = 30; @override void dispose() { _timer.cancel(); super.dispose(); } startTimer() { Timer.periodic(const 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(); SignalRHelper signalRHelper = new SignalRHelper(); if (!signalRHelper.getConnectionState()) signalRHelper.startSignalRConnection(); super.initState(); } @override Widget build(BuildContext context) { return AppScaffold( appBar: AppHeader(), body: Column( children: [ 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, 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(), 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), child: Image.asset( "assets/images/cloud_logo.png", height: SizeConfig.getHeightMultiplier() * 6, ), ), ], ), ), // This trailing comma makes auto-formatting nicer for build methods. ); } }