149 lines
3.7 KiB
Dart
149 lines
3.7 KiB
Dart
import 'package:intl/intl.dart';
|
|
|
|
class FilamentModel {
|
|
final String id;
|
|
final String name;
|
|
final String type; // PLA, ABS, PETG, etc.
|
|
final String color;
|
|
final double weight; // in Gramm
|
|
final double price; // Preis
|
|
final String? manufacturer;
|
|
final String? purchaseDate;
|
|
final String? notes;
|
|
final int? pices;
|
|
final int? printingTemp;
|
|
final int? bedTemp;
|
|
|
|
FilamentModel({
|
|
required this.id,
|
|
required this.name,
|
|
required this.type,
|
|
required this.color,
|
|
required this.weight,
|
|
required this.price,
|
|
this.manufacturer,
|
|
this.purchaseDate,
|
|
this.notes,
|
|
this.pices,
|
|
this.printingTemp,
|
|
this.bedTemp,
|
|
});
|
|
|
|
// JSON Serialisierung
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'type': type,
|
|
'color': color,
|
|
'weight': weight,
|
|
'price': price,
|
|
'manufacturer': manufacturer,
|
|
'purchaseDate': purchaseDate,
|
|
'notes': notes,
|
|
'pices': pices,
|
|
'printingTemp': printingTemp,
|
|
'bedTemp': bedTemp,
|
|
};
|
|
}
|
|
|
|
// JSON Deserialisierung
|
|
factory FilamentModel.fromJson(Map<String, dynamic> json) {
|
|
return FilamentModel(
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
type: json['type'] as String,
|
|
color: json['color'] as String,
|
|
weight: (json['weight'] as num).toDouble(),
|
|
price: (json['price'] as num).toDouble(),
|
|
manufacturer: json['manufacturer'] as String?,
|
|
purchaseDate: json['purchaseDate'] as String?,
|
|
notes: json['notes'] as String?,
|
|
pices: json['pices'] as int?,
|
|
printingTemp: json['printingTemp'] as int?,
|
|
bedTemp: json['bedTemp'] as int?,
|
|
);
|
|
}
|
|
|
|
// CopyWith für Updates
|
|
FilamentModel copyWith({
|
|
String? id,
|
|
String? name,
|
|
String? type,
|
|
String? color,
|
|
double? weight,
|
|
double? price,
|
|
String? manufacturer,
|
|
String? purchaseDate,
|
|
String? notes,
|
|
int? pices,
|
|
int? printingTemp,
|
|
int? bedTemp,
|
|
}) {
|
|
return FilamentModel(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
type: type ?? this.type,
|
|
color: color ?? this.color,
|
|
weight: weight ?? this.weight,
|
|
price: price ?? this.price,
|
|
manufacturer: manufacturer ?? this.manufacturer,
|
|
purchaseDate: purchaseDate ?? this.purchaseDate,
|
|
notes: notes ?? this.notes,
|
|
pices: pices ?? this.pices,
|
|
printingTemp: printingTemp ?? this.printingTemp,
|
|
bedTemp: bedTemp ?? this.bedTemp,
|
|
);
|
|
}
|
|
|
|
static String formatDate(DateTime date) {
|
|
final DateFormat formatter = DateFormat('dd.MM.yyyy');
|
|
return formatter.format(date);
|
|
}
|
|
|
|
static List<FilamentModel> mockupFilamentList = [
|
|
FilamentModel(
|
|
id: '1',
|
|
name: '3Djake ECO Filament',
|
|
type: 'PLA',
|
|
color: 'White',
|
|
weight: 1000.0,
|
|
price: 19.99,
|
|
manufacturer: '3Djake.at',
|
|
purchaseDate: formatDate(DateTime(2026, 1, 10)),
|
|
notes: 'Great quality filament for everyday printing.',
|
|
pices: 1,
|
|
printingTemp: 207,
|
|
bedTemp: 55,
|
|
),
|
|
FilamentModel(
|
|
id: '2',
|
|
name: 'Geeetech',
|
|
type: 'PETG',
|
|
color: 'Black',
|
|
weight: 1000.0,
|
|
price: 9.99,
|
|
manufacturer: 'geeetech.com',
|
|
purchaseDate: formatDate(DateTime(2025, 10, 10)),
|
|
notes: 'Durable and strong, perfect for functional parts.',
|
|
pices: 8,
|
|
printingTemp: 207,
|
|
bedTemp: 55,
|
|
),
|
|
FilamentModel(
|
|
id: '3',
|
|
name: 'Tinmorry',
|
|
type: 'ASA',
|
|
color: 'Black',
|
|
weight: 1000.0,
|
|
price: 16.01,
|
|
pices: 1,
|
|
manufacturer: 'tinmorry.com',
|
|
purchaseDate: formatDate(DateTime(2026, 1, 10)),
|
|
notes: 'Weather-resistant filament for outdoor use.',
|
|
printingTemp: 265,
|
|
bedTemp: 100,
|
|
),
|
|
];
|
|
}
|