create project

This commit is contained in:
2026-05-19 11:46:42 +08:00
commit dcdf1f60b1
60 changed files with 9309 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
enum BillType { expense, income }
class Bill {
final String id;
final String userId;
final String? familyId;
final BillType type;
final double amount;
final String category;
final String note;
final String emoji;
final String time;
final String date;
final String createdAt;
const Bill({
required this.id,
required this.userId,
this.familyId,
required this.type,
required this.amount,
required this.category,
this.note = '',
this.emoji = '📝',
required this.time,
required this.date,
this.createdAt = '',
});
bool get isExpense => type == BillType.expense;
bool get isIncome => type == BillType.income;
factory Bill.fromJson(Map<String, dynamic> json) {
return Bill(
id: json['id'] as String? ?? '',
userId: json['userId'] as String? ?? '',
familyId: json['familyId'] as String?,
type: json['type'] as String? == 'income' ? BillType.income : BillType.expense,
amount: (json['amount'] as num?)?.toDouble() ?? 0,
category: json['category'] as String? ?? '',
note: json['note'] as String? ?? '',
emoji: json['emoji'] as String? ?? '📝',
time: json['time'] as String? ?? '00:00',
date: json['date'] as String? ?? '',
createdAt: json['createdAt'] as String? ?? '',
);
}
}

View File

@@ -0,0 +1,53 @@
class FamilyMember {
final String userId;
final String nickname;
final String role;
final String joinedAt;
const FamilyMember({
required this.userId,
required this.nickname,
this.role = 'member',
this.joinedAt = '',
});
factory FamilyMember.fromJson(Map<String, dynamic> json) {
return FamilyMember(
userId: json['userId'] as String? ?? '',
nickname: json['nickname'] as String? ?? '',
role: json['role'] as String? ?? 'member',
joinedAt: json['joinedAt'] as String? ?? '',
);
}
}
class Family {
final String id;
final String name;
final String inviteCode;
final String createdBy;
final String createdAt;
final List<FamilyMember> members;
const Family({
required this.id,
required this.name,
required this.inviteCode,
this.createdBy = '',
this.createdAt = '',
this.members = const [],
});
factory Family.fromJson(Map<String, dynamic> json) {
return Family(
id: json['id'] as String? ?? '',
name: json['name'] as String? ?? '',
inviteCode: json['inviteCode'] as String? ?? '',
createdBy: json['createdBy'] as String? ?? '',
createdAt: json['createdAt'] as String? ?? '',
members: (json['members'] as List<dynamic>?)
?.map((m) => FamilyMember.fromJson(m as Map<String, dynamic>))
.toList() ?? [],
);
}
}

View File

@@ -0,0 +1,45 @@
class User {
final String id;
final String phone;
final String nickname;
final String? email;
final List<String> familyIds;
final String? activeFamilyId;
final String joinDate;
final String createdAt;
const User({
required this.id,
required this.phone,
required this.nickname,
this.email,
this.familyIds = const [],
this.activeFamilyId,
this.joinDate = '',
this.createdAt = '',
});
factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'] as String? ?? '',
phone: json['phone'] as String? ?? '',
nickname: json['nickname'] as String? ?? '',
email: json['email'] as String?,
familyIds: (json['familyIds'] as List<dynamic>?)?.cast<String>() ?? [],
activeFamilyId: json['activeFamilyId'] as String?,
joinDate: json['joinDate'] as String? ?? '',
createdAt: json['createdAt'] as String? ?? '',
);
}
Map<String, dynamic> toJson() => {
'id': id,
'phone': phone,
'nickname': nickname,
'email': email,
'familyIds': familyIds,
'activeFamilyId': activeFamilyId,
'joinDate': joinDate,
'createdAt': createdAt,
};
}