proto ready
This commit is contained in:
@@ -103,6 +103,7 @@ class _DataManager{
|
||||
}
|
||||
bool joined = false;
|
||||
for (var m_joinedService in joinedServices){
|
||||
Map<String, dynamic> joinedSer = jsonDecode(m_joinedService);
|
||||
if(service['id'] == jsonDecode(m_joinedService)['service_id']){
|
||||
//Joined this
|
||||
JoinedServices.add(jsonDecode(m_joinedService));
|
||||
|
||||
120
lib/home.dart
120
lib/home.dart
@@ -103,15 +103,13 @@ class _HomePageState extends State<HomePage> {
|
||||
DataManager.instance().JoinedServices.length, (index) {
|
||||
Map<String, dynamic> service =
|
||||
(DataManager.instance().JoinedServices[index]);
|
||||
return ServiceCard(
|
||||
tokenId: int.parse(service['id']),
|
||||
return JoinedCard(
|
||||
appointmentId: int.parse(service['appointment_id']),
|
||||
id: int.parse(service['service_id']),
|
||||
sTime: DateTime.parse(
|
||||
service['start_time'] ?? DateTime.now().toString()),
|
||||
eTime: DateTime.parse(
|
||||
service['end_time'] ?? DateTime.now().toString()),
|
||||
name: service['name']!,
|
||||
memberCount: service['members']!.split(',').length - 1,
|
||||
queueIndex: int.parse(service['member_pos']),
|
||||
duration: Helpers.ParseDuration(service['duration'])
|
||||
);
|
||||
}),
|
||||
@@ -137,14 +135,13 @@ class _HomePageState extends State<HomePage> {
|
||||
Map<String, dynamic> service =
|
||||
DataManager.instance().AvailableServices[index];
|
||||
return ServiceCard(
|
||||
tokenId: -1,
|
||||
id: int.parse(service['id']),
|
||||
sTime: DateTime.parse(
|
||||
service['start_time'] ?? DateTime.now().toString()),
|
||||
eTime: DateTime.parse(
|
||||
service['end_time'] ?? DateTime.now().toString()),
|
||||
name: service['name']!,
|
||||
memberCount: service['members']!.split(',').length - 1,
|
||||
memberCount: int.parse(service['member_count']),
|
||||
duration: Helpers.ParseDuration(service['duration']));
|
||||
}),
|
||||
],
|
||||
@@ -160,23 +157,14 @@ class _HomePageState extends State<HomePage> {
|
||||
required DateTime eTime,
|
||||
required String name,
|
||||
required int memberCount,
|
||||
required int tokenId,
|
||||
required Duration duration}) {
|
||||
|
||||
|
||||
DateTime eta = sTime.add(duration * (tokenId > 0 ? tokenId : memberCount));
|
||||
DateTime eta = sTime.add(duration * memberCount);
|
||||
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
|
||||
if(tokenId > 0){return;}
|
||||
|
||||
// await Navigator.of(context).push(MaterialPageRoute(
|
||||
// builder: (context) => ServiceInfoPage(
|
||||
// id: id,
|
||||
// tokenId: tokenId,
|
||||
// )));
|
||||
|
||||
bool confirmed = await Dialogs.AskQuestion(context, "Confirm", "Are you sure to join to this Queue?\n\nQueue Name : ${name}");
|
||||
if(confirmed){
|
||||
Dialogs.waiting(context);
|
||||
@@ -207,19 +195,8 @@ class _HomePageState extends State<HomePage> {
|
||||
])
|
||||
],
|
||||
),
|
||||
SizedBox(height: tokenId > 0 ? 0 : 10,),
|
||||
(tokenId > 0) ? Column(
|
||||
children: [
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Icon(Icons.token,size: 25,),
|
||||
Text(
|
||||
" ${tokenId}",
|
||||
style: TextStyle(fontSize: 40),
|
||||
),
|
||||
]),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
SizedBox(height: 10,),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(flex:1,child: Icon(Icons.people)),
|
||||
@@ -229,26 +206,13 @@ class _HomePageState extends State<HomePage> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(flex:1,child: Icon(Icons.access_time)),
|
||||
Expanded(flex: 4,child: Text("Be there around ${Helpers.DateTimeToRelative(eta)}",maxLines: 3,overflow: TextOverflow.ellipsis,))
|
||||
Expanded(flex: 4,child:
|
||||
eta.isBefore(DateTime.now()) ? Text("Available right now !") : Text("Be there around ${Helpers.DateTimeToRelative(eta)}",maxLines: 3,overflow: TextOverflow.ellipsis,)
|
||||
)
|
||||
]),
|
||||
// (sTime.isAfter(DateTime.now()))
|
||||
// ? Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
// children: [
|
||||
// Expanded(flex:1,child: Icon(Icons.access_time)),
|
||||
// Expanded(flex: 4,child: Text("Starts ${Helpers.DateTimeToRelative(sTime)}",maxLines: 3,overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: 13),))
|
||||
// ])
|
||||
// : Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
// children: [
|
||||
// Expanded(flex:1,child: Icon(Icons.directions_run_outlined)),
|
||||
// Expanded(flex: 4,
|
||||
// child: Text(
|
||||
// "Ongoing until ${Helpers.DateTimeToRelative(eTime)}"),
|
||||
// )
|
||||
// ]),
|
||||
|
||||
(tokenId <=0) ?
|
||||
|
||||
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 10,),
|
||||
@@ -259,12 +223,68 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
),
|
||||
],
|
||||
) : Container()
|
||||
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget JoinedCard(
|
||||
{required int id,
|
||||
required DateTime sTime,
|
||||
required String name,
|
||||
required int queueIndex,
|
||||
required int appointmentId,
|
||||
required Duration duration}) {
|
||||
|
||||
DateTime eta = sTime.add(duration * appointmentId);
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Icon(Icons.people_alt_rounded,size: 25,),
|
||||
Text(
|
||||
" ${queueIndex-1}",
|
||||
style: TextStyle(fontSize: 25),
|
||||
),
|
||||
])
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Icon(Icons.token,size: 25,),
|
||||
Text(
|
||||
" ${appointmentId}",
|
||||
style: TextStyle(fontSize: 40),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(flex:1,child: Icon(Icons.access_time)),
|
||||
Expanded(flex: 4,child:
|
||||
eta.isBefore(DateTime.now()) ? Text("You're late !") : Text("Be there around ${Helpers.DateTimeToRelative(eta)}",maxLines: 3,overflow: TextOverflow.ellipsis,)
|
||||
)
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
Reset();
|
||||
// AutoLogin();
|
||||
// Reset();
|
||||
AutoLogin();
|
||||
}
|
||||
|
||||
void Reset() async{
|
||||
|
||||
Reference in New Issue
Block a user