Update TaskQueueView with TestSuiteButton and LeaderboardSubmissionButton

Integrated both the TestSuiteButton and LeaderboardSubmissionButton in the TaskQueueView. Added conditions to disable the LeaderboardSubmissionButton based on benchmark running status and if the benchmarkStatusMap is empty. The onPressed logic for both buttons has been integrated as per requirements.
pull/5352/head
hunteraraujo 2023-09-26 16:28:52 -07:00
parent d056793309
commit efe1b3e0eb
1 changed files with 37 additions and 48 deletions

View File

@ -1,6 +1,9 @@
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.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_queue/leaderboard_submission_button.dart';
import 'package:auto_gpt_flutter_client/views/task_queue/leaderboard_submission_dialog.dart';
import 'package:auto_gpt_flutter_client/views/task_queue/test_suite_button.dart';
import 'package:flutter/material.dart';
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
import 'package:provider/provider.dart';
@ -90,56 +93,42 @@ class TaskQueueView extends StatelessWidget {
bottom: 20,
left: 20,
right: 20,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
border: Border.all(color: Colors.green, width: 3),
),
child: ElevatedButton(
onPressed: viewModel.isBenchmarkRunning
? null
: () {
// TODO: We should not be passing this dependency in like this
final chatViewModel =
Provider.of<ChatViewModel>(context, listen: false);
final taskViewModel =
Provider.of<TaskViewModel>(context, listen: false);
chatViewModel.clearCurrentTaskAndChats();
// Call runBenchmark method from SkillTreeViewModel
viewModel.runBenchmark(chatViewModel, taskViewModel);
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.center, // Center the children
children: [
Text(
'Initiate test suite',
style: TextStyle(
color: Colors.green, // Text color is set to green
fontWeight: FontWeight.bold, // Make text bold
fontSize: 16, // Increase font size
),
),
SizedBox(width: 10), // Gap of 10 between text and icon
Icon(
Icons.play_arrow,
color: Colors.green, // Icon color is set to green
size: 24, // Increase icon size
),
],
child: Column(
children: [
// TestSuiteButton
TestSuiteButton(
onPressed: viewModel.isBenchmarkRunning
? null
: () {
final chatViewModel = Provider.of<ChatViewModel>(
context,
listen: false);
final taskViewModel = Provider.of<TaskViewModel>(
context,
listen: false);
chatViewModel.clearCurrentTaskAndChats();
viewModel.runBenchmark(chatViewModel, taskViewModel);
},
isDisabled: viewModel.isBenchmarkRunning,
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
minimumSize: MaterialStateProperty.all(
Size(double.infinity, 50)), // Full width
padding: MaterialStateProperty.all(EdgeInsets.all(0)),
SizedBox(height: 8), // Gap of 8 points between buttons
// LeaderboardSubmissionButton
LeaderboardSubmissionButton(
onPressed: viewModel.benchmarkStatusMap.isEmpty ||
viewModel.isBenchmarkRunning
? null
: () {
showDialog(
context: context,
builder: (context) => LeaderboardSubmissionDialog(
onSubmit: viewModel.submitToLeaderboard,
),
);
},
isDisabled: viewModel.isBenchmarkRunning ||
viewModel.benchmarkStatusMap.isEmpty,
),
),
],
),
),
],