mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
Refactor supplement intake handling to support fractional units and update notification service initialization for Linux
This commit is contained in:
@@ -103,13 +103,13 @@ class SupplementProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> recordIntake(int supplementId, double dosage, {int? unitsTaken, String? notes}) async {
|
||||
Future<void> recordIntake(int supplementId, double dosage, {double? unitsTaken, String? notes}) async {
|
||||
try {
|
||||
final intake = SupplementIntake(
|
||||
supplementId: supplementId,
|
||||
takenAt: DateTime.now(),
|
||||
dosageTaken: dosage,
|
||||
unitsTaken: unitsTaken ?? 1,
|
||||
unitsTaken: unitsTaken ?? 1.0,
|
||||
notes: notes,
|
||||
);
|
||||
|
||||
@@ -118,7 +118,7 @@ class SupplementProvider with ChangeNotifier {
|
||||
|
||||
// Show confirmation notification
|
||||
final supplement = _supplements.firstWhere((s) => s.id == supplementId);
|
||||
final unitsText = unitsTaken != null && unitsTaken > 1 ? '$unitsTaken ${supplement.unitType}' : '';
|
||||
final unitsText = unitsTaken != null && unitsTaken != 1 ? '${unitsTaken.toStringAsFixed(unitsTaken % 1 == 0 ? 0 : 1)} ${supplement.unitType}' : '';
|
||||
await _notificationService.showInstantNotification(
|
||||
'Supplement Taken',
|
||||
'Recorded ${supplement.name}${unitsText.isNotEmpty ? ' - $unitsText' : ''} ($dosage ${supplement.unit})',
|
||||
|
Reference in New Issue
Block a user