/// Settings tab: theme mode, API endpoint, and bank link status. library; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/bank_provider.dart'; import '../providers/theme_provider.dart'; import '../utils/connect_bank.dart'; import '../utils/constants.dart'; import '../utils/helpers.dart'; import '../widgets/responsive_body.dart'; class SettingsScreen extends StatelessWidget { const SettingsScreen({super.key}); @override Widget build(BuildContext context) { final themeController = context.watch(); final bank = context.watch(); final theme = Theme.of(context); return Scaffold( appBar: AppBar(title: const Text('Settings')), body: ResponsiveBody( child: ListView( children: [ const SizedBox(height: 8), Text('Appearance', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Text( 'Theme is saved with shared_preferences and restored on launch.', style: theme.textTheme.bodyMedium, ), const SizedBox(height: 16), SegmentedButton( segments: const [ ButtonSegment( value: ThemeMode.system, label: Text('System'), icon: Icon(Icons.brightness_auto), ), ButtonSegment( value: ThemeMode.light, label: Text('Light'), icon: Icon(Icons.light_mode_outlined), ), ButtonSegment( value: ThemeMode.dark, label: Text('Dark'), icon: Icon(Icons.dark_mode_outlined), ), ], selected: {themeController.themeMode}, onSelectionChanged: (selection) { themeController.setThemeMode(selection.first); }, ), const SizedBox(height: 28), Text('Backend', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Card( child: Column( children: [ ListTile( leading: const Icon(Icons.dns_outlined), title: const Text('API base URL'), subtitle: Text(bank.apiBaseUrl), ), const Divider(height: 1), ListTile( leading: Icon( bank.isLinked ? Icons.link : Icons.link_off_outlined, ), title: const Text('Bank link'), subtitle: Text( bank.isLinked ? 'Linked · ${bank.status.status}' : 'Not linked', ), trailing: bank.isLinked ? null : TextButton( onPressed: bank.isConnecting ? null : () => runConnectBank(context, bank), child: Text( bank.isConnecting ? 'Opening…' : 'Connect', ), ), ), const Divider(height: 1), ListTile( leading: const Icon(Icons.open_in_browser_outlined), title: const Text('Enable Banking redirect'), subtitle: Text(kEnableBankingRedirectUri), ), ], ), ), const SizedBox(height: 12), Text( 'Enable Banking only allows http(s) redirects. Keep ' '$kEnableBankingRedirectUri in the Control Panel and backend ' 'REDIRECT_URI. The app captures that callback path in a WebView. ' 'Override with `--dart-define=API_BASE_URL=https://…`.', style: theme.textTheme.bodyMedium, ), const SizedBox(height: 28), Text('About', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Card( child: Column( children: [ const ListTile( leading: Icon(Icons.apps), title: Text(kAppName), subtitle: Text('Personal bank data via Enable Banking'), ), const Divider(height: 1), const ListTile( leading: Icon(Icons.fingerprint), title: Text('Package'), subtitle: Text(kPackageName), ), const Divider(height: 1), ListTile( leading: const Icon(Icons.contrast), title: const Text('Active theme'), subtitle: Text(labelForThemeMode(themeController.themeMode)), ), ], ), ), const SizedBox(height: 24), ], ), ), ); } }