...
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sudoku_app/models/sudoku_theme.dart'; // 👈 [추가]
|
||||
import 'package:sudoku_app/models/sudoku_theme.dart'; // 👈 테마 모델 임포트
|
||||
|
||||
class SudokuBoard extends StatelessWidget {
|
||||
final int blockSize;
|
||||
final SudokuTheme theme; // 👈 [추가]
|
||||
final List<int> cells; // 👈 [수정] List<String> -> List<int>
|
||||
final List<int> originalCells; // 👈 [수정] List<String> -> List<int>
|
||||
final SudokuTheme theme; // 👈 이번 게임의 테마
|
||||
final List<int> cells; // 👈 List<int> (0, 1, 10...)
|
||||
final List<int> originalCells; // 👈 List<int> (0, 1, 10...)
|
||||
final int? selectedIndex;
|
||||
final int? selectedNumberPad;
|
||||
final int? selectedNumberPad; // 10진수 숫자 (1, 10...)
|
||||
final Set<int> incorrectCells;
|
||||
final Function(int) onCellTapped;
|
||||
|
||||
const SudokuBoard({
|
||||
super.key,
|
||||
required this.blockSize,
|
||||
required this.theme, // 👈 [추가]
|
||||
required this.theme,
|
||||
required this.cells,
|
||||
required this.originalCells,
|
||||
required this.selectedIndex,
|
||||
@@ -26,6 +26,7 @@ class SudokuBoard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int gridSize = blockSize * blockSize;
|
||||
// 그리드 크기에 따라 폰트 크기 동적 조절
|
||||
final double fontSize = (gridSize > 9) ? (gridSize > 16 ? 12 : 16) : 24;
|
||||
|
||||
return AspectRatio(
|
||||
@@ -40,16 +41,18 @@ class SudokuBoard extends StatelessWidget {
|
||||
int row = index ~/ gridSize;
|
||||
int col = index % gridSize;
|
||||
|
||||
int cellValue = cells[index]; // 👈 [수정] 0, 1, 10...
|
||||
bool isEditable = (originalCells[index] == 0); // 👈 [수정] "0" -> 0
|
||||
int cellValue = cells[index]; // 0, 1, 10...
|
||||
bool isEditable = (originalCells[index] == 0);
|
||||
bool isSelected = (index == selectedIndex);
|
||||
|
||||
bool isHighlighted = (cellValue != 0 && // 👈 [수정]
|
||||
// int == int 비교
|
||||
bool isHighlighted = (cellValue != 0 &&
|
||||
selectedNumberPad != null &&
|
||||
cellValue == selectedNumberPad); // 👈 [수정] int == int 비교
|
||||
cellValue == selectedNumberPad);
|
||||
|
||||
bool isIncorrect = incorrectCells.contains(index);
|
||||
|
||||
// blockSize에 따른 동적 보더
|
||||
BorderSide thickBorder = const BorderSide(color: Colors.black, width: 2.0);
|
||||
BorderSide thinBorder = const BorderSide(color: Colors.grey, width: 0.5);
|
||||
|
||||
@@ -75,7 +78,7 @@ class SudokuBoard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
// 🔽 [수정] 0이면 비우고, 아니면 테마 기호("1", "A", "🍎") 표시
|
||||
// 0이면 비우고, 아니면 테마 기호("1", "A", "🍎") 표시
|
||||
cellValue == 0 ? '' : theme.getSymbol(cellValue),
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
|
||||
Reference in New Issue
Block a user