New
This commit is contained in:
@@ -8,6 +8,8 @@ import '../../models/scripture.dart';
|
||||
import '../calendar/calendar_screen.dart';
|
||||
import '../log/log_screen.dart';
|
||||
import '../devotional/devotional_screen.dart';
|
||||
import '../settings/appearance_screen.dart';
|
||||
import '../settings/cycle_settings_screen.dart';
|
||||
import '../../widgets/tip_card.dart';
|
||||
import '../../widgets/cycle_ring.dart';
|
||||
import '../../widgets/scripture_card.dart';
|
||||
@@ -203,7 +205,7 @@ class _DashboardTabState extends ConsumerState<_DashboardTab> {
|
||||
icon: const Icon(Icons.shuffle),
|
||||
label: const Text('Random Verse'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: AppColors.sageGreen,
|
||||
foregroundColor: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -219,7 +221,7 @@ class _DashboardTabState extends ConsumerState<_DashboardTab> {
|
||||
const QuickLogButtons(),
|
||||
const SizedBox(height: 24),
|
||||
if (role == UserRole.wife)
|
||||
TipCard(phase: phase, isMarried: isMarried),
|
||||
_buildWifeTipsSection(context),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
@@ -383,8 +385,8 @@ class _SettingsTab extends ConsumerWidget {
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.blushPink,
|
||||
AppColors.rose.withOpacity(0.7)
|
||||
Theme.of(context).colorScheme.primary.withOpacity(0.7),
|
||||
Theme.of(context).colorScheme.secondary.withOpacity(0.7)
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
@@ -440,7 +442,13 @@ class _SettingsTab extends ConsumerWidget {
|
||||
'Bible Version ($translationLabel)',
|
||||
onTap: () => BibleUtils.showTranslationPicker(context, ref),
|
||||
),
|
||||
_buildSettingsTile(context, Icons.palette_outlined, 'Appearance'),
|
||||
_buildSettingsTile(context, Icons.palette_outlined, 'Appearance',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AppearanceScreen()));
|
||||
}),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.favorite_border,
|
||||
@@ -452,15 +460,32 @@ class _SettingsTab extends ConsumerWidget {
|
||||
context,
|
||||
Icons.share_outlined,
|
||||
'Share with Husband',
|
||||
onTap: () => _showShareDialog(context, ref),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SharingSettingsScreen()));
|
||||
},
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup(context, 'Cycle', [
|
||||
_buildSettingsTile(
|
||||
context, Icons.calendar_today_outlined, 'Cycle Settings'),
|
||||
context, Icons.calendar_today_outlined, 'Cycle Settings',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CycleSettingsScreen()));
|
||||
}),
|
||||
_buildSettingsTile(
|
||||
context, Icons.trending_up_outlined, 'Cycle History'),
|
||||
context, Icons.trending_up_outlined, 'Cycle History',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CycleHistoryScreen()));
|
||||
}),
|
||||
_buildSettingsTile(
|
||||
context, Icons.download_outlined, 'Export Data'),
|
||||
]),
|
||||
@@ -549,7 +574,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.toList();
|
||||
|
||||
|
||||
final updatedProfile = userProfile.copyWith(favoriteFoods: favorites);
|
||||
ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
|
||||
Navigator.pop(context);
|
||||
@@ -571,7 +596,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.share_outlined, color: AppColors.sageGreen),
|
||||
Icon(Icons.share_outlined, color: Theme.of(context).colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Share with Husband'),
|
||||
],
|
||||
@@ -587,9 +612,9 @@ class _SettingsTab extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.sageGreen.withOpacity(0.1),
|
||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColors.sageGreen.withOpacity(0.3)),
|
||||
border: Border.all(color: Theme.of(context).colorScheme.primary.withOpacity(0.3)),
|
||||
),
|
||||
child: SelectableText(
|
||||
pairingCode,
|
||||
@@ -597,7 +622,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 4,
|
||||
color: AppColors.sageGreen,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -613,7 +638,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.sageGreen,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Done'),
|
||||
@@ -623,3 +648,54 @@ class _SettingsTab extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildWifeTipsSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Health Tips',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Regular Check-ups',
|
||||
content:
|
||||
'Schedule regular gynecological check-ups to monitor your reproductive health.',
|
||||
icon: Icons.medical_services,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Healthy Lifestyle',
|
||||
content:
|
||||
'Maintain a balanced diet, exercise regularly, and get adequate sleep.',
|
||||
icon: Icons.healing,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Partner Communication',
|
||||
content:
|
||||
'Discuss health concerns openly with your partner to ensure mutual understanding.',
|
||||
icon: Icons.chat,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
165
lib/screens/husband/_HusbandLearnScreen.dart
Normal file
165
lib/screens/husband/_HusbandLearnScreen.dart
Normal file
@@ -0,0 +1,165 @@
|
||||
class _HusbandLearnScreen extends StatelessWidget {
|
||||
const _HusbandLearnScreen();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Learn',
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.navyBlue,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_buildSection(context, 'Understanding Her', [
|
||||
_LearnItem(
|
||||
icon: Icons.loop,
|
||||
title: 'The 4 Phases of Her Cycle',
|
||||
subtitle: 'What\'s happening in her body each month',
|
||||
articleId: 'four_phases',
|
||||
),
|
||||
_LearnItem(
|
||||
icon: Icons.psychology_outlined,
|
||||
title: 'Why Does Her Mood Change?',
|
||||
subtitle: 'Hormones explained simply',
|
||||
articleId: 'mood_changes',
|
||||
),
|
||||
_LearnItem(
|
||||
icon: Icons.medical_information_outlined,
|
||||
title: 'PMS is Real',
|
||||
subtitle: 'Medical facts for supportive husbands',
|
||||
articleId: 'pms_is_real',
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 24),
|
||||
_buildSection(context, 'Biblical Manhood', [
|
||||
_LearnItem(
|
||||
icon: Icons.favorite,
|
||||
title: 'Loving Like Christ',
|
||||
subtitle: 'Ephesians 5 in daily practice',
|
||||
articleId: 'loving_like_christ',
|
||||
),
|
||||
_LearnItem(
|
||||
icon: Icons.handshake,
|
||||
title: 'Servant Leadership at Home',
|
||||
subtitle: 'What it really means',
|
||||
articleId: 'servant_leadership',
|
||||
),
|
||||
_LearnItem(
|
||||
icon: Icons.auto_awesome,
|
||||
title: 'Praying for Your Wife',
|
||||
subtitle: 'Practical guide',
|
||||
articleId: 'praying_for_wife',
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 24),
|
||||
_buildSection(context, 'NFP for Husbands', [
|
||||
_LearnItem(
|
||||
icon: Icons.show_chart,
|
||||
title: 'Reading the Charts Together',
|
||||
subtitle: 'Understanding fertility signs',
|
||||
articleId: 'reading_charts',
|
||||
),
|
||||
_LearnItem(
|
||||
icon: Icons.schedule,
|
||||
title: 'Abstinence as Spiritual Discipline',
|
||||
subtitle: 'Growing together during fertile days',
|
||||
articleId: 'abstinence_discipline',
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSection(BuildContext context, String title, List<_LearnItem> items) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.warmGray,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: items
|
||||
.map((item) => ListTile(
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.navyBlue.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
item.icon,
|
||||
color: AppColors.navyBlue,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
item.title,
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.charcoal,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
item.subtitle,
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 13,
|
||||
color: AppColors.warmGray,
|
||||
),
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppColors.lightGray,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => LearnArticleScreen(articleId: item.articleId),
|
||||
),
|
||||
);
|
||||
},
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _LearnItem {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String articleId;
|
||||
|
||||
const _LearnItem({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.articleId,
|
||||
});
|
||||
}
|
||||
204
lib/screens/learn/husband_learn_screen.dart
Normal file
204
lib/screens/learn/husband_learn_screen.dart
Normal file
@@ -0,0 +1,204 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:christian_period_tracker/models/scripture.dart';
|
||||
|
||||
class HusbandLearnScreen extends StatelessWidget {
|
||||
const HusbandLearnScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reproductive Health Education'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.bookmark),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHealthTipsSection(context),
|
||||
const SizedBox(height: 24),
|
||||
_buildDiseasePreventionSection(context),
|
||||
const SizedBox(height: 24),
|
||||
_buildPracticalAdviceSection(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHealthTipsSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Reproductive Health Tips',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Understanding Female Cycles',
|
||||
content: 'Learn about the different phases of your wife\'s menstrual cycle and how they affect her health.',
|
||||
icon: Icons.calendar_month,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Supportive Role',
|
||||
content: 'Be supportive during different phases, understanding when she may need more emotional support or rest.',
|
||||
icon: Icons.support_agent,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Nutritional Support',
|
||||
content: 'Understand how nutrition affects reproductive health and discuss dietary choices together.',
|
||||
icon: Icons.food_bank,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiseasePreventionSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Disease Prevention Between Partners',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Safe Sexual Practices',
|
||||
content: 'Use protection consistently to prevent sexually transmitted infections and maintain mutual health.',
|
||||
icon: Icons.protect,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Regular Testing',
|
||||
content: 'Schedule regular STI screenings together with your partner for early detection and treatment.',
|
||||
icon: Icons.medical_information,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Open Communication',
|
||||
content: 'Discuss health concerns openly to ensure both partners understand each other\'s needs and maintain trust.',
|
||||
icon: Icons.chat,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPracticalAdviceSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Practical Advice for Partnership',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Educate Yourself',
|
||||
content: 'Take the initiative to learn about reproductive health and partner needs.',
|
||||
icon: Icons.school,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Active Listening',
|
||||
content: 'Listen attentively when your wife discusses her health concerns or feelings.',
|
||||
icon: Icons.mic_none,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTipCard(BuildContext context, {required String title, required String content, required IconData icon}) {
|
||||
return Card(
|
||||
elevation: 1,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 24, color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
content,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
201
lib/screens/learn/wife_learn_screen.dart
Normal file
201
lib/screens/learn/wife_learn_screen.dart
Normal file
@@ -0,0 +1,201 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:christian_period_tracker/models/scripture.dart';
|
||||
|
||||
class WifeLearnScreen extends StatelessWidget {
|
||||
const WifeLearnScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reproductive Health Education'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.bookmark),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHealthTipsSection(context),
|
||||
const SizedBox(height: 24),
|
||||
_buildDiseasePreventionSection(context),
|
||||
const SizedBox(height: 24),
|
||||
_buildPracticalAdviceSection(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHealthTipsSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Reproductive Health Tips',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Regular Medical Check-ups',
|
||||
content: 'Schedule regular gynecological check-ups to monitor your reproductive health and catch any potential issues early.',
|
||||
icon: Icons.medical_services,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Healthy Lifestyle',
|
||||
content: 'Maintain a balanced diet, exercise regularly, and get adequate sleep to support overall reproductive wellness.',
|
||||
icon: Icons.healing,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Stress Management',
|
||||
content: 'Chronic stress can affect menstrual cycles and fertility. Practice mindfulness techniques and seek support when needed.',
|
||||
icon: Icons.spa,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiseasePreventionSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Disease Prevention Between Partners',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Safe Sexual Practices',
|
||||
content: 'Use protection consistently to prevent sexually transmitted infections and maintain mutual health.',
|
||||
icon: Icons.protect,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Regular Testing',
|
||||
content: 'Schedule regular STI screenings together with your partner for early detection and treatment.',
|
||||
icon: Icons.medical_information,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Open Communication',
|
||||
content: 'Discuss health concerns openly to ensure both partners understand each other\'s needs and maintain trust.',
|
||||
icon: Icons.chat,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPracticalAdviceSection(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Practical Advice for Partnership',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Support System',
|
||||
content: 'Build a support system that includes both your partner and trusted healthcare providers.',
|
||||
icon: Icons.supervisor_account,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTipCard(
|
||||
context,
|
||||
title: 'Educate Together',
|
||||
content: 'Both partners should educate themselves about reproductive health to make informed decisions together.',
|
||||
icon: Icons.school,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTipCard(BuildContext context, {required String title, required String content, required IconData icon}) {
|
||||
return Card(
|
||||
elevation: 1,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 24, color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
content,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
162
lib/screens/settings/appearance_screen.dart
Normal file
162
lib/screens/settings/appearance_screen.dart
Normal file
@@ -0,0 +1,162 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../models/user_profile.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
import '../../theme/app_theme.dart';
|
||||
|
||||
class AppearanceScreen extends ConsumerWidget {
|
||||
const AppearanceScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final userProfile = ref.watch(userProfileProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Appearance'),
|
||||
),
|
||||
body: userProfile == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
_buildThemeModeSelector(context, ref, userProfile.themeMode),
|
||||
const SizedBox(height: 24),
|
||||
_buildAccentColorSelector(
|
||||
context, ref, userProfile.accentColor, AppColors.sageGreen),
|
||||
const SizedBox(height: 32),
|
||||
_buildRelationshipStatusSelector(context, ref, userProfile.relationshipStatus),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildThemeModeSelector(
|
||||
BuildContext context, WidgetRef ref, AppThemeMode currentMode) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Theme Mode',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SegmentedButton<AppThemeMode>(
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: AppThemeMode.light,
|
||||
label: Text('Light'),
|
||||
icon: Icon(Icons.light_mode),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: AppThemeMode.dark,
|
||||
label: Text('Dark'),
|
||||
icon: Icon(Icons.dark_mode),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: AppThemeMode.system,
|
||||
label: Text('System'),
|
||||
icon: Icon(Icons.brightness_auto),
|
||||
),
|
||||
],
|
||||
selected: {currentMode},
|
||||
onSelectionChanged: (Set<AppThemeMode> newSelection) {
|
||||
if (newSelection.isNotEmpty) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateThemeMode(newSelection.first);
|
||||
}
|
||||
},
|
||||
style: SegmentedButton.styleFrom(
|
||||
fixedSize: const Size.fromHeight(48),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAccentColorSelector(BuildContext context, WidgetRef ref,
|
||||
String currentAccent) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Accent Color',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Wrap(
|
||||
spacing: 16,
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateAccentColor('0xFFA8C5A8');
|
||||
},
|
||||
child: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.sageGreen,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary, // Assuming currentAccent is sageGreen
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.check, color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRelationshipStatusSelector(
|
||||
BuildContext context, WidgetRef ref, RelationshipStatus currentStatus) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Relationship Status',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SegmentedButton<RelationshipStatus>(
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: RelationshipStatus.single,
|
||||
label: Text('Single'),
|
||||
icon: Icon(Icons.person_outline),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: RelationshipStatus.engaged,
|
||||
label: Text('Engaged'),
|
||||
icon: Icon(Icons.favorite_border),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: RelationshipStatus.married,
|
||||
label: Text('Married'),
|
||||
icon: Icon(Icons.favorite),
|
||||
),
|
||||
],
|
||||
selected: {currentStatus},
|
||||
onSelectionChanged: (Set<RelationshipStatus> newSelection) {
|
||||
if (newSelection.isNotEmpty) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateRelationshipStatus(newSelection.first);
|
||||
}
|
||||
},
|
||||
style: SegmentedButton.styleFrom(
|
||||
fixedSize: const Size.fromHeight(48),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
240
lib/screens/settings/cycle_history_screen.dart
Normal file
240
lib/screens/settings/cycle_history_screen.dart
Normal file
@@ -0,0 +1,240 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import '../../models/cycle_entry.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
|
||||
class CycleHistoryScreen extends ConsumerWidget {
|
||||
const CycleHistoryScreen({super.key});
|
||||
|
||||
void _showDeleteAllDialog(BuildContext context, WidgetRef ref) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Delete All History?'),
|
||||
content: const Text(
|
||||
'This will permanently delete all cycle entries. This action cannot be undone.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
ref.read(cycleEntriesProvider.notifier).clearEntries();
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('All cycle history has been deleted.')),
|
||||
);
|
||||
},
|
||||
child: const Text('Delete All', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteMonthDialog(BuildContext context, WidgetRef ref) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const _DeleteMonthDialog(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final entries = ref.watch(cycleEntriesProvider);
|
||||
|
||||
final groupedEntries = groupBy(
|
||||
entries,
|
||||
(CycleEntry entry) => DateFormat('MMMM yyyy').format(entry.date),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cycle History'),
|
||||
actions: [
|
||||
if (entries.isNotEmpty)
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) {
|
||||
if (value == 'delete_all') {
|
||||
_showDeleteAllDialog(context, ref);
|
||||
} else if (value == 'delete_month') {
|
||||
_showDeleteMonthDialog(context, ref);
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
value: 'delete_month',
|
||||
child: Text('Delete by Month'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'delete_all',
|
||||
child: Text('Delete All Data'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
body: entries.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No cycle history found.',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: groupedEntries.keys.length,
|
||||
itemBuilder: (context, index) {
|
||||
final month = groupedEntries.keys.elementAt(index);
|
||||
final monthEntries = groupedEntries[month]!;
|
||||
return ExpansionTile(
|
||||
title: Text(month, style: Theme.of(context).textTheme.titleLarge),
|
||||
initiallyExpanded: index == 0,
|
||||
children: monthEntries.map((entry) {
|
||||
return Dismissible(
|
||||
key: Key(entry.id),
|
||||
direction: DismissDirection.endToStart,
|
||||
onDismissed: (direction) {
|
||||
ref.read(cycleEntriesProvider.notifier).deleteEntry(entry.id);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Entry for ${DateFormat.yMMMd().format(entry.date)} deleted.')),
|
||||
);
|
||||
},
|
||||
background: Container(
|
||||
color: Colors.red,
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: const Icon(Icons.delete, color: Colors.white),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(DateFormat.yMMMMEEEEd().format(entry.date)),
|
||||
subtitle: Text(_buildEntrySummary(entry)),
|
||||
isThreeLine: true,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _buildEntrySummary(CycleEntry entry) {
|
||||
final summary = <String>[];
|
||||
if (entry.isPeriodDay) {
|
||||
summary.add('Period');
|
||||
}
|
||||
if (entry.mood != null) {
|
||||
summary.add('Mood: ${entry.mood!.label}');
|
||||
}
|
||||
if (entry.symptomCount > 0) {
|
||||
summary.add('${entry.symptomCount} symptom(s)');
|
||||
}
|
||||
if (entry.notes != null && entry.notes!.isNotEmpty) {
|
||||
summary.add('Note');
|
||||
}
|
||||
if (summary.isEmpty) {
|
||||
return 'No specific data logged.';
|
||||
}
|
||||
return summary.join(' • ');
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteMonthDialog extends ConsumerStatefulWidget {
|
||||
const _DeleteMonthDialog();
|
||||
|
||||
@override
|
||||
ConsumerState<_DeleteMonthDialog> createState() => _DeleteMonthDialogState();
|
||||
}
|
||||
|
||||
class _DeleteMonthDialogState extends ConsumerState<_DeleteMonthDialog> {
|
||||
late int _selectedYear;
|
||||
late int _selectedMonth;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final now = DateTime.now();
|
||||
_selectedYear = now.year;
|
||||
_selectedMonth = now.month;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final years =
|
||||
List.generate(5, (index) => DateTime.now().year - index);
|
||||
final months = List.generate(12, (index) => index + 1);
|
||||
|
||||
return AlertDialog(
|
||||
title: const Text('Delete by Month'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text('Select a month and year to delete all entries from.'),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
DropdownButton<int>(
|
||||
value: _selectedMonth,
|
||||
items: months.map((month) => DropdownMenuItem(
|
||||
value: month,
|
||||
child: Text(DateFormat('MMMM').format(DateTime(0, month))),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
_selectedMonth = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
DropdownButton<int>(
|
||||
value: _selectedYear,
|
||||
items: years
|
||||
.map((year) => DropdownMenuItem(
|
||||
value: year,
|
||||
child: Text(year.toString()),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
_selectedYear = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(cycleEntriesProvider.notifier)
|
||||
.deleteEntriesForMonth(_selectedYear, _selectedMonth);
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Deleted entries for ${DateFormat('MMMM yyyy').format(DateTime(0, _selectedMonth))}.')),
|
||||
);
|
||||
},
|
||||
child: const Text('Delete', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
143
lib/screens/settings/cycle_settings_screen.dart
Normal file
143
lib/screens/settings/cycle_settings_screen.dart
Normal file
@@ -0,0 +1,143 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../models/user_profile.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
|
||||
class CycleSettingsScreen extends ConsumerStatefulWidget {
|
||||
const CycleSettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<CycleSettingsScreen> createState() =>
|
||||
_CycleSettingsScreenState();
|
||||
}
|
||||
|
||||
class _CycleSettingsScreenState extends ConsumerState<CycleSettingsScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late TextEditingController _cycleLengthController;
|
||||
late TextEditingController _periodLengthController;
|
||||
DateTime? _lastPeriodStartDate;
|
||||
bool _isIrregularCycle = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final userProfile = ref.read(userProfileProvider);
|
||||
_cycleLengthController = TextEditingController(
|
||||
text: userProfile?.averageCycleLength.toString() ?? '28');
|
||||
_periodLengthController = TextEditingController(
|
||||
text: userProfile?.averagePeriodLength.toString() ?? '5');
|
||||
_lastPeriodStartDate = userProfile?.lastPeriodStartDate;
|
||||
_isIrregularCycle = userProfile?.isIrregularCycle ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_cycleLengthController.dispose();
|
||||
_periodLengthController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _saveSettings() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final userProfile = ref.read(userProfileProvider);
|
||||
if (userProfile != null) {
|
||||
final updatedProfile = userProfile.copyWith(
|
||||
averageCycleLength: int.tryParse(_cycleLengthController.text) ?? userProfile.averageCycleLength,
|
||||
averagePeriodLength: int.tryParse(_periodLengthController.text) ?? userProfile.averagePeriodLength,
|
||||
lastPeriodStartDate: _lastPeriodStartDate,
|
||||
isIrregularCycle: _isIrregularCycle,
|
||||
);
|
||||
ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
|
||||
Navigator.of(context).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Cycle settings saved!')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cycle Settings'),
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _cycleLengthController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Average Cycle Length (days)',
|
||||
hintText: 'e.g., 28',
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || int.tryParse(value) == null) {
|
||||
return 'Please enter a valid number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _periodLengthController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Average Period Length (days)',
|
||||
hintText: 'e.g., 5',
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || int.tryParse(value) == null) {
|
||||
return 'Please enter a valid number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('Last Period Start Date'),
|
||||
subtitle: Text(_lastPeriodStartDate == null
|
||||
? 'Not set'
|
||||
: DateFormat.yMMMMd().format(_lastPeriodStartDate!)),
|
||||
trailing: const Icon(Icons.calendar_today),
|
||||
onTap: () async {
|
||||
final pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _lastPeriodStartDate ?? DateTime.now(),
|
||||
firstDate: DateTime(DateTime.now().year - 1),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (pickedDate != null) {
|
||||
setState(() {
|
||||
_lastPeriodStartDate = pickedDate;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('My cycle is irregular'),
|
||||
value: _isIrregularCycle,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isIrregularCycle = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
ElevatedButton(
|
||||
onPressed: _saveSettings,
|
||||
child: const Text('Save Settings'),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
70
lib/screens/settings/export_data_screen.dart
Normal file
70
lib/screens/settings/export_data_screen.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
import '../../services/pdf_service.dart';
|
||||
import '../../services/ics_service.dart';
|
||||
|
||||
class ExportDataScreen extends ConsumerWidget {
|
||||
const ExportDataScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final userProfile = ref.watch(userProfileProvider);
|
||||
final cycleEntries = ref.watch(cycleEntriesProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Export Data'),
|
||||
),
|
||||
body: userProfile == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.picture_as_pdf),
|
||||
title: const Text('Export as PDF'),
|
||||
subtitle: const Text('Generate a printable PDF report of your cycle data.'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () async {
|
||||
try {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Generating PDF report...')),
|
||||
);
|
||||
await PdfService.generateCycleReport(userProfile, cycleEntries);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('PDF report generated successfully!')),
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to generate PDF: $e')),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.calendar_month),
|
||||
title: const Text('Export to Calendar File (.ics)'),
|
||||
subtitle: const Text('Generate a calendar file for your cycle dates.'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () async {
|
||||
try {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Generating ICS file...')),
|
||||
);
|
||||
await IcsService.generateCycleCalendar(cycleEntries);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('ICS file generated successfully!')),
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to generate ICS file: $e')),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
141
lib/screens/settings/privacy_settings_screen.dart
Normal file
141
lib/screens/settings/privacy_settings_screen.dart
Normal file
@@ -0,0 +1,141 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:health/health.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
import '../../services/health_service.dart';
|
||||
|
||||
class PrivacySettingsScreen extends ConsumerStatefulWidget {
|
||||
const PrivacySettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<PrivacySettingsScreen> createState() =>
|
||||
_PrivacySettingsScreenState();
|
||||
}
|
||||
|
||||
class _PrivacySettingsScreenState extends ConsumerState<PrivacySettingsScreen> {
|
||||
bool _hasPermissions = false;
|
||||
final HealthService _healthService = HealthService();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkPermissions();
|
||||
}
|
||||
|
||||
Future<void> _checkPermissions() async {
|
||||
final hasPermissions = await _healthService.hasPermissions(_healthService.menstruationDataTypes);
|
||||
setState(() {
|
||||
_hasPermissions = hasPermissions;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _requestPermissions() async {
|
||||
final authorized = await _healthService.requestAuthorization(_healthService.menstruationDataTypes);
|
||||
if (authorized) {
|
||||
_hasPermissions = true;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Health app access granted!')),
|
||||
);
|
||||
} else {
|
||||
_hasPermissions = false;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Health app access denied.')),
|
||||
);
|
||||
}
|
||||
setState(() {}); // Rebuild to update UI
|
||||
}
|
||||
|
||||
Future<void> _syncPeriodDays(bool sync) async {
|
||||
if (sync) {
|
||||
if (!_hasPermissions) {
|
||||
// Request permissions if not already granted
|
||||
final authorized = await _healthService.requestAuthorization(_healthService.menstruationDataTypes);
|
||||
if (!authorized) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Cannot sync without health app permissions.')),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_hasPermissions = true;
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Syncing period data...')),
|
||||
);
|
||||
}
|
||||
final userProfile = ref.read(userProfileProvider);
|
||||
final cycleEntries = ref.read(cycleEntriesProvider);
|
||||
|
||||
if (userProfile != null) {
|
||||
final success = await _healthService.writeMenstruationData(cycleEntries);
|
||||
if (mounted) {
|
||||
if (success) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Period data synced successfully!')),
|
||||
);
|
||||
// Optionally store a flag in userProfile if sync is active
|
||||
// userProfile.copyWith(syncPeriodToHealth: true)
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Failed to sync period data.')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Logic to disable sync (e.g., revoke permissions if Health package supports it,
|
||||
// or just stop writing data in future)
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Period data sync disabled.')),
|
||||
);
|
||||
}
|
||||
}
|
||||
setState(() {}); // Rebuild to update UI
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This value would ideally come from userProfile.syncPeriodToHealth
|
||||
bool syncPeriodToHealth = _hasPermissions;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Privacy Settings'),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('Health App Integration'),
|
||||
subtitle: _hasPermissions
|
||||
? const Text('Connected to Health App. Period data can be synced.')
|
||||
: const Text('Not connected. Tap to grant access.'),
|
||||
trailing: _hasPermissions ? const Icon(Icons.check_circle, color: Colors.green) : const Icon(Icons.warning, color: Colors.orange),
|
||||
onTap: _requestPermissions,
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Sync Period Days'),
|
||||
subtitle: const Text('Automatically sync your period start and end dates to your health app.'),
|
||||
value: syncPeriodToHealth,
|
||||
onChanged: (value) async {
|
||||
if (value) {
|
||||
await _syncPeriodDays(true);
|
||||
} else {
|
||||
await _syncPeriodDays(false);
|
||||
}
|
||||
setState(() {
|
||||
syncPeriodToHealth = value; // Update local state for toggle
|
||||
});
|
||||
},
|
||||
enabled: _hasPermissions, // Only enable if connected
|
||||
),
|
||||
// TODO: Add more privacy settings if needed
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
87
lib/screens/settings/sharing_settings_screen.dart
Normal file
87
lib/screens/settings/sharing_settings_screen.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../models/user_profile.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
|
||||
class SharingSettingsScreen extends ConsumerWidget {
|
||||
const SharingSettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final userProfile = ref.watch(userProfileProvider);
|
||||
|
||||
if (userProfile == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sharing Settings'),
|
||||
),
|
||||
body: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sharing Settings'),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
SwitchListTile(
|
||||
title: const Text('Share Moods'),
|
||||
value: userProfile.shareMoods,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareMoods: value));
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Share Symptoms'),
|
||||
value: userProfile.shareSymptoms,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareSymptoms: value));
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Share Cravings'),
|
||||
value: userProfile.shareCravings,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareCravings: value));
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Share Energy Levels'),
|
||||
value: userProfile.shareEnergyLevels,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareEnergyLevels: value));
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Share Sleep Data'),
|
||||
value: userProfile.shareSleep,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareSleep: value));
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: const Text('Share Intimacy Details'),
|
||||
value: userProfile.shareIntimacy,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(userProfileProvider.notifier)
|
||||
.updateProfile(userProfile.copyWith(shareIntimacy: value));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user