import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../../shared/widgets/app_button.dart'; import '../../domain/entities/app_settings.dart'; import '../providers/settings_provider.dart'; import '../widgets/settings_widgets.dart'; import '../../../../shared/widgets/app_toast.dart'; class NotificationSettingsScreen extends ConsumerWidget { const NotificationSettingsScreen({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final notifications = ref.watch(appSettingsProvider).notifications; Future update(NotificationSettingsConfig updated) async { await ref.read(appSettingsProvider.notifier).updateNotifications(updated); if (context.mounted) { showAppToastFromSnackBar(context, const SnackBar(content: Text('Notification settings saved')), ); } } return SettingsPageLayout( title: 'Notification Settings', subtitle: 'Configure email, SMS, push, and in-app notifications', child: Column( children: [ SettingsFormCard( title: 'Email Notifications', children: [ SettingsSwitchTile( title: 'Asset Allocation', subtitle: 'Notify when an asset is allocated to an employee', value: notifications.emailAssetAllocation, onChanged: (v) => update(notifications.copyWith(emailAssetAllocation: v)), ), SettingsSwitchTile( title: 'Asset Return', subtitle: 'Notify when an asset is returned', value: notifications.emailAssetReturn, onChanged: (v) => update(notifications.copyWith(emailAssetReturn: v)), ), SettingsSwitchTile( title: 'Maintenance Request', subtitle: 'Notify when a maintenance request is created', value: notifications.emailMaintenanceRequest, onChanged: (v) => update(notifications.copyWith(emailMaintenanceRequest: v)), ), SettingsSwitchTile( title: 'Warranty Expiry', subtitle: 'Notify before asset warranty expires', value: notifications.emailWarrantyExpiry, onChanged: (v) => update(notifications.copyWith(emailWarrantyExpiry: v)), ), ], ), const SizedBox(height: 16), SettingsFormCard( title: 'Other Channels', children: [ SettingsSwitchTile( title: 'SMS Notifications', value: notifications.smsEnabled, onChanged: (v) => update(notifications.copyWith(smsEnabled: v)), ), SettingsSwitchTile( title: 'Push Notifications', value: notifications.pushEnabled, onChanged: (v) => update(notifications.copyWith(pushEnabled: v)), ), SettingsSwitchTile( title: 'In-App Notifications', value: notifications.inAppEnabled, onChanged: (v) => update(notifications.copyWith(inAppEnabled: v)), ), ], ), const SizedBox(height: 24), AppButton( label: 'Settings Auto-Saved', onPressed: () { showAppToastFromSnackBar(context, const SnackBar( content: Text('Notification settings are saved automatically'), ), ); }, ), ], ), ); } }