Scrollen kann nun aktiviert werden. Habe die erste Seite soweit responsive angepasst.
This commit is contained in:
parent
f26f257e02
commit
6504b7d0c4
|
|
@ -10,6 +10,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|||
//import 'package:learn_project/screens/splash_page.dart';
|
||||
|
||||
import 'utils/constants.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
|
@ -23,6 +24,7 @@ Future<void> main() async {
|
|||
anonKey : dotenv.env['NEXT_PUBLIC_SUPABASE_ANON_KEY'] ?? 'default_key',
|
||||
|
||||
);
|
||||
await autoLogin();
|
||||
var singleCategories = Categories.instance;
|
||||
singleCategories.updateCategoryAmount('Ingosltadt');
|
||||
runApp(
|
||||
|
|
@ -39,12 +41,27 @@ const timeSpan = "";
|
|||
|
||||
/// Error message to display the user when unexpected error occurs.
|
||||
const unexpectedErrorMessage = 'Unexpected error occurred.';
|
||||
|
||||
Future<void> autoLogin() async {
|
||||
final error = await supabase.auth.signInWithPassword(
|
||||
email: dotenv.env['NEXT_PRIVATE_SUPABASE_APPUSER'] ?? 'default_url',
|
||||
password: dotenv.env['NEXT_PRIVATE_SUPABASE_APPPWD'] ?? 'default_url',
|
||||
);
|
||||
if (error != null) {
|
||||
print('Login fehlgeschlagen: ${error!}');
|
||||
} else {
|
||||
print('AppUser erfolgreich eingeloggt');
|
||||
}
|
||||
}
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//set initial orentation to langscape
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitDown,
|
||||
DeviceOrientation.portraitUp,
|
||||
]);
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
//title: 'Recipes',
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ class Frame28 extends StatelessWidget {
|
|||
final Category category;
|
||||
|
||||
const Frame28({super.key, required this.events, required this.color, required this.screen_size, required this.category});
|
||||
|
||||
|
||||
void toggleExpanded() {
|
||||
}
|
||||
/* void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
|
|
@ -103,7 +105,7 @@ class Frame28 extends StatelessWidget {
|
|||
Container(
|
||||
height: 35,
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: const TimeButtonSection(), // Dein Button-Bereich
|
||||
child: TimeButtonSection(onToggle: toggleExpanded), // Dein Button-Bereich
|
||||
),
|
||||
Container(
|
||||
height: 10,
|
||||
|
|
@ -183,6 +185,18 @@ class Frame28 extends StatelessWidget {
|
|||
childCount: events.length,
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children:[
|
||||
LostEvents(),
|
||||
Container(
|
||||
height: 20),
|
||||
Image.asset(
|
||||
'assets/images/FooterFooter.png', // Pfad zum Bild
|
||||
//height: 120, // Höhe des Bildes
|
||||
width: 390, // Breite des Bildes
|
||||
),]),
|
||||
),
|
||||
]);
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
|
|||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:Emma_home/main.dart';
|
||||
import 'package:Emma_home/utils/data.dart';
|
||||
import 'dart:math';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
|
@ -16,6 +17,12 @@ class HomePage extends StatefulWidget {
|
|||
}
|
||||
class _HomePage extends State<HomePage> {
|
||||
late Future<void> _fetchDataFuture;
|
||||
bool isScrollable = false;
|
||||
void toggleExpanded() {
|
||||
setState(() {
|
||||
isScrollable = !isScrollable;
|
||||
});
|
||||
}
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -97,17 +104,33 @@ class _HomePage extends State<HomePage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
//var appBarHeight = Scaffold.of(context).appBarMaxHeight;
|
||||
|
||||
//var single_categories = Categories.instance;
|
||||
//single_categories.updateCategoryAmount('Ingolstadt');
|
||||
|
||||
/*24 is for notification bar on Android*/
|
||||
//final double itemHeight = (size.height - kToolbarHeight - 270) / 4; 290 for iOs 230 android
|
||||
final double itemHeight = (size.height - 240-90) / 4;
|
||||
final double itemWidth = (size.width-40)/ 2;
|
||||
// Verfügbarer Bereich auf dem Bildschirm
|
||||
|
||||
|
||||
// ScrollController und Status-Variable
|
||||
ScrollController _scrollController = ScrollController();
|
||||
|
||||
|
||||
|
||||
// Verfügbarer Bereich auf dem Bildschirm
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
double statusBarHeight = MediaQuery.of(context).padding.top;
|
||||
double HeaderHeight = 60;
|
||||
double TimeButtonHeight = 35;
|
||||
double TimeButtonpadding = 20;
|
||||
double FooterHeight = 91;
|
||||
double bottomPadding = MediaQuery.of(context).padding.bottom;
|
||||
final staticContentheight=statusBarHeight+HeaderHeight +TimeButtonHeight+TimeButtonpadding+FooterHeight+bottomPadding;
|
||||
double amaountOfCategoryLines = 4;//singleCategories.categories.length/2;
|
||||
double paddingHeight = 10;
|
||||
double shaddowHeight = 10;
|
||||
|
||||
final dynamicContentHeight= ((amaountOfCategoryLines+1)*paddingHeight)+ (amaountOfCategoryLines*shaddowHeight);
|
||||
final resultHeightRemove= staticContentheight+dynamicContentHeight;
|
||||
final int itemHeight = ((screenHeight - resultHeightRemove)/4).toInt();//240-90) / 4;
|
||||
final double itemWidth = (size.width-40)/ 2;
|
||||
MediaQueryData queryData;
|
||||
queryData = MediaQuery.of(context);
|
||||
|
||||
|
|
@ -178,31 +201,28 @@ class _HomePage extends State<HomePage> {
|
|||
flexibleSpace: Container(),
|
||||
);
|
||||
var body = SafeArea(
|
||||
|
||||
child:Consumer<Categories>(
|
||||
builder: (context, singleCategories, child) {return
|
||||
Column(
|
||||
SingleChildScrollView(
|
||||
physics: isScrollable
|
||||
? AlwaysScrollableScrollPhysics()
|
||||
: NeverScrollableScrollPhysics(),
|
||||
child:Column(
|
||||
children: <Widget>[
|
||||
//Header Container
|
||||
//HeaderSection(),
|
||||
Container(height: 10),
|
||||
//Body Container
|
||||
Expanded(
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder:
|
||||
(BuildContext context, bool innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
Container(height: 14),
|
||||
Container(
|
||||
height: 35,
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: const TimeButtonSection(), // Dein Button-Bereich
|
||||
child: TimeButtonSection(onToggle: toggleExpanded), // Dein Button-Bereich
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
body: Column(
|
||||
children: [
|
||||
GridView.builder(
|
||||
GridView.builder(
|
||||
controller: _scrollController,
|
||||
physics: isScrollable
|
||||
? AlwaysScrollableScrollPhysics()
|
||||
: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap:
|
||||
true, // Damit der GridView korrekt in die Column passt
|
||||
//physics: NeverScrollableScrollPhysics(), // Deaktiviert das Scrolling des GridView
|
||||
|
|
@ -236,7 +256,7 @@ class _HomePage extends State<HomePage> {
|
|||
child:
|
||||
SizedBox(
|
||||
width: itemWidth,
|
||||
height: itemHeight,
|
||||
height: itemHeight.toDouble(),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
|
|
@ -244,7 +264,7 @@ class _HomePage extends State<HomePage> {
|
|||
top: 0,
|
||||
child: Container(
|
||||
width: itemWidth,
|
||||
height: itemHeight,
|
||||
height: itemHeight.toDouble(),
|
||||
decoration: ShapeDecoration(
|
||||
image: DecorationImage(
|
||||
image:
|
||||
|
|
@ -326,6 +346,7 @@ class _HomePage extends State<HomePage> {
|
|||
);
|
||||
},
|
||||
),
|
||||
//Body Container
|
||||
Container(
|
||||
height: 20,),
|
||||
Image.asset(
|
||||
|
|
@ -335,9 +356,6 @@ class _HomePage extends State<HomePage> {
|
|||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);})
|
||||
);
|
||||
|
||||
|
|
@ -347,5 +365,11 @@ class _HomePage extends State<HomePage> {
|
|||
body: Consumer<Categories>(
|
||||
builder: (context, singleCategories, child) {return body;}),
|
||||
);
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
|||
import 'package:Emma_home/utils/helper_functions.dart';
|
||||
|
||||
class TimeButtonSection extends StatefulWidget {
|
||||
const TimeButtonSection({super.key});
|
||||
const TimeButtonSection({required this.onToggle, Key? key}) : super(key: key);
|
||||
final VoidCallback onToggle;
|
||||
|
||||
|
||||
@override
|
||||
_TimeButtonSection createState() => _TimeButtonSection();
|
||||
|
|
@ -48,6 +50,7 @@ class _TimeButtonSection extends State<TimeButtonSection> {
|
|||
_isToMorrowActive = !_isToMorrowActive;
|
||||
_isWEActive = false;
|
||||
});
|
||||
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: _isToMorrowActive ? Colors.black : Colors.white,
|
||||
|
|
@ -86,7 +89,7 @@ class _TimeButtonSection extends State<TimeButtonSection> {
|
|||
),
|
||||
// Button with calendar icon
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
onPressed: widget.onToggle,
|
||||
icon: const Icon(Icons.calendar_today, color: Colors.black),
|
||||
),
|
||||
],
|
||||
|
|
@ -1546,7 +1549,8 @@ class Event_Card extends StatelessWidget {
|
|||
class LostEvents extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
return Container(
|
||||
child:Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 350,
|
||||
|
|
@ -1651,6 +1655,6 @@ class LostEvents extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -766,5 +766,5 @@ packages:
|
|||
source: hosted
|
||||
version: "2.0.3"
|
||||
sdks:
|
||||
dart: ">=3.4.0 <4.0.0"
|
||||
dart: ">=3.4.4 <4.0.0"
|
||||
flutter: ">=3.22.0"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.2.4 <4.0.0'
|
||||
sdk: '>=3.4.4 <4.0.0'
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
|
|
@ -34,12 +34,12 @@ dependencies:
|
|||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
cupertino_icons: ^1.0.6
|
||||
supabase_flutter: ^2.7.0
|
||||
timeago: ^3.1.0
|
||||
image_picker: ^1.1.2
|
||||
provider: ^6.0.5
|
||||
flutter_dotenv: ^5.1.0
|
||||
flutter_dotenv: ^5.2.1
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
|||
Loading…
Reference in New Issue