Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ PODS:
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)
- RecaptchaInterop (100.0.0)
- sign_in_with_apple (0.0.1):
Expand All @@ -822,6 +825,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

Expand Down Expand Up @@ -867,6 +871,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/google_sign_in_ios/darwin"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
sign_in_with_apple:
:path: ".symlinks/plugins/sign_in_with_apple/ios"
url_launcher_ios:
Expand Down Expand Up @@ -902,11 +908,12 @@ SPEC CHECKSUMS:
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
leveldb-library: f03246171cce0484482ec291f88b6d563699ee06
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586

PODFILE CHECKSUM: d5ebeed53a738c4992d155ad65b0166c472906e5

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
55 changes: 55 additions & 0 deletions lib/Plans/FindPlans/find_plans_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import 'plan.dart';

class FindPlansProvider with ChangeNotifier {
List<Plan> _plans = [];
bool _isLoading = false;
String _error = '';

List<Plan> get plans => _plans;
bool get isLoading => _isLoading;
String get error => _error;

Future<void> fetchPlans() async {
_isLoading = true;
notifyListeners();

try {
CollectionReference planCollection = FirebaseFirestore.instance.collection('plans');
QuerySnapshot snapshot = await planCollection.get();
_plans = snapshot.docs.map((doc) {
final data = doc.data() as Map<String, dynamic>;
return Plan.fromFirestore(data);
}).toList();
_error = '';
await savePlansToFile(_plans);
print("Plans fetched and saved successfully: ${_plans.length} plans");
} catch (error) {
_error = "Error fetching plans: $error";
print(_error);
} finally {
_isLoading = false;
notifyListeners();
}
}

Future<void> savePlansToFile(List<Plan> plans) async {
try {
final directory = await getApplicationDocumentsDirectory();
final filePath = '${directory.path}/plans.txt';
final file = File(filePath);
final data = plans.map((plan) => plan.toMap().toString()).join('\n');
await file.writeAsString(data);
print('Plans saved to $filePath');
} catch (e) {
print('Error saving plans to file: $e');
}
}

Future<void> refreshData() async {
await fetchPlans();
}
}
55 changes: 55 additions & 0 deletions lib/Plans/FindPlans/plan.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class Plan {
final String title;
final String discription;
final String startdate;
final String enddate;
final String location;
final String kind;
final String imageurl;
final String maxpeople;
final List<String> peoplelist;
final List<String> buzzwordlist;

Plan({
required this.title,
required this.discription,
required this.startdate,
required this.enddate,
required this.location,
required this.kind,
required this.imageurl,
required this.maxpeople,
required this.peoplelist,
required this.buzzwordlist,
});

factory Plan.fromFirestore(Map<String, dynamic> data) {
return Plan(
title: data['title'] ?? '',
discription: data['discription'] ?? '',
startdate: data['startdate'] ?? '',
enddate: data['enddate'] ?? '',
location: data['location'] ?? '',
kind: data['kind'] ?? '',
imageurl: data['imageurl'] ?? '',
maxpeople: data['maxpeople'] ?? '',
peoplelist: List<String>.from(data['peoplelist'] ?? []),
buzzwordlist: List<String>.from(data['buzzwordlist'] ?? []),
);
}

Map<String, dynamic> toMap() {
return {
'title': title,
'discription': discription,
'startdate': startdate,
'enddate': enddate,
'location': location,
'kind': kind,
'imageurl': imageurl,
'maxpeople': maxpeople,
'peoplelist': peoplelist,
'buzzwordlist': buzzwordlist,
};
}
}
89 changes: 89 additions & 0 deletions lib/Plans/FindPlans/plan_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
import 'plan.dart';

class PlanTile extends StatelessWidget {
final Plan plan;
final VoidCallback onTap;

const PlanTile({
Key? key,
required this.plan,
required this.onTap,
}) : super(key: key);

@override
Widget build(BuildContext context) {
print('Loading image from URL: ${plan.imageurl}'); // URL zum Debuggen ausgeben

return GestureDetector(
onTap: onTap,
child: Container(
margin: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(4.0),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(8.0),
),
child: Stack(
children: [
plan.imageurl.isNotEmpty
? Image.network(
plan.imageurl,
width: double.infinity,
height: double.infinity,
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / (loadingProgress.expectedTotalBytes ?? 1)
: null,
),
);
},
errorBuilder: (context, error, stackTrace) {
print('Error loading image: $error'); // Ausgabe des Fehlers in der Konsole
return const Center(
child: Icon(
Icons.broken_image,
size: 50,
color: Colors.grey,
),
);
},
)
: const Center(
child: Icon(
Icons.event,
size: 50,
color: Colors.grey,
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
color: Colors.black.withOpacity(0.5),
padding: const EdgeInsets.all(8),
child: Text(
plan.title,
style: const TextStyle(
fontSize: 16,
color: Colors.white,
),
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
),
);
}
}
Loading