Your commit message here

This commit is contained in:
2025-12-19 22:47:27 -06:00
parent 5d746d694e
commit 464692ce56
21 changed files with 3018 additions and 0 deletions

View File

@@ -7,13 +7,23 @@ import '../../theme/app_theme.dart';
import 'package:uuid/uuid.dart';
class LogScreen extends ConsumerStatefulWidget {
<<<<<<< HEAD
const LogScreen({super.key});
=======
final DateTime? initialDate;
const LogScreen({super.key, this.initialDate});
>>>>>>> 6742220 (Your commit message here)
@override
ConsumerState<LogScreen> createState() => _LogScreenState();
}
class _LogScreenState extends ConsumerState<LogScreen> {
<<<<<<< HEAD
=======
late DateTime _selectedDate;
String? _existingEntryId;
>>>>>>> 6742220 (Your commit message here)
bool _isPeriodDay = false;
FlowIntensity? _flowIntensity;
MoodLevel? _mood;
@@ -24,9 +34,61 @@ class _LogScreenState extends ConsumerState<LogScreen> {
bool _hasBreastTenderness = false;
bool _hasFatigue = false;
bool _hasAcne = false;
<<<<<<< HEAD
final TextEditingController _notesController = TextEditingController();
@override
=======
bool _hasLowerBackPain = false;
bool _hasConstipation = false;
bool _hasDiarrhea = false;
bool _hasInsomnia = false;
int _stressLevel = 1;
final TextEditingController _notesController = TextEditingController();
@override
void initState() {
super.initState();
_selectedDate = widget.initialDate ?? DateTime.now();
// Defer data loading to avoid build-time ref.read
WidgetsBinding.instance.addPostFrameCallback((_) {
_loadExistingData();
});
}
void _loadExistingData() {
final entries = ref.read(cycleEntriesProvider);
try {
final entry = entries.firstWhere(
(e) => DateUtils.isSameDay(e.date, _selectedDate),
);
setState(() {
_existingEntryId = entry.id;
_isPeriodDay = entry.isPeriodDay;
_flowIntensity = entry.flowIntensity;
_mood = entry.mood;
_energyLevel = entry.energyLevel;
_crampIntensity = entry.crampIntensity ?? 0;
_hasHeadache = entry.hasHeadache;
_hasBloating = entry.hasBloating;
_hasBreastTenderness = entry.hasBreastTenderness;
_hasFatigue = entry.hasFatigue;
_hasAcne = entry.hasAcne;
_hasLowerBackPain = entry.hasLowerBackPain;
_hasConstipation = entry.hasConstipation;
_hasDiarrhea = entry.hasDiarrhea;
_hasInsomnia = entry.hasInsomnia;
_stressLevel = entry.stressLevel ?? 1;
_notesController.text = entry.notes ?? '';
});
} catch (_) {
// No existing entry for this day
}
}
@override
>>>>>>> 6742220 (Your commit message here)
void dispose() {
_notesController.dispose();
super.dispose();
@@ -34,8 +96,13 @@ class _LogScreenState extends ConsumerState<LogScreen> {
Future<void> _saveEntry() async {
final entry = CycleEntry(
<<<<<<< HEAD
id: const Uuid().v4(),
date: DateTime.now(),
=======
id: _existingEntryId ?? const Uuid().v4(),
date: _selectedDate,
>>>>>>> 6742220 (Your commit message here)
isPeriodDay: _isPeriodDay,
flowIntensity: _isPeriodDay ? _flowIntensity : null,
mood: _mood,
@@ -46,28 +113,60 @@ class _LogScreenState extends ConsumerState<LogScreen> {
hasBreastTenderness: _hasBreastTenderness,
hasFatigue: _hasFatigue,
hasAcne: _hasAcne,
<<<<<<< HEAD
=======
hasLowerBackPain: _hasLowerBackPain,
hasConstipation: _hasConstipation,
hasDiarrhea: _hasDiarrhea,
hasInsomnia: _hasInsomnia,
stressLevel: _stressLevel > 1 ? _stressLevel : null,
>>>>>>> 6742220 (Your commit message here)
notes: _notesController.text.isNotEmpty ? _notesController.text : null,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
<<<<<<< HEAD
await ref.read(cycleEntriesProvider.notifier).addEntry(entry);
=======
if (_existingEntryId != null) {
await ref.read(cycleEntriesProvider.notifier).updateEntry(entry);
} else {
await ref.read(cycleEntriesProvider.notifier).addEntry(entry);
}
>>>>>>> 6742220 (Your commit message here)
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Entry saved!', style: GoogleFonts.outfit()),
<<<<<<< HEAD
backgroundColor: AppColors.sageGreen,
=======
backgroundColor: AppColors.success,
>>>>>>> 6742220 (Your commit message here)
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
);
<<<<<<< HEAD
_resetForm();
=======
if (widget.initialDate != null) {
Navigator.pop(context);
} else {
_resetForm();
}
>>>>>>> 6742220 (Your commit message here)
}
}
void _resetForm() {
setState(() {
<<<<<<< HEAD
=======
_existingEntryId = null;
>>>>>>> 6742220 (Your commit message here)
_isPeriodDay = false;
_flowIntensity = null;
_mood = null;
@@ -78,12 +177,26 @@ class _LogScreenState extends ConsumerState<LogScreen> {
_hasBreastTenderness = false;
_hasFatigue = false;
_hasAcne = false;
<<<<<<< HEAD
=======
_hasLowerBackPain = false;
_hasConstipation = false;
_hasDiarrhea = false;
_hasInsomnia = false;
_stressLevel = 1;
>>>>>>> 6742220 (Your commit message here)
_notesController.clear();
});
}
@override
Widget build(BuildContext context) {
<<<<<<< HEAD
=======
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
>>>>>>> 6742220 (Your commit message here)
return SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.all(20),
@@ -91,6 +204,7 @@ class _LogScreenState extends ConsumerState<LogScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header
<<<<<<< HEAD
Text(
'How are you feeling?',
style: GoogleFonts.outfit(
@@ -105,11 +219,49 @@ class _LogScreenState extends ConsumerState<LogScreen> {
fontSize: 14,
color: AppColors.warmGray,
),
=======
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'How are you feeling?',
style: GoogleFonts.outfit(
fontSize: 28,
fontWeight: FontWeight.w600,
color: theme.colorScheme.onSurface,
),
),
Text(
_formatDate(_selectedDate),
style: GoogleFonts.outfit(
fontSize: 14,
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
if (widget.initialDate == null)
IconButton(
onPressed: () => ref.read(navigationProvider.notifier).setIndex(0),
icon: const Icon(Icons.close),
style: IconButton.styleFrom(
backgroundColor: theme.colorScheme.surfaceVariant.withOpacity(0.5),
),
),
],
>>>>>>> 6742220 (Your commit message here)
),
const SizedBox(height: 24),
// Period Toggle
_buildSectionCard(
<<<<<<< HEAD
=======
context,
>>>>>>> 6742220 (Your commit message here)
title: 'Period',
child: Row(
children: [
@@ -118,7 +270,11 @@ class _LogScreenState extends ConsumerState<LogScreen> {
'Is today a period day?',
style: GoogleFonts.outfit(
fontSize: 16,
<<<<<<< HEAD
color: AppColors.charcoal,
=======
color: theme.colorScheme.onSurface,
>>>>>>> 6742220 (Your commit message here)
),
),
),
@@ -135,6 +291,10 @@ class _LogScreenState extends ConsumerState<LogScreen> {
if (_isPeriodDay) ...[
const SizedBox(height: 16),
_buildSectionCard(
<<<<<<< HEAD
=======
context,
>>>>>>> 6742220 (Your commit message here)
title: 'Flow Intensity',
child: Row(
children: FlowIntensity.values.map((flow) {
@@ -142,17 +302,31 @@ class _LogScreenState extends ConsumerState<LogScreen> {
return Expanded(
child: GestureDetector(
onTap: () => setState(() => _flowIntensity = flow),
<<<<<<< HEAD
child: Container(
=======
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
>>>>>>> 6742220 (Your commit message here)
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: isSelected
<<<<<<< HEAD
? AppColors.menstrualPhase.withOpacity(0.2)
: AppColors.lightGray.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
border: isSelected
? Border.all(color: AppColors.menstrualPhase)
: null,
=======
? AppColors.menstrualPhase.withOpacity(isDark ? 0.3 : 0.2)
: theme.colorScheme.surfaceVariant.withOpacity(0.3),
borderRadius: BorderRadius.circular(10),
border: isSelected
? Border.all(color: AppColors.menstrualPhase)
: Border.all(color: Colors.transparent),
>>>>>>> 6742220 (Your commit message here)
),
child: Column(
children: [
@@ -160,7 +334,11 @@ class _LogScreenState extends ConsumerState<LogScreen> {
Icons.water_drop,
color: isSelected
? AppColors.menstrualPhase
<<<<<<< HEAD
: AppColors.warmGray,
=======
: theme.colorScheme.onSurfaceVariant,
>>>>>>> 6742220 (Your commit message here)
size: 20,
),
const SizedBox(height: 4),
@@ -168,9 +346,16 @@ class _LogScreenState extends ConsumerState<LogScreen> {
flow.label,
style: GoogleFonts.outfit(
fontSize: 11,
<<<<<<< HEAD
color: isSelected
? AppColors.menstrualPhase
: AppColors.warmGray,
=======
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
color: isSelected
? AppColors.menstrualPhase
: theme.colorScheme.onSurfaceVariant,
>>>>>>> 6742220 (Your commit message here)
),
),
],
@@ -187,6 +372,10 @@ class _LogScreenState extends ConsumerState<LogScreen> {
// Mood
_buildSectionCard(
<<<<<<< HEAD
=======
context,
>>>>>>> 6742220 (Your commit message here)
title: 'Mood',
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@@ -194,16 +383,29 @@ class _LogScreenState extends ConsumerState<LogScreen> {
final isSelected = _mood == mood;
return GestureDetector(
onTap: () => setState(() => _mood = mood),
<<<<<<< HEAD
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: isSelected
? AppColors.softGold.withOpacity(0.2)
=======
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: isSelected
? AppColors.softGold.withOpacity(isDark ? 0.3 : 0.2)
>>>>>>> 6742220 (Your commit message here)
: Colors.transparent,
borderRadius: BorderRadius.circular(12),
border: isSelected
? Border.all(color: AppColors.softGold)
<<<<<<< HEAD
: null,
=======
: Border.all(color: Colors.transparent),
>>>>>>> 6742220 (Your commit message here)
),
child: Column(
children: [
@@ -218,9 +420,16 @@ class _LogScreenState extends ConsumerState<LogScreen> {
mood.label,
style: GoogleFonts.outfit(
fontSize: 10,
<<<<<<< HEAD
color: isSelected
? AppColors.softGold
: AppColors.warmGray,
=======
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
color: isSelected
? AppColors.softGold
: theme.colorScheme.onSurfaceVariant,
>>>>>>> 6742220 (Your commit message here)
),
),
],
@@ -233,6 +442,7 @@ class _LogScreenState extends ConsumerState<LogScreen> {
const SizedBox(height: 16),
<<<<<<< HEAD
// Energy Level
_buildSectionCard(
title: 'Energy Level',
@@ -241,17 +451,43 @@ class _LogScreenState extends ConsumerState<LogScreen> {
Row(
children: [
const Icon(Icons.battery_1_bar, color: AppColors.warmGray),
=======
// Energy & Stress Levels
_buildSectionCard(
context,
title: 'Daily Levels',
child: Column(
children: [
// Energy Level
Row(
children: [
SizedBox(
width: 80,
child: Text(
'Energy',
style: GoogleFonts.outfit(
fontSize: 14,
color: theme.colorScheme.onSurface,
),
),
),
>>>>>>> 6742220 (Your commit message here)
Expanded(
child: Slider(
value: _energyLevel.toDouble(),
min: 1,
max: 5,
divisions: 4,
<<<<<<< HEAD
=======
activeColor: AppColors.sageGreen,
>>>>>>> 6742220 (Your commit message here)
onChanged: (value) {
setState(() => _energyLevel = value.round());
},
),
),
<<<<<<< HEAD
const Icon(Icons.battery_full, color: AppColors.sageGreen),
],
),
@@ -261,6 +497,59 @@ class _LogScreenState extends ConsumerState<LogScreen> {
fontSize: 13,
color: AppColors.warmGray,
),
=======
SizedBox(
width: 50,
child: Text(
_getEnergyLabel(_energyLevel),
textAlign: TextAlign.end,
style: GoogleFonts.outfit(
fontSize: 11,
color: theme.colorScheme.onSurfaceVariant,
),
),
),
],
),
const SizedBox(height: 12),
// Stress Level
Row(
children: [
SizedBox(
width: 80,
child: Text(
'Stress',
style: GoogleFonts.outfit(
fontSize: 14,
color: theme.colorScheme.onSurface,
),
),
),
Expanded(
child: Slider(
value: _stressLevel.toDouble(),
min: 1,
max: 5,
divisions: 4,
activeColor: AppColors.ovulationPhase,
onChanged: (value) {
setState(() => _stressLevel = value.round());
},
),
),
SizedBox(
width: 50,
child: Text(
'$_stressLevel/5',
textAlign: TextAlign.end,
style: GoogleFonts.outfit(
fontSize: 12,
color: theme.colorScheme.onSurfaceVariant,
),
),
),
],
>>>>>>> 6742220 (Your commit message here)
),
],
),
@@ -270,6 +559,10 @@ class _LogScreenState extends ConsumerState<LogScreen> {
// Symptoms
_buildSectionCard(
<<<<<<< HEAD
=======
context,
>>>>>>> 6742220 (Your commit message here)
title: 'Symptoms',
child: Column(
children: [
@@ -282,7 +575,11 @@ class _LogScreenState extends ConsumerState<LogScreen> {
'Cramps',
style: GoogleFonts.outfit(
fontSize: 14,
<<<<<<< HEAD
color: AppColors.charcoal,
=======
color: theme.colorScheme.onSurface,
>>>>>>> 6742220 (Your commit message here)
),
),
),
@@ -299,12 +596,22 @@ class _LogScreenState extends ConsumerState<LogScreen> {
),
),
SizedBox(
<<<<<<< HEAD
width: 40,
child: Text(
_crampIntensity == 0 ? 'None' : '$_crampIntensity/5',
style: GoogleFonts.outfit(
fontSize: 12,
color: AppColors.warmGray,
=======
width: 50,
child: Text(
_crampIntensity == 0 ? 'None' : '$_crampIntensity/5',
textAlign: TextAlign.end,
style: GoogleFonts.outfit(
fontSize: 11,
color: theme.colorScheme.onSurfaceVariant,
>>>>>>> 6742220 (Your commit message here)
),
),
),
@@ -316,11 +623,23 @@ class _LogScreenState extends ConsumerState<LogScreen> {
spacing: 8,
runSpacing: 8,
children: [
<<<<<<< HEAD
_buildSymptomChip('Headache', _hasHeadache, (v) => setState(() => _hasHeadache = v)),
_buildSymptomChip('Bloating', _hasBloating, (v) => setState(() => _hasBloating = v)),
_buildSymptomChip('Breast Tenderness', _hasBreastTenderness, (v) => setState(() => _hasBreastTenderness = v)),
_buildSymptomChip('Fatigue', _hasFatigue, (v) => setState(() => _hasFatigue = v)),
_buildSymptomChip('Acne', _hasAcne, (v) => setState(() => _hasAcne = v)),
=======
_buildSymptomChip(context, 'Headache', _hasHeadache, (v) => setState(() => _hasHeadache = v)),
_buildSymptomChip(context, 'Bloating', _hasBloating, (v) => setState(() => _hasBloating = v)),
_buildSymptomChip(context, 'Breast Tenderness', _hasBreastTenderness, (v) => setState(() => _hasBreastTenderness = v)),
_buildSymptomChip(context, 'Fatigue', _hasFatigue, (v) => setState(() => _hasFatigue = v)),
_buildSymptomChip(context, 'Acne', _hasAcne, (v) => setState(() => _hasAcne = v)),
_buildSymptomChip(context, 'Back Pain', _hasLowerBackPain, (v) => setState(() => _hasLowerBackPain = v)),
_buildSymptomChip(context, 'Constipation', _hasConstipation, (v) => setState(() => _hasConstipation = v)),
_buildSymptomChip(context, 'Diarrhea', _hasDiarrhea, (v) => setState(() => _hasDiarrhea = v)),
_buildSymptomChip(context, 'Insomnia', _hasInsomnia, (v) => setState(() => _hasInsomnia = v)),
>>>>>>> 6742220 (Your commit message here)
],
),
],
@@ -331,12 +650,17 @@ class _LogScreenState extends ConsumerState<LogScreen> {
// Notes
_buildSectionCard(
<<<<<<< HEAD
=======
context,
>>>>>>> 6742220 (Your commit message here)
title: 'Notes',
child: TextField(
controller: _notesController,
maxLines: 3,
decoration: InputDecoration(
hintText: 'Add any notes about how you\'re feeling...',
<<<<<<< HEAD
hintStyle: GoogleFonts.outfit(
color: AppColors.lightGray,
fontSize: 14,
@@ -346,6 +670,18 @@ class _LogScreenState extends ConsumerState<LogScreen> {
style: GoogleFonts.outfit(
fontSize: 14,
color: AppColors.charcoal,
=======
filled: true,
fillColor: isDark ? theme.colorScheme.surface : theme.colorScheme.surfaceVariant.withOpacity(0.1),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
),
style: GoogleFonts.outfit(
fontSize: 14,
color: theme.colorScheme.onSurface,
>>>>>>> 6742220 (Your commit message here)
),
),
),
@@ -355,6 +691,10 @@ class _LogScreenState extends ConsumerState<LogScreen> {
// Save Button
SizedBox(
width: double.infinity,
<<<<<<< HEAD
=======
height: 54,
>>>>>>> 6742220 (Your commit message here)
child: ElevatedButton(
onPressed: _saveEntry,
child: const Text('Save Entry'),
@@ -367,16 +707,32 @@ class _LogScreenState extends ConsumerState<LogScreen> {
);
}
<<<<<<< HEAD
Widget _buildSectionCard({required String title, required Widget child}) {
=======
Widget _buildSectionCard(BuildContext context, {required String title, required Widget child}) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
>>>>>>> 6742220 (Your commit message here)
return Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
<<<<<<< HEAD
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: AppColors.charcoal.withOpacity(0.05),
=======
color: theme.cardTheme.color,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: theme.colorScheme.outline.withOpacity(0.05)),
boxShadow: isDark ? null : [
BoxShadow(
color: Colors.black.withOpacity(0.05),
>>>>>>> 6742220 (Your commit message here)
blurRadius: 10,
offset: const Offset(0, 4),
),
@@ -390,7 +746,11 @@ class _LogScreenState extends ConsumerState<LogScreen> {
style: GoogleFonts.outfit(
fontSize: 16,
fontWeight: FontWeight.w600,
<<<<<<< HEAD
color: AppColors.charcoal,
=======
color: theme.colorScheme.onSurface,
>>>>>>> 6742220 (Your commit message here)
),
),
const SizedBox(height: 12),
@@ -400,6 +760,7 @@ class _LogScreenState extends ConsumerState<LogScreen> {
);
}
<<<<<<< HEAD
Widget _buildSymptomChip(String label, bool isSelected, ValueChanged<bool> onChanged) {
return GestureDetector(
onTap: () => onChanged(!isSelected),
@@ -416,6 +777,36 @@ class _LogScreenState extends ConsumerState<LogScreen> {
fontSize: 13,
color: isSelected ? AppColors.ovulationPhase : AppColors.warmGray,
fontWeight: isSelected ? FontWeight.w500 : FontWeight.w400,
=======
Widget _buildSymptomChip(BuildContext context, String label, bool isSelected, ValueChanged<bool> onChanged) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () => onChanged(!isSelected),
borderRadius: BorderRadius.circular(20),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration: BoxDecoration(
color: isSelected
? theme.colorScheme.tertiary.withOpacity(isDark ? 0.3 : 0.2)
: theme.colorScheme.surfaceVariant.withOpacity(0.3),
borderRadius: BorderRadius.circular(20),
border: isSelected
? Border.all(color: theme.colorScheme.tertiary)
: Border.all(color: Colors.transparent),
),
child: Text(
label,
style: GoogleFonts.outfit(
fontSize: 13,
color: isSelected ? theme.colorScheme.onSurface : theme.colorScheme.onSurfaceVariant,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
),
>>>>>>> 6742220 (Your commit message here)
),
),
),
@@ -423,12 +814,28 @@ class _LogScreenState extends ConsumerState<LogScreen> {
}
String _formatDate(DateTime date) {
<<<<<<< HEAD
=======
final now = DateTime.now();
if (DateUtils.isSameDay(date, now)) {
return 'Today, ${_getMonth(date.month)} ${date.day}';
}
const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
return '${days[date.weekday - 1]}, ${_getMonth(date.month)} ${date.day}';
}
String _getMonth(int month) {
>>>>>>> 6742220 (Your commit message here)
const months = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
<<<<<<< HEAD
const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
return '${days[date.weekday - 1]}, ${months[date.month - 1]} ${date.day}';
=======
return months[month - 1];
>>>>>>> 6742220 (Your commit message here)
}
String _getEnergyLabel(int level) {