Files
Auto-GPT/frontend/lib/views/task_queue/task_queue_view.dart
hunteraraujo 454b78c1ac Integrate callGenerateReport with TaskQueueView's Checkmark Button
This commit integrates the `callGenerateReport` method from `SkillTreeViewModel` into the `TaskQueueView`. Now, when the user clicks the green checkmark button, the `callGenerateReport` method is triggered with hardcoded values for testing purposes.

Note: The implementation is still temporary and will be updated for dynamic behavior in the future.
2023-09-16 11:04:40 -07:00

82 lines
3.0 KiB
Dart

import 'package:auto_gpt_flutter_client/models/benchmark_service/report_request_body.dart';
import 'package:flutter/material.dart';
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
import 'package:provider/provider.dart';
// TODO: Add view model for task queue instead of skill tree view model
class TaskQueueView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final viewModel = Provider.of<SkillTreeViewModel>(context);
// Reverse the node hierarchy
final reversedHierarchy =
viewModel.selectedNodeHierarchy?.reversed.toList() ?? [];
return Material(
color: Colors.white,
child: Stack(
children: [
// The list of tasks (tiles)
ListView.builder(
itemCount: reversedHierarchy.length,
itemBuilder: (context, index) {
final node = reversedHierarchy[index];
return Container(
margin: EdgeInsets.fromLTRB(20, 5, 20, 5),
decoration: BoxDecoration(
color: Colors.white, // white background
border: Border.all(
color: Colors.black, width: 1), // thin black border
borderRadius: BorderRadius.circular(4), // small corner radius
),
child: ListTile(
title: Center(child: Text('${node.label}')),
subtitle:
Center(child: Text('${node.data.info.description}')),
),
);
},
),
// Checkmark button at the bottom right
Positioned(
bottom: 50,
right: 50,
child: Tooltip(
message: 'Run suite of tests',
child: ElevatedButton(
onPressed: () {
// Create a ReportRequestBody with hardcoded values
ReportRequestBody reportRequestBody = ReportRequestBody(
category: "coding",
tests: [],
mock: true,
);
// Call callGenerateReport method from SkillTreeViewModel
viewModel.callGenerateReport(reportRequestBody);
},
child: Icon(Icons.check, color: Colors.green),
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
backgroundColor: MaterialStateProperty.all(Colors.white),
side: MaterialStateProperty.all(
BorderSide(color: Colors.green, width: 3)),
minimumSize:
MaterialStateProperty.all(Size(50, 50)), // Square size
padding: MaterialStateProperty.all(EdgeInsets.all(0)),
),
),
),
),
],
),
);
}
}