Implement Notifications and Pad Tracking Enhancements
This commit is contained in:
@@ -5,8 +5,7 @@ import '../../theme/app_theme.dart';
|
||||
import '../../models/user_profile.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
import '../../services/mock_data_service.dart';
|
||||
import '../../providers/cycle_provider.dart'; // Ensure cycleEntriesProvider is available
|
||||
import '../settings/appearance_screen.dart';
|
||||
import 'husband_appearance_screen.dart';
|
||||
|
||||
class HusbandSettingsScreen extends ConsumerWidget {
|
||||
const HusbandSettingsScreen({super.key});
|
||||
@@ -72,20 +71,22 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
final mockWife = mockService.generateMockWifeProfile();
|
||||
final currentProfile = ref.read(userProfileProvider);
|
||||
if (currentProfile != null) {
|
||||
final updatedProfile = currentProfile.copyWith(
|
||||
partnerName: mockWife.name,
|
||||
averageCycleLength: mockWife.averageCycleLength,
|
||||
averagePeriodLength: mockWife.averagePeriodLength,
|
||||
lastPeriodStartDate: mockWife.lastPeriodStartDate,
|
||||
favoriteFoods: mockWife.favoriteFoods,
|
||||
);
|
||||
await ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
|
||||
final updatedProfile = currentProfile.copyWith(
|
||||
partnerName: mockWife.name,
|
||||
averageCycleLength: mockWife.averageCycleLength,
|
||||
averagePeriodLength: mockWife.averagePeriodLength,
|
||||
lastPeriodStartDate: mockWife.lastPeriodStartDate,
|
||||
favoriteFoods: mockWife.favoriteFoods,
|
||||
);
|
||||
await ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(updatedProfile);
|
||||
}
|
||||
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Demo data loaded')),
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Demo data loaded')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,23 +113,26 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
...BibleTranslation.values.map((translation) => ListTile(
|
||||
title: Text(
|
||||
translation.label,
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: ref.watch(userProfileProvider)?.bibleTranslation == translation
|
||||
? const Icon(Icons.check, color: AppColors.sageGreen)
|
||||
: null,
|
||||
onTap: () async {
|
||||
final profile = ref.read(userProfileProvider);
|
||||
if (profile != null) {
|
||||
await ref.read(userProfileProvider.notifier).updateProfile(
|
||||
profile.copyWith(bibleTranslation: translation),
|
||||
);
|
||||
}
|
||||
if (context.mounted) Navigator.pop(context);
|
||||
},
|
||||
)),
|
||||
title: Text(
|
||||
translation.label,
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: ref.watch(userProfileProvider)?.bibleTranslation ==
|
||||
translation
|
||||
? const Icon(Icons.check, color: AppColors.sageGreen)
|
||||
: null,
|
||||
onTap: () async {
|
||||
final profile = ref.read(userProfileProvider);
|
||||
if (profile != null) {
|
||||
await ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(
|
||||
profile.copyWith(bibleTranslation: translation),
|
||||
);
|
||||
}
|
||||
if (context.mounted) Navigator.pop(context);
|
||||
},
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -138,104 +142,112 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
void _showConnectDialog(BuildContext context, WidgetRef ref) {
|
||||
final codeController = TextEditingController();
|
||||
bool shareDevotional = true;
|
||||
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => StatefulBuilder(
|
||||
builder: (context, setState) => AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.link, color: AppColors.navyBlue),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Connect with Wife'),
|
||||
],
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Enter the pairing code from your wife\'s app:',
|
||||
style: GoogleFonts.outfit(fontSize: 14, color: AppColors.warmGray),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: codeController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'e.g., ABC123',
|
||||
border: OutlineInputBorder(),
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.link, color: AppColors.navyBlue),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Connect with Wife'),
|
||||
],
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Enter the pairing code from your wife\'s app:',
|
||||
style:
|
||||
GoogleFonts.outfit(fontSize: 14, color: AppColors.warmGray),
|
||||
),
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Your wife can find this code in her Settings under "Share with Husband".',
|
||||
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: codeController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'e.g., ABC123',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Your wife can find this code in her Settings under "Share with Husband".',
|
||||
style:
|
||||
GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: Checkbox(
|
||||
value: shareDevotional,
|
||||
onChanged: (val) => setState(() => shareDevotional = val ?? true),
|
||||
activeColor: AppColors.navyBlue,
|
||||
),
|
||||
SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: Checkbox(
|
||||
value: shareDevotional,
|
||||
onChanged: (val) =>
|
||||
setState(() => shareDevotional = val ?? true),
|
||||
activeColor: AppColors.navyBlue,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Share Devotional Plans',
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.bold, fontSize: 14, color: AppColors.charcoal),
|
||||
),
|
||||
Text(
|
||||
'Allow her to see the teaching plans you create.',
|
||||
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Share Devotional Plans',
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: AppColors.charcoal),
|
||||
),
|
||||
Text(
|
||||
'Allow her to see the teaching plans you create.',
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 12, color: AppColors.warmGray),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
],
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final code = codeController.text.trim();
|
||||
|
||||
Navigator.pop(context);
|
||||
|
||||
// Update preference
|
||||
final user = ref.read(userProfileProvider);
|
||||
if (user != null) {
|
||||
await ref.read(userProfileProvider.notifier).updateProfile(
|
||||
user.copyWith(isDataShared: shareDevotional)
|
||||
);
|
||||
}
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final code = codeController.text.trim();
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Settings updated & Connected!'),
|
||||
backgroundColor: AppColors.sageGreen,
|
||||
),
|
||||
);
|
||||
|
||||
if (code.isNotEmpty) {
|
||||
Navigator.pop(context);
|
||||
|
||||
// Update preference
|
||||
final user = ref.read(userProfileProvider);
|
||||
if (user != null) {
|
||||
await ref.read(userProfileProvider.notifier).updateProfile(
|
||||
user.copyWith(isDataShared: shareDevotional));
|
||||
}
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Settings updated & Connected!'),
|
||||
backgroundColor: AppColors.sageGreen,
|
||||
),
|
||||
);
|
||||
|
||||
if (code.isNotEmpty) {
|
||||
// Load demo data as simulation
|
||||
final mockService = MockDataService();
|
||||
final entries = mockService.generateMockCycleEntries();
|
||||
for (var entry in entries) {
|
||||
await ref.read(cycleEntriesProvider.notifier).addEntry(entry);
|
||||
await ref
|
||||
.read(cycleEntriesProvider.notifier)
|
||||
.addEntry(entry);
|
||||
}
|
||||
final mockWife = mockService.generateMockWifeProfile();
|
||||
final currentProfile = ref.read(userProfileProvider);
|
||||
@@ -248,18 +260,20 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
lastPeriodStartDate: mockWife.lastPeriodStartDate,
|
||||
favoriteFoods: mockWife.favoriteFoods,
|
||||
);
|
||||
await ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
|
||||
await ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(updatedProfile);
|
||||
}
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.navyBlue,
|
||||
foregroundColor: Colors.white,
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.navyBlue,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Connect'),
|
||||
),
|
||||
child: const Text('Connect'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -268,7 +282,8 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// Theme aware colors
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final cardColor = Theme.of(context).cardTheme.color; // Using theme card color
|
||||
final cardColor =
|
||||
Theme.of(context).cardTheme.color; // Using theme card color
|
||||
final textColor = Theme.of(context).textTheme.bodyLarge?.color;
|
||||
|
||||
return SafeArea(
|
||||
@@ -282,7 +297,8 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).textTheme.displayMedium?.color ?? AppColors.navyBlue,
|
||||
color: Theme.of(context).textTheme.displayMedium?.color ??
|
||||
AppColors.navyBlue,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
@@ -297,7 +313,8 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
leading: Icon(Icons.notifications_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
title: Text('Notifications',
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: textColor)),
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Switch(value: true, onChanged: (val) {}),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
@@ -305,8 +322,10 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
leading: Icon(Icons.link,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
title: Text('Connect with Wife',
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Icon(Icons.chevron_right, color: Theme.of(context).disabledColor),
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Icon(Icons.chevron_right,
|
||||
color: Theme.of(context).disabledColor),
|
||||
onTap: () => _showConnectDialog(context, ref),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
@@ -314,18 +333,24 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
leading: Icon(Icons.menu_book_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
title: Text('Bible Translation',
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: textColor)),
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
ref.watch(userProfileProvider.select((u) => u?.bibleTranslation.label)) ?? 'ESV',
|
||||
ref.watch(userProfileProvider
|
||||
.select((u) => u?.bibleTranslation.label)) ??
|
||||
'ESV',
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color ?? AppColors.warmGray,
|
||||
color:
|
||||
Theme.of(context).textTheme.bodyMedium?.color ??
|
||||
AppColors.warmGray,
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, color: Theme.of(context).disabledColor),
|
||||
Icon(Icons.chevron_right,
|
||||
color: Theme.of(context).disabledColor),
|
||||
],
|
||||
),
|
||||
onTap: () => _showTranslationPicker(context, ref),
|
||||
@@ -335,13 +360,15 @@ class HusbandSettingsScreen extends ConsumerWidget {
|
||||
leading: Icon(Icons.palette_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
title: Text('Appearance',
|
||||
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Icon(Icons.chevron_right, color: Theme.of(context).disabledColor),
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.w500, color: textColor)),
|
||||
trailing: Icon(Icons.chevron_right,
|
||||
color: Theme.of(context).disabledColor),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AppearanceScreen(),
|
||||
builder: (context) => const HusbandAppearanceScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user