mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-21 23:14:24 +01:00
In this commit, the app underwent significant UI improvements by leveraging new, more modular widgets (NewTaskButton and TaskListTile). This ensures better code maintainability and a cleaner architecture. Key changes include: Integrated ChangeNotifierProvider in main.dart to facilitate the creation and broadcasting of TaskViewModel. Refactored TaskView to utilize the newly created NewTaskButton and TaskListTile widgets. Updated MainLayout to reflect the changes and provide a more cohesive user experience.
76 lines
2.3 KiB
Dart
76 lines
2.3 KiB
Dart
import 'package:auto_gpt_flutter_client/views/new_task_button.dart';
|
|
import 'package:auto_gpt_flutter_client/views/task_list_tile.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
|
|
|
class TaskView extends StatefulWidget {
|
|
final TaskViewModel viewModel;
|
|
|
|
const TaskView({Key? key, required this.viewModel}) : super(key: key);
|
|
|
|
@override
|
|
_TaskViewState createState() => _TaskViewState();
|
|
}
|
|
|
|
class _TaskViewState extends State<TaskView> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
// Schedule the fetchTasks call for after the initial build
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
widget.viewModel.fetchTasks();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: Column(
|
|
children: [
|
|
// Title and New Task button
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
'Tasks',
|
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal),
|
|
),
|
|
SizedBox(height: 8),
|
|
NewTaskButton(
|
|
onPressed: () {
|
|
// TODO: Implement add new task action
|
|
print('Add new task button pressed');
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
// Task List
|
|
Expanded(
|
|
child: ListView.builder(
|
|
itemCount: widget.viewModel.tasks.length,
|
|
itemBuilder: (context, index) {
|
|
final task = widget.viewModel.tasks[index];
|
|
return TaskListTile(
|
|
task: task,
|
|
onTap: () {
|
|
// TODO: Implement the action when a task is tapped. This should trigger the TaskView to update.
|
|
print('Task ${task.title} tapped');
|
|
},
|
|
onDelete: () {
|
|
// TODO: Implement the action when a task is needing to be deleted. This should trigger the TaskView to update.
|
|
print('Task ${task.title} delete button tapped');
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|