...
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
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<int> (0, 1, 10...)
|
||||
final List<int> originalCells; // 👈 List<int> (0, 1, 10...)
|
||||
final SudokuTheme theme;
|
||||
final List<int> cells;
|
||||
final List<int> originalCells;
|
||||
final int? selectedIndex;
|
||||
final int? selectedNumberPad; // 10진수 숫자 (1, 10...)
|
||||
final int? selectedNumberPad;
|
||||
final Set<int> incorrectCells;
|
||||
final Function(int) onCellTapped;
|
||||
|
||||
@@ -26,7 +26,6 @@ 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(
|
||||
@@ -41,18 +40,19 @@ class SudokuBoard extends StatelessWidget {
|
||||
int row = index ~/ gridSize;
|
||||
int col = index % gridSize;
|
||||
|
||||
int cellValue = cells[index]; // 0, 1, 10...
|
||||
int cellValue = cells[index];
|
||||
bool isEditable = (originalCells[index] == 0);
|
||||
bool isSelected = (index == selectedIndex);
|
||||
|
||||
// int == int 비교
|
||||
int selectedNumAsInt = selectedNumberPad ?? -1;
|
||||
String selectedNumAsSymbol = (selectedNumberPad != null) ? theme.getSymbol(selectedNumberPad!) : "";
|
||||
|
||||
bool isHighlighted = (cellValue != 0 &&
|
||||
selectedNumberPad != null &&
|
||||
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);
|
||||
|
||||
@@ -61,15 +61,14 @@ class SudokuBoard extends StatelessWidget {
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
// 🔽 [수정] 'isSelected' 조건 제거 (배경색 없음)
|
||||
color: isIncorrect
|
||||
? Colors.red.shade100
|
||||
: isSelected
|
||||
? Colors.blue.shade100
|
||||
: isHighlighted
|
||||
? Colors.blue.shade200
|
||||
: isEditable
|
||||
? Colors.white
|
||||
: Colors.grey.shade200,
|
||||
? Colors.red.shade100 // 1순위: 틀림
|
||||
: isHighlighted
|
||||
? Colors.blue.shade200 // 2순위: 숫자 하이라이트
|
||||
: isEditable
|
||||
? Colors.white
|
||||
: Colors.grey.shade200, // 기본
|
||||
border: Border(
|
||||
top: (row == 0) ? thickBorder : thinBorder,
|
||||
left: (col == 0) ? thickBorder : thinBorder,
|
||||
@@ -78,16 +77,18 @@ class SudokuBoard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
// 0이면 비우고, 아니면 테마 기호("1", "A", "🍎") 표시
|
||||
cellValue == 0 ? '' : theme.getSymbol(cellValue),
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isIncorrect
|
||||
? Colors.red.shade900
|
||||
: isEditable
|
||||
? Colors.blue
|
||||
: Colors.black,
|
||||
// 🔽 [수정] 'isSelected'를 최우선 순위로 추가 (텍스트 색상 변경)
|
||||
color: isSelected
|
||||
? Colors.orange.shade700 // 1순위: 선택된 셀
|
||||
: isIncorrect
|
||||
? Colors.red.shade900 // 2순위: 틀린 셀
|
||||
: isEditable
|
||||
? Colors.blue // 3순위: 수정 가능 셀
|
||||
: Colors.black, // 기본 (원본 숫자)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user