small fix, don't worry about it

This commit is contained in:
Tomas Dvorak
2026-04-10 12:05:40 +02:00
parent 7b7ed0083f
commit 5ab2773f98
55 changed files with 3240 additions and 483 deletions
@@ -1,6 +1,6 @@
import 'package:hive/hive.dart';
part 'cached_goal.g.dart';
part 'cached_goal_model.g.dart';
@HiveType(typeId: 0)
class CachedGoal extends HiveObject {
@@ -1,5 +1,11 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'cached_goal_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class CachedGoalAdapter extends TypeAdapter<CachedGoal> {
@override
final int typeId = 0;
@@ -29,33 +35,34 @@ class CachedGoalAdapter extends TypeAdapter<CachedGoal> {
@override
void write(BinaryWriter writer, CachedGoal obj) {
writer.writeByte(13);
writer.writeByte(0);
writer.write(obj.id);
writer.writeByte(1);
writer.write(obj.ownerId);
writer.writeByte(2);
writer.write(obj.title);
writer.writeByte(3);
writer.write(obj.description);
writer.writeByte(4);
writer.write(obj.progress);
writer.writeByte(5);
writer.write(obj.locationLat);
writer.writeByte(6);
writer.write(obj.locationLng);
writer.writeByte(7);
writer.write(obj.locationName);
writer.writeByte(8);
writer.write(obj.imageUrl);
writer.writeByte(9);
writer.write(obj.completed);
writer.writeByte(10);
writer.write(obj.createdAt);
writer.writeByte(11);
writer.write(obj.updatedAt);
writer.writeByte(12);
writer.write(obj.isDirty);
writer
..writeByte(13)
..writeByte(0)
..write(obj.id)
..writeByte(1)
..write(obj.ownerId)
..writeByte(2)
..write(obj.title)
..writeByte(3)
..write(obj.description)
..writeByte(4)
..write(obj.progress)
..writeByte(5)
..write(obj.locationLat)
..writeByte(6)
..write(obj.locationLng)
..writeByte(7)
..write(obj.locationName)
..writeByte(8)
..write(obj.imageUrl)
..writeByte(9)
..write(obj.completed)
..writeByte(10)
..write(obj.createdAt)
..writeByte(11)
..write(obj.updatedAt)
..writeByte(12)
..write(obj.isDirty);
}
@override
@@ -64,5 +71,7 @@ class CachedGoalAdapter extends TypeAdapter<CachedGoal> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CachedGoalAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
other is CachedGoalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
+79
View File
@@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import '../../core/utils/unit_conversion_utils.dart';
class User extends Equatable {
final String id;
@@ -13,6 +14,13 @@ class User extends Equatable {
final String? websiteUrl;
final DateTime? countdownStartDate;
final DateTime? countdownEndDate;
final Gender? gender;
final DateTime? birthDate;
final int? storedAge;
final double? heightCm;
final double? weightKg;
final HeightUnit heightUnit;
final WeightUnit weightUnit;
final DateTime createdAt;
final DateTime updatedAt;
@@ -29,6 +37,13 @@ class User extends Equatable {
this.websiteUrl,
this.countdownStartDate,
this.countdownEndDate,
this.gender,
this.birthDate,
this.storedAge,
this.heightCm,
this.weightKg,
this.heightUnit = HeightUnit.metric,
this.weightUnit = WeightUnit.metric,
required this.createdAt,
required this.updatedAt,
});
@@ -45,6 +60,33 @@ class User extends Equatable {
return countdownEndDate!.difference(DateTime.now()).inDays;
}
int? get age {
if (storedAge != null) return storedAge;
if (birthDate == null) return null;
return UnitConversionUtils.calculateAge(birthDate!);
}
String get formattedHeight {
if (heightCm == null) return '';
return UnitConversionUtils.formatHeight(heightCm!, heightUnit);
}
String get formattedWeight {
if (weightKg == null) return '';
return UnitConversionUtils.formatWeight(weightKg!, weightUnit);
}
double? get bmi {
if (heightCm == null || weightKg == null) return null;
return UnitConversionUtils.calculateBmi(weightKg!, heightCm!);
}
String get bmiCategory {
final bmiValue = bmi;
if (bmiValue == null) return '';
return UnitConversionUtils.getBmiCategory(bmiValue);
}
User copyWith({
String? id,
String? username,
@@ -58,6 +100,13 @@ class User extends Equatable {
String? websiteUrl,
DateTime? countdownStartDate,
DateTime? countdownEndDate,
Gender? gender,
DateTime? birthDate,
int? storedAge,
double? heightCm,
double? weightKg,
HeightUnit? heightUnit,
WeightUnit? weightUnit,
DateTime? createdAt,
DateTime? updatedAt,
}) {
@@ -74,6 +123,13 @@ class User extends Equatable {
websiteUrl: websiteUrl ?? this.websiteUrl,
countdownStartDate: countdownStartDate ?? this.countdownStartDate,
countdownEndDate: countdownEndDate ?? this.countdownEndDate,
gender: gender ?? this.gender,
birthDate: birthDate ?? this.birthDate,
storedAge: storedAge ?? this.storedAge,
heightCm: heightCm ?? this.heightCm,
weightKg: weightKg ?? this.weightKg,
heightUnit: heightUnit ?? this.heightUnit,
weightUnit: weightUnit ?? this.weightUnit,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
@@ -93,6 +149,13 @@ class User extends Equatable {
websiteUrl,
countdownStartDate,
countdownEndDate,
gender,
birthDate,
storedAge,
heightCm,
weightKg,
heightUnit,
weightUnit,
createdAt,
updatedAt,
];
@@ -111,6 +174,13 @@ class User extends Equatable {
'website_url': websiteUrl,
'countdown_start_date': countdownStartDate?.toIso8601String(),
'countdown_end_date': countdownEndDate?.toIso8601String(),
'gender': gender?.toDatabaseString(),
'birth_date': birthDate?.toIso8601String().split('T').first,
'age': storedAge,
'height_cm': heightCm,
'weight_kg': weightKg,
'height_unit': heightUnit.code,
'weight_unit': weightUnit.code,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
};
@@ -134,6 +204,15 @@ class User extends Equatable {
countdownEndDate: json['countdown_end_date'] != null
? DateTime.parse(json['countdown_end_date'] as String)
: null,
gender: json['gender'] != null ? Gender.fromString(json['gender'] as String) : null,
birthDate: json['birth_date'] != null ? DateTime.parse(json['birth_date'] as String) : null,
storedAge: json['age'] as int?,
heightCm: json['height_cm'] as double?,
weightKg: json['weight_kg'] as double?,
heightUnit: json['height_unit'] != null ?
HeightUnit.values.firstWhere((unit) => unit.code == json['height_unit']) : HeightUnit.metric,
weightUnit: json['weight_unit'] != null ?
WeightUnit.values.firstWhere((unit) => unit.code == json['weight_unit']) : WeightUnit.metric,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
);