diff --git a/abc/lib/tutFun.dart b/abc/lib/tutFun.dart new file mode 120000 index 0000000..aa9d744 --- /dev/null +++ b/abc/lib/tutFun.dart @@ -0,0 +1 @@ +../../src/tutFun.dart \ No newline at end of file diff --git a/src/main.dart b/src/main.dart index 7d9ca9d..c132267 100644 --- a/src/main.dart +++ b/src/main.dart @@ -1,22 +1,48 @@ import 'package:flutter/material.dart'; - import 'game.dart'; +import 'tutFun.dart'; void main() { - runApp(const MainApp()); + runApp(const MainApp()); } class MainApp extends StatelessWidget { - const MainApp({super.key}); + const MainApp({super.key}); - @override - Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold( - body: Center( - child: Text('Wow, nice, Hello World!'), - ), - ), - ); - } + @override + Widget build(BuildContext context) { + return const MaterialApp( + home: Scaffold( + body: Center( + //child: Text('Wow, nice, Hello World!'), + child: Tile("A", HitType.hit), + ), + ), + ); + } +} + +class Tile extends StatelessWidget { + const Tile(this.letter, this.hitType, {super.key}); + + final String letter; + final HitType hitType; + + @override + Widget build(BuildContext context) { + return Container( + child: Center( + child: Text( + letter.toUpperCase(), + style: Theme.of(context).textTheme.titleLarge, + ), + ), + decoration: BoxDecoration( + border: Border.all(color: Colors.grey.shade300), + color: tutTileColor(hitType), + ), + height: 60, + width: 60, + ); + } } diff --git a/src/tutFun.dart b/src/tutFun.dart new file mode 100644 index 0000000..0f90d09 --- /dev/null +++ b/src/tutFun.dart @@ -0,0 +1,17 @@ +library; + +import 'package:flutter/material.dart'; +import 'game.dart'; + +Color tutTileColor(HitType t) { + if (t == HitType.hit) { + return Colors.green; + } + if (t == HitType.partial) { + return Colors.yellow; + } + if (t == HitType.miss) { + return Colors.grey; + } + return Colors.white; +}