...
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins-dependencies
|
||||
/build/
|
||||
/coverage/
|
||||
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
|
||||
channel: "stable"
|
||||
|
||||
project_type: package
|
||||
@@ -0,0 +1,3 @@
|
||||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
@@ -0,0 +1 @@
|
||||
TODO: Add your license here.
|
||||
@@ -0,0 +1,39 @@
|
||||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||
-->
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
@@ -0,0 +1,6 @@
|
||||
// packages/feature_game_sudoku/lib/feature_game_sudoku.dart
|
||||
|
||||
// app_sudoku가 IntroScreen의 다음 화면으로 사용할 '로비 화면'
|
||||
export 'screens/sudoku_lobby_screen.dart';
|
||||
|
||||
// (GameScreen 등은 로비 화면만 알면 되므로 굳이 export 안 해도 됨)
|
||||
@@ -0,0 +1,89 @@
|
||||
// packages/feature_game_sudoku/lib/models/game_level.dart
|
||||
// (이 파일은 service_api에서 이동해 옴)
|
||||
|
||||
class GameLevel {
|
||||
final int levelIndex; // 1-11
|
||||
final String name; // "입문 (4x4)"
|
||||
final int blockSize; // 2, 3, 4
|
||||
final int generatorLevel; // 서버에 요청할 생성기 난이도 (1~5)
|
||||
final String contextId; // 랭킹 ID "SUDOKU_4x4_L1"
|
||||
|
||||
final bool isSequentialNumbers;
|
||||
final bool isSequentialLetters;
|
||||
|
||||
const GameLevel({
|
||||
required this.levelIndex,
|
||||
required this.name,
|
||||
required this.blockSize,
|
||||
required this.generatorLevel,
|
||||
required this.contextId,
|
||||
this.isSequentialNumbers = false,
|
||||
this.isSequentialLetters = false,
|
||||
});
|
||||
}
|
||||
|
||||
class AppLevels {
|
||||
static final List<GameLevel> allLevels = [
|
||||
// --- 2x2 (blockSize = 2) ---
|
||||
const GameLevel(
|
||||
levelIndex: 1, name: "입문 (4x4)", blockSize: 2, generatorLevel: 1,
|
||||
contextId: "SUDOKU_4x4_L1", isSequentialNumbers: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 2, name: "초급 (4x4)", blockSize: 2, generatorLevel: 3,
|
||||
contextId: "SUDOKU_4x4_L3", isSequentialLetters: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 3, name: "숙련 (4x4)", blockSize: 2, generatorLevel: 5,
|
||||
contextId: "SUDOKU_4x4_L5"
|
||||
),
|
||||
|
||||
// --- 3x3 (blockSize = 3) ---
|
||||
const GameLevel(
|
||||
levelIndex: 4, name: "쉬움 (9x9)", blockSize: 3, generatorLevel: 1,
|
||||
contextId: "SUDOKU_9x9_L1", isSequentialNumbers: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 5, name: "중급 (9x9)", blockSize: 3, generatorLevel: 2,
|
||||
contextId: "SUDOKU_9x9_L2", isSequentialLetters: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 6, name: "상급 (9x9)", blockSize: 3, generatorLevel: 3,
|
||||
contextId: "SUDOKU_9x9_L3"
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 7, name: "어려움 (9x9)", blockSize: 3, generatorLevel: 4,
|
||||
contextId: "SUDOKU_9x9_L4"
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 8, name: "최상급 (9x9)", blockSize: 3, generatorLevel: 5,
|
||||
contextId: "SUDOKU_9x9_L5"
|
||||
),
|
||||
|
||||
// --- 4x4 (blockSize = 4) ---
|
||||
const GameLevel(
|
||||
levelIndex: 9, name: "전문가 (16x16)", blockSize: 4, generatorLevel: 1,
|
||||
contextId: "SUDOKU_16x16_L1", isSequentialNumbers: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 10, name: "마스터 (16x16)", blockSize: 4, generatorLevel: 3,
|
||||
contextId: "SUDOKU_16x16_L3", isSequentialLetters: true
|
||||
),
|
||||
const GameLevel(
|
||||
levelIndex: 11, name: "지옥 (16x16)", blockSize: 4, generatorLevel: 5,
|
||||
contextId: "SUDOKU_16x16_L5"
|
||||
),
|
||||
];
|
||||
|
||||
static GameLevel getLevel(int levelIndex) {
|
||||
if (levelIndex < 1) levelIndex = 1;
|
||||
if (levelIndex > allLevels.length) levelIndex = allLevels.length;
|
||||
return allLevels.firstWhere((level) => level.levelIndex == levelIndex,
|
||||
orElse: () => allLevels[0]
|
||||
);
|
||||
}
|
||||
|
||||
static Map<String, String> get contextIdToNameMap {
|
||||
return { for (var level in allLevels) level.contextId : level.name };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,575 @@
|
||||
// packages/feature_game_sudoku/lib/screens/game_screen.dart
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
// [C] 서비스 import
|
||||
import 'package:service_api/service_api.dart';
|
||||
|
||||
// [A] 공통 위젯 import
|
||||
import 'package:feature_common/feature_common.dart';
|
||||
|
||||
// [B] 같은 패키지 내의 위젯 import
|
||||
import '../widgets/number_pad.dart';
|
||||
import '../widgets/sudoku_board.dart';
|
||||
import '../models/game_level.dart';
|
||||
|
||||
// ❌ [삭제] enum _RankSubmissionStep
|
||||
|
||||
class GameScreen extends StatefulWidget {
|
||||
final SudokuGameDto gameData;
|
||||
final String themeName;
|
||||
final String userId;
|
||||
final String? userName;
|
||||
final int levelIndex;
|
||||
|
||||
const GameScreen({
|
||||
super.key,
|
||||
required this.gameData,
|
||||
required this.themeName,
|
||||
required this.userId,
|
||||
required this.userName,
|
||||
required this.levelIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
State<GameScreen> createState() => _GameScreenState();
|
||||
}
|
||||
|
||||
class _GameScreenState extends State<GameScreen> {
|
||||
final PuzzleService _puzzleService = PuzzleService();
|
||||
final IdentityService _identityService = IdentityService();
|
||||
|
||||
late final GameLevel currentLevel;
|
||||
late final int blockSize;
|
||||
late final int gridSize;
|
||||
late final SudokuTheme activeTheme;
|
||||
|
||||
late List<int> puzzleCells;
|
||||
late List<int> solutionCells;
|
||||
late List<int> originalCells;
|
||||
|
||||
int? selectedIndex;
|
||||
int score = 5;
|
||||
int secondsElapsed = 0;
|
||||
Timer? timer;
|
||||
int? selectedNumberPad;
|
||||
Set<int> incorrectCells = {};
|
||||
bool isValidating = false;
|
||||
|
||||
// ❌ [삭제] 랭킹 다이얼로그 전용 상태 변수
|
||||
// _RankSubmissionStep _rankStep = _RankSubmissionStep.enterName;
|
||||
// List<GameRankDto> _rankingList = [];
|
||||
// GameRankWithRankNumber? _myRankResult;
|
||||
// String _submittedPlayerName = "";
|
||||
|
||||
late final TransformationController _transformationController;
|
||||
|
||||
// ... ( _charToInt, _intToChar, initState, dispose, startTimer, onCellTapped, _checkIfBoardIsFull ... )
|
||||
// ... ( onNumberTapped, onUndoTapped, onHintTapped, _onRestartGameTapped, _onQuitGameTapped, _resetBoardZoom ... )
|
||||
// ... ( 이 함수들은 모두 동일합니다 )
|
||||
int _charToInt(String char) {
|
||||
if (char == '0') return 0;
|
||||
if (char.codeUnitAt(0) >= '1'.codeUnitAt(0) && char.codeUnitAt(0) <= '9'.codeUnitAt(0)) {
|
||||
return int.parse(char);
|
||||
}
|
||||
if (char.codeUnitAt(0) >= 'A'.codeUnitAt(0) && char.codeUnitAt(0) <= 'Z'.codeUnitAt(0)) {
|
||||
return char.codeUnitAt(0) - 'A'.codeUnitAt(0) + 10;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
String _intToChar(int num) {
|
||||
if (num == 0) return '0';
|
||||
if (num >= 1 && num <= 9) return num.toString();
|
||||
if (num >= 10 && num <= 35) return String.fromCharCode('A'.codeUnitAt(0) + (num - 10));
|
||||
return '?';
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
currentLevel = AppLevels.getLevel(widget.levelIndex);
|
||||
blockSize = currentLevel.blockSize;
|
||||
gridSize = blockSize * blockSize;
|
||||
|
||||
_transformationController = TransformationController();
|
||||
|
||||
String themeForThisGame = widget.themeName;
|
||||
bool isEasyMode = currentLevel.isSequentialNumbers || currentLevel.isSequentialLetters;
|
||||
|
||||
if (currentLevel.isSequentialNumbers) {
|
||||
themeForThisGame = AppThemes.numbers;
|
||||
} else if (currentLevel.isSequentialLetters) {
|
||||
themeForThisGame = AppThemes.letters;
|
||||
}
|
||||
|
||||
activeTheme = AppThemes.buildGameTheme(
|
||||
themeForThisGame,
|
||||
gridSize,
|
||||
isEasyMode: isEasyMode,
|
||||
);
|
||||
|
||||
puzzleCells = widget.gameData.question.split('').map(_charToInt).toList();
|
||||
solutionCells = widget.gameData.solution.split('').map(_charToInt).toList();
|
||||
originalCells = widget.gameData.question.split('').map(_charToInt).toList();
|
||||
|
||||
startTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer?.cancel();
|
||||
_transformationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void startTimer() {
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
setState(() {
|
||||
secondsElapsed++;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void onCellTapped(int index) {
|
||||
if (originalCells[index] == 0) {
|
||||
|
||||
if (incorrectCells.isNotEmpty && !incorrectCells.contains(index)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('틀린 값을 먼저 수정해주세요. (되돌리기 ↩)'),
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
|
||||
if (selectedNumberPad != null) {
|
||||
final int numberValue = selectedNumberPad!;
|
||||
puzzleCells[index] = numberValue;
|
||||
|
||||
if (numberValue != solutionCells[index]) {
|
||||
if (!incorrectCells.contains(index)) {
|
||||
if (score > 0) {
|
||||
score--;
|
||||
}
|
||||
incorrectCells.add(index);
|
||||
}
|
||||
} else {
|
||||
incorrectCells.remove(index);
|
||||
}
|
||||
|
||||
_checkIfBoardIsFull();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _checkIfBoardIsFull() {
|
||||
if (!puzzleCells.contains(0) && !isValidating) {
|
||||
_validateGame();
|
||||
}
|
||||
}
|
||||
|
||||
void onNumberTapped(int numberValue) {
|
||||
setState(() {
|
||||
if (selectedNumberPad == numberValue) {
|
||||
selectedNumberPad = null;
|
||||
} else {
|
||||
selectedNumberPad = numberValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void onUndoTapped() {
|
||||
if (incorrectCells.isNotEmpty) {
|
||||
int errorIndex = incorrectCells.first;
|
||||
setState(() {
|
||||
puzzleCells[errorIndex] = 0;
|
||||
incorrectCells.remove(errorIndex);
|
||||
selectedIndex = errorIndex;
|
||||
});
|
||||
}
|
||||
else if (selectedIndex != null && originalCells[selectedIndex!] == 0) {
|
||||
setState(() {
|
||||
puzzleCells[selectedIndex!] = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onHintTapped() {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('힌트 기능은 준비 중입니다.')),
|
||||
);
|
||||
}
|
||||
|
||||
void _onRestartGameTapped() {
|
||||
setState(() {
|
||||
puzzleCells = originalCells.toList();
|
||||
incorrectCells.clear();
|
||||
selectedIndex = null;
|
||||
selectedNumberPad = null;
|
||||
score = 5;
|
||||
_resetBoardZoom();
|
||||
|
||||
timer?.cancel();
|
||||
secondsElapsed = 0;
|
||||
startTimer();
|
||||
});
|
||||
}
|
||||
|
||||
void _onQuitGameTapped() {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
void _resetBoardZoom() {
|
||||
_transformationController.value = Matrix4.identity();
|
||||
}
|
||||
|
||||
Future<void> _validateGame() async {
|
||||
if (isValidating) return;
|
||||
setState(() { isValidating = true; });
|
||||
|
||||
timer?.cancel();
|
||||
String currentAnswer = puzzleCells.map(_intToChar).join('');
|
||||
|
||||
try {
|
||||
final bool result = await _puzzleService.validateSolution(
|
||||
widget.gameData.puzzleId,
|
||||
currentAnswer,
|
||||
);
|
||||
|
||||
if (result) {
|
||||
if(mounted) {
|
||||
// 🔽 [수정] _showRankingDialog() 호출 대신
|
||||
// 공통 게임 완료 화면(GameCompletionScreen)으로 이동
|
||||
|
||||
// 1. 점수 포맷터 정의
|
||||
String formatSudokuScore(int primary, int? secondary) {
|
||||
final min = (primary ~/ 60).toString().padLeft(2, '0');
|
||||
final sec = (primary % 60).toString().padLeft(2, '0');
|
||||
final time = '$min:$sec';
|
||||
int displayScore = 5 - (secondary ?? 5);
|
||||
return '$time (Score: $displayScore)';
|
||||
}
|
||||
|
||||
// 2. 레벨 저장 콜백 정의
|
||||
Future<void> saveSudokuProgress(String playerName) async {
|
||||
// (playerName은 공통 화면이 IdentityService로 저장하므로 여기선 사용 안 함)
|
||||
|
||||
final int currentMaxLevel = await _identityService.getMaxUnlockedLevel();
|
||||
if (currentMaxLevel < 99) {
|
||||
if (widget.levelIndex >= currentMaxLevel) {
|
||||
int nextLevel = widget.levelIndex + 1;
|
||||
if (nextLevel > AppLevels.allLevels.length) {
|
||||
await _identityService.saveMaxUnlockedLevel(99);
|
||||
} else {
|
||||
await _identityService.saveMaxUnlockedLevel(nextLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 화면 이동
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => GameCompletionScreen(
|
||||
args: GameResultArgs(
|
||||
gameType: 'SUDOKU',
|
||||
contextId: currentLevel.contextId,
|
||||
primaryScore: secondsElapsed,
|
||||
secondaryScore: (5 - score),
|
||||
userId: widget.userId,
|
||||
userName: widget.userName,
|
||||
scoreFormatter: formatSudokuScore,
|
||||
onProgressSave: saveSudokuProgress,
|
||||
onScreenClose: () {
|
||||
// 공통 화면에서 '닫기'를 누르면 게임 화면도 닫힘
|
||||
if (Navigator.canPop(context)) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('🤔 틀린 부분이 있습니다.')),
|
||||
);
|
||||
}
|
||||
startTimer();
|
||||
}
|
||||
} catch (e) {
|
||||
if(mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('오류: $e')),
|
||||
);
|
||||
}
|
||||
startTimer();
|
||||
} finally {
|
||||
if(mounted) {
|
||||
setState(() { isValidating = false; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ❌ [삭제] _showRankingDialog() 메서드 전체 (약 150줄) 삭제
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<ThemeNotifier>();
|
||||
|
||||
String formattedTime =
|
||||
'${(secondsElapsed ~/ 60).toString().padLeft(2, '0')}:${(secondsElapsed % 60).toString().padLeft(2, '0')}';
|
||||
|
||||
final Map<int, int> numberCounts = {};
|
||||
for (int i = 1; i <= gridSize; i++) { numberCounts[i] = 0; }
|
||||
for (int cellValue in puzzleCells) {
|
||||
if (cellValue > 0) {
|
||||
numberCounts[cellValue] = (numberCounts[cellValue] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bool isLandscape = constraints.maxWidth > constraints.maxHeight;
|
||||
if (isLandscape) {
|
||||
return _buildLandscapeLayout(context, numberCounts, constraints, formattedTime);
|
||||
} else {
|
||||
return _buildPortraitLayout(context, numberCounts, constraints, formattedTime);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const AdBannerWidget(), // 👈 [A] feature_common의 AdBannerWidget
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPortraitLayout(BuildContext context, Map<int, int> numberCounts, BoxConstraints constraints, String formattedTime) {
|
||||
final double boardWidth = (constraints.maxWidth > 600) ? 600 : constraints.maxWidth;
|
||||
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: boardWidth),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0),
|
||||
child: _buildGameInfoWidget(formattedTime),
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildSudokuBoardWidget(),
|
||||
const SizedBox(height: 15),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: _buildControlPanelWidget(context, numberCounts, isLandscape: false, boardWidth: boardWidth),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLandscapeLayout(BuildContext context, Map<int, int> numberCounts, BoxConstraints constraints, String formattedTime) {
|
||||
const double infoBarHeight = 60.0;
|
||||
double boardWidth = constraints.maxHeight - infoBarHeight - 32.0;
|
||||
|
||||
double controlPanelWidth;
|
||||
const double numberPadScaleRatio = 0.6;
|
||||
double padWidth = boardWidth * numberPadScaleRatio;
|
||||
|
||||
if (padWidth < 200) padWidth = 200;
|
||||
if (padWidth > 350) padWidth = 350;
|
||||
controlPanelWidth = padWidth + 100;
|
||||
|
||||
double totalWidth = boardWidth + controlPanelWidth + 16.0;
|
||||
if (totalWidth > (constraints.maxWidth - 32.0)) {
|
||||
double scale = (constraints.maxWidth - 32.0) / totalWidth;
|
||||
boardWidth *= scale;
|
||||
controlPanelWidth *= scale;
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildGameInfoWidget(formattedTime),
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: boardWidth,
|
||||
child: _buildSudokuBoardWidget(),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
SizedBox(
|
||||
width: controlPanelWidth,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildControlPanelWidget(context, numberCounts, isLandscape: true, boardWidth: boardWidth),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGameInfoWidget(String formattedTime) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text('SCORE: $score', style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
Text(formattedTime, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSudokuBoardWidget() {
|
||||
return GestureDetector(
|
||||
onLongPress: _resetBoardZoom,
|
||||
child: InteractiveViewer(
|
||||
transformationController: _transformationController,
|
||||
boundaryMargin: const EdgeInsets.all(20.0),
|
||||
minScale: 1.0,
|
||||
maxScale: 2.5,
|
||||
child: SudokuBoard(
|
||||
blockSize: blockSize,
|
||||
theme: activeTheme,
|
||||
cells: puzzleCells,
|
||||
originalCells: originalCells,
|
||||
selectedIndex: selectedIndex,
|
||||
selectedNumberPad: selectedNumberPad,
|
||||
incorrectCells: incorrectCells,
|
||||
onCellTapped: onCellTapped,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildControlPanelWidget(BuildContext context, Map<int, int> numberCounts, {required bool isLandscape, required double boardWidth}) {
|
||||
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
|
||||
const double numberPadScaleRatio = 0.6;
|
||||
double? padMaxWidth;
|
||||
|
||||
if (!isLandscape) {
|
||||
padMaxWidth = boardWidth * numberPadScaleRatio;
|
||||
} else {
|
||||
padMaxWidth = boardWidth * numberPadScaleRatio;
|
||||
if (padMaxWidth < 200) padMaxWidth = 200;
|
||||
}
|
||||
|
||||
Widget numberPadGrid = ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: padMaxWidth ?? double.infinity),
|
||||
child: NumberPad(
|
||||
blockSize: blockSize,
|
||||
theme: activeTheme,
|
||||
numberCounts: numberCounts,
|
||||
selectedNumber: selectedNumberPad,
|
||||
onNumberTapped: onNumberTapped,
|
||||
isLandscape: isLandscape,
|
||||
),
|
||||
);
|
||||
|
||||
Widget leftButtons = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.close, color: themeData.colorScheme.error, size: 30),
|
||||
onPressed: _onQuitGameTapped,
|
||||
tooltip: "게임 종료",
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh, color: themeData.colorScheme.secondary, size: 30),
|
||||
onPressed: _onRestartGameTapped,
|
||||
tooltip: "다시하기",
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget rightButtons = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: onHintTapped,
|
||||
icon: Icon(Icons.lightbulb_outline, color: themeData.colorScheme.secondary, size: 30),
|
||||
tooltip: "힌트",
|
||||
),
|
||||
IconButton(
|
||||
onPressed: onUndoTapped,
|
||||
icon: Icon(Icons.undo, color: themeData.colorScheme.error, size: 30),
|
||||
tooltip: "되돌리기",
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (isLandscape) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
numberPadGrid,
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
leftButtons,
|
||||
rightButtons
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
leftButtons,
|
||||
Expanded(child: numberPadGrid),
|
||||
rightButtons,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
// packages/feature_game_sudoku/lib/screens/sudoku_lobby_screen.dart
|
||||
import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
// [C] 서비스 import
|
||||
import 'package:service_api/service_api.dart';
|
||||
// [A] 공통 셸(Shell) 위젯 import
|
||||
import 'package:feature_common/feature_common.dart';
|
||||
// [B] 같은 패키지 내의 화면/모델 import
|
||||
import 'game_screen.dart';
|
||||
import '../models/game_level.dart'; // 👈 스도쿠 전용 레벨
|
||||
|
||||
class SudokuLobbyScreen extends StatefulWidget {
|
||||
const SudokuLobbyScreen({ super.key });
|
||||
|
||||
@override
|
||||
State<SudokuLobbyScreen> createState() => _SudokuLobbyScreenState();
|
||||
}
|
||||
|
||||
class _SudokuLobbyScreenState extends State<SudokuLobbyScreen> {
|
||||
int _maxUnlockedLevel = 1;
|
||||
Map<int, (int, int)> _rankHistory = {};
|
||||
String? _userName;
|
||||
late String _selectedThemeName;
|
||||
bool _isLoading = false;
|
||||
|
||||
final PuzzleService _puzzleService = PuzzleService();
|
||||
final IdentityService _identityService = IdentityService();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedThemeName = AppThemes.random;
|
||||
_loadProgress();
|
||||
}
|
||||
|
||||
Future<void> _loadProgress() async {
|
||||
final maxLevel = await _identityService.getMaxUnlockedLevel();
|
||||
final String? myName = await _identityService.getSavedUserName();
|
||||
if (mounted) { setState(() { _maxUnlockedLevel = maxLevel; _userName = myName; }); }
|
||||
if (myName == null) return;
|
||||
try {
|
||||
final Map<int, int> oldRankMap = await _identityService.getLastSavedRankMap();
|
||||
List<Future<List<GameRankDto>>> rankFutures = [];
|
||||
for (final level in AppLevels.allLevels) {
|
||||
rankFutures.add(_puzzleService.fetchRanks('SUDOKU', level.contextId));
|
||||
}
|
||||
final List<List<GameRankDto>> allRankResults = await Future.wait(rankFutures);
|
||||
Map<int, int> newRankMapForStorage = {};
|
||||
Map<int, (int, int)> newRankHistoryForState = {};
|
||||
for (int i = 0; i < AppLevels.allLevels.length; i++) {
|
||||
final level = AppLevels.allLevels[i];
|
||||
final currentRanks = allRankResults[i];
|
||||
final int levelIndex = level.levelIndex;
|
||||
final int oldRank = oldRankMap[levelIndex] ?? 0;
|
||||
int currentRank = 0;
|
||||
int myRankIndex = currentRanks.indexWhere((r) => r.playerName == myName);
|
||||
if (myRankIndex != -1) { currentRank = myRankIndex + 1; }
|
||||
newRankMapForStorage[levelIndex] = currentRank;
|
||||
newRankHistoryForState[levelIndex] = (oldRank, currentRank);
|
||||
}
|
||||
await _identityService.saveLastRankMap(newRankMapForStorage);
|
||||
if (mounted) { setState(() { _rankHistory = newRankHistoryForState; }); }
|
||||
log("모든 레벨 랭킹 변동 확인 완료. (유저: $myName)");
|
||||
} catch (e) {
|
||||
log("SudokuLobbyScreen: 랭킹 확인 실패: $e");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _startGame(GameLevel level) async {
|
||||
setState(() { _isLoading = true; });
|
||||
try {
|
||||
final String difficulty = level.levelIndex.toString();
|
||||
final SudokuGameDto gameData = await _puzzleService.startGame(difficulty);
|
||||
final String userId = await _identityService.getOrCreateUserId();
|
||||
final String? userName = _userName;
|
||||
if (mounted) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => GameScreen(
|
||||
gameData: gameData,
|
||||
themeName: _selectedThemeName,
|
||||
userId: userId,
|
||||
userName: userName,
|
||||
levelIndex: level.levelIndex,
|
||||
),
|
||||
),
|
||||
);
|
||||
_loadProgress(); // 게임 끝나고 돌아오면 랭킹 새로고침
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('게임 로딩 실패: $e')),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() { _isLoading = false; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<ThemeNotifier>(); // 테마 감지
|
||||
final bool allLevelsUnlocked = _maxUnlockedLevel >= 99;
|
||||
final theme = Theme.of(context);
|
||||
|
||||
// [A] feature_common의 CommonGameShell을 사용
|
||||
return CommonGameShell(
|
||||
title: '스도쿠 게임', // 셸의 AppBar에 표시될 제목
|
||||
|
||||
// 🔽 [수정] 랭킹 버튼 클릭 시 실행될 함수를 주입
|
||||
onRankingPressed: () {
|
||||
|
||||
// 1. 스도쿠 레벨(AppLevels)을 공통 모델(GameDifficulty)로 변환
|
||||
final List<GameDifficulty> sudokuDifficulties = AppLevels.allLevels
|
||||
.map((level) => GameDifficulty(
|
||||
name: level.name,
|
||||
contextId: level.contextId,
|
||||
))
|
||||
.toList();
|
||||
|
||||
// 2. 공통 랭킹 화면(RankingScreen)에 주입하며 호출
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RankingScreen(
|
||||
gameType: 'SUDOKU', // 👈 이 게임은 스도쿠
|
||||
difficulties: sudokuDifficulties, // 👈 스도쿠 난이도 목록
|
||||
initialDifficultyName: AppLevels.getLevel(_maxUnlockedLevel).name,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
// 🔽 셸의 'body'에 스도쿠 레벨 목록을 전달
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const double maxContentRatio = 0.6;
|
||||
final double constrainedWidth = (constraints.maxHeight * maxContentRatio) > 500
|
||||
? 500 : (constraints.maxHeight * maxContentRatio);
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: constrainedWidth),
|
||||
child: Column(
|
||||
children: [
|
||||
// 테마 선택 Dropdown
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text("테마: ", style: TextStyle(fontSize: 18)),
|
||||
DropdownButton<String>(
|
||||
value: _selectedThemeName,
|
||||
items: AppThemes.selectableThemeNames.map((themeName) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: themeName,
|
||||
child: Text(themeName, style: const TextStyle(fontSize: 20)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (themeName) {
|
||||
if (themeName != null) {
|
||||
setState(() { _selectedThemeName = themeName; });
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 레벨 목록 ListView
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: AppLevels.allLevels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final GameLevel level = AppLevels.allLevels[index];
|
||||
final bool isUnlocked = allLevelsUnlocked || level.levelIndex <= _maxUnlockedLevel;
|
||||
final (int oldRank, int currentRank) = _rankHistory[level.levelIndex] ?? (0, 0);
|
||||
Widget? trailingWidget = isUnlocked ? const Icon(Icons.play_arrow_rounded) : null;
|
||||
String? subtitleText;
|
||||
Color? subtitleColor;
|
||||
|
||||
if (currentRank > 0) {
|
||||
String rankStr = "${currentRank}위";
|
||||
if (oldRank > 0) {
|
||||
int change = oldRank - currentRank;
|
||||
if (change > 0) {
|
||||
subtitleText = "$rankStr (▲ $change)";
|
||||
subtitleColor = Colors.green;
|
||||
trailingWidget = const Icon(Icons.arrow_circle_up_rounded, color: Colors.green, size: 28);
|
||||
} else if (change < 0) {
|
||||
subtitleText = "$rankStr (▼ ${change.abs()})";
|
||||
subtitleColor = Colors.red;
|
||||
trailingWidget = const Icon(Icons.arrow_circle_down_rounded, color: Colors.red, size: 28);
|
||||
} else {
|
||||
subtitleText = "$rankStr (유지)";
|
||||
subtitleColor = Colors.grey;
|
||||
trailingWidget = const Icon(Icons.check_circle_outline_rounded, color: Colors.grey, size: 28);
|
||||
}
|
||||
} else {
|
||||
subtitleText = "$rankStr (신규 진입)";
|
||||
subtitleColor = Colors.blue;
|
||||
trailingWidget = const Icon(Icons.new_releases_rounded, color: Colors.blue, size: 28);
|
||||
}
|
||||
} else {
|
||||
if (oldRank > 0) {
|
||||
subtitleText = "랭킹 이탈 (이전 ${oldRank}위)";
|
||||
subtitleColor = Colors.orange;
|
||||
trailingWidget = const Icon(Icons.warning_amber_rounded, color: Colors.orange, size: 28);
|
||||
}
|
||||
}
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
isUnlocked ? Icons.lock_open_rounded : Icons.lock_rounded,
|
||||
color: isUnlocked ? theme.primaryColor : Colors.grey,
|
||||
),
|
||||
title: Text(level.name, style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: isUnlocked ? FontWeight.bold : FontWeight.normal,
|
||||
color: isUnlocked ? theme.textTheme.bodyLarge?.color : Colors.grey,
|
||||
)),
|
||||
subtitle: subtitleText != null
|
||||
? Text(subtitleText, style: TextStyle(color: subtitleColor, fontWeight: FontWeight.bold))
|
||||
: null,
|
||||
trailing: trailingWidget,
|
||||
onTap: isUnlocked && !_isLoading
|
||||
? () => _startGame(level)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// packages/feature_game_sudoku/lib/widgets/number_pad.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:service_api/service_api.dart'; // 👈 SudokuTheme import
|
||||
|
||||
class NumberPad extends StatelessWidget {
|
||||
final int blockSize;
|
||||
final SudokuTheme theme;
|
||||
final Map<int, int> 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;
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final bool isDark = themeData.brightness == Brightness.dark;
|
||||
|
||||
final Color selectedColor = themeData.primaryColor;
|
||||
final Color onSelectedColor = themeData.colorScheme.onPrimary;
|
||||
|
||||
final Color completedColor = isDark ? Colors.white24 : Colors.black26;
|
||||
final Color completedTextColor = isDark ? Colors.white54 : Colors.black54;
|
||||
|
||||
final Color defaultTextColor = isDark ? Colors.white70 : Colors.black87;
|
||||
|
||||
List<Widget> 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 ? selectedColor : null,
|
||||
foregroundColor: isSelected ? onSelectedColor : defaultTextColor,
|
||||
disabledBackgroundColor: completedColor,
|
||||
disabledForegroundColor: completedTextColor,
|
||||
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: FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
child: Text(numberSymbol),
|
||||
),
|
||||
);
|
||||
|
||||
if (isLandscape) {
|
||||
return Flexible(child: button);
|
||||
} else {
|
||||
return button;
|
||||
}
|
||||
});
|
||||
|
||||
if (isLandscape) {
|
||||
return Wrap(
|
||||
runSpacing: 4.0,
|
||||
spacing: 4.0,
|
||||
children: numberButtons,
|
||||
);
|
||||
} else {
|
||||
return GridView.count(
|
||||
crossAxisCount: blockSize,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
mainAxisSpacing: 4,
|
||||
crossAxisSpacing: 4,
|
||||
children: numberButtons,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// packages/feature_game_sudoku/lib/widgets/sudoku_board.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:service_api/service_api.dart'; // 👈 SudokuTheme import
|
||||
|
||||
class SudokuBoard extends StatelessWidget {
|
||||
final int blockSize;
|
||||
final SudokuTheme theme;
|
||||
final List<int> cells;
|
||||
final List<int> originalCells;
|
||||
final int? selectedIndex;
|
||||
final int? selectedNumberPad;
|
||||
final Set<int> incorrectCells;
|
||||
final Function(int) onCellTapped;
|
||||
|
||||
const SudokuBoard({
|
||||
super.key,
|
||||
required this.blockSize,
|
||||
required this.theme,
|
||||
required this.cells,
|
||||
required this.originalCells,
|
||||
required this.selectedIndex,
|
||||
required this.selectedNumberPad,
|
||||
required this.incorrectCells,
|
||||
required this.onCellTapped,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int gridSize = blockSize * blockSize;
|
||||
final double fontSize = (gridSize > 9) ? (gridSize > 16 ? 12 : 16) : 24;
|
||||
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final ColorScheme colorScheme = themeData.colorScheme;
|
||||
final bool isDark = themeData.brightness == Brightness.dark;
|
||||
|
||||
final Color thickBorderColor = colorScheme.onSurface.withOpacity(isDark ? 0.8 : 1.0);
|
||||
final Color thinBorderColor = themeData.dividerColor;
|
||||
|
||||
final Color incorrectBg = colorScheme.error.withOpacity(0.2);
|
||||
final Color highlightedBg = colorScheme.primary.withOpacity(0.2);
|
||||
final Color editableBg = themeData.scaffoldBackgroundColor;
|
||||
final Color fixedBg = isDark ? colorScheme.surfaceVariant : colorScheme.onSurface.withOpacity(0.1);
|
||||
|
||||
final Color selectedTextColor = colorScheme.secondary;
|
||||
final Color incorrectTextColor = colorScheme.error;
|
||||
final Color editableTextColor = colorScheme.primary;
|
||||
final Color fixedTextColor = colorScheme.onSurface;
|
||||
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
child: GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: gridSize,
|
||||
),
|
||||
itemCount: gridSize * gridSize,
|
||||
itemBuilder: (context, index) {
|
||||
int row = index ~/ gridSize;
|
||||
int col = index % gridSize;
|
||||
|
||||
int cellValue = cells[index];
|
||||
bool isEditable = (originalCells[index] == 0);
|
||||
bool isSelected = (index == selectedIndex);
|
||||
|
||||
bool isHighlighted = (cellValue != 0 &&
|
||||
selectedNumberPad != null &&
|
||||
cellValue == selectedNumberPad);
|
||||
|
||||
bool isIncorrect = incorrectCells.contains(index);
|
||||
|
||||
BorderSide thickBorder = BorderSide(color: thickBorderColor, width: 2.0);
|
||||
BorderSide thinBorder = BorderSide(color: thinBorderColor, width: 0.5);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onCellTapped(index),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: isIncorrect
|
||||
? incorrectBg
|
||||
: isHighlighted
|
||||
? highlightedBg
|
||||
: isEditable
|
||||
? editableBg
|
||||
: fixedBg,
|
||||
border: Border(
|
||||
top: (row == 0) ? thickBorder : thinBorder,
|
||||
left: (col == 0) ? thickBorder : thinBorder,
|
||||
right: (col == gridSize - 1) ? thickBorder : (col % blockSize == blockSize - 1) ? thickBorder : thinBorder,
|
||||
bottom: (row == gridSize - 1) ? thickBorder : (row % blockSize == blockSize - 1) ? thickBorder : thinBorder,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
cellValue == 0 ? '' : theme.getSymbol(cellValue),
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isSelected
|
||||
? selectedTextColor
|
||||
: isIncorrect
|
||||
? incorrectTextColor
|
||||
: isEditable
|
||||
? editableTextColor
|
||||
: fixedTextColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
name: feature_game_sudoku
|
||||
description: The Sudoku game feature, including the game screen, board, and number pad.
|
||||
version: 1.0.0
|
||||
publish_to: 'none'
|
||||
resolution: workspace
|
||||
environment:
|
||||
sdk: '^3.9.2'
|
||||
flutter: '>=3.10.0'
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# 1. 공통 서비스 로직 (필수)
|
||||
# GameLevel, SudokuGameDto, SudokuTheme, PuzzleService, IdentityService 등을 사용
|
||||
service_api:
|
||||
path: ../service_api
|
||||
|
||||
# 2. UI 및 상태 관리
|
||||
provider: ^6.0.0 # (GameScreen에서 ThemeNotifier를 watch)
|
||||
|
||||
feature_common:
|
||||
path: ../feature_common
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
lints: ^3.0.0
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:feature_game_sudoku/feature_game_sudoku.dart';
|
||||
|
||||
void main() {
|
||||
test('adds one to input values', () {
|
||||
final calculator = Calculator();
|
||||
expect(calculator.addOne(2), 3);
|
||||
expect(calculator.addOne(-7), -6);
|
||||
expect(calculator.addOne(0), 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user