43 lines
1.0 KiB
Dart
43 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cpd/model/habit.dart';
|
|
import 'package:cpd/model/habit_list.dart';
|
|
|
|
class Habitmanager {
|
|
static Habitmanager? _instance;
|
|
|
|
factory Habitmanager() {
|
|
_instance ??= Habitmanager._internal();
|
|
return _instance!;
|
|
}
|
|
|
|
//privater konstruktor
|
|
Habitmanager._internal();
|
|
|
|
//fügt vordefinierte Gewohnheit hinzu
|
|
void addDefaultHabit(Habit habit) {
|
|
habits.add(habit);
|
|
}
|
|
|
|
//fügt benutzerdefinierte Gewohneheit hinzu
|
|
void addNewHabit(bool isComplete,
|
|
String title,
|
|
String subtitle,
|
|
Icon ? icon,) {
|
|
Icon defaultIcon = const Icon(Icons.label_important);
|
|
Habit newHabit = Habit(
|
|
isComplete: isComplete,
|
|
title: title,
|
|
subtitle: subtitle,
|
|
icon: icon ?? defaultIcon
|
|
);
|
|
habits.add(newHabit);
|
|
}
|
|
|
|
// muss implementiert werden
|
|
void updateHabitList() {
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
// Rufe setState auf, um die UI zu aktualisieren
|
|
print('Habit list updated');
|
|
});
|
|
}
|
|
} |