mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
refactor: update color opacity methods to use withValues for consistency
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; // Import this
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; // Import this
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:supplements/logging.dart';
|
import 'package:supplements/logging.dart';
|
||||||
|
|
||||||
import 'providers/settings_provider.dart';
|
import 'providers/settings_provider.dart';
|
||||||
|
@@ -10,10 +10,6 @@ enum ThemeOption {
|
|||||||
class SettingsProvider extends ChangeNotifier {
|
class SettingsProvider extends ChangeNotifier {
|
||||||
ThemeOption _themeOption = ThemeOption.system;
|
ThemeOption _themeOption = ThemeOption.system;
|
||||||
|
|
||||||
// Profile fields
|
|
||||||
DateTime? _dateOfBirth;
|
|
||||||
String? _gender;
|
|
||||||
|
|
||||||
// Time range settings (stored as hours, 0-23)
|
// Time range settings (stored as hours, 0-23)
|
||||||
int _morningStart = 5;
|
int _morningStart = 5;
|
||||||
int _morningEnd = 10;
|
int _morningEnd = 10;
|
||||||
@@ -76,13 +72,6 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
final themeIndex = prefs.getInt('theme_option') ?? 0;
|
final themeIndex = prefs.getInt('theme_option') ?? 0;
|
||||||
_themeOption = ThemeOption.values[themeIndex];
|
_themeOption = ThemeOption.values[themeIndex];
|
||||||
|
|
||||||
// Load profile fields
|
|
||||||
final dobString = prefs.getString('date_of_birth');
|
|
||||||
if (dobString != null) {
|
|
||||||
_dateOfBirth = DateTime.tryParse(dobString);
|
|
||||||
}
|
|
||||||
_gender = prefs.getString('gender');
|
|
||||||
|
|
||||||
// Load time range settings
|
// Load time range settings
|
||||||
_morningStart = prefs.getInt('morning_start') ?? 5;
|
_morningStart = prefs.getInt('morning_start') ?? 5;
|
||||||
_morningEnd = prefs.getInt('morning_end') ?? 10;
|
_morningEnd = prefs.getInt('morning_end') ?? 10;
|
||||||
@@ -112,8 +101,6 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setDateOfBirthAndGender(DateTime dateOfBirth, String gender) async {
|
Future<void> setDateOfBirthAndGender(DateTime dateOfBirth, String gender) async {
|
||||||
_dateOfBirth = dateOfBirth;
|
|
||||||
_gender = gender;
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
@@ -87,7 +87,7 @@ class SupplementProvider with ChangeNotifier, WidgetsBindingObserver {
|
|||||||
|
|
||||||
if (currentDate != lastCheckDate) {
|
if (currentDate != lastCheckDate) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
printLog('Date changed detected: ${lastCheckDate} -> ${currentDate}');
|
printLog('Date changed detected: $lastCheckDate -> $currentDate');
|
||||||
printLog('Refreshing today\'s intakes for new day...');
|
printLog('Refreshing today\'s intakes for new day...');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +175,6 @@ class SupplementProvider with ChangeNotifier, WidgetsBindingObserver {
|
|||||||
printLog('Adding supplement: ${supplement.name}');
|
printLog('Adding supplement: ${supplement.name}');
|
||||||
final id = await _databaseHelper.insertSupplement(supplement);
|
final id = await _databaseHelper.insertSupplement(supplement);
|
||||||
printLog('Supplement inserted with ID: $id');
|
printLog('Supplement inserted with ID: $id');
|
||||||
final newSupplement = supplement.copyWith(id: id);
|
|
||||||
|
|
||||||
// Notifications will be rescheduled in grouped mode after reloading supplements
|
|
||||||
|
|
||||||
await loadSupplements();
|
await loadSupplements();
|
||||||
printLog('Supplements reloaded, count: ${_supplements.length}');
|
printLog('Supplements reloaded, count: ${_supplements.length}');
|
||||||
|
@@ -342,7 +342,7 @@ class _AddSupplementScreenState extends State<AddSupplementScreen> {
|
|||||||
// Show ingredients summary
|
// Show ingredients summary
|
||||||
if (_ingredientControllers.isNotEmpty && _ingredientControllers.any((c) => c.nameController.text.isNotEmpty && (double.tryParse(c.amountController.text) ?? 0) > 0))
|
if (_ingredientControllers.isNotEmpty && _ingredientControllers.any((c) => c.nameController.text.isNotEmpty && (double.tryParse(c.amountController.text) ?? 0) > 0))
|
||||||
Card(
|
Card(
|
||||||
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.primaryContainer.withValues(alpha: 0.3),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@@ -164,9 +164,9 @@ class _ArchivedSupplementCard extends StatelessWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.3),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.2),
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -180,7 +180,7 @@ class _ArchivedSupplementCard extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.1),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -262,7 +262,7 @@ class _ArchivedSupplementCard extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.3),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -284,7 +284,7 @@ class _ArchivedSupplementCard extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@@ -480,7 +480,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
|||||||
'${dayIntakes.length} supplement${dayIntakes.length != 1 ? 's' : ''} taken',
|
'${dayIntakes.length} supplement${dayIntakes.length != 1 ? 's' : ''} taken',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: isWideScreen ? 16 : 14,
|
fontSize: isWideScreen ? 16 : 14,
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer.withOpacity(0.8),
|
color: Theme.of(context).colorScheme.onPrimaryContainer.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -554,10 +554,10 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
|||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.1),
|
color: color.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: color.withOpacity(0.3),
|
color: color.withValues(alpha: 0.3),
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -566,7 +566,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.2),
|
color: color.withValues(alpha: 0.2),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -594,7 +594,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: color.withOpacity(0.8),
|
color: color.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@@ -261,9 +261,9 @@ class _TimeRangeSelector extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.1),
|
color: color.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: color.withOpacity(0.3)),
|
border: Border.all(color: color.withValues(alpha: 0.3)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
@@ -108,7 +108,6 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildGroupedSupplementsList(BuildContext context, List<Supplement> supplements, SettingsProvider settingsProvider) {
|
Widget _buildGroupedSupplementsList(BuildContext context, List<Supplement> supplements, SettingsProvider settingsProvider) {
|
||||||
final provider = Provider.of<SupplementProvider>(context, listen: false);
|
|
||||||
final groupedSupplements = _groupSupplementsByTimeOfDay(supplements, settingsProvider);
|
final groupedSupplements = _groupSupplementsByTimeOfDay(supplements, settingsProvider);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
@@ -196,10 +195,10 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.1),
|
color: color.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: color.withOpacity(0.3),
|
color: color.withValues(alpha: 0.3),
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -208,7 +207,7 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.2),
|
color: color.withValues(alpha: 0.2),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -236,7 +235,7 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: color.withOpacity(0.8),
|
color: color.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -246,7 +245,7 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.15),
|
color: color.withValues(alpha: 0.15),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -279,268 +278,7 @@ class SupplementsListScreen extends StatelessWidget {
|
|||||||
|
|
||||||
return grouped;
|
return grouped;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showTakeDialog(BuildContext context, Supplement supplement) {
|
|
||||||
final unitsController = TextEditingController(text: supplement.numberOfUnits.toString());
|
|
||||||
final notesController = TextEditingController();
|
|
||||||
DateTime selectedDateTime = DateTime.now();
|
|
||||||
bool useCustomTime = false;
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => StatefulBuilder(
|
|
||||||
builder: (context, setState) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text('Take ${supplement.name}'),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: unitsController,
|
|
||||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Number of ${supplement.unitType}',
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
suffixText: supplement.unitType,
|
|
||||||
),
|
|
||||||
onChanged: (value) => setState(() {}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Total dosage:',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
supplement.ingredientsDisplay,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// Time selection section
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.3),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.access_time,
|
|
||||||
size: 16,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text(
|
|
||||||
'When did you take it?',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: RadioListTile<bool>(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: const Text('Just now', style: TextStyle(fontSize: 12)),
|
|
||||||
value: false,
|
|
||||||
groupValue: useCustomTime,
|
|
||||||
onChanged: (value) => setState(() => useCustomTime = value!),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: RadioListTile<bool>(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: const Text('Custom time', style: TextStyle(fontSize: 12)),
|
|
||||||
value: true,
|
|
||||||
groupValue: useCustomTime,
|
|
||||||
onChanged: (value) => setState(() => useCustomTime = value!),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (useCustomTime) ...[
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
border: Border.all(
|
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.5),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
// Date picker
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.calendar_today,
|
|
||||||
size: 14,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Date: ${selectedDateTime.day}/${selectedDateTime.month}/${selectedDateTime.year}',
|
|
||||||
style: const TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final date = await showDatePicker(
|
|
||||||
context: context,
|
|
||||||
initialDate: selectedDateTime,
|
|
||||||
firstDate: DateTime.now().subtract(const Duration(days: 7)),
|
|
||||||
lastDate: DateTime.now(),
|
|
||||||
);
|
|
||||||
if (date != null) {
|
|
||||||
setState(() {
|
|
||||||
selectedDateTime = DateTime(
|
|
||||||
date.year,
|
|
||||||
date.month,
|
|
||||||
date.day,
|
|
||||||
selectedDateTime.hour,
|
|
||||||
selectedDateTime.minute,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text('Change', style: TextStyle(fontSize: 10)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
// Time picker
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.access_time,
|
|
||||||
size: 14,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Time: ${selectedDateTime.hour.toString().padLeft(2, '0')}:${selectedDateTime.minute.toString().padLeft(2, '0')}',
|
|
||||||
style: const TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final time = await showTimePicker(
|
|
||||||
context: context,
|
|
||||||
initialTime: TimeOfDay.fromDateTime(selectedDateTime),
|
|
||||||
);
|
|
||||||
if (time != null) {
|
|
||||||
setState(() {
|
|
||||||
selectedDateTime = DateTime(
|
|
||||||
selectedDateTime.year,
|
|
||||||
selectedDateTime.month,
|
|
||||||
selectedDateTime.day,
|
|
||||||
time.hour,
|
|
||||||
time.minute,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text('Change', style: TextStyle(fontSize: 10)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
TextField(
|
|
||||||
controller: notesController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Notes (optional)',
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
maxLines: 2,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
final unitsTaken = double.tryParse(unitsController.text) ?? supplement.numberOfUnits.toDouble();
|
|
||||||
// For now, we'll record 0 as total dosage since we're transitioning to ingredients
|
|
||||||
// This will be properly implemented when we add the full ingredient tracking
|
|
||||||
final totalDosageTaken = 0.0;
|
|
||||||
context.read<SupplementProvider>().recordIntake(
|
|
||||||
supplement.id!,
|
|
||||||
totalDosageTaken,
|
|
||||||
unitsTaken: unitsTaken,
|
|
||||||
notes: notesController.text.isNotEmpty ? notesController.text : null,
|
|
||||||
takenAt: useCustomTime ? selectedDateTime : null,
|
|
||||||
);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('${supplement.name} recorded!'),
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Record'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _editSupplement(BuildContext context, Supplement supplement) {
|
void _editSupplement(BuildContext context, Supplement supplement) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
|
@@ -187,7 +187,7 @@ class SimpleNotificationService {
|
|||||||
final units = s.numberOfUnits;
|
final units = s.numberOfUnits;
|
||||||
final unitType = s.unitType;
|
final unitType = s.unitType;
|
||||||
final perUnit = s.ingredientsPerUnit;
|
final perUnit = s.ingredientsPerUnit;
|
||||||
return '${s.name} — $units $unitType (${perUnit})';
|
return '${s.name} — $units $unitType ($perUnit)';
|
||||||
}).toList();
|
}).toList();
|
||||||
final body = bodyLines.join('\n');
|
final body = bodyLines.join('\n');
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ class SimpleNotificationService {
|
|||||||
createdAtEpochMs: createdAtMs,
|
createdAtEpochMs: createdAtMs,
|
||||||
title: title,
|
title: title,
|
||||||
payload: payloadStr,
|
payload: payloadStr,
|
||||||
singleId: isSingle ? items.first.id as int? : null,
|
singleId: isSingle ? items.first.id : null,
|
||||||
timeKey: isSingle ? null : timeKey,
|
timeKey: isSingle ? null : timeKey,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@@ -51,10 +51,10 @@ Future<void> showBulkTakeDialog(
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.5),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -108,7 +108,7 @@ Future<void> showBulkTakeDialog(
|
|||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@@ -76,10 +76,10 @@ Future<void> showTakeSupplementDialog(
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.primaryContainer.withValues(alpha: 0.3),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -137,7 +137,7 @@ Future<void> showTakeSupplementDialog(
|
|||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.5),
|
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@@ -19,7 +19,7 @@ class InfoChip extends StatelessWidget {
|
|||||||
width: fullWidth ? double.infinity : null,
|
width: fullWidth ? double.infinity : null,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.4),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.4),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@@ -65,7 +65,7 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
? Colors.green.shade600
|
? Colors.green.shade600
|
||||||
: isTakenToday
|
: isTakenToday
|
||||||
? Theme.of(context).colorScheme.secondary
|
? Theme.of(context).colorScheme.secondary
|
||||||
: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
: Theme.of(context).colorScheme.outline.withValues(alpha: 0.2),
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -89,7 +89,7 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
? Colors.green.shade500
|
? Colors.green.shade500
|
||||||
: isTakenToday
|
: isTakenToday
|
||||||
? Theme.of(context).colorScheme.secondary
|
? Theme.of(context).colorScheme.secondary
|
||||||
: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
: Theme.of(context).colorScheme.primary.withValues(alpha: 0.1),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -284,8 +284,8 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isCompletelyTaken
|
color: isCompletelyTaken
|
||||||
? Colors.green.shade700.withOpacity(0.8)
|
? Colors.green.shade700.withValues(alpha: 0.8)
|
||||||
: Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.7),
|
: Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.7),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isCompletelyTaken
|
color: isCompletelyTaken
|
||||||
@@ -359,7 +359,7 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.3),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -381,10 +381,10 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -441,7 +441,7 @@ class _SupplementCardState extends State<SupplementCard> {
|
|||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.2),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -516,7 +516,7 @@ class _InfoChip extends StatelessWidget {
|
|||||||
width: fullWidth ? double.infinity : null,
|
width: fullWidth ? double.infinity : null,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.4),
|
color: Theme.of(context).colorScheme.surfaceVariant.withValues(alpha: 0.4),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
Reference in New Issue
Block a user