From 4aa6dc0bb1d8720fb3e32647101bc9e0ad567934 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 3 Oct 2024 23:12:51 +0200 Subject: [PATCH] =?UTF-8?q?neue=20Variante=20hab=20den=20Header=20nun=20in?= =?UTF-8?q?=20die=20Appbar=20eingef=C3=BCgt=20also=20abgewandelt.=20Evtl.?= =?UTF-8?q?=20ist=20das=20Logo=20zu=20klein.=20FUnktional=20kalppt=20das?= =?UTF-8?q?=20mit=20dem=20Header=20noch=20nicht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/Musik_Icon.png | Bin 0 -> 480 bytes lib/main.dart | 2 + lib/screens/MainScreen.dart | 132 +++++++++++++++++++++++++++++++++++ lib/screens/home.dart | 115 ++++++++++++++++++++++++++++-- 4 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 assets/images/Musik_Icon.png create mode 100644 lib/screens/MainScreen.dart diff --git a/assets/images/Musik_Icon.png b/assets/images/Musik_Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c2080564d8521987e1d5dc4105e7f887277db4d9 GIT binary patch literal 480 zcmV<60U!Q}P)P000;W1^@s654Bdt00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yP=Z1 zO@M#ET}Dhnw8TfEkul?g_)dJoAHX+zAr8b*etY6UsPiW=SMYV`#1%1vQpBSOY$T57 z8_%Q`-9fY_W-y3}#d0)a@`HOXz=->q_(c4~3Sa}j#!Fx^m1#@`@Z#2+e-hB_++JrR0bcetWLxLGbQeuq3*FR9wQX)E`;z%AF2_>9DX=0M+F5gA)V zPG>9G)X0PGY%Q1Wv8{}4O306CFb|H|i>AT!6h_RtIia4w2FqYXm!&OlFtQRqAka~B zS#fP!q(536uJ0tRKdC)_f0i30x-#dF1f!CyA7soe`-Q3Pk67tAT7+-U W4t46R(q<3<0000 _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, ); }