diff --git a/assets/images/Musik_Icon.png b/assets/images/Musik_Icon.png new file mode 100644 index 0000000..c208056 Binary files /dev/null and b/assets/images/Musik_Icon.png differ diff --git a/lib/main.dart b/lib/main.dart index 4a96f28..2dd093a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:learn_project/screens/home.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; +import 'screens/MainScreen.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'; @@ -42,6 +43,7 @@ class MyApp extends StatelessWidget { ), ), home: HomePage(), + //home: MainScreen(), ); } } diff --git a/lib/screens/MainScreen.dart b/lib/screens/MainScreen.dart new file mode 100644 index 0000000..27c6764 --- /dev/null +++ b/lib/screens/MainScreen.dart @@ -0,0 +1,132 @@ +import 'package:flutter/material.dart'; +import 'subheader_Datepicker.dart'; + +class MainScreen extends StatefulWidget { + @override + _MainScreenState createState() => _MainScreenState(); +} + +class _MainScreenState extends State with SingleTickerProviderStateMixin { + Widget _currentBody = HomeBody(); + + void _changeBody(Widget newBody) { + setState(() { + _currentBody = newBody; + }); + } + late TabController _tabController; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 2, vsync: this); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading:SizedBox( + height: 50, + width: 63, + child: IconButton( + icon: Image.asset('assets/images/logo.png'), + onPressed: () { + // Open drawer or perform action + }, + ),), + title: Row( + children: [ +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(), + ), + ), + ), + ], + ), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () { + // Perform search action + }, + ), + 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: () {}, + ), + ), + ], + bottom: PreferredSize( + preferredSize: Size.fromHeight(1.0), + child: Container( + color: Colors.black, + height: 1.0, + ), + ), + flexibleSpace: Container( + + ), + ), + body: _currentBody, + bottomNavigationBar: BottomAppBar( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconButton( + icon: Icon(Icons.home), + onPressed: () => _changeBody(HomeBody()), + ), + IconButton( + icon: Icon(Icons.settings), + onPressed: () => _changeBody(SettingsBody()), + ), + // Add more buttons as needed + ], + ), + ), + ); + } +} + +class HomeBody extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Center(child: Text('Home Screen')); + } +} + +class SettingsBody extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Center(child: Text('Settings Screen')); + } +} \ No newline at end of file diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 16d0f74..6213641 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -19,16 +19,55 @@ class HomePage extends StatelessWidget { } Future>> fetchEvents(String category) async { try { + final today = DateTime.now().toUtc().toString().split(' ')[0]; final response = await supabase .from("events") //.innerJoin('event_category', 'events.id = event_category.event_id') - .select('id,name,description,detail,subheader,location(name),time(event_id,start_date),event_category!inner(event_id)') + .select('id,name,description,detail,subheader,location(name),time!inner(*),event_category!inner(event_id)') .eq('event_category.category_id',category); //.gte('time.start_date', DateTime.now().toIso8601String().split('T')[0]) // Beginn des heutigen Tages //.lt('time.start_date', DateTime.now().add(Duration(days: 1)).toIso8601String().split('T')[0]); // Morgen; //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']; + //final test = response[0]['time'][0]['start_date']; + return (response as List).cast>(); + } catch (e) { + throw Exception('Failed to fetch data: $e'); + } + } + Future>> fetchEventsToday(String category) async { + try { + final today = DateTime.now().toUtc().toString().split(' ')[0]; + final response = await supabase + .from("events") + //.innerJoin('event_category', 'events.id = event_category.event_id') + .select('id,name,description,detail,subheader,location(name),time!inner(*),event_category!inner(event_id)') + .eq('event_category.category_id',category)//; + .eq('time.start_date', today); + //.gte('time.start_date', DateTime.now().toIso8601String().split('T')[0]) // Beginn des heutigen Tages + //.lt('time.start_date', DateTime.now().add(Duration(days: 1)).toIso8601String().split('T')[0]); // Morgen; + //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'); + } + } + Future>> fetchEventsTomorrow(String category) async { + try { + final today = DateTime.now().toUtc().toString().split(' ')[0]; + final response = await supabase + .from("events") + //.innerJoin('event_category', 'events.id = event_category.event_id') + .select('id,name,description,detail,subheader,location(name),time!inner(*),event_category!inner(event_id)') + .eq('event_category.category_id',category)//; + .eq('time.start_date', today); + //.gte('time.start_date', DateTime.now().toIso8601String().split('T')[0]) // Beginn des heutigen Tages + //.lt('time.start_date', DateTime.now().add(Duration(days: 1)).toIso8601String().split('T')[0]); // Morgen; + //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'); @@ -41,11 +80,78 @@ class HomePage extends StatelessWidget { /*24 is for notification bar on Android*/ final double itemHeight = (size.height - kToolbarHeight - 24) / 5; final double itemWidth = size.width / 2.3; + var appBar = AppBar( + leading:SizedBox( + height: 60, + width: 63, + child: IconButton( + icon: Image.asset('assets/images/logo.png'), + onPressed: () { + // Open drawer or perform action + }, + ),), + title: Row( + children: [ +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(), + ), + ), + ), + ], + ), + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () { + // Perform search action + }, + ), + 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: () {}, + ), + ), + ], + bottom: PreferredSize( + preferredSize: Size.fromHeight(1.0), + child: Container( + color: Colors.black, + height: 1.0, + ), + ), + flexibleSpace: Container( + + ), + ); var body = SafeArea( child: Column( children: [ //Header Container - HeaderSection(), + //HeaderSection(), + Container(height:10), //Body Container Expanded( child: NestedScrollView( @@ -83,7 +189,7 @@ class HomePage extends StatelessWidget { await _loadData(); */ List> events2 = await fetchEvents(Data.recipes[index].category); - Navigator.pushReplacement( + Navigator.push( context, MaterialPageRoute( builder: (context) => Frame28( @@ -154,6 +260,7 @@ class HomePage extends StatelessWidget { return Scaffold( backgroundColor: Colors.white, + appBar: appBar, body: body, ); }