Files
OpenMediacenterMobileFlutter/lib/DrawerPage.dart
T

112 lines
2.7 KiB
Dart
Raw Normal View History

2022-04-15 21:57:15 +02:00
import 'package:flutter/material.dart';
2022-08-28 18:48:53 +02:00
import 'navigation/categorie_screen.dart';
import 'navigation/shufflescreen.dart';
import 'navigation/video_feed.dart';
2022-04-15 21:57:15 +02:00
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();
}
2022-08-28 18:48:53 +02:00
enum Section { HOME, SHUFFLE, LOGOUT, CATEGORIE }
2022-04-15 21:57:15 +02:00
class _DrawerPageState extends State<DrawerPage> {
2022-08-25 19:48:09 +02:00
Section _sec = Section.HOME;
2022-04-15 21:57:15 +02:00
@override
Widget build(BuildContext context) {
Widget body;
String title;
2022-08-25 19:48:09 +02:00
switch (_sec) {
2022-04-15 21:57:15 +02:00
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;
2022-08-28 18:48:53 +02:00
case Section.CATEGORIE:
body = CategorieScreen();
title = "Categories";
break;
2022-04-15 21:57:15 +02:00
}
2022-08-25 19:48:09 +02:00
final loginCtx = LoginContext.of(context);
2022-04-15 21:57:15 +02:00
return Scaffold(
2022-08-25 22:48:44 +02:00
appBar: AppBar(
title: Text(title),
actions: [
IconButton(
onPressed: () {
loginCtx.onLoggin(false);
Token.getInstance().setToken("", "");
},
icon: const Icon(Icons.logout))
],
),
2022-04-15 21:57:15 +02:00
body: body,
drawer: Drawer(
child: ListView(children: [
ListTile(
title: const Text('Home'),
leading: const Icon(Icons.home),
onTap: () {
setState(() {
2022-08-25 19:48:09 +02:00
_sec = Section.HOME;
2022-04-15 21:57:15 +02:00
});
Navigator.pop(context);
},
),
ListTile(
title: const Text('Shuffle'),
leading: const Icon(Icons.update),
onTap: () {
setState(() {
2022-08-25 19:48:09 +02:00
_sec = Section.SHUFFLE;
2022-04-15 21:57:15 +02:00
});
Navigator.pop(context);
},
),
2022-08-28 18:48:53 +02:00
ListTile(
title: const Text('Categories'),
leading: const Icon(Icons.category),
onTap: () {
setState(() {
_sec = Section.CATEGORIE;
});
Navigator.pop(context);
},
),
2022-04-15 21:57:15 +02:00
ListTile(
title: const Text('Settings'),
leading: const Icon(Icons.settings),
onTap: () {
setState(() {
2022-08-25 19:48:09 +02:00
_sec = Section.LOGOUT;
2022-04-15 21:57:15 +02:00
});
Navigator.pop(context);
},
),
]),
),
);
}
}