|
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'; |
|
|
|
|
|
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: [ |
|
|
|
Expanded( |
|
child: ListView.builder( |
|
itemCount: |
|
widget.testSuite.tests.length, |
|
itemBuilder: (context, index) { |
|
final task = widget.testSuite.tests[index]; |
|
return TaskListTile( |
|
task: task, |
|
onTap: () { |
|
|
|
widget.viewModel.selectTask(task.id); |
|
|
|
|
|
|
|
final chatViewModel = |
|
Provider.of<ChatViewModel>(context, listen: false); |
|
chatViewModel.setCurrentTaskId(task.id); |
|
|
|
print('Task ${task.title} tapped'); |
|
}, |
|
onDelete: () { |
|
|
|
widget.viewModel.deleteTask(task.id); |
|
|
|
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, |
|
); |
|
}, |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
} |
|
|