2023-11-21 21:52:39 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-10 07:20:15 +01:00
|
|
|
import 'startpage.dart';
|
|
|
|
import 'recipeformpage.dart';
|
2023-11-21 21:52:39 +01:00
|
|
|
import 'menu.dart';
|
|
|
|
import 'menu_content.dart';
|
2024-01-10 07:20:15 +01:00
|
|
|
import 'recipesoverview.dart';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
import 'firebase_options.dart';
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await Firebase.initializeApp(
|
|
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
|
|
);
|
2023-11-21 21:52:39 +01:00
|
|
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Kochkomplize',
|
|
|
|
theme: ThemeData(
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.greenAccent),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
home: const MyHomePage(title: 'Kochkomplize'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
MenuContent? _selectedMenuContent;
|
|
|
|
|
2024-01-10 07:20:15 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_selectedMenuContent = Startpage(); // Initialisiere mit Startseite
|
|
|
|
}
|
|
|
|
|
2023-11-21 21:52:39 +01:00
|
|
|
void _onMenuItemSelected(String menuItem) {
|
|
|
|
setState(() {
|
|
|
|
switch (menuItem) {
|
|
|
|
case 'Meine Rezepte':
|
2024-01-10 07:20:15 +01:00
|
|
|
_selectedMenuContent = RecipesOverview();
|
|
|
|
break;
|
|
|
|
case 'Startseite':
|
|
|
|
_selectedMenuContent = Startpage();
|
2023-11-21 21:52:39 +01:00
|
|
|
break;
|
2024-01-10 07:20:15 +01:00
|
|
|
// case 'Texterkennung Bild':
|
|
|
|
// _selectedMenuContent = TextScan();
|
|
|
|
// break;
|
2023-11-21 21:52:39 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-01-10 07:20:15 +01:00
|
|
|
void _addRecipe() {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(builder: (context) => const Recipeformpage()),
|
|
|
|
);
|
2023-11-21 21:52:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
|
|
|
drawer: Menu(onMenuItemSelected: _onMenuItemSelected),
|
|
|
|
body: _selectedMenuContent?.build(context) ?? Container(),
|
2024-01-10 07:20:15 +01:00
|
|
|
floatingActionButton: _selectedMenuContent is RecipesOverview
|
|
|
|
? FloatingActionButton(
|
|
|
|
onPressed: _addRecipe,
|
|
|
|
tooltip: 'Rezept hinzufügen',
|
2023-11-21 21:52:39 +01:00
|
|
|
child: const Icon(Icons.add),
|
2024-01-10 07:20:15 +01:00
|
|
|
)
|
|
|
|
: null, // Kein Button für andere Seiten
|
2023-11-21 21:52:39 +01:00
|
|
|
);
|
|
|
|
}
|
2024-01-10 07:20:15 +01:00
|
|
|
}
|
|
|
|
|