Refactor: Implement multi-item inventory for Pad Tracker and dynamic navigation
This commit is contained in:
@@ -7,18 +7,27 @@ import '../../models/cycle_entry.dart';
|
||||
import '../../models/scripture.dart';
|
||||
import '../calendar/calendar_screen.dart';
|
||||
import '../log/log_screen.dart';
|
||||
import '../log/pad_tracker_screen.dart';
|
||||
import '../devotional/devotional_screen.dart';
|
||||
import '../settings/appearance_screen.dart';
|
||||
import '../settings/cycle_settings_screen.dart';
|
||||
import '../settings/relationship_settings_screen.dart';
|
||||
import '../settings/goal_settings_screen.dart'; // Add this
|
||||
import '../settings/cycle_history_screen.dart';
|
||||
import '../settings/sharing_settings_screen.dart';
|
||||
import '../settings/notification_settings_screen.dart';
|
||||
import '../settings/supplies_settings_screen.dart';
|
||||
import '../learn/wife_learn_screen.dart';
|
||||
import '../../widgets/tip_card.dart';
|
||||
import '../../widgets/cycle_ring.dart';
|
||||
import '../../widgets/scripture_card.dart';
|
||||
import '../../widgets/pad_tracker_card.dart';
|
||||
import '../../widgets/quick_log_buttons.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
import '../../providers/navigation_provider.dart';
|
||||
import '../../services/cycle_service.dart';
|
||||
import '../../services/bible_utils.dart';
|
||||
import '../../providers/scripture_provider.dart'; // Import the new provider
|
||||
import '../../providers/scripture_provider.dart';
|
||||
|
||||
class HomeScreen extends ConsumerWidget {
|
||||
const HomeScreen({super.key});
|
||||
@@ -26,19 +35,25 @@ class HomeScreen extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selectedIndex = ref.watch(navigationProvider);
|
||||
final isPadTrackingEnabled = ref.watch(userProfileProvider.select((u) => u?.isPadTrackingEnabled ?? false));
|
||||
final isSingle = ref.watch(userProfileProvider.select((u) => u?.relationshipStatus == RelationshipStatus.single));
|
||||
|
||||
final tabs = [
|
||||
const _DashboardTab(),
|
||||
const CalendarScreen(),
|
||||
const LogScreen(),
|
||||
if (isPadTrackingEnabled) const PadTrackerScreen(),
|
||||
const DevotionalScreen(),
|
||||
const WifeLearnScreen(),
|
||||
_SettingsTab(
|
||||
onReset: () =>
|
||||
ref.read(navigationProvider.notifier).setIndex(0)),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: selectedIndex,
|
||||
children: [
|
||||
const _DashboardTab(),
|
||||
const CalendarScreen(),
|
||||
const LogScreen(),
|
||||
const DevotionalScreen(),
|
||||
_SettingsTab(
|
||||
onReset: () =>
|
||||
ref.read(navigationProvider.notifier).setIndex(0)),
|
||||
],
|
||||
index: selectedIndex >= tabs.length ? 0 : selectedIndex,
|
||||
children: tabs,
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -55,31 +70,42 @@ class HomeScreen extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
currentIndex: selectedIndex,
|
||||
currentIndex: selectedIndex >= tabs.length ? 0 : selectedIndex,
|
||||
onTap: (index) =>
|
||||
ref.read(navigationProvider.notifier).setIndex(index),
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
items: [
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home_outlined),
|
||||
activeIcon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.calendar_today_outlined),
|
||||
activeIcon: Icon(Icons.calendar_today),
|
||||
label: 'Calendar',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.add_circle_outline),
|
||||
activeIcon: Icon(Icons.add_circle),
|
||||
label: 'Log',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
if (isPadTrackingEnabled)
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.inventory_2_outlined),
|
||||
activeIcon: Icon(Icons.inventory_2),
|
||||
label: 'Supplies',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.menu_book_outlined),
|
||||
activeIcon: Icon(Icons.menu_book),
|
||||
label: 'Devotional',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.school_outlined),
|
||||
activeIcon: Icon(Icons.school),
|
||||
label: 'Learn',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
activeIcon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
@@ -162,6 +188,10 @@ class _DashboardTabState extends ConsumerState<_DashboardTab> {
|
||||
phase: phase,
|
||||
),
|
||||
),
|
||||
if (phase == CyclePhase.menstrual) ...[
|
||||
const SizedBox(height: 24),
|
||||
const PadTrackerCard(),
|
||||
],
|
||||
const SizedBox(height: 32),
|
||||
// Main Scripture Card with Navigation
|
||||
Stack(
|
||||
@@ -352,6 +382,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
final translationLabel =
|
||||
ref.watch(userProfileProvider.select((u) => u?.bibleTranslation.label)) ??
|
||||
'ESV';
|
||||
final isSingle = ref.watch(userProfileProvider.select((u) => u?.relationshipStatus == RelationshipStatus.single));
|
||||
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
@@ -435,7 +466,49 @@ class _SettingsTab extends ConsumerWidget {
|
||||
const SizedBox(height: 24),
|
||||
_buildSettingsGroup(context, 'Preferences', [
|
||||
_buildSettingsTile(
|
||||
context, Icons.notifications_outlined, 'Notifications'),
|
||||
context,
|
||||
Icons.notifications_outlined,
|
||||
'Notifications',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NotificationSettingsScreen()));
|
||||
},
|
||||
),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.inventory_2_outlined,
|
||||
'Period Supplies',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SuppliesSettingsScreen()));
|
||||
},
|
||||
),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.favorite_outline, // Use a different icon for Relationship
|
||||
'Relationship Status',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const RelationshipSettingsScreen()));
|
||||
},
|
||||
),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.flag_outlined,
|
||||
'Cycle Goal',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const GoalSettingsScreen()));
|
||||
},
|
||||
),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.book_outlined,
|
||||
@@ -456,17 +529,18 @@ class _SettingsTab extends ConsumerWidget {
|
||||
onTap: () => _showFavoritesDialog(context, ref),
|
||||
),
|
||||
_buildSettingsTile(context, Icons.lock_outline, 'Privacy'),
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.share_outlined,
|
||||
'Share with Husband',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SharingSettingsScreen()));
|
||||
},
|
||||
),
|
||||
if (!isSingle)
|
||||
_buildSettingsTile(
|
||||
context,
|
||||
Icons.share_outlined,
|
||||
'Share with Husband',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SharingSettingsScreen()));
|
||||
},
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup(context, 'Cycle', [
|
||||
@@ -484,7 +558,7 @@ class _SettingsTab extends ConsumerWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CycleHistoryScreen()));
|
||||
builder: (context) => CycleHistoryScreen()));
|
||||
}),
|
||||
_buildSettingsTile(
|
||||
context, Icons.download_outlined, 'Export Data'),
|
||||
@@ -698,4 +772,53 @@ Widget _buildWifeTipsSection(BuildContext context) {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTipCard(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String content,
|
||||
required IconData icon,
|
||||
}) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: GoogleFonts.outfit(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
content,
|
||||
style: GoogleFonts.outfit(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user