Import sorgenti Flutter di Henflow (export da Nextcloud: lib/ + documenti di progetto)
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
class BreedCatalogItem {
|
||||
final String id;
|
||||
final String name;
|
||||
final String description;
|
||||
final String eggColor;
|
||||
final double eggsPerHenPerDay;
|
||||
final String assetPath;
|
||||
|
||||
const BreedCatalogItem({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.eggColor,
|
||||
required this.eggsPerHenPerDay,
|
||||
required this.assetPath,
|
||||
});
|
||||
}
|
||||
|
||||
const List<BreedCatalogItem> breedCatalog = [
|
||||
BreedCatalogItem(
|
||||
id: 'marans',
|
||||
name: 'name_marans',
|
||||
description: 'desc_marans',
|
||||
eggColor: 'color_dark_brown',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/marans.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'araucana',
|
||||
name: 'name_araucana',
|
||||
description: 'desc_araucana',
|
||||
eggColor: 'color_blue',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/araucana.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'olive',
|
||||
name: 'name_olive',
|
||||
description: 'desc_olive',
|
||||
eggColor: 'color_olive',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/olive.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'livorno',
|
||||
name: 'name_livorno',
|
||||
description: 'desc_livorno',
|
||||
eggColor: 'color_white',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/livorno.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'sussex',
|
||||
name: 'name_sussex',
|
||||
description: 'desc_sussex',
|
||||
eggColor: 'color_cream',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/sussex.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'australorp',
|
||||
name: 'name_australorp',
|
||||
description: 'desc_australorp',
|
||||
eggColor: 'color_light_brown',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/australorp.jpg',
|
||||
),
|
||||
BreedCatalogItem(
|
||||
id: 'generic',
|
||||
name: 'name_generic',
|
||||
description: 'desc_generic',
|
||||
eggColor: 'color_light_brown',
|
||||
eggsPerHenPerDay: 1.0,
|
||||
assetPath: 'assets/breeds/generic.jpg',
|
||||
),
|
||||
];
|
||||
|
||||
BreedCatalogItem breedFromId(String id) {
|
||||
return breedCatalog.firstWhere(
|
||||
(e) => e.id == id,
|
||||
orElse: () => breedCatalog.first,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'breed_catalog.dart';
|
||||
import 'hen.dart';
|
||||
|
||||
class BreedSetting {
|
||||
final String breedId;
|
||||
List<Hen> hens;
|
||||
|
||||
BreedSetting({
|
||||
required this.breedId,
|
||||
required this.hens,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'breedId': breedId,
|
||||
'hens': hens.map((e) => e.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
factory BreedSetting.fromMap(Map<String, dynamic> map) {
|
||||
return BreedSetting(
|
||||
breedId: map['breedId'],
|
||||
hens: ((map['hens'] ?? []) as List)
|
||||
.map((e) => Hen.fromMap(Map<String, dynamic>.from(e)))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
int get activeHensCount {
|
||||
return hens.where((hen) => hen.isLaying).length;
|
||||
}
|
||||
|
||||
double get dailyProduction =>
|
||||
activeHensCount * breedFromId(breedId).eggsPerHenPerDay;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
class Customer {
|
||||
final String id;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final String phoneNumber;
|
||||
|
||||
Customer({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.phoneNumber,
|
||||
});
|
||||
|
||||
String get fullName => '$firstName $lastName'.trim();
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'firstName': firstName,
|
||||
'lastName': lastName,
|
||||
'phoneNumber': phoneNumber,
|
||||
};
|
||||
}
|
||||
|
||||
factory Customer.fromMap(Map<String, dynamic> map) {
|
||||
return Customer(
|
||||
id: map['id'],
|
||||
firstName: map['firstName'],
|
||||
lastName: map['lastName'],
|
||||
phoneNumber: map['phoneNumber'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
class Hen {
|
||||
final String id;
|
||||
final String name;
|
||||
final DateTime birthDate;
|
||||
bool isLaying;
|
||||
|
||||
Hen({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.birthDate,
|
||||
this.isLaying = true,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'birthDate': birthDate.toIso8601String(),
|
||||
'isLaying': isLaying,
|
||||
};
|
||||
}
|
||||
|
||||
factory Hen.fromMap(Map<String, dynamic> map) {
|
||||
return Hen(
|
||||
id: map['id'],
|
||||
name: map['name'],
|
||||
birthDate: DateTime.parse(map['birthDate']),
|
||||
isLaying: map['isLaying'] ?? true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
class Reservation {
|
||||
final String id;
|
||||
final String customerName;
|
||||
final String breedId;
|
||||
final int eggsRequested;
|
||||
final DateTime createdAt;
|
||||
final DateTime deliveryDate;
|
||||
bool isDelivered;
|
||||
|
||||
Reservation({
|
||||
required this.id,
|
||||
required this.customerName,
|
||||
required this.breedId,
|
||||
required this.eggsRequested,
|
||||
required this.createdAt,
|
||||
required this.deliveryDate,
|
||||
this.isDelivered = false,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'customerName': customerName,
|
||||
'breedId': breedId,
|
||||
'eggsRequested': eggsRequested,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'deliveryDate': deliveryDate.toIso8601String(),
|
||||
'isDelivered': isDelivered,
|
||||
};
|
||||
}
|
||||
|
||||
factory Reservation.fromMap(Map<String, dynamic> map) {
|
||||
return Reservation(
|
||||
id: map['id'],
|
||||
customerName: map['customerName'],
|
||||
breedId: map['breedId'],
|
||||
eggsRequested: map['eggsRequested'],
|
||||
createdAt: DateTime.parse(map['createdAt']),
|
||||
deliveryDate: DateTime.parse(map['deliveryDate']),
|
||||
isDelivered: map['isDelivered'] ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user