|
@@ -1,5 +1,6 @@
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.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/utils/widgets/custom_appbar.dart';
|
|
import 'package:turquessa_mesas_hoster/core/models/mesas_model.dart';
|
|
import 'package:turquessa_mesas_hoster/core/models/mesas_model.dart';
|
|
|
|
|
|
@@ -13,6 +14,7 @@ class HomeScreen extends StatefulWidget {
|
|
}
|
|
}
|
|
|
|
|
|
class Formulario extends State<HomeScreen> {
|
|
class Formulario extends State<HomeScreen> {
|
|
|
|
+ int _selectedIndex = 0;
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
@@ -30,7 +32,7 @@ class Formulario extends State<HomeScreen> {
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
final mesaViewModel = Provider.of<MesaViewModel>(context);
|
|
final mesaViewModel = Provider.of<MesaViewModel>(context);
|
|
- var _selectedIndex;
|
|
|
|
|
|
+
|
|
return Scaffold(
|
|
return Scaffold(
|
|
backgroundColor: Colors.grey.shade200,
|
|
backgroundColor: Colors.grey.shade200,
|
|
appBar: AppBar(
|
|
appBar: AppBar(
|
|
@@ -40,7 +42,7 @@ class Formulario extends State<HomeScreen> {
|
|
children: [
|
|
children: [
|
|
NavigationRail(
|
|
NavigationRail(
|
|
backgroundColor: Color.fromARGB(255, 25, 30, 41),
|
|
backgroundColor: Color.fromARGB(255, 25, 30, 41),
|
|
- selectedIndex: ,
|
|
|
|
|
|
+ selectedIndex: _selectedIndex,
|
|
onDestinationSelected: (int index) {
|
|
onDestinationSelected: (int index) {
|
|
setState(() {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
_selectedIndex = index;
|
|
@@ -83,7 +85,9 @@ class Formulario extends State<HomeScreen> {
|
|
final mesa = mesaViewModel.mesas[index];
|
|
final mesa = mesaViewModel.mesas[index];
|
|
return GestureDetector(
|
|
return GestureDetector(
|
|
onTap: () {
|
|
onTap: () {
|
|
- mesaViewModel.selectMesa(mesa);
|
|
|
|
|
|
+ setState(() {
|
|
|
|
+ mesaViewModel.selectMesa(mesa);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
child: TableCard(
|
|
child: TableCard(
|
|
icon: Icons.table_chart,
|
|
icon: Icons.table_chart,
|
|
@@ -96,24 +100,27 @@ 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(
|
|
|
|
+ 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: mesaViewModel.selectedMesa ??
|
|
|
|
+ Mesa(
|
|
|
|
+ activa: false, id: 0, nombre: 'Mesa sin nombre')),
|
|
|
|
+ )),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -152,42 +159,85 @@ class TableCard extends StatelessWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class TableDetailsPanel extends StatelessWidget {
|
|
|
|
- final TableItem table;
|
|
|
|
|
|
+class TablaDetalles extends StatelessWidget {
|
|
|
|
+ final Mesa table;
|
|
|
|
|
|
- const TableDetailsPanel({
|
|
|
|
|
|
+ const TablaDetalles({
|
|
Key? key,
|
|
Key? key,
|
|
required this.table,
|
|
required this.table,
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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(
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
|
+ ),
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ // Encabezado del panel
|
|
|
|
+ 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,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ // Indicador de estado
|
|
|
|
+ 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 de la mesa
|
|
|
|
+ Padding(
|
|
|
|
+ padding: const EdgeInsets.all(16),
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ Text(
|
|
|
|
+ 'ID: ${table.id}',
|
|
|
|
+ style: const TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
- ),
|
|
|
|
- ],
|
|
|
|
|
|
+ const SizedBox(height: 8),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
- ),
|
|
|
|
- // Contenido específico según el tipo
|
|
|
|
- ],
|
|
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|