From 18257ff1d2498738432f075109abe05402d424e0 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 1 Oct 2024 19:50:38 +0200 Subject: [PATCH] Not perfect but not to bad --- ios/Runner/AppDelegate.swift | 2 +- lib/main.dart | 27 +- lib/screens/detail_widget.dart | 630 ++----------------- lib/screens/details_db.dart | 6 +- lib/screens/home.dart | 236 +++---- lib/screens/subheader_Datepicker.dart | 872 +++++++++++++++++++++++--- lib/utils/class.dart | 9 +- lib/utils/data.dart | 100 ++- lib/utils/helper_functions.dart | 19 + pubspec.lock | 24 +- 10 files changed, 1072 insertions(+), 853 deletions(-) create mode 100644 lib/utils/helper_functions.dart diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..b636303 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import UIKit import Flutter -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/lib/main.dart b/lib/main.dart index c52e449..a1cacc3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,32 +1,35 @@ import 'package:flutter/material.dart'; import 'package:learn_project/screens/home.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; -import 'package:learn_project/screens/account_page.dart'; -import 'package:learn_project/screens/login_page.dart'; -import 'package:learn_project/screens/splash_page.dart'; +//import 'package:learn_project/screens/account_page.dart'; +//import 'package:learn_project/screens/login_page.dart'; +//import 'package:learn_project/screens/splash_page.dart'; -import 'utils/constants.dart'; +//import 'utils/constants.dart'; - Future main() async { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Supabase.initialize( url: 'https://vvtefqdqahcpzgolvupv.supabase.co', - anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZ2dGVmcWRxYWhjcHpnb2x2dXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTYwMjE3ODksImV4cCI6MjAzMTU5Nzc4OX0.6g5EtS9HrgxC6cpCYgOT0HLpA4lEnASQbKs9mfnUM7k', - //Locale - //url:'http://192.168.179.86:8000/',// - // annonKey: //Constants.supabaseAnnonKey,//'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZ2dGVmcWRxYWhjcHpnb2x2dXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTYwMjE2NTIsImV4cCI6MjAzMTU5NzY1Mn0.1bp5V61Oguo5zLUhCFJmCabUY1sujeISr_CR2XUKvh4',// + anonKey: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZ2dGVmcWRxYWhjcHpnb2x2dXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTYwMjE3ODksImV4cCI6MjAzMTU5Nzc4OX0.6g5EtS9HrgxC6cpCYgOT0HLpA4lEnASQbKs9mfnUM7k', + //Locale + //url:'http://192.168.179.86:8000/',// + // annonKey: //Constants.supabaseAnnonKey,//'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZ2dGVmcWRxYWhjcHpnb2x2dXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTYwMjE2NTIsImV4cCI6MjAzMTU5NzY1Mn0.1bp5V61Oguo5zLUhCFJmCabUY1sujeISr_CR2XUKvh4',// ); - runApp( MyApp()); + runApp(MyApp()); } /// Supabase client final supabase = Supabase.instance.client; + /// Error message to display the user when unexpected error occurs. const unexpectedErrorMessage = 'Unexpected error occurred.'; + class MyApp extends StatelessWidget { const MyApp({super.key}); - + @override Widget build(BuildContext context) { return MaterialApp( @@ -97,4 +100,4 @@ class _HomePageState extends State { - */ \ No newline at end of file + */ diff --git a/lib/screens/detail_widget.dart b/lib/screens/detail_widget.dart index 43b7704..a13b46c 100644 --- a/lib/screens/detail_widget.dart +++ b/lib/screens/detail_widget.dart @@ -1,12 +1,29 @@ import 'package:flutter/material.dart'; import 'package:learn_project/screens/subheader_Datepicker.dart'; +//import 'package:learn_project/main.dart'; +import 'package:intl/intl.dart'; +//import 'package:supabase_flutter/supabase_flutter.dart'; +class Frame28 extends StatelessWidget { + final List> events; + + const Frame28({Key? key, required this.events}) : super(key: key); + + /* void initState() { + super.initState(); + _loadData(); + } */ +/* */ -class Frame28 extends StatelessWidget { @override Widget build(BuildContext context) { - var body = SafeArea( - child: Column( + //_loadData(); + var body = CustomScrollView( + slivers: [ + SliverSafeArea(sliver: SliverToBoxAdapter( + child: Container( + alignment: Alignment.center, + child: Column( children: [ //Header Container HeaderSection(), @@ -21,577 +38,66 @@ class Frame28 extends StatelessWidget { Container( width: 380, //height: 259, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Column( + + child: const Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ // TODO: muss noch angepasst werden jedes mal wenn ein neuer Tag ist wieder diesen Text anzeigen - Text( - 'Heute', - style: TextStyle( - color: Color(0xFF171717), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w600, - height: 0, - ), - ), + SizedBox(height: 10), + Text( 'Heute', style: TextStyle(color: Color(0xFF171717), fontSize: 12, fontFamily: 'Inter', fontWeight: FontWeight.w600, height: 0,),), + //Kurze Zwischenbereich zum trennen + SizedBox(height: 4), + //EventCard2Section(), + /* const SizedBox(height: 20), + EventCard2Section(), + const SizedBox(height: 20), + Text('Morgen', style: TextStyle(color: Color(0xFF171717), fontSize: 12, fontFamily: 'Inter', fontWeight: FontWeight.w600, height: 0,),), //Kurze Zwischenbereich zum trennen const SizedBox(height: 4), - - Container( - width: 379, - height: 120, - child: Stack( - children: [ - Positioned( - left: 0, - top: 0, - child: Container( - width: 360, - height: 110, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - border: Border( - left: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - top: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - right: BorderSide(color: Color(0xFFBFBCBC)), - bottom: BorderSide(color: Color(0xFFBFBCBC)), - ), - boxShadow: [ - BoxShadow( - color: Color(0xFFF8AB14), - blurRadius: 0, - offset: Offset(0, 10), - spreadRadius: 0, - ) - ], - ), - ), - ), - Positioned( - left: 230, - top: 1, - child: Image.asset( - 'assets/images/Vector01.png', // Pfad zum Bild - height: 110, // Höhe des Bildes - width: 130, // Breite des Bildes - ), - ), - Positioned( - right: 30, - top: 12, - child: Container( - width: 32, - height: 32, - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 32, - height: 32, - decoration: BoxDecoration( - color: Color.fromARGB(196, 171, 170, 170), // Hintergrundfarbe des Buttons - shape: BoxShape.circle, // Runde Form - ), - child: IconButton( - padding: EdgeInsets.zero, // Entfernt zusätzlichen Abstand - icon: Icon(Icons.bookmark_border_outlined), - color: Colors.white, // Icon-Farbe - iconSize: 16, // Größe des Icons - onPressed: () { - // Aktion beim Drücken des Buttons - }, - ), - ), - ], - ), - ), - ), - - Positioned( - left: 15, - top: 14, - child: SizedBox( - //width: 55, - //height: 24, - child: Text( - 'Suxul', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0, - ), - ), - ), - ), - Positioned( - left: 92, - top: 14, - child: Text( - 'Weiberfasching', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - Positioned( - left: 15, - top: 90, - child: SizedBox( - //width: 196, - //height: 15, - child: Text( - 'Eintritt: Bis 21 Uhr frei', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - ), - Positioned( - left: 15, - top: 70, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: '20:30', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0.06, - ), - ), - ])))), - Positioned( - left: 15, - top: 45, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: 'Beginn\n', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w200, - height: 0.14, - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - const SizedBox(height: 20), - Container( - width: 379, - height: 120, - child: Stack( - children: [ - Positioned( - left: 0, - top: 0, - child: Container( - width: 360, - height: 110, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - border: Border( - left: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - top: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - right: BorderSide(color: Color(0xFFBFBCBC)), - bottom: BorderSide(color: Color(0xFFBFBCBC)), - ), - boxShadow: [ - BoxShadow( - color: Color(0xFFF8AB14), - blurRadius: 0, - offset: Offset(0, 10), - spreadRadius: 0, - ) - ], - ), - ), - ), - Positioned( - left: 230, - top: 1, - child: Image.asset( - 'assets/images/Vector01.png', // Pfad zum Bild - height: 110, // Höhe des Bildes - width: 130, // Breite des Bildes - ), - ), - Positioned( - right: 30, - top: 12, - child: Container( - width: 32, - height: 32, - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 32, - height: 32, - decoration: BoxDecoration( - color: Color.fromARGB(196, 171, 170, 170), // Hintergrundfarbe des Buttons - shape: BoxShape.circle, // Runde Form - ), - child: IconButton( - padding: EdgeInsets.zero, // Entfernt zusätzlichen Abstand - icon: Icon(Icons.bookmark_border_outlined), - color: Colors.white, // Icon-Farbe - iconSize: 16, // Größe des Icons - onPressed: () { - // Aktion beim Drücken des Buttons - }, - ), - ), - ], - ), - ), - ), - - Positioned( - left: 15, - top: 14, - child: SizedBox( - //width: 55, - //height: 24, - child: Text( - 'Suxul', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0, - ), - ), - ), - ), - Positioned( - left: 92, - top: 14, - child: Text( - 'Weiberfasching', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - Positioned( - left: 15, - top: 90, - child: SizedBox( - //width: 196, - //height: 15, - child: Text( - 'Eintritt: Bis 21 Uhr frei', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - ), - Positioned( - left: 15, - top: 70, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: '20:30', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0.06, - ), - ), - ])))), - Positioned( - left: 15, - top: 45, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: 'Beginn\n', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w200, - height: 0.14, - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - - ], - ), - ), - const SizedBox(height: 20), - Container( - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // TODO: muss noch angepasst werden jedes mal wenn ein neuer Tag ist wieder diesen Text anzeigen - Text( - 'Morgen', - style: TextStyle( - color: Color(0xFF171717), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w600, - height: 0, - ), - ), - //Kurze Zwischenbereich zum trennen - const SizedBox(height: 4), - - Container( - width: 379, - height: 120, - child: Stack( - children: [ - Positioned( - left: 0, - top: 0, - child: Container( - width: 360, - height: 110, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - border: Border( - left: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - top: BorderSide(width: 1, color: Color(0xFFBFBCBC)), - right: BorderSide(color: Color(0xFFBFBCBC)), - bottom: BorderSide(color: Color(0xFFBFBCBC)), - ), - boxShadow: [ - BoxShadow( - color: Color(0xFFF8AB14), - blurRadius: 0, - offset: Offset(0, 10), - spreadRadius: 0, - ) - ], - ), - ), - ), - Positioned( - left: 230, - top: 1, - child: Image.asset( - 'assets/images/Vector01.png', // Pfad zum Bild - height: 110, // Höhe des Bildes - width: 130, // Breite des Bildes - ), - ), - Positioned( - right: 30, - top: 12, - child: Container( - width: 32, - height: 32, - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 32, - height: 32, - decoration: BoxDecoration( - color: Color.fromARGB(196, 171, 170, 170), // Hintergrundfarbe des Buttons - shape: BoxShape.circle, // Runde Form - ), - child: IconButton( - padding: EdgeInsets.zero, // Entfernt zusätzlichen Abstand - icon: Icon(Icons.bookmark_border_outlined), - color: Colors.white, // Icon-Farbe - iconSize: 16, // Größe des Icons - onPressed: () { - // Aktion beim Drücken des Buttons - }, - ), - ), - ], - ), - ), - ), - - Positioned( - left: 15, - top: 14, - child: SizedBox( - //width: 55, - //height: 24, - child: Text( - 'Suxul', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0, - ), - ), - ), - ), - Positioned( - left: 92, - top: 14, - child: Text( - 'Weiberfasching', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - Positioned( - left: 15, - top: 90, - child: SizedBox( - //width: 196, - //height: 15, - child: Text( - 'Eintritt: Bis 21 Uhr frei', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w400, - height: 0, - ), - ), - ), - ), - Positioned( - left: 15, - top: 70, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: '20:30', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 18, - fontFamily: 'Inter', - fontWeight: FontWeight.w800, - height: 0.06, - ), - ), - ])))), - Positioned( - left: 15, - top: 45, - child: SizedBox( - width: 72.79, - height: 44.40, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: 'Beginn\n', - style: TextStyle( - color: Color(0xFF0A0A0A), - fontSize: 12, - fontFamily: 'Inter', - fontWeight: FontWeight.w200, - height: 0.14, - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - ], + EventCard2Section(), + const SizedBox(height: 20), + EventCard2Section(), + const SizedBox(height: 20), + EventCard2Section(), + const SizedBox(height: 20), + EventCard2Section(), + const SizedBox(height: 20), + EventCard2Section(), */ + ], ), ), ], - ), - ), - ], - )],),); + ),]) + ),),), + SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + return EventCard2Section( + title: events[index]['name'], + description: events[index]['description'], + location: events[index]['location']['name'], + start_time: extractTime24h(events[index]['time'][0]['start_date']), + ); + }, + childCount: events.length, + ),), + + ]); return Scaffold(backgroundColor: Colors.white, body: body, ); } +} +String extractTime24h(String timestamp) { + try { + DateTime dateTime = DateTime.parse(timestamp); + String hours = dateTime.hour.toString().padLeft(2, '0'); + String minutes = dateTime.minute.toString().padLeft(2, '0'); + return '$hours:$minutes'; + } catch (e) { + print('Error parsing timestamp: $e'); + return '--:--'; // or some other error indicator + } } \ No newline at end of file diff --git a/lib/screens/details_db.dart b/lib/screens/details_db.dart index 96a1323..9603dcd 100644 --- a/lib/screens/details_db.dart +++ b/lib/screens/details_db.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:learn_project/utils/class.dart'; -import 'package:learn_project/utils/widgets.dart'; +//import 'package:learn_project/utils/class.dart'; +//import 'package:learn_project/utils/widgets.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; -import 'dart:async'; +//import 'dart:async'; class DetailsPage extends StatelessWidget { diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 90b97b5..8469677 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -3,54 +3,93 @@ import 'package:learn_project/screens/details_db.dart'; import 'package:learn_project/utils/data.dart'; import 'package:learn_project/screens/subheader_Datepicker.dart'; import 'package:learn_project/screens/detail_widget.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; +import 'package:learn_project/main.dart'; + class HomePage extends StatelessWidget { const HomePage({super.key}); + Future>> _loadData() async { + final _data = await supabase.from('events').select(); + //get the id of the event + return _data; + //Create a date entry and connect it with the event + + // Überprüfe, ob der Insert erfolgreich war + } + Future>> fetchEvents(String category) async { + try { + final response = await supabase + .from("events") + //.innerJoin('event_category', 'events.id = event_category.event_id') + .select('id,name,description,detail,subheader,location(name),time(start_date),event_category(*), event_category!inner(events_id)') + .eq('event_category.category_id',category); + //select('id, name, cities(id, name)') + //find all events mit Ort und zusatzinfos die die Kathegorie haben welche ausgewählt wurde am heutigen Tag dann kommender Tag usw. + final test = response[0]['time'][0]['start_date']; + return (response as List).cast>(); + } catch (e) { + throw Exception('Failed to fetch data: $e'); + } + } @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; + + /*24 is for notification bar on Android*/ + final double itemHeight = (size.height - kToolbarHeight - 24) / 5; + final double itemWidth = size.width / 2.3; var body = SafeArea( child: Column( children: [ //Header Container HeaderSection(), - //Body Container Expanded( child: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverToBoxAdapter( - child: Container( - height: 35, - padding: const EdgeInsets.all(0), - child: ButtonSection(), // Dein Button-Bereich - ), + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverToBoxAdapter( + child: Container( + height: 35, + padding: const EdgeInsets.all(0), + child: ButtonSection(), // Dein Button-Bereich ), - ]; - }, - body:Column( - children:[ - GridView.builder( - shrinkWrap: true, // Damit der GridView korrekt in die Column passt - //physics: NeverScrollableScrollPhysics(), // Deaktiviert das Scrolling des GridView - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, // Anzahl der Spalten im Grid - ), - itemCount: Data.recipes.length, // Anzahl der Elemente im Grid - itemBuilder: (BuildContext context, int index) { + ), + ]; + }, + body: Column( + children: [ + GridView.builder( + shrinkWrap: + true, // Damit der GridView korrekt in die Column passt + //physics: NeverScrollableScrollPhysics(), // Deaktiviert das Scrolling des GridView + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: (itemWidth / + itemHeight), // Anzahl der Spalten im Grid + ), + itemCount: + Data.recipes.length, // Anzahl der Elemente im Grid + itemBuilder: (BuildContext context, int index) { return Padding( padding: const EdgeInsets.all(6.0), child: InkWell( - onTap: () { - Navigator.push( + onTap: () async { + /* List> events = + await _loadData(); */ + List> events2 = + await fetchEvents(Data.recipes[index].category); + Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => Frame28( - //recipe: Data.recipes[index], + events: events2, ))); }, child: Card( - color: Color.fromARGB(255, 249, 171, 21), + color: Data.recipes[index].color,//Color.fromARGB(255, 249, 171, 21), //color: Color.fromARGB(255, 253, 73, 73), //FD4949 //Nachtleben //color: Color.fromARGB(255, 80, 168, 250), //50A8FA//Kunst //color: Color.fromARGB(255, 80, 240, 250), //50F0FA //Sport @@ -76,11 +115,12 @@ class HomePage extends StatelessWidget { tag: Data.recipes[index].id, child: FadeInImage( image: AssetImage( - Data.recipes[index].imageUrl, - ), + Data.recipes[index].imageUrl, + ), fit: BoxFit.cover, placeholder: AssetImage( - 'assets/images/loading.gif', ), + 'assets/images/loading.gif', + ), ), ), ), @@ -102,141 +142,21 @@ class HomePage extends StatelessWidget { ), ); }, - ), - Image.asset( - 'assets/images/FooterFooter.png', // Pfad zum Bild - height: 127, // Höhe des Bildes - width: 390, // Breite des Bildes - ), - ], - ), - ), - ), - - - /* Expanded( - child: Column( - children:[ - Container( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), - height: 35, - child: ButtonSection(), - ), - Expanded( - child:GridView.builder( - shrinkWrap: false, - itemCount: Data.recipes.length, - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2), - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(6.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => DetailsPage( - //recipe: Data.recipes[index], - ))); - }, - child: Card( - color: Color.fromARGB(255, 249, 171, 21), - //color: Color.fromARGB(255, 253, 73, 73), //FD4949 //Nachtleben - //color: Color.fromARGB(255, 80, 168, 250), //50A8FA//Kunst - //color: Color.fromARGB(255, 80, 240, 250), //50F0FA //Sport - //color: Color.fromARGB(255, 130, 73, 253), //8249FD //Gesundheit - //color: Color.fromARGB(255, 253, 73, 73), //FD4949//Essen - //color: Color.fromARGB(255, 255, 0, 199), //FF00C7//Soziales - //color: Color.fromARGB(255, 66, 255, 0), //42FF00//Familie - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), - ), - child: Container( - width: MediaQuery.of(context).size.width / 2, - height: 50, - child: Column( - children: [ - Expanded( - child: ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(6.0), - topRight: Radius.circular(6.0), - ), - child: Hero( - tag: Data.recipes[index].id, - child: FadeInImage( - image: AssetImage( - Data.recipes[index].imageUrl), - fit: BoxFit.cover, - placeholder: AssetImage( - 'assets/images/loading.gif'), - ), - ), - ), - ), - Text( - Data.recipes[index].title, - style: TextStyle( - color: Colors.white, - fontSize: 20, - fontWeight: FontWeight.bold), - ), - Padding( - padding: const EdgeInsets.all(2.0), - ), - ], - ), - ), - ), - ), - ); - }), - ),Image.asset( - 'assets/images/FooterFooter.png', // Pfad zum Bild - height: 127, // Höhe des Bildes - width: 390, // Breite des Bildes - ),], - - ), - - ), */ - - - - //Footer Container - //Here you will get unexpected behaviour when keyboard pops-up. - //So its better to use `bottomNavigationBar` to avoid this. - /* Container( - padding: const EdgeInsets.all(8.0), - color: Colors.white, - alignment: Alignment.center, - child: - Image.asset( - 'assets/images/FooterFooter.png', // Pfad zum Bild - height: 127, // Höhe des Bildes - width: 390, // Breite des Bildes - ), - ), */ + ), + Image.asset( + 'assets/images/FooterFooter.png', // Pfad zum Bild + height: 127, // Höhe des Bildes + width: 390, // Breite des Bildes + ), + ], + ), + ), + ), ], ), ); return Scaffold( - /* appBar: AppBar( - centerTitle: true, - title: Text('Recipes'), - titleTextStyle: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold, fontSize: 20), - backgroundColor: Color(0xff263341), - actions: [ - IconButton( - icon: Icon(Icons.search), - onPressed: () {}, - ) - ], - ), */ backgroundColor: Colors.white, body: body, ); diff --git a/lib/screens/subheader_Datepicker.dart b/lib/screens/subheader_Datepicker.dart index 5c7dae2..1f7e450 100644 --- a/lib/screens/subheader_Datepicker.dart +++ b/lib/screens/subheader_Datepicker.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:learn_project/utils/helper_functions.dart'; class ButtonSection extends StatelessWidget { @override @@ -59,109 +60,780 @@ class HeaderSection extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: const EdgeInsets.fromLTRB(5, 2, 5, 5), - height: 76, - color: Colors.white, - alignment: Alignment.bottomLeft, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - height: 50, //height of button - //width of button - child: IconButton( - icon: Image.asset('assets/images/logo.png'), - onPressed: () {}, - ), - ), - const SizedBox( - //width of button - width: 10, - ), - SizedBox( - height: 10, //height of button - width: 20, //width of button - child: Icon(Icons.keyboard_arrow_down), - ), - const SizedBox( - //width of button - width: 10, - ), - SizedBox( - width: 100.0, - child: TextField( - controller: TextEditingController(text: "Ingolstadt"), - decoration: InputDecoration( - border: UnderlineInputBorder(), - ), - ), - ), - // const SizedBox( - // //width of button - // width: 40, - // ), - SizedBox(width:3), - Spacer(), - SizedBox( - height: 41, //height of button - //width of button - child: IconButton( - icon: const Icon(Icons.search), - onPressed: () {}, - ), - ), - const SizedBox( - height: 40, - child: VerticalDivider( - thickness: 1, - width: 20, - color: Colors.black, - ), - ), - SizedBox( - height: 50, //height of button - //width of button - child: IconButton( - icon: Image.asset('assets/images/Login.png'), - onPressed: () {}, - ), - ), - ]), - const Divider( - height: 1, - thickness: 1, - indent: 0, - endIndent: 0, - color: Colors.black, + padding: const EdgeInsets.fromLTRB(5, 2, 5, 5), + height: 76, + color: Colors.white, + alignment: Alignment.bottomLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + height: 50, //height of button + //width of button + child: IconButton( + icon: Image.asset('assets/images/logo.png'), + onPressed: () {}, + ), ), - - ], + const SizedBox( + //width of button + width: 10, + ), + SizedBox( + height: 10, //height of button + width: 20, //width of button + child: Icon(Icons.keyboard_arrow_down), + ), + const SizedBox( + //width of button + width: 10, + ), + SizedBox( + width: 100.0, + child: TextField( + controller: TextEditingController(text: "Ingolstadt"), + decoration: InputDecoration( + border: UnderlineInputBorder(), + ), + ), + ), + // const SizedBox( + // //width of button + // width: 40, + // ), + SizedBox(width: 3), + Spacer(), + SizedBox( + height: 41, //height of button + //width of button + child: IconButton( + icon: const Icon(Icons.search), + onPressed: () {}, + ), + ), + const SizedBox( + height: 40, + child: VerticalDivider( + thickness: 1, + width: 20, + color: Colors.black, + ), + ), + SizedBox( + height: 50, //height of button + //width of button + child: IconButton( + icon: Image.asset('assets/images/Login.png'), + onPressed: () {}, + ), + ), + ]), + const Divider( + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + color: Colors.black, + ), + ], + ), + ); + } +} + +class EventCard2Section extends StatelessWidget { + final String title; + final String description; + final String location; + final String start_time; + + const EventCard2Section({ + Key? key, + required this.title, + required this.description, + required this.location, + required this.start_time, + }) : super(key: key); + @override + Widget build(BuildContext context) { + return Container( + width: 379, + height: 120, + child: Stack( + children: [ + Positioned( + left: 0, + top: 0, + child: Container( + width: 360, + height: 110, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + border: Border( + left: BorderSide(width: 1, color: Color(0xFFBFBCBC)), + top: BorderSide(width: 1, color: Color(0xFFBFBCBC)), + right: BorderSide(color: Color(0xFFBFBCBC)), + bottom: BorderSide(color: Color(0xFFBFBCBC)), + ), + boxShadow: [ + BoxShadow( + color: Color(0xFFF8AB14), + blurRadius: 0, + offset: Offset(0, 10), + spreadRadius: 0, + ) + ], + ), ), - );}} -/* child: SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 30.0), - child: Column( - children: [ + ), + Positioned( + left: 230, + top: 1, + child: Image.asset( + 'assets/images/Vector01.png', // Pfad zum Bild + height: 110, // Höhe des Bildes + width: 130, // Breite des Bildes + ), + ), + Positioned( + right: 30, + top: 12, + child: Container( + width: 32, + height: 32, + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Container( - color: Colors.red, - height: 200.0, - alignment: Alignment.center, - child: Text("Content 1"), - ), - Container( - color: Colors.green, - height: 300.0, - alignment: Alignment.center, - child: Text("Content 1"), - ), - //TextField nearly at bottom - TextField( - decoration: InputDecoration(hintText: "Enter Text Here"), + width: 32, + height: 32, + decoration: BoxDecoration( + color: Color.fromARGB( + 196, 171, 170, 170), // Hintergrundfarbe des Buttons + shape: BoxShape.circle, // Runde Form + ), + child: IconButton( + padding: EdgeInsets.zero, // Entfernt zusätzlichen Abstand + icon: Icon(Icons.bookmark_border_outlined), + color: Colors.white, // Icon-Farbe + iconSize: 16, // Größe des Icons + onPressed: () { + // Aktion beim Drücken des Buttons + }, + ), ), ], ), - ), */ \ No newline at end of file + ), + ), + Positioned( + left: 15, + top: 14, + child: SizedBox( + //width: 55, + //height: 24, + child: Text( + location, + style: TextStyle( + color: Color(0xFF0A0A0A), + fontSize: 18, + fontFamily: 'Inter', + fontWeight: FontWeight.w800, + height: 0, + ), + ), + ), + ), + Positioned( + left: 92, + top: 14, + child: Text( + title, + style: TextStyle( + color: Color(0xFF0A0A0A), + fontSize: 18, + fontFamily: 'Inter', + fontWeight: FontWeight.w400, + height: 0, + ), + + ), + ), + Positioned( + left: 15, + top: 90, + child: SizedBox( + //width: 196, + //height: 15, + child: Text( + shortenText(description,30), + style: TextStyle( + color: Color(0xFF0A0A0A), + fontSize: 12, + fontFamily: 'Inter', + fontWeight: FontWeight.w400, + height: 0, + ), + ), + ), + ), + Positioned( + left: 15, + top: 70, + child: SizedBox( + width: 72.79, + height: 44.40, + child: Text.rich(TextSpan(children: [ + TextSpan( + text: start_time, + style: TextStyle( + color: Color(0xFF0A0A0A), + fontSize: 18, + fontFamily: 'Inter', + fontWeight: FontWeight.w800, + height: 0.06, + ), + ), + ])))), + Positioned( + left: 15, + top: 45, + child: SizedBox( + width: 72.79, + height: 44.40, + child: Text.rich( + TextSpan( + children: [ + TextSpan( + text: 'Beginn\n', + style: TextStyle( + color: Color(0xFF0A0A0A), + fontSize: 12, + fontFamily: 'Inter', + fontWeight: FontWeight.w200, + height: 0.14, + ), + ), + ], + ), + ), + ), + ), + ], + ), + ); + } +} + + + +class GesundheitWellnes extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Column( + children: [ + Container( + width: 167, + height: 130, + child: Stack( + children: [ + Positioned( + left: 0, + top: 0, + child: Container( + width: 167, + height: 130, + decoration: ShapeDecoration( + image: DecorationImage( + image: NetworkImage("https://via.placeholder.com/167x130"), + fit: BoxFit.cover, + ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + shadows: [ + BoxShadow( + color: Color(0xFFF9AB15), + blurRadius: 0, + offset: Offset(0, 10), + spreadRadius: 0, + ) + ], + ), + ), + ), + Positioned( + left: 16, + top: 15, + child: Text( + '64', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ), + Positioned( + left: 13, + top: 86, + child: Text( + 'Musik', + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontFamily: 'Inter', + fontWeight: FontWeight.w800, + height: 0, + ), + ), + ), + Positioned( + left: 127, + top: 9, + child: Container( + width: 31, + height: 31, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(), + ), + ), + ], + ), + ), + ], + ); + } +} + + +class TagSlider extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Column( + children: [ + Container( + width: 390, + height: 73, + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 73, + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 145, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Hip Hop/Rap', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 143, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'EDM/Elektro', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 102, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Elektro', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 180, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Klassische Musik', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 86, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Rock', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 187, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Singer/Songwriter', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 78, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Rap', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 123, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'DJ/Dance', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 78, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Pop', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 256, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Lateinamerikanische Musik', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 110, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Hip Hop', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 84, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Jazz', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 91, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Metal', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + Container( + width: 79, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide(width: 1), + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'R6B', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontFamily: 'Inter', + fontWeight: FontWeight.w500, + height: 0, + ), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ], + ); + } +} \ No newline at end of file diff --git a/lib/utils/class.dart b/lib/utils/class.dart index 6241791..d2c0dc1 100644 --- a/lib/utils/class.dart +++ b/lib/utils/class.dart @@ -1,3 +1,5 @@ +import 'dart:ui'; + class Nutrients { String name; String weight; @@ -6,7 +8,8 @@ class Nutrients { } class Recipe { - String id, imageUrl, title; + String id, imageUrl, title,category; + Color color; List steps; List ingredients; List nutrients; @@ -16,5 +19,7 @@ class Recipe { required this.imageUrl, required this.steps, required this.ingredients, - required this.nutrients}); + required this.nutrients, + required this.color, + required this.category}); } diff --git a/lib/utils/data.dart b/lib/utils/data.dart index a3ea1e2..fec3b8c 100644 --- a/lib/utils/data.dart +++ b/lib/utils/data.dart @@ -2,6 +2,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:learn_project/utils/class.dart'; +//import 'dart:convert'; +import 'package:learn_project/main.dart'; +import 'package:intl/intl.dart' as intl; +import 'package:supabase_flutter/supabase_flutter.dart'; const Duration fakeAPIDuration = Duration(milliseconds: 50); const Duration debounceDuration = Duration(milliseconds: 50); class Data { @@ -10,6 +14,8 @@ class Data { id: '1', title: 'Musik', imageUrl: 'assets/images/Musik.png', + color: Color.fromARGB(255, 249, 171, 21), //FD4949 //Musik + category: '34725c49-740b-45c5-8a51-7c742f92a621', nutrients: [ Nutrients(name: 'Calories', weight: '200', percent: 0.7), Nutrients(name: 'Protein', weight: '10gm', percent: 0.5), @@ -30,6 +36,8 @@ class Data { id: '2', title: 'Nachtleben', imageUrl: 'assets/images/Nachtleben.png', + color: Color.fromARGB(255, 253, 73, 73), //FD4949 //Nachtleben + category: '2d8c714e-3290-4d8c-8a95-e3b100ad8599', nutrients: [ Nutrients(name: 'Calories', weight: '200', percent: 0.7), Nutrients(name: 'Protein', weight: '10gm', percent: 0.5), @@ -50,6 +58,8 @@ class Data { id: '3', title: 'Kunst & Kultur', imageUrl: 'assets/images/Soziales.png', + color: Color.fromARGB(255, 80, 168, 250), //50A8FA//Kunst + category: '09d1f862-2b56-47af-8ee6-3c50056e3fa2', nutrients: [ Nutrients(name: 'Calories', weight: '100', percent: 0.2), Nutrients(name: 'Protein', weight: '10gm', percent: 0.7), @@ -71,6 +81,8 @@ class Data { id: '4', title: 'Sport & Verein', imageUrl: 'assets/images/Sport.png', + color: Color.fromARGB(255, 80, 240, 250), //50F0FA //Sport + category: '', nutrients: [ Nutrients(name: 'Calories', weight: '200', percent: 0.7), Nutrients(name: 'Protein', weight: '10gm', percent: 0.5), @@ -88,9 +100,11 @@ class Data { '4 ounces milk' ]), Recipe( - id: '4', + id: '5', title: 'Gesundheit', imageUrl: 'assets/images/Gesundheit.png', + color: Color.fromARGB(255, 130, 73, 253), //8249FD //Gesundheit + category: '', nutrients: [ Nutrients(name: 'Calories', weight: '200', percent: 0.7), Nutrients(name: 'Protein', weight: '10gm', percent: 0.5), @@ -108,9 +122,11 @@ class Data { '4 ounces milk' ]), Recipe( - id: '4', + id: '6', title: 'Essen & Trinken', imageUrl: 'assets/images/Essen.png', + color: Color.fromARGB(255, 253, 73, 73), //FD4949//Essen + category: '', nutrients: [ Nutrients(name: 'Calories', weight: '200', percent: 0.7), Nutrients(name: 'Protein', weight: '10gm', percent: 0.5), @@ -129,12 +145,90 @@ class Data { ]), ]; - +//color: Color.fromARGB(255, 255, 0, 199), //FF00C7//Soziales + //color: Color.fromARGB(255, 66, 255, 0), //42FF00//Familie, } + +class SupabaseDataService { + + + Future>> fetchEvents(String cathegory) async { + try { + final response = await supabase + .from("events") + .select('id,name,description,detail,subheader,location(name),time(startdate)') + .eq('category(id)',cathegory); + //select('id, name, cities(id, name)') + //find all events mit Ort und zusatzinfos die die Kathegorie haben welche ausgewählt wurde am heutigen Tag dann kommender Tag usw. + return (response as List).cast>(); + } catch (e) { + throw Exception('Failed to fetch data: $e'); + } + } + + Future> fetchSingleRecord(String tableName, String id) async { + try { + final response = await supabase + .from(tableName) + .select() + .eq('id', id) + .single(); + + + return response as Map; + } catch (e) { + throw Exception('Failed to fetch record: $e'); + } + } + + /* Future insertData(String tableName, Map data) async { + try { + final response = await supabase + .from(tableName) + .insert(data); + + if (response.error != null) { + throw response.error!; + } + } catch (e) { + throw Exception('Failed to insert data: $e'); + } + } + + Future updateData(String tableName, String id, Map data) async { + try { + final response = await supabase + .from(tableName) + .update(data) + .eq('id', id); + + if (response.error != null) { + throw response.error!; + } + } catch (e) { + throw Exception('Failed to update data: $e'); + } + } + + Future deleteData(String tableName, String id) async { + try { + final response = await _supabase + .from(tableName) + .delete() + .eq('id', id); + + if (response.error != null) { + throw response.error!; + } + } catch (e) { + throw Exception('Failed to delete data: $e'); + } + } */ +} /* class _AsyncAutocomplete extends StatefulWidget { const _AsyncAutocomplete(); diff --git a/lib/utils/helper_functions.dart b/lib/utils/helper_functions.dart new file mode 100644 index 0000000..946eedc --- /dev/null +++ b/lib/utils/helper_functions.dart @@ -0,0 +1,19 @@ +String shortenText(String text, int maxLength) { + // Wenn der Text kürzer als die maximale Länge ist, gib den Text unverändert zurück + if (text.length <= maxLength) { + return text; + } + + // Den Text bis zur maximalen Länge abschneiden + String shortened = text.substring(0, maxLength); + + // Überprüfen, ob das Zeichen nach der abgeschnittenen Länge ein Leerzeichen ist + // Wenn nicht, das letzte vollständige Wort suchen und entfernen + int lastSpace = shortened.lastIndexOf(' '); + if (lastSpace != -1) { + shortened = shortened.substring(0, lastSpace); + } + + // Drei Punkte hinzufügen + return '$shortened...'; +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 16fea70..c4f87a9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -308,18 +308,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.4" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -348,18 +348,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.15.0" mime: dependency: transitive description: @@ -601,10 +601,10 @@ packages: dependency: transitive description: name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.7.2" timeago: dependency: "direct main" description: @@ -697,10 +697,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.1" + version: "14.2.5" web: dependency: transitive description: