110 lines
3.1 KiB
Dart
110 lines
3.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:queue_mgr/backend/DataManager.dart';
|
|
import 'package:queue_mgr/new_service.dart';
|
|
|
|
import 'backend/DebugHelper.dart';
|
|
|
|
void main() {
|
|
DataManager.instance().GetData();
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Flutter Demo',
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark),
|
|
useMaterial3: true,
|
|
),
|
|
home: const Home(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class Home extends StatefulWidget {
|
|
const Home({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<Home> createState() => _HomeState();
|
|
}
|
|
|
|
class _HomeState extends State<Home> {
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
|
|
refresh();
|
|
}
|
|
|
|
void refresh()async{
|
|
await DataManager.instance().GetData();
|
|
setState(() {
|
|
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text("Queue Management - Admin"),),
|
|
body: Container(
|
|
padding: EdgeInsets.all(20),
|
|
child: Column(
|
|
children: [
|
|
ListView.builder(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount:DataManager.instance().services.length,
|
|
itemBuilder: (context,index){
|
|
dynamic service = jsonDecode(DataManager.instance().services[index]);
|
|
return Card(
|
|
child: Center(
|
|
child: Container(
|
|
padding: EdgeInsets.all(10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(service['start_time']),
|
|
Text(service['name']),
|
|
Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(50),color: Colors.deepPurple), child: SizedBox(width:20,height: 20,child: Center(child: Text(service['members'].toString().split(',').length.toString()))),)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
),
|
|
SizedBox(height: 50,),
|
|
InkWell(
|
|
onTap: (){
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> NewService()));
|
|
},
|
|
child: Card(
|
|
child: Container(
|
|
padding: EdgeInsets.all(10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,children: [
|
|
Icon(Icons.add),
|
|
Text("New Service")
|
|
],),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|