import 'package:cofounderella/themes/theme_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../settings/settings_provider.dart'; class SettingsPage extends StatelessWidget { const SettingsPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Theme.of(context).colorScheme.surface, appBar: AppBar( title: const Text("Settings"), ), body: SingleChildScrollView( child: Column( children: [ Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(12), ), margin: const EdgeInsets.all(16), padding: const EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // dark mode switch const Text("Dark Mode"), Consumer( builder: (context, themeProvider, child) { return CupertinoSwitch( value: themeProvider.isDarkMode, onChanged: (value) { themeProvider.toggleTheme(); }, ); }, ), ], ), ), Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(12), ), margin: const EdgeInsets.all(16), padding: const EdgeInsets.all(16), child: Consumer( builder: (context, settingsProvider, child) { return Padding( padding: const EdgeInsets.all(0.0), child: Column( children: settingsProvider.settingsOptions.map((option) { return SwitchListTile( title: Text(option.title), subtitle: (option.subtitle.isNotEmpty ? Text(option.subtitle) : null), value: option.getValue(), onChanged: option.onChanged, contentPadding: EdgeInsets.zero, ); }).toList(), ), ); }, ), ), ], ), ), ); } }