Refactor architecture, fix all linter issues, and implement specification features (5 tabs, issue dropdowns, contact, info, search, pdf)

This commit is contained in:
2026-09-13 15:30:36 +02:00
parent 239f399af1
commit e6ce9c5012
24 changed files with 2486 additions and 1375 deletions
+73
View File
@@ -0,0 +1,73 @@
import 'package:cloud_firestore/cloud_firestore.dart';
class PostItem {
final String id;
final String title;
final String description;
final String imageUrl;
final List<String> imageUrls;
final DateTime createdDate;
final String? authorUid;
final String? street;
final String? category;
final String? status;
PostItem({
required this.id,
required this.title,
required this.description,
this.imageUrl = '',
List<String>? imageUrls,
required this.createdDate,
this.authorUid,
this.street,
this.category,
this.status = 'Gemeldet',
}) : imageUrls = imageUrls ?? (imageUrl.isNotEmpty ? [imageUrl] : []);
factory PostItem.fromFirestore(DocumentSnapshot doc) {
final data = doc.data() as Map<String, dynamic>? ?? {};
DateTime date;
if (data['createdDate'] is Timestamp) {
date = (data['createdDate'] as Timestamp).toDate();
} else {
date = DateTime.now();
}
final String legacyImage = data['imageUrl'] as String? ?? '';
List<String> images = [];
if (data['imageUrls'] is List) {
images = List<String>.from(data['imageUrls'] as List);
} else if (legacyImage.isNotEmpty) {
images = [legacyImage];
}
return PostItem(
id: doc.id,
title: data['title'] as String? ?? '',
description: data['description'] as String? ?? '',
imageUrl: legacyImage.isNotEmpty ? legacyImage : (images.isNotEmpty ? images.first : ''),
imageUrls: images,
createdDate: date,
authorUid: data['author_uid'] as String?,
street: data['street'] as String?,
category: data['category'] as String?,
status: data['status'] as String? ?? 'Gemeldet',
);
}
Map<String, dynamic> toFirestore() {
return {
'title': title,
'description': description,
'imageUrl': imageUrls.isNotEmpty ? imageUrls.first : '',
'imageUrls': imageUrls,
'createdDate': Timestamp.fromDate(createdDate),
'author_uid': authorUid,
if (street != null) 'street': street,
if (category != null) 'category': category,
if (status != null) 'status': status,
};
}
}