mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
This commit introduces a new StatefulWidget, TestSuiteDetailView, to offer a dedicated view for managing and interacting with individual Test Suites. Key Features: - Created a TestSuiteDetailView class that takes a TestSuite object and a TaskViewModel as parameters. - Added an AppBar with a back button for easy navigation. - Utilized ListView.builder to display a list of tasks that belong to the selected Test Suite. - Integrated with existing TaskViewModel to select and delete tasks within the Test Suite. - Included a Provider for the ChatViewModel to update the current task ID when a task is selected. This new view enhances the user experience by providing a focused interface for managing tasks within individual Test Suites. This facilitates better organization and navigation for the user.
80 lines
2.9 KiB
Dart
80 lines
2.9 KiB
Dart
import 'package:auto_gpt_flutter_client/models/test_suite.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
|
import 'package:auto_gpt_flutter_client/views/task/task_list_tile.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
// TODO: Do we want a view model for every view?
|
|
class TestSuiteDetailView extends StatefulWidget {
|
|
final TaskViewModel viewModel;
|
|
final TestSuite testSuite;
|
|
|
|
const TestSuiteDetailView(
|
|
{Key? key, required this.testSuite, required this.viewModel})
|
|
: super(key: key);
|
|
|
|
@override
|
|
_TestSuiteDetailViewState createState() => _TestSuiteDetailViewState();
|
|
}
|
|
|
|
class _TestSuiteDetailViewState extends State<TestSuiteDetailView> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.grey,
|
|
foregroundColor: Colors.black,
|
|
title: Text("${widget.testSuite.timestamp}"),
|
|
leading: IconButton(
|
|
icon: Icon(Icons.arrow_back),
|
|
onPressed: () => widget.viewModel.deselectTestSuite(),
|
|
),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
// Task List
|
|
Expanded(
|
|
child: ListView.builder(
|
|
itemCount:
|
|
widget.testSuite.tests.length, // Count of tasks passed in
|
|
itemBuilder: (context, index) {
|
|
final task = widget.testSuite.tests[index];
|
|
return TaskListTile(
|
|
task: task,
|
|
onTap: () {
|
|
// Select the task in TaskViewModel
|
|
widget.viewModel.selectTask(task.id);
|
|
|
|
// Update the current task ID in ChatViewModel
|
|
// TODO: Do we want to have a reference to chat view model in this class?
|
|
final chatViewModel =
|
|
Provider.of<ChatViewModel>(context, listen: false);
|
|
chatViewModel.setCurrentTaskId(task.id);
|
|
|
|
print('Task ${task.title} tapped');
|
|
},
|
|
onDelete: () {
|
|
// Delete the task in TaskViewModel
|
|
widget.viewModel.deleteTask(task.id);
|
|
// TODO: Do we want to have a reference to chat view model in this class?
|
|
final chatViewModel =
|
|
Provider.of<ChatViewModel>(context, listen: false);
|
|
if (chatViewModel.currentTaskId == task.id) {
|
|
chatViewModel.clearCurrentTaskAndChats();
|
|
}
|
|
|
|
print('Task ${task.title} delete button tapped');
|
|
},
|
|
selected: task.id == widget.viewModel.selectedTask?.id,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|