This commit is contained in:
lunaticbum 2025-11-10 18:02:01 +09:00
parent 9225ee6026
commit 1883fef583
22 changed files with 991 additions and 286 deletions

3
devtools_options.yaml Normal file
View File

@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

43
ios/Podfile Normal file
View File

@ -0,0 +1,43 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

48
ios/Podfile.lock Normal file
View File

@ -0,0 +1,48 @@
PODS:
- Flutter (1.0.0)
- Google-Mobile-Ads-SDK (11.13.0):
- GoogleUserMessagingPlatform (>= 1.1)
- google_mobile_ads (5.3.1):
- Flutter
- Google-Mobile-Ads-SDK (~> 11.13.0)
- webview_flutter_wkwebview
- GoogleUserMessagingPlatform (3.1.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- webview_flutter_wkwebview (0.0.1):
- Flutter
- FlutterMacOS
DEPENDENCIES:
- Flutter (from `Flutter`)
- google_mobile_ads (from `.symlinks/plugins/google_mobile_ads/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)
SPEC REPOS:
trunk:
- Google-Mobile-Ads-SDK
- GoogleUserMessagingPlatform
EXTERNAL SOURCES:
Flutter:
:path: Flutter
google_mobile_ads:
:path: ".symlinks/plugins/google_mobile_ads/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"
SPEC CHECKSUMS:
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
Google-Mobile-Ads-SDK: 14f57f2dc33532a24db288897e26494640810407
google_mobile_ads: fe0e2c1764ad95323dd0e3081d0bb2d58411f957
GoogleUserMessagingPlatform: befe603da6501006420c206222acd449bba45a9c
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e
COCOAPODS: 1.16.2

View File

@ -7,10 +7,12 @@
objects = {
/* Begin PBXBuildFile section */
0A725DCED1CD98FFB2302DCE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77DE2DA095E51846864B8323 /* Pods_RunnerTests.framework */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
892AD903CF9CF6401853688E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C17158024398284F8AFFB89 /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
@ -42,11 +44,15 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
16622FECA3EBEF8EB65B3451 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
430C66C34C3442E77FF42FC9 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
4C449A31118EAE166EA6F0E7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
77DE2DA095E51846864B8323 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
@ -55,6 +61,10 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9C17158024398284F8AFFB89 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A7B396FC7090E1529EF1895D /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
E3F4FE4B993EBC989F4C963F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
F2F92AAC40F014CF652C59C0 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -62,6 +72,15 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
892AD903CF9CF6401853688E /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C6050980F0BFBC4078BF1FB9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0A725DCED1CD98FFB2302DCE /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -94,6 +113,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
ED39DAD180D309D951343F67 /* Pods */,
C882BDE0FEF4272B17FD0811 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -121,6 +142,29 @@
path = Runner;
sourceTree = "<group>";
};
C882BDE0FEF4272B17FD0811 /* Frameworks */ = {
isa = PBXGroup;
children = (
9C17158024398284F8AFFB89 /* Pods_Runner.framework */,
77DE2DA095E51846864B8323 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
ED39DAD180D309D951343F67 /* Pods */ = {
isa = PBXGroup;
children = (
4C449A31118EAE166EA6F0E7 /* Pods-Runner.debug.xcconfig */,
E3F4FE4B993EBC989F4C963F /* Pods-Runner.release.xcconfig */,
16622FECA3EBEF8EB65B3451 /* Pods-Runner.profile.xcconfig */,
430C66C34C3442E77FF42FC9 /* Pods-RunnerTests.debug.xcconfig */,
A7B396FC7090E1529EF1895D /* Pods-RunnerTests.release.xcconfig */,
F2F92AAC40F014CF652C59C0 /* Pods-RunnerTests.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -128,8 +172,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
D9965B2772196F9BC76EC2E1 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
C6050980F0BFBC4078BF1FB9 /* Frameworks */,
);
buildRules = (
);
@ -145,12 +191,15 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
520C38BB116D4F7C1080344A /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
60E1658554BB66F9045D2A2F /* [CP] Embed Pods Frameworks */,
98993E38BEFD6F91AB8FA262 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@ -238,6 +287,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
520C38BB116D4F7C1080344A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
60E1658554BB66F9045D2A2F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -253,6 +341,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
98993E38BEFD6F91AB8FA262 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
D9965B2772196F9BC76EC2E1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -379,6 +506,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 430C66C34C3442E77FF42FC9 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -396,6 +524,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A7B396FC7090E1529EF1895D /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -411,6 +540,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F2F92AAC40F014CF652C59C0 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;

View File

@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -2,14 +2,20 @@
class GameRankDto {
final String playerName;
final int primaryScore; // ()
final int primaryScore; // ()
final int? secondaryScore; // ( , : 0~4)
GameRankDto({required this.playerName, required this.primaryScore});
GameRankDto({
required this.playerName,
required this.primaryScore,
this.secondaryScore
});
factory GameRankDto.fromJson(Map<String, dynamic> json) {
return GameRankDto(
playerName: json['playerName'],
primaryScore: (json['primaryScore'] as num).toInt(),
secondaryScore: (json['secondaryScore'] as num?)?.toInt(),
);
}
}

View File

@ -1,23 +1,23 @@
// lib/models/sudoku_game_dto.dart
// 🔽 [] PuzzleData.kt의 DTO (puzzleId -> blockSize)
class SudokuGameDto {
final int puzzleId; // 👈 [] ID
final String question;
final String solution;
final int blockSize; // : 3 (3x3 )
// 🔽 [] blockSize로부터 gridSize (: 9)
final int blockSize;
final int gridSize;
SudokuGameDto({
required this.puzzleId, // 👈 []
required this.question,
required this.solution,
required this.blockSize,
}) : gridSize = blockSize * blockSize; // gridSize
}) : gridSize = blockSize * blockSize;
factory SudokuGameDto.fromJson(Map<String, dynamic> json) {
int bs = json['blockSize'] ?? 3;
return SudokuGameDto(
puzzleId: json['puzzleId'], // 👈 [] puzzleId
question: json['question'],
solution: json['solution'],
blockSize: bs,

View File

@ -1,6 +1,7 @@
// lib/models/unified_rank_dto.dart
class UnifiedRankDto {
final String userId; // 👈 [] - ID
final String gameType;
final String? contextId;
final String playerName;
@ -8,6 +9,7 @@ class UnifiedRankDto {
final int? secondaryScore;
UnifiedRankDto({
required this.userId, // 👈 []
required this.gameType,
this.contextId,
required this.playerName,
@ -18,6 +20,7 @@ class UnifiedRankDto {
// Dart JSON으로 ( )
Map<String, dynamic> toJson() {
return {
'userId': userId, // 👈 []
'gameType': gameType,
'contextId': contextId,
'playerName': playerName,

View File

@ -1,21 +1,31 @@
import 'dart:async';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:sudoku_app/models/sudoku_game_dto.dart';
import 'package:sudoku_app/models/sudoku_theme.dart';
import 'package:sudoku_app/models/unified_rank_dto.dart';
import 'package:sudoku_app/services/puzzle_service.dart';
import 'package:sudoku_app/services/identity_service.dart';
import 'package:sudoku_app/widgets/ad_banner_widget.dart';
import 'package:sudoku_app/widgets/number_pad.dart';
import 'package:sudoku_app/widgets/sudoku_board.dart';
import 'package:sudoku_app/models/game_rank_dto.dart';
// 2 UI enum
enum _RankSubmissionStep { enterName, submitting, showList }
class GameScreen extends StatefulWidget {
final SudokuGameDto gameData;
final String themeName;
final String userId;
final String? userName;
const GameScreen({
super.key,
required this.gameData,
required this.themeName,
required this.userId,
required this.userName,
});
@override
@ -24,6 +34,7 @@ class GameScreen extends StatefulWidget {
class _GameScreenState extends State<GameScreen> {
final PuzzleService _puzzleService = PuzzleService();
final IdentityService _identityService = IdentityService();
late final int blockSize;
late final int gridSize;
@ -41,6 +52,11 @@ class _GameScreenState extends State<GameScreen> {
Set<int> incorrectCells = {};
bool isValidating = false;
_RankSubmissionStep _rankStep = _RankSubmissionStep.enterName;
List<GameRankDto> _rankingList = [];
String _submittedPlayerName = "";
// "A" -> 10 ()
int _charToInt(String char) {
if (char == '0') return 0;
@ -96,7 +112,6 @@ class _GameScreenState extends State<GameScreen> {
if (selectedNumberPad != null) {
//
if (incorrectCells.isNotEmpty && !incorrectCells.contains(index)) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
@ -104,15 +119,13 @@ class _GameScreenState extends State<GameScreen> {
duration: Duration(seconds: 1),
),
);
return; //
return;
}
final int numberValue = selectedNumberPad!;
puzzleCells[index] = numberValue;
//
if (numberValue != solutionCells[index]) {
//
if (!incorrectCells.contains(index)) {
if (score > 0) {
score--;
@ -160,16 +173,38 @@ class _GameScreenState extends State<GameScreen> {
);
}
void _onRestartGameTapped() {
setState(() {
puzzleCells = originalCells.toList();
incorrectCells.clear();
selectedIndex = null;
selectedNumberPad = null;
score = 5;
timer?.cancel();
secondsElapsed = 0;
startTimer();
});
}
void _onQuitGameTapped() {
Navigator.of(context).pop();
}
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.question, currentAnswer, blockSize,
widget.gameData.puzzleId,
currentAnswer,
);
if (result) {
if(mounted) _showRankingDialog();
} else {
@ -194,36 +229,144 @@ class _GameScreenState extends State<GameScreen> {
}
}
// (2 UI)
void _showRankingDialog() {
// ... ( )
final nameController = TextEditingController();
final nameController = TextEditingController(text: widget.userName);
bool isSubmitting = false;
final bool hasExistingName = widget.userName != null;
_rankStep = _RankSubmissionStep.enterName;
_rankingList = [];
_submittedPlayerName = "";
String? dialogErrorMessage; // 👈 []
final String contextId = "SUDOKU_${gridSize}x${gridSize}_L${_difficultyLevel(widget.gameData.question)}";
showDialog(
context: context,
barrierDismissible: false,
builder: (ctx) {
return StatefulBuilder(
builder: (context, setDialogState) {
return AlertDialog(
title: const Text('🎉 성공! 기록을 남겨주세요.'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('($contextId)'),
Text('완료 시간: $secondsElapsed'),
const SizedBox(height: 20),
TextField(
controller: nameController,
decoration: const InputDecoration(
labelText: '이름 (10자 이내)',
border: OutlineInputBorder(),
Widget closeButton = TextButton(
onPressed: () {
Navigator.of(ctx).pop();
Navigator.of(context).pop();
},
child: const Text('닫기'),
);
Widget rankListWidget = Expanded(
child: _rankingList.isEmpty
? const Center(child: Text("현재 랭킹이 없습니다."))
: ListView.builder(
itemCount: _rankingList.length,
shrinkWrap: true,
itemBuilder: (context, index) {
final rank = _rankingList[index];
final bool isMe = rank.playerName == _submittedPlayerName;
int displayScore = 5 - (rank.secondaryScore ?? 5);
final min = (rank.primaryScore ~/ 60).toString().padLeft(2, '0');
final sec = (rank.primaryScore % 60).toString().padLeft(2, '0');
final time = '$min:$sec';
return ListTile(
selected: isMe,
selectedTileColor: Colors.blue.shade100,
leading: Text('${index + 1}.', style: const TextStyle(fontWeight: FontWeight.bold)),
title: Text(rank.playerName, style: TextStyle(fontWeight: isMe ? FontWeight.bold : FontWeight.normal)),
trailing: Text('$time (Score: $displayScore)', style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.black87)),
);
},
),
maxLength: 10,
);
Widget nameEntryWidget = Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('완료 시간: $secondsElapsed 초 / 남은 점수: $score'),
const SizedBox(height: 20),
TextField(
controller: nameController,
readOnly: hasExistingName,
decoration: InputDecoration(
labelText: hasExistingName ? '등록된 이름' : '이름 (10자 이내)',
border: const OutlineInputBorder(),
// 🔽 [] TextField에
errorText: dialogErrorMessage,
),
],
),
actions: [
maxLength: 10,
),
],
);
Widget submitButton = ElevatedButton(
onPressed: () async {
final playerName = nameController.text.trim();
if (playerName.isEmpty) {
// SnackBar
setDialogState(() {
dialogErrorMessage = "이름을 입력해주세요.";
});
return;
}
setDialogState(() {
_rankStep = _RankSubmissionStep.submitting;
_submittedPlayerName = playerName;
dialogErrorMessage = null; // 👈 []
});
final rankDto = UnifiedRankDto(
userId: widget.userId,
gameType: 'SUDOKU',
contextId: contextId,
playerName: playerName,
primaryScore: secondsElapsed,
secondaryScore: (5 - score),
);
try {
await _puzzleService.submitRank(rankDto);
if (!hasExistingName) {
await _identityService.saveUserName(playerName);
}
final ranks = await _puzzleService.fetchRanks('SUDOKU', contextId);
setDialogState(() {
_rankingList = ranks;
_rankStep = _RankSubmissionStep.showList;
});
} catch (e) {
// 🔽 [] ( )
log("!!! 랭킹 등록 실패 !!!", error: e);
setDialogState(() {
_rankStep = _RankSubmissionStep.enterName; // 1( )
// 👈 []
dialogErrorMessage = e.toString().replaceFirst("Exception: ", "");
});
// SnackBar
}
},
child: const Text('랭킹 등록'),
);
Widget dialogContent;
if (_rankStep == _RankSubmissionStep.showList) {
dialogContent = rankListWidget;
} else {
dialogContent = nameEntryWidget;
}
List<Widget> dialogActions;
if (_rankStep == _RankSubmissionStep.enterName) {
dialogActions = [
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
@ -231,53 +374,31 @@ class _GameScreenState extends State<GameScreen> {
},
child: const Text('닫기'),
),
isSubmitting
? const Padding(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator(),
)
: ElevatedButton(
onPressed: () async {
final playerName = nameController.text.trim();
if (playerName.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('이름을 입력해주세요.')),
);
return;
}
setDialogState(() { isSubmitting = true; });
final rankDto = UnifiedRankDto(
gameType: 'SUDOKU',
contextId: contextId,
playerName: playerName,
primaryScore: secondsElapsed,
secondaryScore: null,
);
try {
await _puzzleService.submitRank(rankDto);
if (!mounted) return;
Navigator.of(ctx).pop();
Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('랭킹이 등록되었습니다!')),
);
} catch (e) {
setDialogState(() { isSubmitting = false; });
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString())),
);
}
},
child: const Text('랭킹 등록'),
),
],
submitButton
];
} else if (_rankStep == _RankSubmissionStep.submitting) {
dialogActions = [const CircularProgressIndicator()];
} else {
dialogActions = [closeButton];
}
return AlertDialog(
title: Text(_rankStep == _RankSubmissionStep.showList
? '🏆 상위 10개 랭킹 ($contextId)'
: '🎉 성공! 기록을 남겨주세요.'),
content: SizedBox(
width: 400,
height: _rankStep == _RankSubmissionStep.showList ? 400 : null,
child: dialogContent,
),
actions: dialogActions,
);
},
);
},
);
}
int _difficultyLevel(String question) {
int holes = question.split('').where((c) => c == '0').length;
double holeRatio = holes / (gridSize * gridSize);
@ -290,7 +411,6 @@ class _GameScreenState extends State<GameScreen> {
@override
Widget build(BuildContext context) {
// 🔽 [] AppBar로 build
String formattedTime =
'${(secondsElapsed ~/ 60).toString().padLeft(2, '0')}:${(secondsElapsed % 60).toString().padLeft(2, '0')}';
@ -303,94 +423,107 @@ class _GameScreenState extends State<GameScreen> {
}
return Scaffold(
appBar: AppBar(
title: const Text('Sudoku'), // 👈 []
actions: [
// 🔽 [] AppBar
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: Center(
child: Text(
formattedTime,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
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);
}
},
),
),
),
],
),
body: Column(
children: [
// 1.
Expanded(
child: LayoutBuilder(
builder: (context, constraints) {
bool isLandscape = constraints.maxWidth > constraints.maxHeight;
if (isLandscape) {
return _buildLandscapeLayout(context, numberCounts);
} else {
return _buildPortraitLayout(context, numberCounts);
}
},
),
),
// 2.
const AdBannerWidget(),
],
),
);
}
// 🔽 [] formattedTime
Widget _buildPortraitLayout(BuildContext context, Map<int, int> numberCounts) {
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
_buildGameInfoWidget(), // 👈 []
const SizedBox(height: 15),
_buildSudokuBoardWidget(),
const SizedBox(height: 15),
_buildNumberPadWidget(context, numberCounts, isLandscape: false),
],
),
),
const AdBannerWidget(),
],
),
),
);
}
// 🔽 [] formattedTime
Widget _buildLandscapeLayout(BuildContext context, Map<int, int> numberCounts) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 6,
child: Center(
child: AspectRatio(
aspectRatio: 1.0,
child: _buildSudokuBoardWidget(),
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.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildSudokuBoardWidget(),
const SizedBox(height: 15),
_buildNumberPadWidget(context, numberCounts, isLandscape: false, boardWidth: boardWidth),
],
),
),
),
),
),
),
const SizedBox(width: 16),
],
),
),
);
}
Widget _buildLandscapeLayout(BuildContext context, Map<int, int> numberCounts, BoxConstraints constraints, String formattedTime) {
const double infoBarHeight = 60.0;
double boardWidth = constraints.maxHeight - infoBarHeight - 32.0;
const double numberPadScaleRatio = 0.6;
double padWidth = boardWidth * numberPadScaleRatio;
if (padWidth < 200) padWidth = 200;
if (padWidth > 350) padWidth = 350;
double totalWidth = boardWidth + (padWidth + 100) + 16.0;
if (totalWidth > (constraints.maxWidth - 32.0)) {
double scale = (constraints.maxWidth - 32.0) / totalWidth;
boardWidth *= scale;
padWidth *= scale;
}
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
_buildGameInfoWidget(formattedTime),
Expanded(
flex: 4,
child: SingleChildScrollView(
child: Column(
children: [
_buildGameInfoWidget(), // 👈 []
const SizedBox(height: 20),
_buildNumberPadWidget(context, numberCounts, isLandscape: true),
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: boardWidth,
child: _buildSudokuBoardWidget(),
),
const SizedBox(width: 16),
SizedBox(
width: padWidth + 100,
child: SingleChildScrollView(
child: Column(
children: [
_buildNumberPadWidget(context, numberCounts, isLandscape: true, boardWidth: boardWidth),
],
),
),
),
],
),
),
],
@ -398,16 +531,13 @@ class _GameScreenState extends State<GameScreen> {
);
}
// 🔽 [] (, , ) -
Widget _buildGameInfoWidget() {
Widget _buildGameInfoWidget(String formattedTime) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// 1.
Text('SCORE: $score', style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
// 2. (, )
Text(formattedTime, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
Row(
mainAxisSize: MainAxisSize.min,
children: [
@ -427,7 +557,6 @@ class _GameScreenState extends State<GameScreen> {
);
}
// ( )
Widget _buildSudokuBoardWidget() {
return SudokuBoard(
blockSize: blockSize,
@ -441,24 +570,62 @@ class _GameScreenState extends State<GameScreen> {
);
}
// ( )
Widget _buildNumberPadWidget(BuildContext context, Map<int, int> numberCounts, {required bool isLandscape}) {
double? maxWidth = !isLandscape
? 600 * 0.6
: null;
Widget _buildNumberPadWidget(BuildContext context, Map<int, int> numberCounts, {required bool isLandscape, required double boardWidth}) {
const double numberPadScaleRatio = 0.6;
double? padMaxWidth;
if (!isLandscape) {
padMaxWidth = boardWidth * numberPadScaleRatio;
} else {
padMaxWidth = null;
}
return Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
child: NumberPad(
blockSize: blockSize,
theme: activeTheme,
numberCounts: numberCounts,
selectedNumber: selectedNumberPad,
onNumberTapped: onNumberTapped,
isLandscape: isLandscape,
),
Widget numberPadGrid = ConstrainedBox(
constraints: BoxConstraints(maxWidth: padMaxWidth ?? double.infinity),
child: NumberPad(
blockSize: blockSize,
theme: activeTheme,
numberCounts: numberCounts,
selectedNumber: selectedNumberPad,
onNumberTapped: onNumberTapped,
isLandscape: isLandscape,
),
);
Widget quitButton = IconButton(
icon: Icon(Icons.close, color: Colors.red.shade700, size: 30),
onPressed: _onQuitGameTapped,
tooltip: "게임 종료",
);
Widget restartButton = IconButton(
icon: Icon(Icons.refresh, color: Colors.blue.shade700, size: 30),
onPressed: _onRestartGameTapped,
tooltip: "다시하기",
);
if (isLandscape) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
numberPadGrid,
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [quitButton, restartButton],
)
],
);
} else {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
quitButton,
Expanded(child: numberPadGrid),
restartButton,
],
);
}
}
}

View File

@ -4,6 +4,7 @@ import 'package:sudoku_app/models/sudoku_theme.dart';
import 'package:sudoku_app/screens/game_screen.dart';
import 'package:sudoku_app/screens/ranking_screen.dart';
import 'package:sudoku_app/services/puzzle_service.dart';
import 'package:sudoku_app/services/identity_service.dart'; // 👈 ID
import 'package:sudoku_app/widgets/ad_banner_widget.dart';
class HomeScreen extends StatefulWidget {
@ -14,38 +15,39 @@ class HomeScreen extends StatefulWidget {
}
class _HomeScreenState extends State<HomeScreen> {
//
double _difficultyLevel = 2.0;
final List<String> levelLabels = ["Easy", "Normal", "Medium", "Hard", "Expert"];
// 8
double _difficultyLevel = 4.0; // 1.0 ~ 8.0 ( Level 4: 9x9)
final List<String> levelLabels = [
"입문 (4x4)", "초급 (4x4)",
"쉬움 (9x9)", "중급 (9x9)", "어려움 (9x9)",
"전문가 (16x16)", "마스터 (16x16)", "지옥 (16x16)"
];
//
double _blockSize = 3.0;
// 🔽 [] 16x16, 25x25
final List<String> sizeLabels = ["4x4", "9x9"];
//
late String _selectedThemeName;
bool isLoading = false;
final PuzzleService _puzzleService = PuzzleService();
final IdentityService _identityService = IdentityService(); // 👈 ID
@override
void initState() {
super.initState();
// '랜덤'
_selectedThemeName = AppThemes.random;
_selectedThemeName = AppThemes.random; // '랜덤'
}
Future<void> _startGame() async {
setState(() { isLoading = true; });
try {
final String level = _difficultyLevel.round().toString();
final String blockSize = _blockSize.round().toString();
// 1. (String)
final String difficulty = _difficultyLevel.round().toString();
final SudokuGameDto gameData = await _puzzleService.startGame(level, blockSize);
// 2.
final SudokuGameDto gameData = await _puzzleService.startGame(difficulty);
// 3. - ID와
final String userId = await _identityService.getOrCreateUserId();
final String? userName = await _identityService.getSavedUserName();
// '테마 이름(String)'
if (mounted) {
Navigator.push(
context,
@ -53,6 +55,8 @@ class _HomeScreenState extends State<HomeScreen> {
builder: (context) => GameScreen(
gameData: gameData,
themeName: _selectedThemeName,
userId: userId, // 👈 ID
userName: userName, // 👈
),
),
);
@ -76,6 +80,7 @@ class _HomeScreenState extends State<HomeScreen> {
appBar: AppBar(title: const Text('스도쿠 게임')),
body: LayoutBuilder( //
builder: (context, constraints) {
// / (0.6 = 60% )
const double maxContentRatio = 0.6;
final double constrainedWidth = constraints.maxHeight * maxContentRatio;
@ -91,36 +96,22 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 1.
// 1. (8)
const Text("난이도", style: TextStyle(fontSize: 18)),
Text(
levelLabels[_difficultyLevel.round() - 1],
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.blue),
),
Slider(
value: _difficultyLevel,
min: 1.0, max: 5.0, divisions: 4,
min: 1.0, max: 8.0, divisions: 7, // 8
label: levelLabels[_difficultyLevel.round() - 1],
onChanged: (newValue) => setState(() { _difficultyLevel = newValue; }),
),
const SizedBox(height: 20),
// 2.
const Text("그리드 크기", style: TextStyle(fontSize: 18)),
Text(
// 🔽 [] (2.0 -> index 0)
sizeLabels[_blockSize.round() - 2],
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.deepOrange),
),
Slider(
value: _blockSize,
// 🔽 [] 3.0, divisions를 1
min: 2.0, max: 3.0, divisions: 1,
label: sizeLabels[_blockSize.round() - 2],
activeColor: Colors.deepOrange,
onChanged: (newValue) => setState(() { _blockSize = newValue; }),
),
const SizedBox(height: 20),
// 3. (String )
// 2. (String )
const Text("테마", style: TextStyle(fontSize: 18)),
DropdownButton<String>(
value: _selectedThemeName,
@ -150,11 +141,19 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(height: 10),
// "랭킹 보기"
TextButton(
onPressed: () {
// (String)
final String currentDifficultyName = levelLabels[_difficultyLevel.round() - 1];
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const RankingScreen()),
MaterialPageRoute(
builder: (context) => RankingScreen(
initialDifficultyName: currentDifficultyName,
),
),
);
},
child: const Text('랭킹 보기'),

View File

@ -3,7 +3,13 @@ import 'package:sudoku_app/models/game_rank_dto.dart';
import 'package:sudoku_app/services/puzzle_service.dart';
class RankingScreen extends StatefulWidget {
const RankingScreen({super.key});
// 🔽 []
final String? initialDifficultyName;
const RankingScreen({
super.key,
this.initialDifficultyName, // 👈
});
@override
State<RankingScreen> createState() => _RankingScreenState();
@ -11,67 +17,129 @@ class RankingScreen extends StatefulWidget {
class _RankingScreenState extends State<RankingScreen> {
final PuzzleService _puzzleService = PuzzleService();
// FutureBuilder를
late Future<List<GameRankDto>> _rankingFuture;
// 8 Context ID
final Map<String, String> difficultyContexts = {
"입문 (4x4)": "SUDOKU_4x4_L1",
"초급 (4x4)": "SUDOKU_4x4_L2",
"쉬움 (9x9)": "SUDOKU_9x9_L3",
"중급 (9x9)": "SUDOKU_9x9_L4",
"어려움 (9x9)": "SUDOKU_9x9_L5",
"전문가 (16x16)": "SUDOKU_16x16_L6",
"마스터 (16x16)": "SUDOKU_16x16_L7",
"지옥 (16x16)": "SUDOKU_16x16_L8",
};
late String _selectedDifficulty;
@override
void initState() {
super.initState();
// (contextId = null)
_rankingFuture = _puzzleService.fetchRanks('SUDOKU', null);
// 🔽 []
// 1. HomeScreen에서
String defaultDifficulty = widget.initialDifficultyName ?? "중급 (9x9)";
// 2. () (: )
if (!difficultyContexts.containsKey(defaultDifficulty)) {
defaultDifficulty = "중급 (9x9)";
}
// 3.
_fetchRanksForDifficulty(defaultDifficulty);
}
// () 'mm:ss'
String _formatScore(int seconds) {
void _fetchRanksForDifficulty(String difficultyName) {
setState(() {
_selectedDifficulty = difficultyName;
_rankingFuture = _puzzleService.fetchRanks('SUDOKU', difficultyContexts[_selectedDifficulty]);
});
}
// () 'mm:ss'
String _formatTime(int seconds) {
final min = (seconds ~/ 60).toString().padLeft(2, '0');
final sec = (seconds % 60).toString().padLeft(2, '0');
return '$min:$sec';
}
// (5 - score) -> "SCORE: 5"
String _formatScore(int? storedScore) {
int score = 5 - (storedScore ?? 5);
return 'SCORE: $score';
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('스도쿠 전체 랭킹')),
body: FutureBuilder<List<GameRankDto>>(
future: _rankingFuture,
builder: (context, snapshot) {
//
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
//
if (snapshot.hasError) {
return Center(child: Text('랭킹 로딩 실패: ${snapshot.error}'));
}
//
if (!snapshot.hasData || snapshot.data!.isEmpty) {
return const Center(child: Text('등록된 랭킹이 없습니다.'));
}
appBar: AppBar(title: const Text('스도쿠 랭킹')),
body: Column(
children: [
// 1. Dropdown
Padding(
padding: const EdgeInsets.all(16.0),
child: DropdownButton<String>(
value: _selectedDifficulty, // 👈 initState에서
isExpanded: true,
items: difficultyContexts.keys.map((String difficultyName) {
return DropdownMenuItem<String>(
value: difficultyName,
child: Text(difficultyName),
);
}).toList(),
onChanged: (String? newValue) {
if (newValue != null) {
_fetchRanksForDifficulty(newValue);
}
},
),
),
// 2.
Expanded(
child: FutureBuilder<List<GameRankDto>>(
future: _rankingFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return Center(child: Text('랭킹 로딩 실패: ${snapshot.error}'));
}
if (!snapshot.hasData || snapshot.data!.isEmpty) {
return const Center(child: Text('등록된 랭킹이 없습니다.'));
}
//
final ranks = snapshot.data!;
return ListView.builder(
itemCount: ranks.length,
itemBuilder: (context, index) {
final rank = ranks[index];
return ListTile(
leading: Text(
'${index + 1}.',
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
title: Text(rank.playerName, style: const TextStyle(fontSize: 18)),
trailing: Text(
_formatScore(rank.primaryScore), // () mm:ss로
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
);
},
);
},
final ranks = snapshot.data!;
return ListView.builder(
itemCount: ranks.length,
itemBuilder: (context, index) {
final rank = ranks[index];
return ListTile(
leading: Text(
'${index + 1}.',
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
title: Text(rank.playerName, style: const TextStyle(fontSize: 18)),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
_formatTime(rank.primaryScore),
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blue),
),
Text(
_formatScore(rank.secondaryScore),
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
);
},
);
},
),
),
],
),
);
}

View File

@ -0,0 +1,35 @@
// lib/services/identity_service.dart
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uuid/uuid.dart';
// - ID와
class IdentityService {
static const String _userIdKey = 'app_user_id';
static const String _userNameKey = 'app_user_name';
// 1. - ID ( )
Future<String> getOrCreateUserId() async {
final prefs = await SharedPreferences.getInstance();
String? userId = prefs.getString(_userIdKey);
if (userId == null) {
// ID가 V4 UUID
userId = const Uuid().v4();
await prefs.setString(_userIdKey, userId);
}
return userId;
}
// 2.
Future<String?> getSavedUserName() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getString(_userNameKey);
}
// 3. ,
Future<void> saveUserName(String name) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_userNameKey, name);
}
}

View File

@ -1,19 +1,18 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:developer'; // 👈 [] log
import 'package:http/http.dart' as http;
import 'package:sudoku_app/models/sudoku_game_dto.dart';
import 'package:sudoku_app/models/unified_rank_dto.dart';
import 'package:sudoku_app/models/game_rank_dto.dart';
class PuzzleService {
final String _baseUrl = "https://lunaticbum.kr"; // 👈 HTTPS
final String _baseUrl = "https://lunaticbum.kr";
// 🔽 [] 'blockSize'
Future<SudokuGameDto> startGame(String level, String blockSize) async {
// ... (startGame ) ...
Future<SudokuGameDto> startGame(String difficulty) async {
final response = await http.get(
Uri.parse('$_baseUrl/puzzle/sudoku/start?level=$level&blockSizeStr=$blockSize'),
Uri.parse('$_baseUrl/puzzle/sudoku/start?difficulty=$difficulty'),
);
if (response.statusCode == 200) {
final data = jsonDecode(utf8.decode(response.bodyBytes));
return SudokuGameDto.fromJson(data);
@ -22,18 +21,16 @@ class PuzzleService {
}
}
// 🔽 [] puzzleId question, answer, blockSize를
Future<bool> validateSolution(String question, String answer, int blockSize) async {
// ... (validateSolution ) ...
Future<bool> validateSolution(int puzzleId, String answer) async {
final response = await http.post(
Uri.parse('$_baseUrl/puzzle/sudoku/validate'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'question': question, // 👈 []
'puzzleId': puzzleId,
'answer': answer,
'blockSize': blockSize, // 👈 []
}),
);
if (response.statusCode == 200) {
return jsonDecode(response.body)['correct'] ?? false;
} else {
@ -43,43 +40,51 @@ class PuzzleService {
}
}
// POST /api/ranks/submit
Future<void> submitRank(UnifiedRankDto rankDto) async {
final requestBody = jsonEncode(rankDto.toJson());
// 🔽 [ ] 1. JSON
log(">>> 랭킹 등록 요청: $requestBody");
final response = await http.post(
Uri.parse('$_baseUrl/api/ranks/submit'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode(rankDto.toJson()),
body: requestBody,
);
if (response.statusCode != 200) {
// 🔽 [ ] 2. 200(OK)
log("<<< 랭킹 등록 실패: ${response.statusCode}");
try {
final errorBody = utf8.decode(response.bodyBytes);
log("<<< 서버 에러 메시지: $errorBody"); // 👈 (: "이미 사용 중인 이름입니다.")
throw Exception(errorBody);
} catch (e) {
throw Exception('랭킹 등록 실패: ${response.reasonPhrase}');
}
}
// 🔽 [ ] 3.
log("<<< 랭킹 등록 성공: 200 OK");
}
// ... (fetchRanks ) ...
Future<List<GameRankDto>> fetchRanks(String gameType, String? contextId) async {
final queryParams = {
'gameType': gameType,
if (contextId != null) 'contextId': contextId,
};
// URI
final uri = Uri.parse('$_baseUrl/api/ranks/list').replace(queryParameters: queryParams);
final response = await http.get(uri);
if (response.statusCode == 200) {
// [ ... ] JSON
final List<dynamic> data = jsonDecode(utf8.decode(response.bodyBytes));
// JSON GameRankDto로
return data.map((json) => GameRankDto.fromJson(json)).toList();
} else {
throw Exception('랭킹 로딩 실패');
}
}
}

View File

@ -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,

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation
import shared_preferences_foundation
import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
}

42
macos/Podfile Normal file
View File

@ -0,0 +1,42 @@
platform :osx, '10.15'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View File

@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
url: "https://pub.dev"
source: hosted
version: "3.0.7"
fake_async:
dependency: transitive
description:
@ -49,6 +57,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.3"
ffi:
dependency: transitive
description:
name: ffi
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
file:
dependency: transitive
description:
name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev"
source: hosted
version: "7.0.1"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
@ -67,6 +99,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
google_mobile_ads:
dependency: "direct main"
description:
@ -155,6 +192,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
@ -163,6 +232,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
url: "https://pub.dev"
source: hosted
version: "2.5.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "34266009473bf71d748912da4bf62d439185226c03e01e2d9687bc65bbfcb713"
url: "https://pub.dev"
source: hosted
version: "2.4.15"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "1c33a907142607c40a7542768ec9badfd16293bac51da3a4482623d15845f88b"
url: "https://pub.dev"
source: hosted
version: "2.5.5"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
url: "https://pub.dev"
source: hosted
version: "2.4.3"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
sky_engine:
dependency: transitive
description: flutter
@ -224,6 +349,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
uuid:
dependency: "direct main"
description:
name: uuid
sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8
url: "https://pub.dev"
source: hosted
version: "4.5.2"
vector_math:
dependency: transitive
description:
@ -280,6 +413,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.23.2"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.9.2 <4.0.0"
flutter: ">=3.35.0"

View File

@ -11,6 +11,9 @@ dependencies:
sdk: flutter
http: ^1.2.1 # 이 줄 추가 (버전은 최신 버전 확인)
google_mobile_ads: ^5.1.0
# 🔽 [추가] 2줄
shared_preferences: ^2.2.3
uuid: ^4.4.0
dev_dependencies: