Files
Auto-GPT/frontend/lib/views/settings/settings_view.dart
hunteraraujo da8b9d58ac Refactor Settings and Task Views for API Base URL Management
- Deprecated `ApiSettingsViewModel` in favor of enhancing `SettingsViewModel`.
- Moved the API Base URL field from `TaskView` to `SettingsView` to centralize configuration.
- Integrated `RestApiUtility` dependency into `SettingsViewModel` to ensure consistent URL management across the app.
2023-09-24 21:41:12 -07:00

68 lines
2.3 KiB
Dart

import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
import 'package:auto_gpt_flutter_client/views/settings/api_base_url_field.dart';
import 'package:flutter/material.dart';
/// [SettingsView] displays a list of settings that the user can configure.
/// It uses [SettingsViewModel] for state management and logic.
class SettingsView extends StatelessWidget {
final SettingsViewModel viewModel;
/// Constructor for [SettingsView], requiring an instance of [SettingsViewModel].
const SettingsView({Key? key, required this.viewModel}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.grey,
foregroundColor: Colors.black,
title: const Text('Settings'),
),
body: 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
ApiBaseUrlField(),
// 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.
),
],
),
),
ListTile(
title: Text('Sign Out'),
onTap: () {
viewModel.signOut();
},
),
],
),
);
}
}