Browse Source

table

master
Stephane 4 months ago
parent
commit
abd23f4841
  1. 67
      lib/pages/tables.dart

67
lib/pages/tables.dart

@ -306,13 +306,15 @@ class _TablesScreenState extends State<TablesScreen> {
crossAxisCount: crossAxisCount, crossAxisCount: crossAxisCount,
crossAxisSpacing: 12, crossAxisSpacing: 12,
mainAxisSpacing: 12, mainAxisSpacing: 12,
childAspectRatio: isDesktop ? 1.1 : 0.85, // Adjusted childAspectRatio:
isDesktop
? 0.8
: 0.6, // Modifié ici pour diminuer la taille
), ),
itemCount: tables.length, itemCount: tables.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final table = tables[index]; final table = tables[index];
final isSelectable = isTableSelectable(table.status); final isSelectable = isTableSelectable(table.status);
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@ -320,7 +322,6 @@ class _TablesScreenState extends State<TablesScreen> {
border: Border.all(color: Colors.grey.shade200), border: Border.all(color: Colors.grey.shade200),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.05), color: Colors.black.withOpacity(0.05),
blurRadius: 5, blurRadius: 5,
offset: const Offset(0, 2), offset: const Offset(0, 2),
@ -384,8 +385,6 @@ class _TablesScreenState extends State<TablesScreen> {
], ],
), ),
), ),
// Table content
Padding( Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
@ -401,7 +400,7 @@ class _TablesScreenState extends State<TablesScreen> {
color: Colors.black87, color: Colors.black87,
), ),
), ),
const Spacer(), // const Spacer(),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 8, horizontal: 8,
@ -442,25 +441,14 @@ class _TablesScreenState extends State<TablesScreen> {
), ),
], ],
), ),
const Spacer(), // const Spacer(),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: ElevatedButton( child: ElevatedButton(
onPressed: onPressed:
isSelectable isSelectable
? () { ? () {
// Affiche un message // Redirection vers MenuPage avec paramètres
ScaffoldMessenger.of(
context,
).showSnackBar(
SnackBar(
content: Text(
'Table ${table.nom} sélectionnée',
),
),
);
// Redirige vers MenuPage avec les paramètres requis
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -468,8 +456,7 @@ class _TablesScreenState extends State<TablesScreen> {
(context) => MenuPage( (context) => MenuPage(
tableId: table.id, tableId: table.id,
personne: personne:
table table.capacity,
.capacity, // Ajout du paramètre manquant
), ),
), ),
); );
@ -490,6 +477,7 @@ class _TablesScreenState extends State<TablesScreen> {
), ),
), ),
), ),
child: Text( child: Text(
isSelectable isSelectable
? 'Sélectionner' ? 'Sélectionner'
@ -594,9 +582,8 @@ class _AddEditTableDialogState extends State<_AddEditTableDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isEditing = widget.table != null; final isEditing = widget.table != null;
return AlertDialog( return AlertDialog(
title: Text(isEditing ? 'Modifier la table' : 'Ajouter une table'), title: Text(isEditing ? 'Modifier une table' : 'Ajouter une table'),
content: Form( content: Form(
key: _formKey, key: _formKey,
child: Column( child: Column(
@ -604,10 +591,7 @@ class _AddEditTableDialogState extends State<_AddEditTableDialog> {
children: [ children: [
TextFormField( TextFormField(
controller: _nomController, controller: _nomController,
decoration: const InputDecoration( decoration: const InputDecoration(labelText: 'Nom'),
labelText: 'Nom de la table',
border: OutlineInputBorder(),
),
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return 'Veuillez entrer un nom'; return 'Veuillez entrer un nom';
@ -615,13 +599,9 @@ class _AddEditTableDialogState extends State<_AddEditTableDialog> {
return null; return null;
}, },
), ),
const SizedBox(height: 16),
TextFormField( TextFormField(
controller: _capacityController, controller: _capacityController,
decoration: const InputDecoration( decoration: const InputDecoration(labelText: 'Capacité'),
labelText: 'Capacité',
border: OutlineInputBorder(),
),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
@ -633,24 +613,22 @@ class _AddEditTableDialogState extends State<_AddEditTableDialog> {
return null; return null;
}, },
), ),
const SizedBox(height: 16),
DropdownButtonFormField<String>( DropdownButtonFormField<String>(
value: _selectedStatus, value: _selectedStatus,
decoration: const InputDecoration( decoration: const InputDecoration(labelText: 'Statut'),
labelText: 'Statut',
border: OutlineInputBorder(),
),
items: items:
_statusOptions.map((option) { _statusOptions.map((status) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: option['value'], value: status['value'],
child: Text(option['label']!), child: Text(status['label']!),
); );
}).toList(), }).toList(),
onChanged: (value) { onChanged: (value) {
if (value != null) {
setState(() { setState(() {
_selectedStatus = value!; _selectedStatus = value;
}); });
}
}, },
), ),
], ],
@ -664,17 +642,14 @@ class _AddEditTableDialogState extends State<_AddEditTableDialog> {
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
final result = { final tableData = {
'nom': _nomController.text, 'nom': _nomController.text,
'capacity': int.parse(_capacityController.text), 'capacity': int.parse(_capacityController.text),
'status': _selectedStatus, 'status': _selectedStatus,
}; };
Navigator.pop(context, result); Navigator.pop(context, tableData);
} }
}, },
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green.shade700,
),
child: Text(isEditing ? 'Modifier' : 'Ajouter'), child: Text(isEditing ? 'Modifier' : 'Ajouter'),
), ),
], ],

Loading…
Cancel
Save