Files
Tracker/lib/widgets/quick_log_buttons.dart
2025-12-19 22:47:27 -06:00

184 lines
5.5 KiB
Dart

import 'package:flutter/material.dart';
<<<<<<< HEAD
import 'package:google_fonts/google_fonts.dart';
import '../theme/app_theme.dart';
import '../screens/log/log_screen.dart';
class QuickLogButtons extends StatelessWidget {
const QuickLogButtons({super.key});
@override
Widget build(BuildContext context) {
return Row(
children: [
_buildQuickButton(
icon: Icons.water_drop_outlined,
label: 'Period',
color: AppColors.menstrualPhase,
onTap: () => _navigateToLog(context),
),
const SizedBox(width: 12),
_buildQuickButton(
icon: Icons.emoji_emotions_outlined,
label: 'Mood',
color: AppColors.softGold,
onTap: () => _navigateToLog(context),
),
const SizedBox(width: 12),
_buildQuickButton(
icon: Icons.flash_on_outlined,
label: 'Energy',
color: AppColors.follicularPhase,
onTap: () => _navigateToLog(context),
),
const SizedBox(width: 12),
_buildQuickButton(
icon: Icons.healing_outlined,
label: 'Symptoms',
color: AppColors.lavender,
onTap: () => _navigateToLog(context),
=======
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import '../theme/app_theme.dart';
import '../providers/navigation_provider.dart';
class QuickLogButtons extends ConsumerWidget {
const QuickLogButtons({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Row(
children: [
_buildQuickButton(
context,
icon: Icons.water_drop_outlined,
label: 'Period',
color: AppColors.menstrualPhase,
onTap: () => _navigateToLog(ref),
),
const SizedBox(width: 12),
_buildQuickButton(
context,
icon: Icons.emoji_emotions_outlined,
label: 'Mood',
color: AppColors.softGold,
onTap: () => _navigateToLog(ref),
),
const SizedBox(width: 12),
_buildQuickButton(
context,
icon: Icons.flash_on_outlined,
label: 'Energy',
color: AppColors.follicularPhase,
onTap: () => _navigateToLog(ref),
),
const SizedBox(width: 12),
_buildQuickButton(
context,
icon: Icons.healing_outlined,
label: 'Symptoms',
color: AppColors.lavender,
onTap: () => _navigateToLog(ref),
>>>>>>> 6742220 (Your commit message here)
),
],
);
}
<<<<<<< HEAD
void _navigateToLog(BuildContext context) {
// Navigate to the Log tab (index 2) of HomeScreen if possible,
// but since we are inside a tab, we can't easily switch the parent tab index without context. Using a provider or callback would be best.
// For now, let's push the LogScreen as a new route for "Quick Log" feel.
// Ideally we would switch the BottomNavBar index.
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(0),
child: SizedBox.shrink()
),
body: LogScreen()
)),
);
}
Widget _buildQuickButton({
=======
void _navigateToLog(WidgetRef ref) {
// Navigate to the Log tab (index 2)
ref.read(navigationProvider.notifier).setIndex(2);
}
Widget _buildQuickButton(
BuildContext context, {
>>>>>>> 6742220 (Your commit message here)
required IconData icon,
required String label,
required Color color,
required VoidCallback onTap,
}) {
<<<<<<< HEAD
return Expanded(
child: GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
color: color.withOpacity(0.15),
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: color, size: 24),
const SizedBox(height: 6),
Text(
label,
style: GoogleFonts.outfit(
fontSize: 11,
fontWeight: FontWeight.w500,
color: color,
),
),
],
=======
final isDark = Theme.of(context).brightness == Brightness.dark;
return Expanded(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
color: color.withOpacity(isDark ? 0.2 : 0.15),
borderRadius: BorderRadius.circular(12),
border: isDark ? Border.all(color: color.withOpacity(0.3)) : null,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: color, size: 24),
const SizedBox(height: 6),
Text(
label,
style: GoogleFonts.outfit(
fontSize: 11,
fontWeight: FontWeight.w600,
color: isDark ? Colors.white.withOpacity(0.9) : color,
),
),
],
),
>>>>>>> 6742220 (Your commit message here)
),
),
),
);
}
}