main
Yuliya Rudenko 2024-06-19 16:25:05 +02:00
parent 9069c1ff85
commit bed93338b4
9 changed files with 5 additions and 16 deletions

View File

@ -19,13 +19,11 @@ class Habit {
IconData get icon => IconData(iconCodePoint, fontFamily: iconFontFamily); IconData get icon => IconData(iconCodePoint, fontFamily: iconFontFamily);
// Methode zum Aktualisieren der Icon-Daten
void updateIcon(int newCodePoint, String newFontFamily) { void updateIcon(int newCodePoint, String newFontFamily) {
iconCodePoint = newCodePoint; iconCodePoint = newCodePoint;
iconFontFamily = newFontFamily; iconFontFamily = newFontFamily;
} }
//erstellt ein Habit-Objekt aus der DB-Abfrage
factory Habit.fromSqfliteDatabase(Map<String, dynamic> map) { factory Habit.fromSqfliteDatabase(Map<String, dynamic> map) {
return Habit( return Habit(
id: map['id']?.toInt() ?? 0, id: map['id']?.toInt() ?? 0,

View File

@ -9,7 +9,6 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
if (defaultTargetPlatform == TargetPlatform.macOS) { if (defaultTargetPlatform == TargetPlatform.macOS) {
// Initialisierung sqflite_ffi für macOS
sqfliteFfiInit(); sqfliteFfiInit();
databaseFactory = databaseFactoryFfi; databaseFactory = databaseFactoryFfi;
} }

View File

@ -18,7 +18,7 @@ class MyHomePage extends StatefulWidget {
class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin { class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
Future<List<Habit>>? futureTodos; Future<List<Habit>>? futureTodos;
late ToDoInterface todoDB; late ToDoInterface todoDB;
int counterCompleted = 0; //Zähler für abgeschlossene Gewohnheiten int counterCompleted = 0;
@override @override
void initState() { void initState() {
@ -106,7 +106,6 @@ class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMi
fontFamily: "Arial"), fontFamily: "Arial"),
), ),
//UI gebaut basierend auf dem Zustand von futureTodos
Expanded(child: FutureBuilder<List<Habit>>( Expanded(child: FutureBuilder<List<Habit>>(
future: futureTodos, future: futureTodos,
builder: (context, snapshot) { builder: (context, snapshot) {
@ -124,7 +123,6 @@ class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMi
final todos = snapshot.data; final todos = snapshot.data;
final habitCount = countHabits(todos!); final habitCount = countHabits(todos!);
//Fortschritt der abgeschlossenen Geowhnheiten //Fortschritt der abgeschlossenen Geowhnheiten
//Parameter unten bei LinearProgressIndicator
double progressValue = counterCompleted / habitCount; double progressValue = counterCompleted / habitCount;
return Column( return Column(
@ -205,7 +203,6 @@ class MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMi
), ),
), ),
//öffnet ein Popup zum Hinzufügen einer neue Gewohnheit
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
foregroundColor: Colors.deepPurpleAccent, foregroundColor: Colors.deepPurpleAccent,
child: const Icon(Icons.add), child: const Icon(Icons.add),

View File

@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:cpd/pages/iconpage.dart'; import 'package:cpd/pages/iconpage.dart';
class AddHabitPopup extends StatefulWidget { class AddHabitPopup extends StatefulWidget {
//Callback nimmt Titel, Untertitel und Icon als Parameter der neuen Gewohnheit an
final void Function(String, String, IconData) onSubmit; final void Function(String, String, IconData) onSubmit;
@override @override

View File

@ -27,7 +27,6 @@ class EditHabitDialogState extends State<EditHabitDialog> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// Initialisierung mit den aktuellen Daten der Gewohnheit
newTitle = widget.todo.title; newTitle = widget.todo.title;
newSubtitle = widget.todo.subtitle; newSubtitle = widget.todo.subtitle;
newIcon = widget.todo.icon; newIcon = widget.todo.icon;

View File

@ -6,7 +6,6 @@ import '../database/todo_interface.dart';
class MyListView extends StatefulWidget { class MyListView extends StatefulWidget {
final List<Habit> habits; final List<Habit> habits;
//DB-Schnittstelle für Gewohnheiten
final ToDoInterface todoDB; final ToDoInterface todoDB;
final Function fetchTodos; final Function fetchTodos;
//Eine Funktion zum Aktualisieren des Zählers für abgeschlossene Gewohnheiten //Eine Funktion zum Aktualisieren des Zählers für abgeschlossene Gewohnheiten
@ -62,7 +61,6 @@ class MyListViewState extends State<MyListView> {
), ),
), ),
onDismissed: (direction) async { onDismissed: (direction) async {
// Löschen
if (direction == DismissDirection.endToStart) { if (direction == DismissDirection.endToStart) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@ -74,7 +72,6 @@ class MyListViewState extends State<MyListView> {
}); });
widget.fetchTodos(); widget.fetchTodos();
} }
// Bearbeiten
else if (direction == DismissDirection.startToEnd) { else if (direction == DismissDirection.startToEnd) {
showDialog( showDialog(
context: context, context: context,

View File

@ -24,7 +24,7 @@ void main() {
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// close the addhabit-dialog, as it was already tested in addhabit_popup.dart //schließt das addhabit-dialog, da es schon in addhabit-popup.dart getestet wurde
await tester.tap(find.byType(IconButton)); await tester.tap(find.byType(IconButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });

View File

@ -68,7 +68,7 @@ void main() {
expect(find.byType(EditHabitDialog), findsOneWidget); expect(find.byType(EditHabitDialog), findsOneWidget);
//close the EditHabitDialog as it was already tested in edithabit_dialog_test.dart //schließt das Edithabit-Dialog, da es schon in edithabit_dialog.dart getestet wurde
final cancelButtonFinder = find.widgetWithText(TextButton, 'Cancel'); final cancelButtonFinder = find.widgetWithText(TextButton, 'Cancel');
expect(cancelButtonFinder, findsOneWidget); expect(cancelButtonFinder, findsOneWidget);
await tester.tap(cancelButtonFinder); await tester.tap(cancelButtonFinder);