drawer navigation

This commit is contained in:
Andrei Stoica 2024-12-21 06:59:12 -05:00
parent c133eda312
commit a9df9ab96b
1 changed files with 34 additions and 9 deletions

View File

@ -30,27 +30,52 @@ class MyHomePage extends StatefulWidget {
State<MyHomePage> createState() => _MyHomePageState(); State<MyHomePage> createState() => _MyHomePageState();
} }
enum GameType { classicTTC, superTTC }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
GameType type = GameType.classicTTC;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
drawer: Drawer( drawer: Drawer(
key: _scaffoldKey,
child: ListView( child: ListView(
children: [ children: [
DrawerHeader( const DrawerHeader(
child: Text("Game Types"), child: Text(
), "Game Types",
ListTile(title: Text("Clasic")), style: TextStyle(fontSize: 25),
ListTile(title: Text("Super")), ),
], ),
)), ListTile(
title: const Text("Classic"),
onTap: () {
setState(() {
type = GameType.classicTTC;
});
Navigator.pop(context);
},
),
ListTile(
title: const Text("Super"),
onTap: () {
setState(() {
type = GameType.superTTC;
});
Navigator.pop(context);
}),
],
)),
appBar: AppBar( appBar: AppBar(
title: Text(widget.title), title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.inversePrimary, backgroundColor: Theme.of(context).colorScheme.inversePrimary,
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: ClassicGame(), child: type == GameType.classicTTC
? const ClassicGame()
: const Center(child: Text("Under Construction")),
)); ));
} }
} }