New pallette!

This commit is contained in:
Andrew 2023-03-05 19:14:18 +07:00
parent 8a586f0fe6
commit 57004048e5
3 changed files with 555 additions and 248 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:huacu_mobile/game_pallete.dart';
import 'package:huacu_mobile/models/auth_data.dart';
import 'package:huacu_mobile/models/chat_entry.dart';
import 'package:huacu_mobile/models/game.dart';
@ -118,7 +119,7 @@ class _GamePageState extends State<GamePage> {
constrained: false,
boundaryMargin: const EdgeInsets.all(800),
maxScale: 0.8,
minScale: 0.4,
minScale: 0.3,
child:
isGuesser ? _generateGameField() : _generateStaticField(),
),
@ -207,67 +208,68 @@ class _GamePageState extends State<GamePage> {
}
Widget _generateGameField() {
const alphabet = "ABCDEFGHIJKLMNOPQRST";
return Container(
width: (alphabet.length + 3) * 100,
height: 1300,
width: (palletteWidth + 2) * 100,
height: (palletteAlphabet.length + 2) * 100,
padding: const EdgeInsets.all(10),
child: Stack(
children: [
for (int i = 0; i < alphabet.length; i++)
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
for (int j = 0; j < palletteWidth; j++)
Positioned(
left: (i + 1) * 100.0,
top: (j + 1) * 100.0,
left: (j + 1) * 100.0,
top: (i + 1) * 100.0,
child: ColorPlate(
plateName: "${alphabet[i]}$j",
plateName: "${palletteAlphabet[i]}${j + 1}",
size: 90,
onSelected: _onPlateSelected,
),
),
// Now I need to generate letters and numbers around field
for (int i = 0; i < alphabet.length; i++)
for (int i = 1; i <= palletteWidth; i++)
Positioned(
left: (i + 1) * 100.0,
left: i * 100.0,
top: 0,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text(alphabet[i], style: const TextStyle(fontSize: 40)),
child: Text("$i", style: const TextStyle(fontSize: 40)),
),
),
for (int i = 0; i < alphabet.length; i++)
for (int i = 1; i <= palletteWidth; i++)
Positioned(
left: (i + 1) * 100.0,
top: 1100,
left: i * 100.0,
top: (palletteAlphabet.length + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text(alphabet[i], style: const TextStyle(fontSize: 40)),
child: Text("$i", style: const TextStyle(fontSize: 40)),
),
),
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
Positioned(
left: 0,
top: (j + 1) * 100.0,
top: (i + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text("$j", style: const TextStyle(fontSize: 40)),
child: Text(palletteAlphabet[i],
style: const TextStyle(fontSize: 40)),
),
),
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
Positioned(
left: (alphabet.length + 1) * 100,
top: (j + 1) * 100.0,
left: (palletteWidth + 1) * 100,
top: (i + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text("$j", style: const TextStyle(fontSize: 40)),
child: Text(palletteAlphabet[i],
style: const TextStyle(fontSize: 40)),
),
),
],
@ -276,67 +278,68 @@ class _GamePageState extends State<GamePage> {
}
Widget _generateStaticField() {
const alphabet = "ABCDEFGHIJKLMNOPQRST";
return Container(
width: (alphabet.length + 3) * 100,
height: 1300,
width: (palletteWidth + 2) * 100,
height: (palletteAlphabet.length + 2) * 100,
padding: const EdgeInsets.all(10),
child: Stack(
children: [
for (int i = 0; i < alphabet.length; i++)
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
for (int j = 0; j < palletteWidth; j++)
Positioned(
left: (i + 1) * 100.0,
top: (j + 1) * 100.0,
left: (j + 1) * 100.0,
top: (i + 1) * 100.0,
child: StaticColorPlate(
plateName: "${alphabet[i]}$j",
plateName: "${palletteAlphabet[i]}${j + 1}",
size: 90,
marked: guessedColors.contains("${alphabet[i]}$j"),
marked:
guessedColors.contains("${palletteAlphabet[i]}${j + 1}"),
),
),
// Now I need to generate letters and numbers around field
for (int i = 0; i < alphabet.length; i++)
for (int i = 1; i <= palletteWidth; i++)
Positioned(
left: (i + 1) * 100.0,
left: i * 100.0,
top: 0,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text(alphabet[i], style: const TextStyle(fontSize: 40)),
child: Text("$i", style: const TextStyle(fontSize: 40)),
),
),
for (int i = 0; i < alphabet.length; i++)
for (int i = 1; i <= palletteWidth; i++)
Positioned(
left: (i + 1) * 100.0,
top: 1100,
left: i * 100.0,
top: (palletteAlphabet.length + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text(alphabet[i], style: const TextStyle(fontSize: 40)),
child: Text("$i", style: const TextStyle(fontSize: 40)),
),
),
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
Positioned(
left: 0,
top: (j + 1) * 100.0,
top: (i + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text("$j", style: const TextStyle(fontSize: 40)),
child: Text(palletteAlphabet[i],
style: const TextStyle(fontSize: 40)),
),
),
for (int j = 0; j < 10; j++)
for (int i = 0; i < palletteAlphabet.length; i++)
Positioned(
left: (alphabet.length + 1) * 100,
top: (j + 1) * 100.0,
left: (palletteWidth + 1) * 100,
top: (i + 1) * 100,
child: Container(
width: 90,
height: 90,
alignment: Alignment.center,
child: Text("$j", style: const TextStyle(fontSize: 40)),
child: Text(palletteAlphabet[i],
style: const TextStyle(fontSize: 40)),
),
),
],