|
@@ -1,8 +1,9 @@
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:provider/provider.dart';
|
|
|
+import 'package:turquessa_mesas_hoster/core/models/mesa_model.dart';
|
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/custom_appbar.dart';
|
|
|
-import 'package:turquessa_mesas_hoster/core/models/mesas_model.dart';
|
|
|
|
|
|
+import '../../../utils/widgets/ordenes_card.dart';
|
|
|
import '../../viewmodels/viewmodels.dart';
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
@@ -13,6 +14,7 @@ class HomeScreen extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class Formulario extends State<HomeScreen> {
|
|
|
+ int _selectedIndex = 0;
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
@@ -93,7 +95,9 @@ class Formulario extends State<HomeScreen> {
|
|
|
final mesa = mesaViewModel.mesas[index];
|
|
|
return GestureDetector(
|
|
|
onTap: () {
|
|
|
- mesaViewModel.selectMesa(mesa);
|
|
|
+ setState(() {
|
|
|
+ mesaViewModel.selectMesa(mesa);
|
|
|
+ });
|
|
|
},
|
|
|
child: TableCard(
|
|
|
icon: Icons.table_chart,
|
|
@@ -106,24 +110,30 @@ class Formulario extends State<HomeScreen> {
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
- //if (mesaViewModel.selectedMesa != null)
|
|
|
- Expanded(
|
|
|
- flex: 1,
|
|
|
- child: Container(
|
|
|
- margin: const EdgeInsets.all(10),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(10),
|
|
|
- boxShadow: [
|
|
|
- BoxShadow(
|
|
|
- color: Colors.grey.withOpacity(0.2),
|
|
|
- blurRadius: 5,
|
|
|
- spreadRadius: 1,
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- // child: TablaDetalles(table: selectedTable!),
|
|
|
- )),
|
|
|
+ if (mesaViewModel.selectedMesa != null)
|
|
|
+ Expanded(
|
|
|
+ child: Container(
|
|
|
+ margin: const EdgeInsets.all(10),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
+ boxShadow: [
|
|
|
+ BoxShadow(
|
|
|
+ color: Colors.grey.withOpacity(0.2),
|
|
|
+ blurRadius: 5,
|
|
|
+ spreadRadius: 1,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ child: TablaDetalles(
|
|
|
+ status: EstadoPedido.disponible,
|
|
|
+ table: mesaViewModel.selectedMesa ??
|
|
|
+ Mesa(
|
|
|
+ activa: false,
|
|
|
+ id: 0,
|
|
|
+ nombre: 'Mesa sin nombre',
|
|
|
+ estado: EstadoPedido.disponible)),
|
|
|
+ )),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
@@ -162,42 +172,160 @@ class TableCard extends StatelessWidget {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class TableDetailsPanel extends StatelessWidget {
|
|
|
- final TableItem table;
|
|
|
+class TablaDetalles extends StatelessWidget {
|
|
|
+ final Mesa table;
|
|
|
+ final EstadoPedido status;
|
|
|
|
|
|
- const TableDetailsPanel({
|
|
|
+ const TablaDetalles({
|
|
|
Key? key,
|
|
|
required this.table,
|
|
|
+ required this.status,
|
|
|
}) : super(key: key);
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- // Encabezado del panel
|
|
|
- Container(
|
|
|
- padding: const EdgeInsets.all(16),
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: const BorderRadius.vertical(top: Radius.circular(10)),
|
|
|
+ return Container(
|
|
|
+ margin: const EdgeInsets.all(10),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
+ boxShadow: [
|
|
|
+ BoxShadow(
|
|
|
+ color: Colors.grey.withOpacity(0.2),
|
|
|
+ blurRadius: 5,
|
|
|
+ spreadRadius: 1,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ // Header
|
|
|
+ Container(
|
|
|
+ padding: const EdgeInsets.all(16),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: table.activa! ? Colors.blue : Colors.grey,
|
|
|
+ borderRadius:
|
|
|
+ const BorderRadius.vertical(top: Radius.circular(10)),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ const Icon(Icons.table_restaurant,
|
|
|
+ color: Colors.white, size: 24),
|
|
|
+ const SizedBox(width: 8),
|
|
|
+ Text(
|
|
|
+ table.nombre ?? 'Mesa sin nombre',
|
|
|
+ style: const TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ padding:
|
|
|
+ const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white.withOpacity(0.2),
|
|
|
+ borderRadius: BorderRadius.circular(20),
|
|
|
+ ),
|
|
|
+ child: Text(
|
|
|
+ table.activa! ? 'Activa' : 'Inactiva',
|
|
|
+ style: const TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- Icon(Icons.person, color: Colors.white, size: 24),
|
|
|
- const SizedBox(width: 8),
|
|
|
- Text(
|
|
|
- table.name,
|
|
|
- style: const TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
+ // Contenido scrolleable
|
|
|
+ Expanded(
|
|
|
+ child: SingleChildScrollView(
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.all(16),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ 'ID: ${table.id}',
|
|
|
+ style: const TextStyle(fontSize: 16),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 16),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ const Text('Estado: '),
|
|
|
+ Text(
|
|
|
+ status.toString().split('.').last,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ color: Colors.blue,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 16),
|
|
|
+ IconDataByStatus(status: status),
|
|
|
+ const SizedBox(height: 16),
|
|
|
+ const OrdenesScreen(),
|
|
|
+ ],
|
|
|
),
|
|
|
),
|
|
|
- ],
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- // Contenido específico según el tipo
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ ),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+class IconDataByStatus extends StatelessWidget {
|
|
|
+ final EstadoPedido status;
|
|
|
+ const IconDataByStatus({Key? key, required this.status});
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ switch (status) {
|
|
|
+ case EstadoPedido.disponible:
|
|
|
+ return IconButton(
|
|
|
+ onPressed: () {
|
|
|
+ final mesaViewModel =
|
|
|
+ Provider.of<MesaViewModel>(context, listen: false);
|
|
|
+ mesaViewModel.CambiarEstadoPedidoMesa(EstadoPedido.preparacion);
|
|
|
+ },
|
|
|
+ style: ButtonStyle(
|
|
|
+ backgroundColor: MaterialStateProperty.all(
|
|
|
+ const Color.fromARGB(255, 220, 252, 232)),
|
|
|
+ ),
|
|
|
+ icon: const Icon(Icons.table_restaurant_rounded, color: Colors.green),
|
|
|
+ );
|
|
|
+ case EstadoPedido.surtida:
|
|
|
+ return IconButton(
|
|
|
+ onPressed: () {},
|
|
|
+ icon: const Icon(Icons.coffee_rounded,
|
|
|
+ color: Color.fromARGB(255, 220, 234, 254)),
|
|
|
+ );
|
|
|
+ case EstadoPedido.preparacion:
|
|
|
+ return IconButton(
|
|
|
+ onPressed: () {},
|
|
|
+ icon: const Icon(Icons.kitchen_rounded,
|
|
|
+ color: Color.fromARGB(255, 243, 232, 255)),
|
|
|
+ );
|
|
|
+ case EstadoPedido.cobrado:
|
|
|
+ return IconButton(
|
|
|
+ onPressed: () {},
|
|
|
+ icon: const Icon(Icons.money_rounded,
|
|
|
+ color: Color.fromARGB(255, 255, 238, 213)),
|
|
|
+ );
|
|
|
+ default:
|
|
|
+ return IconButton(
|
|
|
+ onPressed: () {},
|
|
|
+ icon: const Icon(Icons.check_circle, color: Colors.grey),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|