Skip to content

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.

Implement SettingsView for User Configurable Settings

hunteraraujobb627442d407
diff --git a/frontend/lib/views/settings/settings_view.dart b/frontend/lib/views/settings/settings_view.dart
new file mode 100644
index 0000000000..97416bbc6d
--- /dev/null
+++ b/frontend/lib/views/settings/settings_view.dart
@@ -0,0 +1,72 @@
+import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
+import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+
+/// [SettingsView] displays a list of settings that the user can configure.
+/// It uses [SettingsViewModel] for state management and logic.
+class SettingsView extends StatelessWidget {
+ const SettingsView({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ // [ChangeNotifierProvider] provides an instance of [SettingsViewModel] to the widget tree.
+ return ChangeNotifierProvider(
+ create: (context) => SettingsViewModel(),
+ child: Scaffold(
+ appBar: AppBar(title: const Text('Settings')),
+ body: Consumer<SettingsViewModel>(
+ builder: (context, viewModel, child) {
+ // A list of settings is displayed using [ListView].
+ return ListView(
+ children: [
+ // Dark Mode Toggle
+ SwitchListTile(
+ title: const Text('Dark Mode'),
+ value: viewModel.isDarkModeEnabled,
+ onChanged: viewModel.toggleDarkMode,
+ ),
+ // Developer Mode Toggle
+ SwitchListTile(
+ title: const Text('Developer Mode'),
+ value: viewModel.isDeveloperModeEnabled,
+ onChanged: viewModel.toggleDeveloperMode,
+ ),
+ // Base URL Configuration
+ ListTile(
+ title: const Text('Base URL'),
+ subtitle: TextFormField(
+ initialValue: viewModel.baseURL,
+ onChanged: viewModel.updateBaseURL,
+ decoration: const InputDecoration(
+ hintText: 'Enter Base URL',
+ ),
+ ),
+ ),
+ // Continuous Mode Steps Configuration
+ ListTile(
+ title: const Text('Continuous Mode Steps'),
+ // User can increment or decrement the number of steps using '+' and '-' buttons.
+ subtitle: Row(
+ children: [
+ IconButton(
+ icon: const Icon(Icons.remove),
+ onPressed: viewModel
+ .decrementContinuousModeSteps, // Decrement the number of steps.
+ ),
+ Text('${viewModel.continuousModeSteps} Steps'),
+ IconButton(
+ icon: const Icon(Icons.add),
+ onPressed: viewModel
+ .incrementContinuousModeSteps, // Increment the number of steps.
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ },
+ ),
+ ),
+ );
+ }
+}