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