Haupt Kategory hinzugefügt => Aufgabe soweit erledigt

This commit is contained in:
Niklas 2024-10-05 14:12:35 +02:00
parent 3857d46953
commit dc4ff86622
5 changed files with 40 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:Emma_home/screens/subheader_Datepicker.dart';
//import 'package:learn_project/main.dart';
import 'package:intl/intl.dart';
import 'package:Emma_home/utils/data.dart';
//import 'package:supabase_flutter/supabase_flutter.dart';
class Frame28 extends StatelessWidget {
@ -94,7 +95,8 @@ class Frame28 extends StatelessWidget {
location: events[index]['location']['name'],
start_time:
extractTime24h(events[index]['time'][0]['start_date']),
color: color,
color: extractColor(events[index]['main_category_id']),
);
},
childCount: events.length,
@ -119,3 +121,17 @@ String extractTime24h(String timestamp) {
return '--:--'; // or some other error indicator
}
}
//TODO: Color muss anhand der Categorie entschieden werden
// Also herauslesen welche Category das Event hat
// Dann den richtigen Eintrag in Data identifizieren udn die Farbe auswählen
Color extractColor(String categoryID)
{
final result = Data.recipes.where((recipe) => recipe.category == categoryID).firstOrNull;
Color categorie_color= Color.fromARGB(255, 255, 255, 255);
if (result!=null)
{
categorie_color=result.color;
}
return categorie_color;
}

View File

@ -25,7 +25,7 @@ class HomePage extends StatelessWidget {
.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)')
'id,name,description,detail,subheader,main_category_id,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;
@ -45,7 +45,7 @@ class HomePage extends StatelessWidget {
.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)')
'id,name,description,detail,subheader,main_category_id,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
@ -253,7 +253,7 @@ class HomePage extends StatelessWidget {
),
Positioned(
left: 13,
top: Data.recipes[index].textheight, //86,
top: Data.recipes[index].textheight, //86, //TODO Bootom?
child:
Container(
width: itemWidth-20,// Set a fixed width or use constraints

View File

@ -1,3 +1,6 @@
import 'dart:math';
import 'package:flutter/material.dart';
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) {
@ -16,4 +19,15 @@ String shortenText(String text, int maxLength) {
// Drei Punkte hinzufügen
return '$shortened...';
}
class ScaleSize {
static double textScaleFactor(BuildContext context, {double maxTextScaleFactor = 2}) {
final width = MediaQuery.of(context).size.width;
double val = (width / 1400) * maxTextScaleFactor;
return max(1, min(val, maxTextScaleFactor));
}
}

View File

@ -1,9 +1,13 @@
import Cocoa
import FlutterMacOS
@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}

View File

@ -39,6 +39,7 @@ dependencies:
timeago: ^3.1.0
image_picker: ^1.1.2
dev_dependencies:
flutter_test:
sdk: flutter