Files
captain-claude/apps/captain-mobile-v2/flutter/lib/widgets/chat_input.dart
ARCHITECT f199daf4ba Change PIN to 1451
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 23:31:52 +00:00

129 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
class ChatInput extends StatefulWidget {
final Function(String) onSend;
final bool isConnected;
final bool isLoading;
const ChatInput({
super.key,
required this.onSend,
this.isConnected = true,
this.isLoading = false,
});
@override
State<ChatInput> createState() => _ChatInputState();
}
class _ChatInputState extends State<ChatInput> {
final _controller = TextEditingController();
final _focusNode = FocusNode();
bool get _canSend =>
widget.isConnected &&
!widget.isLoading &&
_controller.text.trim().isNotEmpty;
void _send() {
if (!_canSend) return;
final text = _controller.text.trim();
_controller.clear();
widget.onSend(text);
}
@override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(
left: 12,
right: 12,
top: 8,
bottom: MediaQuery.of(context).padding.bottom + 8,
),
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
border: Border(
top: BorderSide(color: Colors.grey.shade800),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// Input field
Expanded(
child: Container(
constraints: const BoxConstraints(maxHeight: 120),
decoration: BoxDecoration(
color: const Color(0xFF2D2D2D),
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: widget.isConnected
? Colors.grey.shade700
: Colors.red.shade700,
),
),
child: TextField(
controller: _controller,
focusNode: _focusNode,
maxLines: null,
textInputAction: TextInputAction.newline,
onChanged: (_) => setState(() {}),
style: const TextStyle(
color: Colors.white,
fontSize: 15,
),
decoration: InputDecoration(
hintText: widget.isConnected
? 'Message Claude...'
: 'Disconnected',
hintStyle: TextStyle(
color: Colors.grey.shade500,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
border: InputBorder.none,
),
),
),
),
const SizedBox(width: 8),
// Send button
Container(
decoration: BoxDecoration(
color: _canSend ? Colors.orange.shade700 : Colors.grey.shade800,
shape: BoxShape.circle,
),
child: IconButton(
onPressed: _canSend ? _send : null,
icon: widget.isLoading
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.grey.shade400,
),
)
: Icon(
Icons.send,
color: _canSend ? Colors.white : Colors.grey.shade600,
),
),
),
],
),
);
}
}