mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
feat: Add settings provider for theme and time range management
- Implemented SettingsProvider to manage user preferences for theme options and time ranges for reminders. - Added persistent reminder settings with configurable retry intervals and maximum attempts. - Created UI for settings screen to allow users to customize their preferences. - Integrated shared_preferences for persistent storage of user settings. feat: Introduce Ingredient model - Created Ingredient model to represent nutritional components with properties for id, name, amount, and unit. - Added methods for serialization and deserialization of Ingredient objects. feat: Develop Archived Supplements Screen - Implemented ArchivedSupplementsScreen to display archived supplements with options to unarchive or delete. - Added UI components for listing archived supplements and handling user interactions. chore: Update dependencies in pubspec.yaml and pubspec.lock - Updated shared_preferences dependency to the latest version. - Removed flutter_datetime_picker_plus dependency and added file dependency. - Updated Flutter SDK constraint to >=3.27.0.
This commit is contained in:
64
lib/models/ingredient.dart
Normal file
64
lib/models/ingredient.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
class Ingredient {
|
||||
final int? id;
|
||||
final String name; // e.g., "Vitamin K2", "Vitamin D3"
|
||||
final double amount; // e.g., 75, 20
|
||||
final String unit; // e.g., "mcg", "mg", "IU"
|
||||
|
||||
const Ingredient({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.amount,
|
||||
required this.unit,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'amount': amount,
|
||||
'unit': unit,
|
||||
};
|
||||
}
|
||||
|
||||
factory Ingredient.fromMap(Map<String, dynamic> map) {
|
||||
return Ingredient(
|
||||
id: map['id'],
|
||||
name: map['name'],
|
||||
amount: map['amount']?.toDouble() ?? 0.0,
|
||||
unit: map['unit'],
|
||||
);
|
||||
}
|
||||
|
||||
Ingredient copyWith({
|
||||
int? id,
|
||||
String? name,
|
||||
double? amount,
|
||||
String? unit,
|
||||
}) {
|
||||
return Ingredient(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
amount: amount ?? this.amount,
|
||||
unit: unit ?? this.unit,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '$amount$unit $name';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is Ingredient &&
|
||||
other.name == name &&
|
||||
other.amount == amount &&
|
||||
other.unit == unit;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return name.hashCode ^ amount.hashCode ^ unit.hashCode;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user