super_tik_tac_toe/lib/main.dart

82 lines
2.2 KiB
Dart
Raw Normal View History

2024-12-06 15:33:35 -05:00
import 'package:flutter/material.dart';
2024-12-21 06:36:11 -05:00
import 'clasic.dart';
2024-12-06 15:33:35 -05:00
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
2024-12-06 21:21:10 -05:00
title: 'Super Tic-Tac-Toe',
2024-12-06 15:33:35 -05:00
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
2024-12-06 21:21:10 -05:00
home: const MyHomePage(title: 'Local Tic Tac Toe'),
2024-12-06 15:33:35 -05:00
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
2024-12-21 06:59:12 -05:00
enum GameType { classicTTC, superTTC }
2024-12-06 15:33:35 -05:00
class _MyHomePageState extends State<MyHomePage> {
2024-12-21 06:59:12 -05:00
GameType type = GameType.classicTTC;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
2024-12-06 15:33:35 -05:00
@override
Widget build(BuildContext context) {
return Scaffold(
2024-12-21 06:36:11 -05:00
drawer: Drawer(
2024-12-21 06:59:12 -05:00
key: _scaffoldKey,
2024-12-21 06:36:11 -05:00
child: ListView(
2024-12-21 06:59:12 -05:00
children: [
const DrawerHeader(
child: Text(
"Game Types",
style: TextStyle(fontSize: 25),
),
),
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);
}),
],
)),
2024-12-21 06:36:11 -05:00
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Padding(
2024-12-06 21:21:10 -05:00
padding: const EdgeInsets.all(10),
2024-12-21 06:59:12 -05:00
child: type == GameType.classicTTC
? const ClassicGame()
: const Center(child: Text("Under Construction")),
2024-12-21 06:36:11 -05:00
));
2024-12-20 12:41:49 -05:00
}
2024-12-06 15:33:35 -05:00
}