Training kann nun angeklickt werden
parent
a15259ecd2
commit
402c9a8835
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'training_detail_screen.dart';
|
||||||
|
|
||||||
class FavoritesTab extends StatelessWidget {
|
class FavoritesTab extends StatelessWidget {
|
||||||
const FavoritesTab({super.key});
|
const FavoritesTab({super.key});
|
||||||
|
|
@ -44,47 +45,57 @@ class FavoritesTab extends StatelessWidget {
|
||||||
final trainingData = trainingSnapshot.data!.data() as Map<String, dynamic>;
|
final trainingData = trainingSnapshot.data!.data() as Map<String, dynamic>;
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.all(8.0),
|
margin: const EdgeInsets.all(8.0),
|
||||||
child: Padding(
|
child: InkWell(
|
||||||
padding: const EdgeInsets.all(16.0),
|
onTap: () {
|
||||||
child: Column(
|
Navigator.push(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
context,
|
||||||
children: [
|
MaterialPageRoute(
|
||||||
Text(
|
builder: (context) => TrainingDetailScreen(trainingId: favorites[index]),
|
||||||
trainingData['title'] ?? 'Unbekannt',
|
),
|
||||||
style: const TextStyle(
|
);
|
||||||
fontSize: 18,
|
},
|
||||||
fontWeight: FontWeight.bold,
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
trainingData['title'] ?? 'Unbekannt',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Text(
|
||||||
Text(
|
trainingData['description'] ?? 'Keine Beschreibung',
|
||||||
trainingData['description'] ?? 'Keine Beschreibung',
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Text(
|
||||||
Text(
|
'Dauer: ${trainingData['duration'] ?? '-'} Minuten',
|
||||||
'Dauer: ${trainingData['duration'] ?? '-'} Minuten',
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Row(
|
||||||
Row(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Level: ${trainingData['year'] ?? '-'}',
|
||||||
'Level: ${trainingData['year'] ?? '-'}',
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
),
|
||||||
),
|
IconButton(
|
||||||
IconButton(
|
icon: const Icon(Icons.favorite, color: Colors.red),
|
||||||
icon: const Icon(Icons.favorite, color: Colors.red),
|
onPressed: () async {
|
||||||
onPressed: () async {
|
await FirebaseFirestore.instance.collection('User').doc(user.uid).update({
|
||||||
await FirebaseFirestore.instance.collection('User').doc(user.uid).update({
|
'favorites': FieldValue.arrayRemove([favorites[index]]),
|
||||||
'favorites': FieldValue.arrayRemove([favorites[index]]),
|
});
|
||||||
});
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'training_detail_screen.dart';
|
||||||
|
|
||||||
class SearchTab extends StatefulWidget {
|
class SearchTab extends StatefulWidget {
|
||||||
const SearchTab({super.key});
|
const SearchTab({super.key});
|
||||||
|
|
@ -180,78 +181,88 @@ class _SearchTabState extends State<SearchTab> {
|
||||||
final isFavorite = _favorites.contains(docs[index].id);
|
final isFavorite = _favorites.contains(docs[index].id);
|
||||||
return Card(
|
return Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Column(
|
child: InkWell(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
onTap: () {
|
||||||
children: [
|
Navigator.push(
|
||||||
Expanded(
|
context,
|
||||||
child: (data['picture'] is String && data['picture'] != '')
|
MaterialPageRoute(
|
||||||
? Image.network(
|
builder: (context) => TrainingDetailScreen(trainingId: docs[index].id),
|
||||||
data['picture'],
|
|
||||||
width: double.infinity,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
color: Colors.grey[300],
|
|
||||||
child: const Center(
|
|
||||||
child: Icon(Icons.fitness_center, size: 40),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
data['title'] ?? '-',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
data['description'] ?? '-',
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.grey[600],
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
'${data['duration'] ?? '-'} Minuten',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.grey[600],
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.star, size: 16, color: Colors.amber),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text('${data['rating overall'] ?? '-'}'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text('Level: ${data['year'] ?? '-'}'),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
isFavorite ? Icons.favorite : Icons.favorite_border,
|
|
||||||
color: isFavorite ? Colors.red : null,
|
|
||||||
),
|
|
||||||
onPressed: () => _toggleFavorite(docs[index].id, isFavorite),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: (data['picture'] is String && data['picture'] != '')
|
||||||
|
? Image.network(
|
||||||
|
data['picture'],
|
||||||
|
width: double.infinity,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
child: const Center(
|
||||||
|
child: Icon(Icons.fitness_center, size: 40),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
data['title'] ?? '-',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
data['description'] ?? '-',
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[600],
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'${data['duration'] ?? '-'} Minuten',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey[600],
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.star, size: 16, color: Colors.amber),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text('${data['rating overall'] ?? '-'}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text('Level: ${data['year'] ?? '-'}'),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
isFavorite ? Icons.favorite : Icons.favorite_border,
|
||||||
|
color: isFavorite ? Colors.red : null,
|
||||||
|
),
|
||||||
|
onPressed: () => _toggleFavorite(docs[index].id, isFavorite),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}, childCount: docs.length),
|
}, childCount: docs.length),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
|
class TrainingDetailScreen extends StatelessWidget {
|
||||||
|
final String trainingId;
|
||||||
|
|
||||||
|
const TrainingDetailScreen({super.key, required this.trainingId});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Training Details'),
|
||||||
|
),
|
||||||
|
body: FutureBuilder<DocumentSnapshot>(
|
||||||
|
future: FirebaseFirestore.instance.collection('Training').doc(trainingId).get(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
if (!snapshot.hasData || !snapshot.data!.exists) {
|
||||||
|
return const Center(child: Text('Training nicht gefunden'));
|
||||||
|
}
|
||||||
|
final data = snapshot.data!.data() as Map<String, dynamic>;
|
||||||
|
return SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 200,
|
||||||
|
color: Colors.grey[300],
|
||||||
|
child: const Center(
|
||||||
|
child: Icon(Icons.image, size: 64, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
data['title'] ?? 'Unbekannt',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
data['description'] ?? 'Keine Beschreibung',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Dauer: ${data['duration'] ?? '-'} Minuten',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Level: ${data['year'] ?? '-'}',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Bewertung: ${data['rating overall'] ?? '-'}',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Kategorie: ${data['category'] ?? '-'}',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue