...
This commit is contained in:
+14
-13
@@ -7,7 +7,7 @@ class NumberPad extends StatelessWidget {
|
||||
final Map<int, int> numberCounts;
|
||||
final int? selectedNumber;
|
||||
final Function(int) onNumberTapped;
|
||||
final bool isLandscape; // 👈 [추가] 이 파라미터가 있어야 합니다
|
||||
final bool isLandscape;
|
||||
|
||||
const NumberPad({
|
||||
super.key,
|
||||
@@ -16,14 +16,13 @@ class NumberPad extends StatelessWidget {
|
||||
required this.numberCounts,
|
||||
required this.selectedNumber,
|
||||
required this.onNumberTapped,
|
||||
required this.isLandscape, // 👈 [추가] 생성자에 추가
|
||||
required this.isLandscape,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int gridSize = blockSize * blockSize;
|
||||
|
||||
// 1. 버튼 위젯 리스트 생성
|
||||
List<Widget> numberButtons = List.generate(gridSize, (index) {
|
||||
int numberValue = index + 1;
|
||||
String numberSymbol = theme.getSymbol(numberValue);
|
||||
@@ -34,38 +33,40 @@ class NumberPad extends StatelessWidget {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: isSelected ? Colors.blue.shade300 : null,
|
||||
foregroundColor: isSelected ? Colors.white : null,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
|
||||
textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
// 🔽 [수정] 패딩을 조절해 버튼을 채움
|
||||
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),
|
||||
child: Text(numberSymbol),
|
||||
// 🔽 [수정] Text를 FittedBox로 감싸 기호가 버튼에 꽉 차게 함
|
||||
child: FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
child: Text(numberSymbol),
|
||||
),
|
||||
);
|
||||
|
||||
// 가로 모드(Wrap)에서는 Flexible로 감싸고,
|
||||
// 세로 모드(Grid)에서는 감싸지 않음
|
||||
if (isLandscape) {
|
||||
// Flexible을 사용해 Wrap 내에서 버튼이 공간을 차지하도록 함
|
||||
return Flexible(child: button);
|
||||
} else {
|
||||
return button;
|
||||
}
|
||||
});
|
||||
|
||||
// 2. 가로/세로 모드에 따라 다른 레이아웃 반환
|
||||
if (isLandscape) {
|
||||
// --- 가로 모드: Wrap 사용 (버튼이 가로로 흐름) ---
|
||||
return Wrap(
|
||||
runSpacing: 4.0, // 줄(세로) 간격
|
||||
spacing: 4.0, // 버튼(가로) 간격
|
||||
runSpacing: 4.0,
|
||||
spacing: 4.0,
|
||||
children: numberButtons,
|
||||
);
|
||||
} else {
|
||||
// --- 세로 모드: GridView 사용 (블록 모양) ---
|
||||
return GridView.count(
|
||||
crossAxisCount: blockSize, // 2x2, 3x3, 4x4, 5x5
|
||||
crossAxisCount: blockSize,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
|
||||
Reference in New Issue
Block a user