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