display single tile

This commit is contained in:
Михаил Капелько
2026-06-01 19:37:13 +03:00
parent 471d81bca0
commit 2bcea6ab15
3 changed files with 57 additions and 13 deletions

1
abc/lib/tutFun.dart Symbolic link
View File

@@ -0,0 +1 @@
../../src/tutFun.dart

View File

@@ -1,22 +1,48 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'game.dart'; import 'game.dart';
import 'tutFun.dart';
void main() { void main() {
runApp(const MainApp()); runApp(const MainApp());
} }
class MainApp extends StatelessWidget { class MainApp extends StatelessWidget {
const MainApp({super.key}); const MainApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const MaterialApp( return const MaterialApp(
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: Text('Wow, nice, Hello World!'), //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,
);
}
} }

17
src/tutFun.dart Normal file
View File

@@ -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;
}