import 'package:flutter/material.dart'; import 'navigation/categorie_screen.dart'; import 'navigation/shufflescreen.dart'; import 'navigation/video_feed.dart'; import 'api/token.dart'; import 'login/logincontext.dart'; class DrawerPage extends StatefulWidget { const DrawerPage({Key? key, required this.title}) : super(key: key); final String title; @override _DrawerPageState createState() => _DrawerPageState(); } enum Section { HOME, SHUFFLE, LOGOUT, CATEGORIE } class _DrawerPageState extends State { Section _sec = Section.HOME; @override Widget build(BuildContext context) { Widget body; String title; switch (_sec) { case Section.HOME: body = const VideoFeed(); title = widget.title; break; case Section.SHUFFLE: body = const ShuffleScreen(); title = "Shuffle"; break; case Section.LOGOUT: body = const Text("also todo"); title = "Settings"; break; case Section.CATEGORIE: body = CategorieScreen(); title = "Categories"; break; } final loginCtx = LoginContext.of(context); return Scaffold( appBar: AppBar( title: Text(title), actions: [ IconButton( onPressed: () { loginCtx.onLoggin(false); Token.getInstance().setToken("", ""); }, icon: const Icon(Icons.logout)) ], ), body: body, drawer: Drawer( child: ListView(children: [ ListTile( title: const Text('Home'), leading: const Icon(Icons.home), onTap: () { setState(() { _sec = Section.HOME; }); Navigator.pop(context); }, ), ListTile( title: const Text('Shuffle'), leading: const Icon(Icons.update), onTap: () { setState(() { _sec = Section.SHUFFLE; }); Navigator.pop(context); }, ), ListTile( title: const Text('Categories'), leading: const Icon(Icons.category), onTap: () { setState(() { _sec = Section.CATEGORIE; }); Navigator.pop(context); }, ), ListTile( title: const Text('Settings'), leading: const Icon(Icons.settings), onTap: () { setState(() { _sec = Section.LOGOUT; }); Navigator.pop(context); }, ), ]), ), ); } }