add service for appwrite

This commit is contained in:
2026-02-24 22:38:01 +01:00
parent 487379ed0a
commit 9c8cdb3845
9 changed files with 649 additions and 67 deletions

View File

@@ -6,6 +6,7 @@ import 'package:intl/intl.dart';
import '../models/home_model.dart';
class AddWeightDialog extends StatefulWidget {
final String userId;
final String personName;
/// Letztes bekanntes Gewicht dieser Person wird für weightChange benötigt.
@@ -16,6 +17,7 @@ class AddWeightDialog extends StatefulWidget {
const AddWeightDialog({
super.key,
required this.userId,
required this.personName,
required this.lastWeight,
this.existingEntry,
@@ -23,11 +25,16 @@ class AddWeightDialog extends StatefulWidget {
/// Öffnet den Dialog zum Hinzufügen eines neuen Eintrags.
static Future<WeightModel?> show({
required String userId,
required String personName,
required double lastWeight,
}) {
return Get.dialog<WeightModel>(
AddWeightDialog(personName: personName, lastWeight: lastWeight),
AddWeightDialog(
userId: userId,
personName: personName,
lastWeight: lastWeight,
),
barrierColor: Colors.black.withValues(alpha: 0.55),
);
}
@@ -40,6 +47,7 @@ class AddWeightDialog extends StatefulWidget {
}) {
return Get.dialog<WeightModel>(
AddWeightDialog(
userId: entry.documentId,
personName: entry.name,
lastWeight: previousWeight,
existingEntry: entry,
@@ -135,9 +143,10 @@ class _AddWeightDialogState extends State<AddWeightDialog>
final name = _nameController.text.trim();
final entry = WeightModel(
// Im Edit-Modus dieselbe ID behalten
id:
widget.existingEntry?.id ??
documentId:
widget.existingEntry?.documentId ??
DateTime.now().millisecondsSinceEpoch.toString(),
name: name,
weight: _parsedWeight!,
date: _selectedDate,