Files
geo/app/lib/presentation/widgets/chat/chat_input.dart
Pierre f7baa7492c feat: Mise à jour des interfaces mobiles v3.2.3
- Amélioration des interfaces utilisateur sur mobile
- Optimisation de la responsivité des composants Flutter
- Mise à jour des widgets de chat et communication
- Amélioration des formulaires et tableaux
- Ajout de nouveaux composants pour l'administration
- Optimisation des thèmes et styles visuels

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 20:35:40 +02:00

220 lines
6.0 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:geosector_app/core/theme/app_theme.dart';
/// Widget pour la zone de saisie des messages
class ChatInput extends StatefulWidget {
final Function(String) onMessageSent;
const ChatInput({
super.key,
required this.onMessageSent,
});
@override
State<ChatInput> createState() => _ChatInputState();
}
class _ChatInputState extends State<ChatInput> {
final TextEditingController _controller = TextEditingController();
bool _isComposing = false;
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(
horizontal: AppTheme.spacingM,
vertical: AppTheme.spacingS,
),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 5,
offset: const Offset(0, -2),
),
],
),
child: Row(
children: [
// Bouton pour ajouter des pièces jointes
IconButton(
icon: const Icon(Icons.attach_file),
color: AppTheme.primaryColor,
onPressed: () {
// Afficher les options de pièces jointes
_showAttachmentOptions(context);
},
),
// Champ de saisie du message
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: 'Écrivez votre message...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide.none,
),
filled: true,
fillColor: Colors.grey[100],
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
),
textCapitalization: TextCapitalization.sentences,
maxLines: null,
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
onChanged: (text) {
setState(() {
_isComposing = text.isNotEmpty;
});
},
),
),
// Bouton d'envoi
IconButton(
icon: Icon(
_isComposing ? Icons.send : Icons.mic,
color: _isComposing ? AppTheme.primaryColor : Colors.grey[600],
),
onPressed: _isComposing
? () {
final text = _controller.text.trim();
if (text.isNotEmpty) {
widget.onMessageSent(text);
_controller.clear();
setState(() {
_isComposing = false;
});
}
}
: () {
// Activer la reconnaissance vocale
},
),
],
),
);
}
// Afficher les options de pièces jointes
void _showAttachmentOptions(BuildContext context) {
showModalBottomSheet(
context: context,
builder: (context) => Container(
padding: const EdgeInsets.symmetric(
vertical: AppTheme.spacingL,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'Ajouter une pièce jointe',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
const SizedBox(height: AppTheme.spacingL),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildAttachmentOption(
context,
Icons.photo,
'Photo',
Colors.green,
() {
Navigator.pop(context);
// Sélectionner une photo
},
),
_buildAttachmentOption(
context,
Icons.camera_alt,
'Caméra',
Colors.blue,
() {
Navigator.pop(context);
// Prendre une photo
},
),
_buildAttachmentOption(
context,
Icons.insert_drive_file,
'Document',
Colors.orange,
() {
Navigator.pop(context);
// Sélectionner un document
},
),
_buildAttachmentOption(
context,
Icons.location_on,
'Position',
Colors.red,
() {
Navigator.pop(context);
// Partager la position
},
),
],
),
const SizedBox(height: AppTheme.spacingL),
],
),
),
);
}
// Construire une option de pièce jointe
Widget _buildAttachmentOption(
BuildContext context,
IconData icon,
String label,
Color color,
VoidCallback onTap,
) {
return InkWell(
onTap: onTap,
child: Column(
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.1),
shape: BoxShape.circle,
),
child: Icon(
icon,
color: color,
size: 28,
),
),
const SizedBox(height: 8),
Text(
label,
style: TextStyle(
color: Colors.grey[800],
fontSize: 12,
),
),
],
),
);
}
}