64 lines
2.2 KiB
Dart
64 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../models/user_profile.dart'; // Import UserProfile
|
|
import '../../providers/user_provider.dart';
|
|
|
|
class NotificationSettingsScreen extends ConsumerWidget {
|
|
const NotificationSettingsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final userProfile = ref.watch(userProfileProvider);
|
|
|
|
if (userProfile == null) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Notifications')),
|
|
body: const Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Notifications'),
|
|
),
|
|
body: ListView(
|
|
padding: const EdgeInsets.all(16.0),
|
|
children: [
|
|
SwitchListTile(
|
|
title: const Text('Period Estimate'),
|
|
subtitle: const Text('Get notified when your period is predicted to start soon.'),
|
|
value: userProfile.notifyPeriodEstimate,
|
|
onChanged: (value) async {
|
|
await ref
|
|
.read(userProfileProvider.notifier)
|
|
.updateProfile(userProfile.copyWith(notifyPeriodEstimate: value));
|
|
},
|
|
),
|
|
const Divider(),
|
|
SwitchListTile(
|
|
title: const Text('Period Start'),
|
|
subtitle: const Text('Get notified when a period starts (or husband needs to know).'),
|
|
value: userProfile.notifyPeriodStart,
|
|
onChanged: (value) async {
|
|
await ref
|
|
.read(userProfileProvider.notifier)
|
|
.updateProfile(userProfile.copyWith(notifyPeriodStart: value));
|
|
},
|
|
),
|
|
const Divider(),
|
|
SwitchListTile(
|
|
title: const Text('Low Supply Alert'),
|
|
subtitle: const Text('Get notified when pad inventory is running low.'),
|
|
value: userProfile.notifyLowSupply,
|
|
onChanged: (value) async {
|
|
await ref
|
|
.read(userProfileProvider.notifier)
|
|
.updateProfile(userProfile.copyWith(notifyLowSupply: value));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|