diff --git a/lib/screens/husband/_HusbandLearnScreen.dart b/lib/screens/husband/_HusbandLearnScreen.dart index 12e4759..a1666cc 100644 --- a/lib/screens/husband/_HusbandLearnScreen.dart +++ b/lib/screens/husband/_HusbandLearnScreen.dart @@ -19,7 +19,7 @@ class _HusbandLearnScreen extends StatelessWidget { style: GoogleFonts.outfit( fontSize: 28, fontWeight: FontWeight.w600, - color: AppColors.navyBlue, + color: Theme.of(context).textTheme.displayMedium?.color, ), ), const SizedBox(height: 24), @@ -94,14 +94,14 @@ class _HusbandLearnScreen extends StatelessWidget { style: GoogleFonts.outfit( fontSize: 14, fontWeight: FontWeight.w500, - color: AppColors.warmGray, + color: Theme.of(context).textTheme.bodySmall?.color, letterSpacing: 0.5, ), ), const SizedBox(height: 8), Container( decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).cardTheme.color, borderRadius: BorderRadius.circular(12), ), child: Column( @@ -111,12 +111,12 @@ class _HusbandLearnScreen extends StatelessWidget { width: 40, height: 40, decoration: BoxDecoration( - color: AppColors.navyBlue.withOpacity(0.1), + color: Theme.of(context).colorScheme.primary.withOpacity(0.1), borderRadius: BorderRadius.circular(10), ), child: Icon( item.icon, - color: AppColors.navyBlue, + color: Theme.of(context).colorScheme.primary, size: 20, ), ), @@ -125,19 +125,19 @@ class _HusbandLearnScreen extends StatelessWidget { style: GoogleFonts.outfit( fontSize: 15, fontWeight: FontWeight.w500, - color: AppColors.charcoal, + color: Theme.of(context).textTheme.bodyLarge?.color, ), ), subtitle: Text( item.subtitle, style: GoogleFonts.outfit( fontSize: 13, - color: AppColors.warmGray, + color: Theme.of(context).textTheme.bodyMedium?.color, ), ), - trailing: const Icon( + trailing: Icon( Icons.chevron_right, - color: AppColors.lightGray, + color: Theme.of(context).disabledColor, ), onTap: () { Navigator.push( diff --git a/lib/screens/husband/husband_devotional_screen.dart b/lib/screens/husband/husband_devotional_screen.dart index 47e040d..ba68926 100644 --- a/lib/screens/husband/husband_devotional_screen.dart +++ b/lib/screens/husband/husband_devotional_screen.dart @@ -6,6 +6,7 @@ import '../../models/user_profile.dart'; import '../../models/teaching_plan.dart'; import '../../providers/user_provider.dart'; import '../../theme/app_theme.dart'; +import '../../services/bible_xml_parser.dart'; class HusbandDevotionalScreen extends ConsumerStatefulWidget { const HusbandDevotionalScreen({super.key}); @@ -15,7 +16,62 @@ class HusbandDevotionalScreen extends ConsumerStatefulWidget { } class _HusbandDevotionalScreenState extends ConsumerState { - + final _parser = BibleXmlParser(); + Map _scriptures = {}; + bool _loading = true; + BibleTranslation? _currentTranslation; + + @override + void initState() { + super.initState(); + // Initial fetch handled in post-frame or via listen, but let's trigger once here if possible + // We need the ref, which is available. + WidgetsBinding.instance.addPostFrameCallback((_) { + _fetchScriptures(); + }); + } + + Future _fetchScriptures() async { + final user = ref.read(userProfileProvider); + if (user == null) return; + + final translation = user.bibleTranslation; + if (translation == _currentTranslation && _scriptures.isNotEmpty) return; + + setState(() => _loading = true); + + try { + final assetPath = 'assets/bible_xml/${translation.name.toUpperCase()}.xml'; + + // Define verses to fetch + final versesToFetch = [ + '1 Corinthians 11:3', + '1 Timothy 3:4', + '1 Timothy 3:5', + '1 Timothy 3:12', + 'Titus 1:6', + ]; + + final Map results = {}; + + for (final ref in versesToFetch) { + final text = await _parser.getVerseFromAsset(assetPath, ref); + results[ref] = text ?? 'Verse not found.'; + } + + if (mounted) { + setState(() { + _scriptures = results; + _currentTranslation = translation; + _loading = false; + }); + } + } catch (e) { + debugPrint('Error loading scriptures: $e'); + if (mounted) setState(() => _loading = false); + } + } + void _showAddTeachingDialog([TeachingPlan? existingPlan]) { final titleController = TextEditingController(text: existingPlan?.topic); final scriptureController = TextEditingController(text: existingPlan?.scriptureReference); @@ -163,6 +219,13 @@ class _HusbandDevotionalScreenState extends ConsumerState a.date.compareTo(b.date)); + // Listen for translation changes to re-fetch + ref.listen(userProfileProvider, (prev, next) { + if (next?.bibleTranslation != prev?.bibleTranslation) { + _fetchScriptures(); + } + }); + return Scaffold( appBar: AppBar( title: const Text('Spiritual Leadership'), @@ -174,7 +237,7 @@ class _HusbandDevotionalScreenState extends ConsumerState