File size: 3,601 Bytes
b225a21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
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: Column(
children: [
// All settings in a scrollable list
Expanded(
child: ListView(
children: [
// TODO: Add back dark mode toggle
// Dark Mode Toggle
// SwitchListTile(
// title: const Text('Dark Mode'),
// value: viewModel.isDarkModeEnabled,
// onChanged: viewModel.toggleDarkMode,
// ),
// const Divider(),
// Developer Mode Toggle
SwitchListTile(
title: const Text('Developer Mode'),
value: viewModel.isDeveloperModeEnabled,
onChanged: viewModel.toggleDeveloperMode,
),
const Divider(),
// Base URL Configuration
const ListTile(
title: Center(child: Text('Agent Base URL')),
),
ApiBaseUrlField(),
const Divider(),
// Continuous Mode Steps Configuration
ListTile(
title: const Center(child: Text('Continuous Mode Steps')),
// User can increment or decrement the number of steps using '+' and '-' buttons.
subtitle: Row(
mainAxisAlignment:
MainAxisAlignment.center, // Centers the Row's content
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.
),
],
),
),
const Divider(),
],
),
),
// Sign out button fixed at the bottom
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: ElevatedButton.icon(
icon: const Icon(Icons.logout, color: Colors.black),
label:
const Text('Sign Out', style: TextStyle(color: Colors.black)),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
),
onPressed: viewModel.signOut,
),
),
],
),
);
}
}
|