import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../services/authentication_manager.dart'; import 'hose_view.dart'; class MoreView extends StatelessWidget { const MoreView({super.key}); @override Widget build(BuildContext context) { final authManager = context.watch(); return Scaffold( appBar: AppBar( title: const Text('More'), ), body: ListView( children: [ _buildFeaturesSection(context), const Divider(height: 1), _buildAppInfoSection(context), const Divider(height: 1), _buildLogoutSection(context, authManager), ], ), ); } Widget _buildFeaturesSection(BuildContext context) { return Container( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Features', style: Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), Card( child: ListTile( leading: CircleAvatar( backgroundColor: Theme.of(context).colorScheme.primaryContainer, child: Icon( Icons.water_drop, color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), title: const Text('Hose'), subtitle: const Text('Live talkgroup activity monitor'), trailing: const Icon(Icons.chevron_right), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const HoseView(), ), ); }, ), ), ], ), ); } Widget _buildAppInfoSection(BuildContext context) { return Container( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Application', style: Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), const _InfoRow( icon: Icons.info, label: 'App Name', value: 'BM Manager', ), const _InfoRow( icon: Icons.analytics, label: 'Version', value: '1.0.0', ), const _InfoRow( icon: Icons.copyright, label: 'Copyright', value: '2026', ), ], ), ); } Widget _buildLogoutSection( BuildContext context, AuthenticationManager authManager) { return Container( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Account', style: Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), SizedBox( width: double.infinity, child: ElevatedButton.icon( onPressed: () async { final confirm = await showDialog( context: context, builder: (context) => AlertDialog( title: const Text('Logout'), content: const Text('Are you sure you want to logout?'), actions: [ TextButton( onPressed: () => Navigator.pop(context, false), child: const Text('Cancel'), ), TextButton( onPressed: () => Navigator.pop(context, true), style: TextButton.styleFrom(foregroundColor: Colors.red), child: const Text('Logout'), ), ], ), ); if (confirm == true) { await authManager.logout(); } }, icon: const Icon(Icons.logout), label: const Text('Logout'), style: ElevatedButton.styleFrom( backgroundColor: Colors.red, foregroundColor: Colors.white, padding: const EdgeInsets.symmetric(vertical: 12), ), ), ), ], ), ); } } class _InfoRow extends StatelessWidget { final IconData icon; final String label; final String value; const _InfoRow({ required this.icon, required this.label, required this.value, }); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(bottom: 12), child: Row( children: [ Icon(icon, size: 20, color: Theme.of(context).colorScheme.primary), const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: Theme.of(context).textTheme.bodySmall?.copyWith( color: Colors.grey[600], ), ), Text( value, style: Theme.of(context).textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w500, ), ), ], ), ), ], ), ); } }