import 'package:flutter/material.dart'; import 'package:sudoku_app/models/sudoku_theme.dart'; class NumberPad extends StatelessWidget { final int blockSize; final SudokuTheme theme; final Map numberCounts; final int? selectedNumber; final Function(int) onNumberTapped; final bool isLandscape; const NumberPad({ super.key, required this.blockSize, required this.theme, required this.numberCounts, required this.selectedNumber, required this.onNumberTapped, required this.isLandscape, }); @override Widget build(BuildContext context) { final int gridSize = blockSize * blockSize; List numberButtons = List.generate(gridSize, (index) { int numberValue = index + 1; String numberSymbol = theme.getSymbol(numberValue); bool isSelected = (numberValue == selectedNumber); bool isCompleted = (numberCounts[numberValue] ?? 0) >= gridSize; Widget button = ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: isSelected ? Colors.blue.shade300 : null, foregroundColor: isSelected ? Colors.white : null, // 🔽 [수정] 패딩을 조절해 버튼을 채움 padding: const EdgeInsets.all(4.0), // 🔽 [수정] 기본 폰트 크기를 키움 (이모지 등) textStyle: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)) ), onPressed: isCompleted ? null : () => onNumberTapped(numberValue), // 🔽 [수정] Text를 FittedBox로 감싸 기호가 버튼에 꽉 차게 함 child: FittedBox( fit: BoxFit.contain, child: Text(numberSymbol), ), ); if (isLandscape) { return Flexible(child: button); } else { return button; } }); if (isLandscape) { // --- 가로 모드: Wrap 사용 (버튼이 가로로 흐름) --- return Wrap( runSpacing: 4.0, spacing: 4.0, children: numberButtons, ); } else { // --- 세로 모드: GridView 사용 (블록 모양) --- return GridView.count( crossAxisCount: blockSize, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, mainAxisSpacing: 4, crossAxisSpacing: 4, children: numberButtons, ); } } }