AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Update main_layout.dart + main.dart to integrate ChatView
hunteraraujo9f8c93ebb0b8
diff --git a/lib/main.dart b/lib/main.dartindex 8b53d1b77d..a6a3434f8b 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -2,13 +2,14 @@ import 'package:flutter/material.dart';import 'views/main_layout.dart';import 'package:provider/provider.dart';import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';+import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';void main() {runApp(const MyApp());}class MyApp extends StatelessWidget {- const MyApp({Key? key}) : super(key: key); // Corrected the constructor+ const MyApp({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {@@ -17,8 +18,11 @@ class MyApp extends StatelessWidget {theme: ThemeData(primarySwatch: Colors.blue,),- home: ChangeNotifierProvider(- create: (context) => TaskViewModel(),+ home: MultiProvider(+ providers: [+ ChangeNotifierProvider(create: (context) => TaskViewModel()),+ ChangeNotifierProvider(create: (context) => ChatViewModel()),+ ],child: const MainLayout(),), // Set MainLayout as the home screen of the app);diff --git a/lib/views/main_layout.dart b/lib/views/main_layout.dartindex 3639d97818..79106105f3 100644--- a/lib/views/main_layout.dart+++ b/lib/views/main_layout.dart@@ -1,11 +1,12 @@-import 'package:auto_gpt_flutter_client/views/task_view.dart';-import 'package:auto_gpt_flutter_client/views/chat_view.dart';+import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';+import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';+import 'package:auto_gpt_flutter_client/views/task/task_view.dart';+import 'package:auto_gpt_flutter_client/views/chat/chat_view.dart';import 'package:flutter/cupertino.dart';-import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart'; // Importing the TaskViewModel-import 'package:provider/provider.dart'; // Required for accessing the ViewModel+import 'package:provider/provider.dart';class MainLayout extends StatelessWidget {- const MainLayout({Key? key}) : super(key: key); // Corrected the constructor+ const MainLayout({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {@@ -15,17 +16,19 @@ class MainLayout extends StatelessWidget {// Access the TaskViewModel from the contextfinal taskViewModel = Provider.of<TaskViewModel>(context);+ // Access the ChatViewModel from the context+ final chatViewModel = Provider.of<ChatViewModel>(context);+// Check the screen width and return the appropriate layoutif (width > 800) {// For larger screens, return a side-by-side layoutreturn Row(children: [- SizedBox(- width: 280,- child: TaskView(- viewModel:- taskViewModel)), // Pass the viewModel to the TaskView- Expanded(child: ChatView()),+ SizedBox(width: 280, child: TaskView(viewModel: taskViewModel)),+ Expanded(+ child: ChatView(+ viewModel: chatViewModel,+ )),],);} else {@@ -50,16 +53,14 @@ class MainLayout extends StatelessWidget {case 0:returnValue = CupertinoTabView(builder: (context) {return CupertinoPageScaffold(- child: TaskView(- viewModel:- taskViewModel), // Pass the viewModel to the TaskView+ child: TaskView(viewModel: taskViewModel),);});break;case 1:returnValue = CupertinoTabView(builder: (context) {- return const CupertinoPageScaffold(- child: ChatView(),+ return CupertinoPageScaffold(+ child: ChatView(viewModel: chatViewModel),);});break;