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,18 +30,41 @@ 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",
style: TextStyle(fontSize: 25),
), ),
ListTile(title: Text("Clasic")), ),
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(
@ -50,7 +73,9 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
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")),
)); ));
} }
} }