这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

## Features

- Attach images to your chat messages.
- Preview a thumbnail of the attached image before sending.
85 changes: 63 additions & 22 deletions lib/ui/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,72 @@ class _MessageInputState extends ConsumerState<MessageInput> {

return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: 'Type a message...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24.0),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 12.0,
),
if (_selectedImage != null)
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Stack(
alignment: Alignment.topRight,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.file(
_selectedImage!,
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
GestureDetector(
onTap: () {
setState(() {
_selectedImage = null;
_updateCanSend();
});
},
child: Container(
padding: const EdgeInsets.all(2.0),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(12.0),
),
child: const Icon(
Icons.close,
size: 16,
color: Colors.white,
),
),
),
],
),
maxLines: null,
textInputAction: TextInputAction.send,
onSubmitted: (_) {
if (_canSend && !isLoading && activeSession != null) {
_sendMessage();
}
},
enabled: !isLoading && activeSession != null,
),
),
Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: 'Type a message...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24.0),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 12.0,
),
),
maxLines: null,
textInputAction: TextInputAction.send,
onSubmitted: (_) {
if (_canSend && !isLoading && activeSession != null) {
_sendMessage();
}
},
enabled: !isLoading && activeSession != null,
),
),
const SizedBox(width: 8.0),
IconButton(
icon: Icon(
Expand Down