mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-28 19:34:30 +01:00
This commit introduces the ChatInputField widget, a custom text input field designed for use within the ChatView. The ChatInputField widget handles varying screen sizes and gracefully resizes itself according to the available width. It starts with a height of 50 and can expand up to 400 as the user types more lines of text. In addition to the implementation, this commit also includes widget tests to ensure the ChatInputField behaves as expected. - Add ChatInputField widget with dynamic resizing - Include IconButton for sending messages - Add widget tests for ChatInputField - Handle edge cases and overflows
48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class NewTaskButton extends StatelessWidget {
|
|
final VoidCallback onPressed;
|
|
|
|
const NewTaskButton({Key? key, required this.onPressed}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Determine the width of the TaskView
|
|
double taskViewWidth = MediaQuery.of(context).size.width;
|
|
double buttonWidth = taskViewWidth - 20;
|
|
if (buttonWidth > 260) {
|
|
buttonWidth = 260;
|
|
}
|
|
|
|
return ElevatedButton(
|
|
onPressed: onPressed,
|
|
style: ButtonStyle(
|
|
// Set the button's background color
|
|
backgroundColor: MaterialStateProperty.all<Color>(Colors.white),
|
|
// Set the button's edge
|
|
side: MaterialStateProperty.all<BorderSide>(
|
|
const BorderSide(color: Colors.black, width: 0.5)),
|
|
// Set the button's shape with rounded corners
|
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
),
|
|
),
|
|
),
|
|
child: SizedBox(
|
|
width: buttonWidth,
|
|
height: 50,
|
|
child: const Row(
|
|
children: [
|
|
// Black plus icon
|
|
Icon(Icons.add, color: Colors.black),
|
|
SizedBox(width: 8),
|
|
// "New Task" label
|
|
Text('New Task', style: TextStyle(color: Colors.black)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|