├── .gitignore ├── .metadata ├── .vscode ├── launch.json └── settings.json ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── huhx │ │ │ │ └── sudoku │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── launcher_icon.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── launcher_icon.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── launcher_icon.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── launcher_icon.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── launcher_icon.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets ├── image │ ├── logo.png │ ├── sudoku_dark.png │ └── sudoku_light.png ├── sound │ ├── fail.mp3 │ ├── input.mp3 │ ├── operate.mp3 │ └── success.mp3 └── svg │ ├── difficulty.svg │ ├── done.svg │ ├── drawer_menu.svg │ ├── error.svg │ ├── game_status.svg │ ├── home_double_right.svg │ ├── item_about.svg │ ├── item_analyze.svg │ ├── item_feedback.svg │ ├── item_onboarding.svg │ ├── item_record.svg │ ├── level_check.svg │ ├── main_category.svg │ ├── main_home.svg │ ├── main_profile.svg │ ├── more_hor.svg │ ├── operate_clear.svg │ ├── operate_note.svg │ ├── operate_quick_note.svg │ ├── operate_tip.svg │ ├── operate_undo.svg │ ├── reset.svg │ ├── sudoku_answer.svg │ ├── sudoku_color.svg │ ├── sudoku_failed.svg │ ├── sudoku_log.svg │ ├── sudoku_retry.svg │ ├── sudoku_setting.svg │ ├── sudoku_share.svg │ ├── sudoku_start.svg │ ├── sudoku_stop.svg │ ├── sudoku_success.svg │ ├── user_tips.svg │ └── weekday.svg ├── deploy_android.sh ├── images ├── image_1.png ├── image_2.png ├── image_3.png ├── image_4.png ├── image_5.png └── image_6.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-50x50@1x.png │ │ ├── Icon-App-50x50@2x.png │ │ ├── Icon-App-57x57@1x.png │ │ ├── Icon-App-57x57@2x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-72x72@1x.png │ │ ├── Icon-App-72x72@2x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── api │ ├── sudoku_api.dart │ └── sudoku_record_api.dart ├── business │ ├── home │ │ ├── sudoku_calendar_screen.dart │ │ ├── sudoku_drawer.dart │ │ ├── sudoku_failed_screen.dart │ │ ├── sudoku_screen.dart │ │ ├── sudoku_statistics_detail_screen.dart │ │ ├── sudoku_statistics_screen.dart │ │ └── sudoku_success_screen.dart │ ├── profile │ │ └── onboard_screen.dart │ ├── record │ │ ├── data │ │ │ └── sudoku_record_notifier.dart │ │ ├── sudoku_record_board.dart │ │ ├── sudoku_record_list_screen.dart │ │ ├── sudoku_record_screen.dart │ │ └── sudoku_record_slidable.dart │ ├── setting │ │ ├── cache │ │ │ └── clear_cache_item.dart │ │ ├── dark │ │ │ └── dark_item.dart │ │ ├── errorcount │ │ │ └── error_count_item.dart │ │ ├── sound │ │ │ └── play_sound_item.dart │ │ ├── sudoku_about_screen.dart │ │ ├── sudoku_setting_screen.dart │ │ ├── tipcount │ │ │ └── tip_count_item.dart │ │ └── tiplevel │ │ │ ├── tip_level_item.dart │ │ │ └── tip_level_setting_screen.dart │ ├── statistics │ │ └── sudoku_statistics.dart │ └── sudoku │ │ ├── base_sudoku.dart │ │ ├── counter_notifier.dart │ │ ├── sudoku_board.dart │ │ ├── sudoku_counter.dart │ │ ├── sudoku_header.dart │ │ ├── sudoku_key_pad.dart │ │ ├── sudoku_notifier.dart │ │ └── sudoku_operate.dart ├── common │ ├── constant.dart │ ├── context_extension.dart │ ├── env.dart │ └── set_extension.dart ├── component │ └── sudoku_cell.dart ├── main.dart ├── model │ ├── sudoku.dart │ ├── sudoku_config.dart │ ├── sudoku_input.dart │ ├── sudoku_input_log.dart │ ├── sudoku_point.dart │ ├── sudoku_record.dart │ └── sudoku_tip.dart ├── provider │ ├── error_count_provider.dart │ ├── theme_provider.dart │ ├── tip_count_provider.dart │ └── tip_level_provider.dart ├── service │ └── audio_service.dart ├── theme │ ├── color.dart │ ├── shape.dart │ └── theme.dart └── util │ ├── common_util.dart │ ├── date_util.dart │ ├── dio_util.dart │ ├── list_util.dart │ └── prefs_util.dart ├── pubspec.lock └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | # .env 47 | .env 48 | **/*.g.dart -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 17 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 18 | - platform: android 19 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 20 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 21 | - platform: ios 22 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 23 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 24 | 25 | # User provided section 26 | 27 | # List of Local paths (relative to this file) that should be 28 | # ignored by the migrate tool. 29 | # 30 | # Files that are not part of the templates will be ignored by default. 31 | unmanaged_files: 32 | - 'lib/main.dart' 33 | - 'ios/Runner.xcodeproj/project.pbxproj' 34 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Current Device", 6 | "request": "launch", 7 | "type": "dart" 8 | }, 9 | { 10 | "name": "Android SDK built for x86", 11 | "request": "launch", 12 | "type": "dart", 13 | "deviceId": "8DBAE1FB-0CD0-42AA-8052-1020E574A34E" 14 | }, 15 | { 16 | "name": "iPhone 14 Pro Max", 17 | "request": "launch", 18 | "type": "dart", 19 | "deviceId": "emulator-5554" 20 | }, 21 | { 22 | "name": "iPad Pro (12.9-inch)", 23 | "request": "launch", 24 | "type": "dart", 25 | "deviceId": "9D86034F-2DFB-4BC0-83EE-00841DB1504B" 26 | }, 27 | ], 28 | "compounds": [ 29 | { 30 | "name": "All Ios Devices", 31 | "configurations": ["iPhone 14 Pro Max", "iPad Pro (12.9-inch)"], 32 | }, 33 | { 34 | "name": "Android & Ios Devices", 35 | "configurations": ["iPhone 14 Pro Max", "Android SDK built for x86"], 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.classpath": true, 4 | "**/.project": true, 5 | "**/.settings": true, 6 | "**/.factorypath": true, 7 | ".vscode": true, 8 | ".idea": true, 9 | ".dart_tool": true, 10 | "build": true, 11 | "flutter_sudoku.iml": true, 12 | ".flutter-plugins": true, 13 | ".flutter-plugins-dependencies": true, 14 | "symbols": true, 15 | "android/.gradle": true, 16 | "ios/.symlinks": true, 17 | "ios/Pods": true, 18 | "**/*.g.dart": true 19 | }, 20 | "editor.minimap.enabled": false, 21 | "editor.fontFamily": "Monaco, 'Courier New', monospace", 22 | "editor.fontSize": 12, 23 | "gitlens.mode.active": "zen", 24 | "dart.closingLabels": false, 25 | "dart.lineLength": 120, 26 | "editor.rulers": [120], 27 | "editor.semanticHighlighting.enabled": false 28 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 huhx 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_sudoku 2 | 3 | 一个使用Flutter编写的每日数独小🎮游戏 4 | 5 | ## Preview 6 | 7 | | 数独首页 | 数独记录列表 | 数独设置 | 8 | |-------------------------|-------------------------|-------------------------| 9 | | ![数独首页](images/image_1.png) | ![数独记录列表](images/image_2.png) | ![数独设置](images/image_3.png) | 10 | 11 | | 数独记录详情 | 数独分享 | 数独主题 | 12 | |-------------------------|-------------------------|-------------------------| 13 | | ![数独记录详情](images/image_4.png) | ![数独分享](images/image_5.png) | ![数独主题](images/image_6.png) | 14 | 15 | ## Downlaod 16 | 17 | * Android: 18 | * 蒲公英: 19 | * google play store: 20 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | use_build_context_synchronously: true 26 | depend_on_referenced_packages: false 27 | 28 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 29 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 30 | 31 | # Additional information about this file can be found at 32 | # https://dart.dev/guides/language/analysis-options 33 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | keystore.gradle -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | apply from: "../keystore.gradle" 28 | 29 | android { 30 | compileSdkVersion 34 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_17 35 | targetCompatibility JavaVersion.VERSION_17 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '17' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | applicationId "com.huhx.sudoku" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | 55 | // fix the issue that debug mode in xiaomi9 pro 56 | } 57 | 58 | signingConfigs { 59 | release { 60 | storeFile file(RELEASE_STORE_FILE) 61 | storePassword RELEASE_STORE_PASSWORD 62 | keyAlias RELEASE_KEY_ALIAS 63 | keyPassword RELEASE_KEY_PASSWORD 64 | 65 | v1SigningEnabled true 66 | v2SigningEnabled true 67 | } 68 | } 69 | 70 | buildTypes { 71 | release { 72 | signingConfig signingConfigs.release 73 | minifyEnabled true 74 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" 75 | } 76 | } 77 | } 78 | 79 | flutter { 80 | source '../..' 81 | } 82 | 83 | dependencies { 84 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 85 | } 86 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 11 | 19 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/huhx/sudoku/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.huhx.sudoku 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-hdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-mdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.8.0' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.4.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/image/logo.png -------------------------------------------------------------------------------- /assets/image/sudoku_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/image/sudoku_dark.png -------------------------------------------------------------------------------- /assets/image/sudoku_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/image/sudoku_light.png -------------------------------------------------------------------------------- /assets/sound/fail.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/sound/fail.mp3 -------------------------------------------------------------------------------- /assets/sound/input.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/sound/input.mp3 -------------------------------------------------------------------------------- /assets/sound/operate.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/sound/operate.mp3 -------------------------------------------------------------------------------- /assets/sound/success.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/assets/sound/success.mp3 -------------------------------------------------------------------------------- /assets/svg/difficulty.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/done.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/drawer_menu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/error.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/game_status.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/home_double_right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/item_about.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/item_analyze.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/item_feedback.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/item_onboarding.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/item_record.svg: -------------------------------------------------------------------------------- 1 | 3 | 6 | 9 | 12 | -------------------------------------------------------------------------------- /assets/svg/level_check.svg: -------------------------------------------------------------------------------- 1 | 3 | 6 | -------------------------------------------------------------------------------- /assets/svg/main_category.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/main_home.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/main_profile.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/more_hor.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/operate_clear.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/operate_note.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/operate_quick_note.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/operate_tip.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/operate_undo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/reset.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_answer.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_failed.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_log.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_retry.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_setting.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_share.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_start.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /assets/svg/sudoku_stop.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/sudoku_success.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/user_tips.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/svg/weekday.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deploy_android.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | COMMIT_HASH=$(git rev-parse --short HEAD) 3 | 4 | # build the apk 5 | echo "------------------------------ start build android apk ------------------------------" 6 | BUILD_START=$(date +%s) 7 | flutter clean 8 | flutter build apk --obfuscate --split-debug-info=symbols --target-platform=android-arm64 --build-name="$COMMIT_HASH" 9 | BUILD_END=$(date +%s) 10 | BUILD_TIME=$((BUILD_END - BUILD_START)) 11 | printf "flutter build took %s seconds.\n" $BUILD_TIME 12 | 13 | echo "------------------------------ start upload apk ------------------------------" 14 | # upload apk to server 15 | UPLOAD_START=$(date +%s) 16 | FILENAME=build/app/outputs/apk/release/app-release.apk 17 | FILE_SIZE=$(stat -f%z "$FILENAME") 18 | 19 | curl -F "file=@$FILENAME" \ 20 | -F "buildInstallType=3" \ 21 | -F "buildPassword=huhx" \ 22 | -F "uKey=$pgyer_key" \ 23 | -F "updateDescription=flutter-sudoku" \ 24 | -F "_api_key=$pgyer_secret" \ 25 | https://upload.pgyer.com/apiv1/app/upload 26 | 27 | UPLOAD_END=$(date +%s) 28 | UPLOAD_TIME=$((UPLOAD_END - UPLOAD_START)) 29 | printf "\n" 30 | printf "upload took %s seconds and size is $FILE_SIZE kb.\n" $UPLOAD_TIME 31 | 32 | echo "------------------------------ start update apk ------------------------------" 33 | 34 | echo "download link: https://www.pgyer.com/9qCn" 35 | 36 | -------------------------------------------------------------------------------- /images/image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_1.png -------------------------------------------------------------------------------- /images/image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_2.png -------------------------------------------------------------------------------- /images/image_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_3.png -------------------------------------------------------------------------------- /images/image_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_4.png -------------------------------------------------------------------------------- /images/image_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_5.png -------------------------------------------------------------------------------- /images/image_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/images/image_6.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - audio_session (0.0.1): 3 | - Flutter 4 | - device_info_plus (0.0.1): 5 | - Flutter 6 | - Flutter (1.0.0) 7 | - flutter_deep_links (0.0.1): 8 | - Flutter 9 | - flutter_keyboard_visibility (0.0.1): 10 | - Flutter 11 | - fluttertoast (0.0.2): 12 | - Flutter 13 | - Toast 14 | - FMDB (2.7.5): 15 | - FMDB/standard (= 2.7.5) 16 | - FMDB/standard (2.7.5) 17 | - just_audio (0.0.1): 18 | - Flutter 19 | - package_info_plus (0.4.5): 20 | - Flutter 21 | - path_provider_foundation (0.0.1): 22 | - Flutter 23 | - FlutterMacOS 24 | - share_plus (0.0.1): 25 | - Flutter 26 | - shared_preferences_foundation (0.0.1): 27 | - Flutter 28 | - FlutterMacOS 29 | - sqflite (0.0.3): 30 | - Flutter 31 | - FMDB (>= 2.7.5) 32 | - Toast (4.0.0) 33 | - url_launcher_ios (0.0.1): 34 | - Flutter 35 | - vibration (1.7.5): 36 | - Flutter 37 | 38 | DEPENDENCIES: 39 | - audio_session (from `.symlinks/plugins/audio_session/ios`) 40 | - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) 41 | - Flutter (from `Flutter`) 42 | - flutter_deep_links (from `.symlinks/plugins/flutter_deep_links/ios`) 43 | - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) 44 | - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) 45 | - just_audio (from `.symlinks/plugins/just_audio/ios`) 46 | - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) 47 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 48 | - share_plus (from `.symlinks/plugins/share_plus/ios`) 49 | - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) 50 | - sqflite (from `.symlinks/plugins/sqflite/ios`) 51 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 52 | - vibration (from `.symlinks/plugins/vibration/ios`) 53 | 54 | SPEC REPOS: 55 | trunk: 56 | - FMDB 57 | - Toast 58 | 59 | EXTERNAL SOURCES: 60 | audio_session: 61 | :path: ".symlinks/plugins/audio_session/ios" 62 | device_info_plus: 63 | :path: ".symlinks/plugins/device_info_plus/ios" 64 | Flutter: 65 | :path: Flutter 66 | flutter_deep_links: 67 | :path: ".symlinks/plugins/flutter_deep_links/ios" 68 | flutter_keyboard_visibility: 69 | :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" 70 | fluttertoast: 71 | :path: ".symlinks/plugins/fluttertoast/ios" 72 | just_audio: 73 | :path: ".symlinks/plugins/just_audio/ios" 74 | package_info_plus: 75 | :path: ".symlinks/plugins/package_info_plus/ios" 76 | path_provider_foundation: 77 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 78 | share_plus: 79 | :path: ".symlinks/plugins/share_plus/ios" 80 | shared_preferences_foundation: 81 | :path: ".symlinks/plugins/shared_preferences_foundation/darwin" 82 | sqflite: 83 | :path: ".symlinks/plugins/sqflite/ios" 84 | url_launcher_ios: 85 | :path: ".symlinks/plugins/url_launcher_ios/ios" 86 | vibration: 87 | :path: ".symlinks/plugins/vibration/ios" 88 | 89 | SPEC CHECKSUMS: 90 | audio_session: 4f3e461722055d21515cf3261b64c973c062f345 91 | device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 92 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 93 | flutter_deep_links: 2c60c51f499089f31e93317a8b5369b325365ad2 94 | flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 95 | fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c 96 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 97 | just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa 98 | package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 99 | path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 100 | share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028 101 | shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 102 | sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a 103 | Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 104 | url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 105 | vibration: 7d883d141656a1c1a6d8d238616b2042a51a1241 106 | 107 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 108 | 109 | COCOAPODS: 1.12.1 110 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 42 | 44 | 50 | 51 | 52 | 53 | 59 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huhx/flutter_sudoku/7e5c8326592b3e3a27a3175e35f54952224aa988/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | 每日数独 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | sudoku 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | CFBundleURLTypes 52 | 53 | 54 | CFBundleTypeRole 55 | Editor 56 | CFBundleURLName 57 | sudoku 58 | CFBundleURLSchemes 59 | 60 | huhx 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/api/sudoku_api.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:dio/dio.dart'; 3 | import 'package:flutter_sudoku/common/env.dart'; 4 | import 'package:flutter_sudoku/model/sudoku.dart'; 5 | import 'package:flutter_sudoku/util/dio_util.dart'; 6 | 7 | class SudokuApi { 8 | Future getSudokuData(DateTime dateTime, Difficulty difficulty) async { 9 | final SudokuRequest request = SudokuRequest(dateTime: dateTime.toDate, difficulty: difficulty); 10 | final Response response = await RestClient.instance.get(Env.sudokuUrl, queryParameters: request.toRequest()); 11 | 12 | return SudokuResponse.fromJson(response.data); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/api/sudoku_record_api.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter_sudoku/business/statistics/sudoku_statistics.dart'; 4 | import 'package:flutter_sudoku/model/sudoku.dart'; 5 | import 'package:flutter_sudoku/model/sudoku_record.dart'; 6 | import 'package:path/path.dart'; 7 | import 'package:sqflite/sqflite.dart'; 8 | 9 | class SudokuRecordApi { 10 | static const String tableName = 'sudoku_record'; 11 | static const String dbName = 'sudoku_record.db'; 12 | static const String tableScript = ''' 13 | CREATE TABLE sudoku_record( 14 | id INTEGER PRIMARY KEY, 15 | year INTEGER NOT NULL, 16 | month INTEGER NOT NULL, 17 | day INTEGER NOT NULL, 18 | difficulty INTEGER NOT NULL, 19 | gameStatus TEXT NOT NULL, 20 | logStatus TEXT NOT NULL, 21 | sudokuInputLog TEXT NOT NULL, 22 | duration INTEGER NOT NULL, 23 | errorCount INTEGER NOT NULL, 24 | tipCount INTEGER NOT NULL, 25 | startTime INTEGER NOT NULL, 26 | endTime INTEGER NOT NULL, 27 | createTime INTEGER NOT NULL 28 | ) 29 | '''; 30 | 31 | Future insert(SudokuRecord sudokuRecord) async { 32 | final Database db = await _getDB(); 33 | await db.insert(tableName, sudokuRecord.toJson(), conflictAlgorithm: ConflictAlgorithm.replace); 34 | } 35 | 36 | Future deleteAll() async { 37 | final Database db = await _getDB(); 38 | await db.rawUpdate('UPDATE sudoku_record SET logStatus = ?', [LogStatus.delete.name]); 39 | } 40 | 41 | Future clear() async { 42 | final Database db = await _getDB(); 43 | await db.delete(tableName); 44 | } 45 | 46 | Future> querySudokuRecord(SudokuRequest request) async { 47 | final Database db = await _getDB(); 48 | final DateTime dateTime = request.dateTime; 49 | final List> maps = await db.query( 50 | tableName, 51 | where: 'year = ? and month = ? and day = ? and difficulty = ?', 52 | whereArgs: [dateTime.year, dateTime.month, dateTime.day, request.difficulty.level], 53 | orderBy: 'createTime desc', 54 | ); 55 | return maps.map((json) => SudokuRecord.fromJson(json)).toList(); 56 | } 57 | 58 | Future delete(int id) async { 59 | final Database db = await _getDB(); 60 | await db.rawUpdate('UPDATE sudoku_record SET logStatus = ? where id = ?', [LogStatus.delete.name, id]); 61 | } 62 | 63 | Future queryStatistics(Difficulty difficulty) async { 64 | final Database db = await _getDB(); 65 | final List> maps = await db.query( 66 | tableName, 67 | where: 'difficulty = ? and logStatus = ?', 68 | whereArgs: [difficulty.level, LogStatus.normal.name], 69 | orderBy: 'createTime desc', 70 | ); 71 | final List records = maps.map((json) => SudokuRecord.fromJson(json)).toList(); 72 | return SudokuStatistics.from(records); 73 | } 74 | 75 | Future> querySudokuRecords(int pageNum) async { 76 | final Database db = await _getDB(); 77 | final List> maps = await db.query( 78 | tableName, 79 | where: 'logStatus = ?', 80 | whereArgs: [LogStatus.normal.name], 81 | offset: (pageNum - 1) * 20, 82 | limit: 20, 83 | orderBy: 'createTime desc', 84 | ); 85 | return maps.map((json) => SudokuRecord.fromJson(json)).toList(); 86 | } 87 | 88 | Future _getDB() async { 89 | return openDatabase( 90 | join(await getDatabasesPath(), dbName), 91 | onCreate: (db, version) => db.execute(tableScript), 92 | version: 1, 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_calendar_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/common/context_extension.dart'; 5 | import 'package:table_calendar/table_calendar.dart'; 6 | 7 | class SudokuCalendarScreen extends StatelessWidget { 8 | final DateTime dateTime; 9 | 10 | const SudokuCalendarScreen(this.dateTime, {super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | leading: const AppbarBackButton(), 17 | title: Text(dateTime.dateString), 18 | ), 19 | body: TableCalendar( 20 | focusedDay: dateTime, 21 | firstDay: DateTime.utc(2020, 10, 4), 22 | lastDay: DateTime.now(), 23 | onDaySelected: (selectedDate, _) => context.pop(selectedDate), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_drawer.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/business/profile/onboard_screen.dart'; 5 | import 'package:flutter_sudoku/business/record/sudoku_record_list_screen.dart'; 6 | import 'package:flutter_sudoku/business/setting/sudoku_about_screen.dart'; 7 | import 'package:flutter_sudoku/business/setting/sudoku_setting_screen.dart'; 8 | import 'package:flutter_sudoku/common/context_extension.dart'; 9 | import 'package:flutter_sudoku/model/sudoku_config.dart'; 10 | import 'package:fluttertoast/fluttertoast.dart'; 11 | import 'package:url_launcher/url_launcher.dart'; 12 | 13 | class SudokuDrawer extends StatelessWidget { 14 | const SudokuDrawer({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | final TextStyle? textStyle = Theme.of(context).textTheme.bodyMedium; 19 | 20 | return Drawer( 21 | child: Column( 22 | children: [ 23 | DrawerHeader( 24 | child: Align( 25 | alignment: Alignment.centerLeft, 26 | child: Text("每日数独", style: textStyle?.copyWith(fontSize: 24)), 27 | ), 28 | ), 29 | Expanded( 30 | child: ListView( 31 | padding: const EdgeInsets.symmetric(vertical: 0), 32 | children: [ 33 | ListTile( 34 | leading: const SvgIcon(name: "item_onboarding"), 35 | title: Text("玩法介绍", style: textStyle), 36 | onTap: () { 37 | context.pop(); 38 | context.goto(const OnboardScreen()); 39 | }, 40 | ), 41 | ListTile( 42 | leading: const SvgIcon(name: "item_record"), 43 | title: Text("记录", style: textStyle), 44 | onTap: () { 45 | context.pop(); 46 | context.goto(const SudokuRecordListScreen()); 47 | }, 48 | ), 49 | ListTile( 50 | leading: const SvgIcon(name: "sudoku_share"), 51 | title: Text("分享", style: textStyle), 52 | onTap: () { 53 | context.pop(); 54 | context.share(title: '分享一款非常棒的数独游戏, 休闲益智.', subject: "sudoku"); 55 | }, 56 | ), 57 | ListTile( 58 | leading: const SvgIcon(name: "item_about"), 59 | title: Text("关于", style: textStyle), 60 | onTap: () { 61 | context.pop(); 62 | context.goto(const SudokuAboutScreen()); 63 | }, 64 | ), 65 | if (sudokuConfig.isMember) 66 | ListTile( 67 | leading: const SvgIcon(name: "item_feedback"), 68 | title: Text("意见反馈", style: textStyle), 69 | onTap: () async { 70 | context.pop(); 71 | final Uri mail = Uri( 72 | scheme: 'mailto', 73 | path: 'gohuhx@gmail.com', 74 | query: 'subject=[数独]意见反馈&body=意见反馈:', 75 | ); 76 | if (await canLaunchUrl(mail)) { 77 | await launchUrl(mail); 78 | } else { 79 | Fluttertoast.showToast(msg: 'Can not open email app.'); 80 | } 81 | }, 82 | ), 83 | ListTile( 84 | leading: const SvgIcon(name: "sudoku_setting"), 85 | title: Text("设置", style: textStyle), 86 | onTap: () { 87 | context.pop(); 88 | context.goto(const SudokuSettingScreen()); 89 | }, 90 | ), 91 | ], 92 | ), 93 | ), 94 | ], 95 | ), 96 | ); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_failed_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/views.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 4 | import 'package:flutter_sudoku/common/context_extension.dart'; 5 | import 'package:flutter_sudoku/provider/error_count_provider.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | class SudokuFailedScreen extends ConsumerWidget { 9 | final SudokuNotifier sudokuNotifier; 10 | 11 | const SudokuFailedScreen(this.sudokuNotifier, {super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final retryCount = ref.watch(errorCountProvider); 16 | 17 | return Scaffold( 18 | appBar: AppBar( 19 | leading: const AppbarBackButton(), 20 | title: const Text("挑战失败"), 21 | ), 22 | body: Container( 23 | alignment: Alignment.center, 24 | child: Column( 25 | mainAxisAlignment: MainAxisAlignment.center, 26 | children: [ 27 | const SvgIcon(name: "sudoku_failed", size: 64), 28 | const SizedBox(height: 16), 29 | Text(sudokuNotifier.difficulty.label), 30 | const SizedBox(height: 6), 31 | Text(sudokuNotifier.dateString), 32 | const SizedBox(height: 6), 33 | Text("错误:${sudokuNotifier.retryCount}/$retryCount"), 34 | const SizedBox(height: 6), 35 | OutlinedButton( 36 | onPressed: () async { 37 | await sudokuNotifier.reset(); 38 | if (context.mounted) context.pop(); 39 | }, 40 | child: const Text("再次挑战"), 41 | ), 42 | ], 43 | ), 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/business/home/sudoku_calendar_screen.dart'; 5 | import 'package:flutter_sudoku/business/home/sudoku_drawer.dart'; 6 | import 'package:flutter_sudoku/business/setting/sudoku_setting_screen.dart'; 7 | import 'package:flutter_sudoku/business/sudoku/sudoku_board.dart'; 8 | import 'package:flutter_sudoku/business/sudoku/sudoku_header.dart'; 9 | import 'package:flutter_sudoku/business/sudoku/sudoku_key_pad.dart'; 10 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 11 | import 'package:flutter_sudoku/business/sudoku/sudoku_operate.dart'; 12 | import 'package:flutter_sudoku/common/context_extension.dart'; 13 | import 'package:flutter_sudoku/model/sudoku.dart'; 14 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 15 | 16 | class SudokuScreen extends HookConsumerWidget { 17 | final DateTime dateTime; 18 | final Difficulty difficulty; 19 | 20 | const SudokuScreen(this.dateTime, this.difficulty, {super.key}); 21 | 22 | @override 23 | Widget build(BuildContext context, WidgetRef ref) { 24 | final SudokuRequest sudokuRequest = SudokuRequest(dateTime: dateTime, difficulty: difficulty); 25 | final sudokuModel = ref.watch(sudokuProvider(sudokuRequest)); 26 | 27 | return Scaffold( 28 | appBar: AppBar( 29 | leading: Builder( 30 | builder: (context) => SvgActionIcon( 31 | name: "drawer_menu", 32 | onPressed: () => Scaffold.of(context).openDrawer(), 33 | ), 34 | ), 35 | title: InkWell( 36 | child: const Text("数独"), 37 | onTap: () async { 38 | final DateTime? selectedDateTime = await context.goto(SudokuCalendarScreen(dateTime)); 39 | if (selectedDateTime != null && !selectedDateTime.isSameDay(dateTime)) { 40 | await sudokuModel.init(selectedDateTime, difficulty); 41 | } 42 | }, 43 | ), 44 | actions: [ 45 | SvgActionIcon( 46 | name: "sudoku_share", 47 | onPressed: () => context.share(title: sudokuModel.shareTitle, subject: "sudoku"), 48 | ), 49 | SvgActionIcon( 50 | name: "sudoku_setting", 51 | onPressed: () => context.goto(const SudokuSettingScreen()), 52 | ), 53 | ], 54 | ), 55 | drawer: const SudokuDrawer(), 56 | body: sudokuModel.state.when( 57 | loading: () => const CenterProgressIndicator(), 58 | error: (errorText) => const CenterProgressIndicator(), 59 | success: () { 60 | return Container( 61 | padding: const EdgeInsets.symmetric(horizontal: 16), 62 | child: Column( 63 | children: [ 64 | SudokuHeader(sudokuModel), 65 | SudokuBoard(sudokuModel), 66 | SudokuOperate(sudokuModel), 67 | SudokuKeyPad(sudokuModel), 68 | ], 69 | ), 70 | ); 71 | }, 72 | ), 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_statistics_detail_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/api/sudoku_record_api.dart'; 5 | import 'package:flutter_sudoku/business/home/sudoku_screen.dart'; 6 | import 'package:flutter_sudoku/business/statistics/sudoku_statistics.dart'; 7 | import 'package:flutter_sudoku/common/context_extension.dart'; 8 | import 'package:flutter_sudoku/model/sudoku.dart'; 9 | import 'package:get_it/get_it.dart'; 10 | 11 | class SudokuStatisticsDetailScreen extends StatelessWidget { 12 | final Difficulty difficulty; 13 | 14 | const SudokuStatisticsDetailScreen(this.difficulty, {super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return FutureBuilder( 19 | future: GetIt.I().queryStatistics(difficulty), 20 | builder: (context, snap) { 21 | if (!snap.hasData) return const CenterProgressIndicator(); 22 | final SudokuStatistics statistics = snap.data as SudokuStatistics; 23 | 24 | return Padding( 25 | padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 16), 26 | child: Column( 27 | children: [ 28 | ListTile( 29 | title: const Text("总共局数"), 30 | trailing: Text(statistics.totalCount.toString()), 31 | ), 32 | ListTile( 33 | title: const Text("胜局次数"), 34 | trailing: Text(statistics.successCount.toString()), 35 | ), 36 | ListTile( 37 | title: const Text("败局次数"), 38 | trailing: Text(statistics.failedCount.toString()), 39 | ), 40 | ListTile( 41 | title: const Text("最佳时间"), 42 | trailing: Text(statistics.bestTime.timeString), 43 | ), 44 | ListTile( 45 | title: const Text("最长时间"), 46 | trailing: Text(statistics.worstTime.timeString), 47 | ), 48 | ListTile( 49 | title: const Text("平均时间"), 50 | trailing: Text(statistics.avgTime.timeString), 51 | ), 52 | ListTile( 53 | title: const Text("最长连赢"), 54 | trailing: Text(statistics.straightWins.toString()), 55 | ), 56 | ListTile( 57 | title: const Text("最惨连败"), 58 | trailing: Text(statistics.straightLose.toString()), 59 | ), 60 | Expanded( 61 | child: Center( 62 | child: OutlinedButton( 63 | style: OutlinedButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 32)), 64 | onPressed: () => context.pushAndRemoveUntil(SudokuScreen(DateTime.now(), difficulty)), 65 | child: const Text("开始一局"), 66 | ), 67 | ), 68 | ) 69 | ], 70 | ), 71 | ); 72 | }, 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_statistics_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/constant.dart'; 2 | import 'package:app_common_flutter/extension.dart'; 3 | import 'package:app_common_flutter/views.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_sudoku/api/sudoku_record_api.dart'; 6 | import 'package:flutter_sudoku/common/constant.dart'; 7 | import 'package:flutter_sudoku/model/sudoku.dart'; 8 | import 'package:get_it/get_it.dart'; 9 | 10 | import 'sudoku_statistics_detail_screen.dart'; 11 | 12 | class SudokuStatisticsScreen extends StatefulWidget { 13 | const SudokuStatisticsScreen({super.key}); 14 | 15 | @override 16 | State createState() => _SudokuStatisticsScreenState(); 17 | } 18 | 19 | class _SudokuStatisticsScreenState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | return DefaultTabController( 23 | length: Difficulty.values.length, 24 | child: Scaffold( 25 | appBar: AppBar( 26 | leading: const AppbarBackButton(), 27 | title: const Text("统计"), 28 | actions: [ 29 | SvgActionIcon( 30 | package: Comm.package, 31 | name: IconName.delete, 32 | onPressed: () { 33 | context.showCommDialog( 34 | callback: () async { 35 | await GetIt.I().deleteAll(); 36 | setState(() {}); 37 | }, 38 | title: '清空记录', 39 | content: '你确定清空数独记录?', 40 | ); 41 | }, 42 | ), 43 | ], 44 | bottom: TabBar( 45 | tabs: Difficulty.values.map((difficulty) => Tab(text: difficulty.label)).toList(), 46 | indicatorColor: Colors.white, 47 | indicatorWeight: 1, 48 | ), 49 | ), 50 | body: TabBarView( 51 | children: Difficulty.values.map((difficulty) => SudokuStatisticsDetailScreen(difficulty)).toList(), 52 | ), 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/business/home/sudoku_success_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/views.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 4 | import 'package:flutter_sudoku/common/context_extension.dart'; 5 | import 'package:flutter_sudoku/provider/error_count_provider.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | class SudokuSuccessScreen extends ConsumerWidget { 9 | final SudokuNotifier sudokuNotifier; 10 | 11 | const SudokuSuccessScreen(this.sudokuNotifier, {super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final retryCount = ref.watch(errorCountProvider); 16 | 17 | return Scaffold( 18 | appBar: AppBar( 19 | leading: const AppbarBackButton(), 20 | title: const Text("挑战成功"), 21 | ), 22 | body: Container( 23 | alignment: Alignment.center, 24 | child: Column( 25 | mainAxisAlignment: MainAxisAlignment.center, 26 | crossAxisAlignment: CrossAxisAlignment.start, 27 | children: [ 28 | const SvgIcon(name: "sudoku_success", size: 64), 29 | const SizedBox(height: 16), 30 | Text("难度: ${sudokuNotifier.difficulty.label}"), 31 | const SizedBox(height: 6), 32 | Text("用时: ${sudokuNotifier.dateString}"), 33 | const SizedBox(height: 6), 34 | Text("错误:${sudokuNotifier.retryCount}/$retryCount"), 35 | const SizedBox(height: 6), 36 | OutlinedButton( 37 | onPressed: () async { 38 | await sudokuNotifier.next(); 39 | if (context.mounted) context.pop(); 40 | }, 41 | child: const Text("下一关"), 42 | ), 43 | ], 44 | ), 45 | ), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/business/profile/onboard_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/views.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/common/context_extension.dart'; 4 | import 'package:flutter_sudoku/provider/theme_provider.dart'; 5 | import 'package:flutter_sudoku/theme/shape.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | import 'package:introduction_screen/introduction_screen.dart'; 8 | 9 | class OnboardScreen extends ConsumerWidget { 10 | const OnboardScreen({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final ThemeMode themeMode = ref.watch(themeProvider); 15 | 16 | return Scaffold( 17 | appBar: AppBar( 18 | leading: const AppbarBackButton(), 19 | title: const Text("数独教程"), 20 | ), 21 | body: IntroductionScreen( 22 | showDoneButton: true, 23 | showSkipButton: true, 24 | showNextButton: false, 25 | skip: const Text("跳过"), 26 | done: const Text("完成"), 27 | onSkip: () => context.pop(), 28 | onDone: () => context.pop(), 29 | pages: [ 30 | PageViewModel( 31 | decoration: pageDecoration, 32 | title: "什么是数独", 33 | body: "数独是最受欢迎的益智游戏之一,它通过逻辑推理来完成。解题过程不需要计算或者特殊的数学技能,只需要开动你的大脑和集中注意力。每天玩一玩数独游戏,可以提高你的注意力和进一步开发你的大脑。", 34 | image: Image.asset( 35 | getFilename(themeMode), 36 | alignment: Alignment.bottomCenter, 37 | fit: BoxFit.cover, 38 | ), 39 | ), 40 | PageViewModel( 41 | decoration: pageDecoration, 42 | title: "数独的规则", 43 | body: "数独的解题过程就是在9*9的方格内填入1-9的数字, 要求每行每列和每组(粗线方框内的3*3的格子)的数字不能重复。", 44 | image: Image.asset(getFilename(themeMode)), 45 | ), 46 | PageViewModel( 47 | decoration: pageDecoration, 48 | title: "数独的玩法", 49 | body: "游戏可以试错三次,笔记功能可以让你预填,以便后面进行修改。", 50 | image: Image.asset(getFilename(themeMode)), 51 | ), 52 | ], 53 | ), 54 | ); 55 | } 56 | 57 | String getFilename(ThemeMode themeMode) { 58 | return themeMode == ThemeMode.dark ? "assets/image/sudoku_dark.png" : "assets/image/sudoku_light.png"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/business/record/data/sudoku_record_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/business/sudoku/base_sudoku.dart'; 5 | import 'package:flutter_sudoku/model/sudoku.dart'; 6 | import 'package:flutter_sudoku/model/sudoku_input.dart'; 7 | import 'package:flutter_sudoku/model/sudoku_input_log.dart'; 8 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 9 | import 'package:flutter_sudoku/service/audio_service.dart'; 10 | import 'package:flutter_sudoku/theme/color.dart'; 11 | import 'package:get_it/get_it.dart'; 12 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 13 | 14 | class SudokuRecordNotifier extends ChangeNotifier with BaseSudoku { 15 | final SudokuInputLog sudokuInputLog; 16 | 17 | late int currentIndex; 18 | late bool _disposed; 19 | late bool _showAnswer; 20 | 21 | SudokuRecordNotifier({required this.sudokuInputLog}); 22 | 23 | Difficulty get difficulty => sudokuInputLog.difficulty; 24 | DateTime get dateTime => DateTime.fromMillisecondsSinceEpoch(sudokuInputLog.dateTime); 25 | 26 | void init() { 27 | question = toArray(sudokuInputLog.question); 28 | content = toArray(sudokuInputLog.question); 29 | answer = toArray(sudokuInputLog.answer); 30 | 31 | selected = Point.first(); 32 | notesMap = {}; 33 | 34 | highlightPoints = highlight(); 35 | relatedPoints = related(); 36 | textColorMap = {for (final point in empty()) point: inputColor}; 37 | 38 | _disposed = false; 39 | _showAnswer = false; 40 | currentIndex = 0; 41 | } 42 | 43 | Future resetPlay() async { 44 | currentIndex = 0; 45 | content = toArray(sudokuInputLog.question); 46 | 47 | while (!_disposed && currentIndex < sudokuInputLog.sudokuInputs.length) { 48 | await Future.delayed(const Duration(seconds: 1), () { 49 | final SudokuInput sudokuInput = sudokuInputLog.sudokuInputs[currentIndex]; 50 | _onPlay(sudokuInput); 51 | if (!_disposed) { 52 | notifyListeners(); 53 | } 54 | currentIndex++; 55 | }); 56 | } 57 | return _disposed ? GameStatus.running : sudokuInputLog.gameStatus; 58 | } 59 | 60 | void toogleAnswer() { 61 | highlightPoints = []; 62 | relatedPoints = []; 63 | 64 | textColorMap = {for (final point in empty()) point: inputColor}; 65 | notesMap.clear(); 66 | selected = Point.from(-1, -1); 67 | if (_showAnswer) { 68 | content = toArray(sudokuInputLog.question); 69 | } else { 70 | content = toArray(sudokuInputLog.answer); 71 | } 72 | _showAnswer = !_showAnswer; 73 | 74 | notifyListeners(); 75 | } 76 | 77 | void _onPlay(SudokuInput sudokuInput) { 78 | /** 79 | * There are four kinds of operation: 80 | * 1. note model 81 | * 2. input value 82 | * 3. clear 83 | * 4. use tip 84 | * 85 | * But for point 2, 3, 4 they are actually the same: 86 | * 2. random value, maybe correct or wrong 87 | * 3. zero value 88 | * 4. correct value 89 | */ 90 | GetIt.I().playInput(); 91 | selected = sudokuInput.point; 92 | relatedPoints = related(); 93 | 94 | // node model 95 | if (sudokuInput.noteValues.isNotEmpty) { 96 | notesMap[selected] = sudokuInput.noteValues; 97 | content[selected.x][selected.y] = sudokuInput.value; 98 | 99 | highlightPoints = []; 100 | } else { 101 | // input model 102 | content[selected.x][selected.y] = sudokuInput.value; 103 | notesMap[selected] = sudokuInput.noteValues; 104 | highlightPoints = highlight(); 105 | textColorMap[selected] = sudokuInput.isCorrect ? inputColor : errorColor; 106 | } 107 | } 108 | 109 | @override 110 | void dispose() { 111 | _disposed = true; 112 | _showAnswer = false; 113 | super.dispose(); 114 | } 115 | } 116 | 117 | final sudokuRecordProvider = ChangeNotifierProvider.autoDispose.family( 118 | (ref, sudokuInputLog) => SudokuRecordNotifier(sudokuInputLog: sudokuInputLog)..init(), 119 | ); 120 | -------------------------------------------------------------------------------- /lib/business/record/sudoku_record_board.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/component/sudoku_cell.dart'; 3 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | 6 | import 'data/sudoku_record_notifier.dart'; 7 | 8 | class SudokuRecordBoard extends HookConsumerWidget { 9 | final SudokuRecordNotifier sudokuRecordModel; 10 | 11 | const SudokuRecordBoard(this.sudokuRecordModel, {super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | return Table( 16 | children: List.generate( 17 | 9, 18 | (row) => TableRow( 19 | children: List.generate(9, (column) { 20 | final Point point = Point.from(row, column); 21 | 22 | return TableCell( 23 | child: SudokuCell( 24 | boxBorder: point.border, 25 | value: sudokuRecordModel.getValue(point), 26 | noteValue: sudokuRecordModel.getNoteValue(point), 27 | color: sudokuRecordModel.getColor(point), 28 | textColor: sudokuRecordModel.getTextColor(point), 29 | ), 30 | ); 31 | }), 32 | ), 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/business/record/sudoku_record_list_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/pagination.dart'; 3 | import 'package:app_common_flutter/views.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_slidable/flutter_slidable.dart'; 6 | import 'package:flutter_sudoku/api/sudoku_record_api.dart'; 7 | import 'package:flutter_sudoku/business/home/sudoku_statistics_screen.dart'; 8 | import 'package:flutter_sudoku/common/context_extension.dart'; 9 | import 'package:flutter_sudoku/model/sudoku_record.dart'; 10 | import 'package:flutter_sudoku/util/date_util.dart'; 11 | import 'package:get_it/get_it.dart'; 12 | import 'package:pull_to_refresh/pull_to_refresh.dart'; 13 | import 'package:sticky_headers/sticky_headers.dart'; 14 | 15 | import 'sudoku_record_slidable.dart'; 16 | 17 | class SudokuRecordListScreen extends StatefulWidget { 18 | const SudokuRecordListScreen({super.key}); 19 | 20 | @override 21 | State createState() => _SudokuRecordListScreenState(); 22 | } 23 | 24 | class _SudokuRecordListScreenState extends StreamState { 25 | @override 26 | Future fetchPage(int pageKey) async { 27 | if (streamList.isOpen) { 28 | final List sudokuRecords = await GetIt.I().querySudokuRecords(pageKey); 29 | streamList.fetch(sudokuRecords, pageKey); 30 | } 31 | } 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar( 37 | leading: const AppbarBackButton(), 38 | title: const Text("数独记录"), 39 | actions: [ 40 | SvgActionIcon( 41 | name: "item_analyze", 42 | onPressed: () => context.goto(const SudokuStatisticsScreen()), 43 | ) 44 | ], 45 | ), 46 | body: StreamBuilder( 47 | stream: streamList.stream, 48 | builder: (context, snap) { 49 | if (!snap.hasData) return const CenterProgressIndicator(); 50 | final List sudokuRecords = snap.data as List; 51 | 52 | if (sudokuRecords.isEmpty) { 53 | return const EmptyWidget(message: "数独记录为空"); 54 | } 55 | 56 | final Map> recordLogMap = 57 | sudokuRecords.groupBy((readLog) => readLog.createTimeString); 58 | 59 | return SlidableAutoCloseBehavior( 60 | child: SmartRefresher( 61 | controller: streamList.refreshController, 62 | onRefresh: () => streamList.onRefresh(), 63 | onLoading: () => streamList.onLoading(), 64 | enablePullUp: true, 65 | child: ListView.builder( 66 | itemCount: recordLogMap.length, 67 | itemBuilder: (_, index) { 68 | final String dateString = recordLogMap.keys.elementAt(index); 69 | final List recordLogItems = recordLogMap[dateString]!; 70 | 71 | return StickyHeader( 72 | header: Container( 73 | color: Theme.of(context).scaffoldBackgroundColor, 74 | padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), 75 | child: Row( 76 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 77 | children: [ 78 | SimpleTextIcon(icon: "sudoku_log", text: dateString), 79 | SimpleTextIcon(icon: "weekday", text: DateUtil.getWeekFromString(dateString)), 80 | ], 81 | ), 82 | ), 83 | content: ListView.builder( 84 | primary: false, 85 | shrinkWrap: true, 86 | itemBuilder: (context, index) { 87 | return SudokuRecordSlidable( 88 | key: ValueKey(recordLogItems[index].id), 89 | sudokuRecord: recordLogItems[index], 90 | onDelete: (id) async { 91 | streamList.reset(sudokuRecords.where((element) => element.id != id).toList()); 92 | await GetIt.I().delete(id); 93 | }, 94 | ); 95 | }, 96 | itemCount: recordLogItems.length, 97 | ), 98 | ); 99 | }, 100 | ), 101 | ), 102 | ); 103 | }, 104 | ), 105 | ); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /lib/business/record/sudoku_record_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/util.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/business/home/sudoku_screen.dart'; 5 | import 'package:flutter_sudoku/common/context_extension.dart'; 6 | import 'package:flutter_sudoku/model/sudoku.dart'; 7 | import 'package:flutter_sudoku/model/sudoku_record.dart'; 8 | import 'package:flutter_sudoku/util/common_util.dart'; 9 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 10 | 11 | import 'data/sudoku_record_notifier.dart'; 12 | import 'sudoku_record_board.dart'; 13 | 14 | class SudokuRecordScreen extends HookConsumerWidget { 15 | final SudokuRecord sudokuRecord; 16 | 17 | const SudokuRecordScreen(this.sudokuRecord, {super.key}); 18 | 19 | @override 20 | Widget build(BuildContext context, WidgetRef ref) { 21 | final sudokuRecordModel = ref.watch(sudokuRecordProvider(sudokuRecord.sudokuInputLog)); 22 | 23 | return Scaffold( 24 | appBar: AppBar( 25 | leading: const AppbarBackButton(), 26 | title: const Text("数独记录详情"), 27 | actions: [ 28 | Padding( 29 | padding: const EdgeInsets.all(8.0), 30 | child: OutlinedButton( 31 | onPressed: () { 32 | context.pushAndRemoveUntil(SudokuScreen(sudokuRecordModel.dateTime, sudokuRecordModel.difficulty)); 33 | }, 34 | child: const Text("开始一局"), 35 | ), 36 | ) 37 | ], 38 | ), 39 | body: ListView( 40 | padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), 41 | children: [ 42 | Row( 43 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 44 | children: [ 45 | Text("时间:${sudokuRecord.dateString}"), 46 | Text("难度: ${sudokuRecord.difficulty.label}"), 47 | Text("用时: ${sudokuRecord.secondsString}"), 48 | ], 49 | ), 50 | Row( 51 | mainAxisAlignment: MainAxisAlignment.end, 52 | children: [ 53 | IconButton( 54 | icon: const SvgIcon(name: 'sudoku_retry', color: Colors.green), 55 | onPressed: () async { 56 | final GameStatus gameStatus = await sudokuRecordModel.resetPlay(); 57 | if (gameStatus == GameStatus.success) { 58 | CommonUtil.vibrateWarn(); 59 | CommUtil.toast(message: "恭喜你成功过关"); 60 | } else if (gameStatus == GameStatus.failed) { 61 | CommonUtil.vibrateWarn(); 62 | CommUtil.toast(message: "已达到最大错误次数,游戏失败"); 63 | } 64 | }, 65 | ), 66 | IconButton( 67 | icon: const SvgIcon(name: 'sudoku_answer', color: Colors.green), 68 | onPressed: () => sudokuRecordModel.toogleAnswer(), 69 | ), 70 | ], 71 | ), 72 | SudokuRecordBoard(sudokuRecordModel), 73 | const SizedBox(height: 16), 74 | Row( 75 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 76 | children: [ 77 | Text("输入: ${sudokuRecord.sudokuInputLog.inputSteps}次"), 78 | Text("笔记: ${sudokuRecord.sudokuInputLog.noteSteps}次"), 79 | Text("错误: ${sudokuRecord.errorCount}次"), 80 | Text("提示: ${sudokuRecord.tipCount}次"), 81 | ], 82 | ), 83 | ], 84 | ), 85 | ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/business/record/sudoku_record_slidable.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_slidable/flutter_slidable.dart'; 5 | import 'package:flutter_sudoku/common/context_extension.dart'; 6 | import 'package:flutter_sudoku/model/sudoku_record.dart'; 7 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 8 | 9 | import 'sudoku_record_screen.dart'; 10 | 11 | class SudokuRecordSlidable extends ConsumerWidget { 12 | final SudokuRecord sudokuRecord; 13 | final Function(int) onDelete; 14 | 15 | const SudokuRecordSlidable({ 16 | super.key, 17 | required this.sudokuRecord, 18 | required this.onDelete, 19 | }); 20 | 21 | @override 22 | Widget build(BuildContext context, WidgetRef ref) { 23 | return Slidable( 24 | groupTag: "sudoku", 25 | key: ValueKey(sudokuRecord.id), 26 | endActionPane: ActionPane( 27 | motion: const ScrollMotion(), 28 | children: [ 29 | SlidableAction( 30 | onPressed: (_) => onDelete(sudokuRecord.id!), 31 | backgroundColor: const Color(0xFFFE4A49), 32 | foregroundColor: Colors.white, 33 | icon: Icons.delete, 34 | label: 'Delete', 35 | ), 36 | SlidableAction( 37 | onPressed: (_) => context.share(title: sudokuRecord.shareTitle, subject: "sudoku"), 38 | backgroundColor: const Color(0xFF21B7CA), 39 | foregroundColor: Colors.white, 40 | icon: Icons.share, 41 | label: 'Share', 42 | ), 43 | ], 44 | ), 45 | child: SudokuRecordItem(sudokuRecord), 46 | ); 47 | } 48 | } 49 | 50 | class SudokuRecordItem extends StatelessWidget { 51 | final SudokuRecord sudokuRecord; 52 | 53 | const SudokuRecordItem(this.sudokuRecord, {super.key}); 54 | 55 | @override 56 | Widget build(BuildContext context) { 57 | return ListTile( 58 | onTap: () => context.goto(SudokuRecordScreen(sudokuRecord)), 59 | leading: CircleAvatar( 60 | backgroundColor: sudokuRecord.color, 61 | child: Text("${sudokuRecord.duration}", style: const TextStyle(color: Colors.white)), 62 | ), 63 | title: Text(sudokuRecord.startString, style: Theme.of(context).textTheme.bodyMedium), 64 | subtitle: Padding( 65 | padding: const EdgeInsets.only(top: 8), 66 | child: Row( 67 | children: [ 68 | TextIcon(icon: "game_status", text: sudokuRecord.gameStatus.label), 69 | const SizedBox(width: 16), 70 | TextIcon(icon: "user_tips", text: "${sudokuRecord.tipCount}次"), 71 | const SizedBox(width: 16), 72 | TextIcon(icon: "error", text: "${sudokuRecord.errorCount}次"), 73 | const SizedBox(width: 16), 74 | TextIcon(icon: "difficulty", text: sudokuRecord.difficulty.label), 75 | ], 76 | ), 77 | ), 78 | trailing: const ListTileTrailing(), 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lib/business/setting/cache/clear_cache_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_sudoku/api/sudoku_record_api.dart'; 6 | import 'package:flutter_sudoku/common/context_extension.dart'; 7 | import 'package:get_it/get_it.dart'; 8 | 9 | class ClearCacheItem extends StatelessWidget { 10 | const ClearCacheItem({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return CupertinoListTile( 15 | backgroundColor: Theme.of(context).colorScheme.surface, 16 | title: Text('清除缓存', style: Theme.of(context).textTheme.bodyLarge), 17 | trailing: const ListTileTrailing(), 18 | onTap: () => _showConfirmDialog(context), 19 | ); 20 | } 21 | 22 | Future _showConfirmDialog(BuildContext context) async { 23 | context.showCommDialog( 24 | callback: () async { 25 | await GetIt.I().clear(); 26 | if (context.mounted) context.pop(); 27 | }, 28 | title: '清除缓存', 29 | content: '你确定清除缓存?', 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/business/setting/dark/dark_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/provider/theme_provider.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | 6 | class DarkItem extends HookConsumerWidget { 7 | const DarkItem({super.key}); 8 | 9 | @override 10 | Widget build(BuildContext context, WidgetRef ref) { 11 | final themeMode = ref.watch(themeProvider); 12 | 13 | return CupertinoListTile( 14 | backgroundColor: Theme.of(context).colorScheme.surface, 15 | title: Text('夜间模式', style: Theme.of(context).textTheme.bodyLarge), 16 | trailing: Switch.adaptive( 17 | value: themeMode == ThemeMode.dark, 18 | onChanged: (isDark) => ref.read(themeProvider.notifier).setDark(isDark), 19 | ), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/business/setting/errorcount/error_count_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_hooks/flutter_hooks.dart'; 5 | import 'package:flutter_sudoku/provider/error_count_provider.dart'; 6 | import 'package:flutter_sudoku/theme/shape.dart'; 7 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 8 | 9 | class ErrorCountItem extends HookConsumerWidget { 10 | const ErrorCountItem({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final errorCount = ref.watch(errorCountProvider); 15 | final userTextController = useTextEditingController() 16 | ..text = errorCount.toString() 17 | ..selection = TextSelection.fromPosition(const TextPosition(offset: 1)); 18 | 19 | return CupertinoListTile( 20 | backgroundColor: Theme.of(context).colorScheme.surface, 21 | title: Text('错误次数', style: Theme.of(context).textTheme.bodyLarge), 22 | trailing: Flexible( 23 | child: TextFormField( 24 | controller: userTextController, 25 | onTap: () { 26 | userTextController.selection = TextSelection.fromPosition(const TextPosition(offset: 1)); 27 | }, 28 | keyboardType: TextInputType.number, 29 | style: Theme.of(context).textTheme.bodyMedium, 30 | textAlign: TextAlign.end, 31 | decoration: inputDecoration, 32 | inputFormatters: [LengthLimitingTextInputFormatter(1)], 33 | onChanged: (String value) { 34 | if (value.isNotEmpty) { 35 | ref.read(errorCountProvider.notifier).set(int.parse(value)); 36 | } 37 | }, 38 | ), 39 | ), 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/business/setting/sound/play_sound_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_hooks/flutter_hooks.dart'; 4 | import 'package:flutter_sudoku/util/prefs_util.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | 7 | class PlaySoundItem extends HookConsumerWidget { 8 | const PlaySoundItem({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | final isPlaySound = useState(PrefsUtil.isPlaySound()); 13 | 14 | return CupertinoListTile( 15 | backgroundColor: Theme.of(context).colorScheme.surface, 16 | title: Text('音效', style: Theme.of(context).textTheme.bodyLarge), 17 | trailing: Switch.adaptive( 18 | value: isPlaySound.value, 19 | onChanged: (isPlay) { 20 | isPlaySound.value = isPlay; 21 | PrefsUtil.enablePlaySound(isPlay); 22 | }, 23 | ), 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/business/setting/sudoku_about_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/util.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class SudokuAboutScreen extends StatelessWidget { 6 | const SudokuAboutScreen({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | appBar: AppBar( 12 | leading: const AppbarBackButton(), 13 | title: const Text("关于数独"), 14 | ), 15 | body: ListView( 16 | padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), 17 | children: [ 18 | const Text( 19 | "数独游戏", 20 | style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18), 21 | textAlign: TextAlign.center, 22 | ), 23 | Container( 24 | margin: const EdgeInsets.only(top: 16), 25 | height: 120, 26 | width: 120, 27 | decoration: const BoxDecoration( 28 | shape: BoxShape.circle, 29 | image: DecorationImage( 30 | image: AssetImage('assets/image/logo.png'), 31 | fit: BoxFit.contain, 32 | ), 33 | ), 34 | ), 35 | Padding( 36 | padding: const EdgeInsets.only(top: 8, bottom: 16), 37 | child: Text("此版本为${AppConfig.get("version")}", textAlign: TextAlign.center), 38 | ), 39 | const Text( 40 | '''数独是最受欢迎的益智游戏之一,它通过逻辑推理来完成. 解题过程不需要计算或者特殊的数学技能,只需要开动你的大脑和集中注意力. 每天玩一玩数独游戏,可以提高你的注意力和进一步开发你的大脑. 数独的解题过程就是在9*9的方格内填入1-9的数字,要求每行每列和每组(粗线方框内的3*3的格子)的数字不能重复. 41 | ''', 42 | style: TextStyle(height: 1.5), 43 | ) 44 | ], 45 | ), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/business/setting/sudoku_setting_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/views.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sudoku/model/sudoku_config.dart'; 5 | 6 | import 'cache/clear_cache_item.dart'; 7 | import 'dark/dark_item.dart'; 8 | import 'errorcount/error_count_item.dart'; 9 | import 'sound/play_sound_item.dart'; 10 | import 'tipcount/tip_count_item.dart'; 11 | import 'tiplevel/tip_level_item.dart'; 12 | 13 | class SudokuSettingScreen extends StatelessWidget { 14 | const SudokuSettingScreen({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | leading: const AppbarBackButton(), 21 | title: const Text("设置"), 22 | ), 23 | body: ListView( 24 | children: [ 25 | CupertinoListSection.insetGrouped( 26 | backgroundColor: Theme.of(context).scaffoldBackgroundColor, 27 | additionalDividerMargin: 8, 28 | margin: const EdgeInsets.only(left: 16, right: 16, top: 20), 29 | children: const [ 30 | ClearCacheItem(), 31 | PlaySoundItem(), 32 | DarkItem(), 33 | ], 34 | ), 35 | if (sudokuConfig.isMember) 36 | CupertinoListSection.insetGrouped( 37 | backgroundColor: Theme.of(context).scaffoldBackgroundColor, 38 | additionalDividerMargin: 8, 39 | margin: const EdgeInsets.only(left: 16, right: 16, top: 20), 40 | children: const [ 41 | TipLevelItem(), 42 | ErrorCountItem(), 43 | TipCountItem(), 44 | ], 45 | ), 46 | ], 47 | ), 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/business/setting/tipcount/tip_count_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_hooks/flutter_hooks.dart'; 5 | import 'package:flutter_sudoku/provider/tip_count_provider.dart'; 6 | import 'package:flutter_sudoku/theme/shape.dart'; 7 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 8 | 9 | class TipCountItem extends HookConsumerWidget { 10 | const TipCountItem({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final tipCount = ref.watch(tipCountProvider); 15 | final userTextController = useTextEditingController() 16 | ..text = tipCount.toString() 17 | ..selection = TextSelection.fromPosition(const TextPosition(offset: 1)); 18 | 19 | return CupertinoListTile( 20 | backgroundColor: Theme.of(context).colorScheme.surface, 21 | title: Text('提醒次数', style: Theme.of(context).textTheme.bodyLarge), 22 | trailing: Flexible( 23 | child: TextFormField( 24 | controller: userTextController, 25 | onTap: () => userTextController.selection = TextSelection.fromPosition(const TextPosition(offset: 1)), 26 | textAlign: TextAlign.end, 27 | keyboardType: TextInputType.number, 28 | decoration: inputDecoration, 29 | inputFormatters: [LengthLimitingTextInputFormatter(1)], 30 | onChanged: (String value) { 31 | if (value.isNotEmpty) { 32 | ref.read(tipCountProvider.notifier).set(int.parse(value)); 33 | } 34 | }, 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/business/setting/tiplevel/tip_level_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/business/setting/tiplevel/tip_level_setting_screen.dart'; 4 | import 'package:flutter_sudoku/common/context_extension.dart'; 5 | import 'package:flutter_sudoku/model/sudoku_tip.dart'; 6 | import 'package:flutter_sudoku/provider/tip_level_provider.dart'; 7 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 8 | 9 | class TipLevelItem extends HookConsumerWidget { 10 | const TipLevelItem({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context, WidgetRef ref) { 14 | final tipLevel = ref.watch(tipLevelProvider); 15 | 16 | return CupertinoListTile( 17 | backgroundColor: Theme.of(context).colorScheme.surface, 18 | title: Text('智能等级', style: Theme.of(context).textTheme.bodyLarge), 19 | trailing: Text(tipLevel.description), 20 | onTap: () async { 21 | final TipLevel? result = await context.goto(TipLevelSettingScreen(tipLevel: tipLevel)); 22 | if (result != null) { 23 | ref.read(tipLevelProvider.notifier).set(result); 24 | } 25 | }, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/business/setting/tiplevel/tip_level_setting_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/views.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_hooks/flutter_hooks.dart'; 4 | import 'package:flutter_sudoku/common/context_extension.dart'; 5 | import 'package:flutter_sudoku/model/sudoku_tip.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | class TipLevelSettingScreen extends HookConsumerWidget { 9 | final TipLevel tipLevel; 10 | 11 | const TipLevelSettingScreen({required this.tipLevel, super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final tipLevelState = useState(tipLevel); 16 | 17 | return Scaffold( 18 | appBar: AppBar( 19 | leading: const AppbarBackButton(), 20 | title: const Text("智能等级设置"), 21 | actions: [ 22 | SvgActionIcon( 23 | name: "done", 24 | onPressed: () => context.pop(tipLevelState.value), 25 | ) 26 | ], 27 | ), 28 | body: ListView( 29 | padding: const EdgeInsets.symmetric(vertical: 12), 30 | physics: const ListScrollPhysics(), 31 | children: TipLevel.values.map((tipLevel) { 32 | return TipLevelItem( 33 | isChecked: tipLevelState.value == tipLevel, 34 | tipLevel: tipLevel, 35 | label: tipLevel.description, 36 | callback: () => tipLevelState.value = tipLevel, 37 | ); 38 | }).toList(), 39 | ), 40 | ); 41 | } 42 | } 43 | 44 | class TipLevelItem extends StatelessWidget { 45 | final bool isChecked; 46 | final TipLevel tipLevel; 47 | final String label; 48 | final VoidCallback callback; 49 | 50 | const TipLevelItem({ 51 | super.key, 52 | required this.isChecked, 53 | required this.tipLevel, 54 | required this.label, 55 | required this.callback, 56 | }); 57 | 58 | @override 59 | Widget build(BuildContext context) { 60 | return InkWell( 61 | onTap: callback, 62 | child: Padding( 63 | padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), 64 | child: Row( 65 | children: [ 66 | Opacity( 67 | opacity: isChecked ? 1 : 0, 68 | child: const SvgIcon(name: "level_check"), 69 | ), 70 | const SizedBox(width: 10), 71 | Text(label), 72 | ], 73 | ), 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/business/statistics/sudoku_statistics.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:flutter_sudoku/model/sudoku.dart'; 5 | import 'package:flutter_sudoku/model/sudoku_record.dart'; 6 | 7 | class SudokuStatistics extends Equatable { 8 | final int totalCount; 9 | final int successCount; 10 | final int failedCount; 11 | final int bestTime; 12 | final int worstTime; 13 | final int avgTime; 14 | final int straightWins; 15 | final int straightLose; 16 | 17 | const SudokuStatistics({ 18 | required this.totalCount, 19 | required this.successCount, 20 | required this.failedCount, 21 | required this.bestTime, 22 | required this.worstTime, 23 | required this.avgTime, 24 | required this.straightWins, 25 | required this.straightLose, 26 | }); 27 | 28 | @override 29 | List get props { 30 | return [ 31 | totalCount, 32 | successCount, 33 | failedCount, 34 | bestTime, 35 | worstTime, 36 | avgTime, 37 | straightWins, 38 | straightLose, 39 | ]; 40 | } 41 | 42 | static SudokuStatistics from(List records) { 43 | final List success = records.where((record) => record.isSuccess).toList(); 44 | final List failed = records.where((record) => record.isFailed).toList(); 45 | 46 | return SudokuStatistics( 47 | totalCount: records.length, 48 | successCount: success.length, 49 | failedCount: failed.length, 50 | bestTime: success.isEmpty ? 0 : success.map((record) => record.duration).reduce(min), 51 | worstTime: success.isEmpty ? 0 : success.map((record) => record.duration).reduce(max), 52 | avgTime: success.isEmpty ? 0 : success.map((record) => record.duration).reduce((a, b) => a + b) ~/ success.length, 53 | straightWins: getStraightWins(records), 54 | straightLose: getStraightLose(records), 55 | ); 56 | } 57 | 58 | static int getStraightWins(List records) { 59 | return _getStraightValue(records, GameStatus.success); 60 | } 61 | 62 | static int getStraightLose(List records) { 63 | return _getStraightValue(records, GameStatus.failed); 64 | } 65 | 66 | static int _getStraightValue(List records, GameStatus status) { 67 | int maximum = 0, current = 0; 68 | final int length = records.length; 69 | for (int i = 0; i < length; i++) { 70 | if (records[i].gameStatus == status) { 71 | current += 1; 72 | } else { 73 | maximum = max(maximum, current); 74 | current = 0; 75 | } 76 | } 77 | return max(maximum, current); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/business/sudoku/base_sudoku.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/extension.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 4 | import 'package:flutter_sudoku/theme/color.dart'; 5 | import 'package:flutter_sudoku/util/list_util.dart'; 6 | 7 | mixin BaseSudoku { 8 | late List> question; 9 | late List> content; 10 | late List> answer; 11 | late Point selected; 12 | 13 | late Map?> notesMap; 14 | 15 | late Map textColorMap; 16 | late List highlightPoints; 17 | late List relatedPoints; 18 | 19 | Color? getColor(Point point) { 20 | if (point == selected) { 21 | return selectedColor; 22 | } 23 | 24 | if (highlightPoints.contains(point)) { 25 | return highlightColor; 26 | } 27 | 28 | if (relatedPoints.contains(point)) { 29 | return relatedColor; 30 | } 31 | return null; 32 | } 33 | 34 | Color? getTextColor(Point point) { 35 | return textColorMap[point]; 36 | } 37 | 38 | List? getNoteValue(Point point) { 39 | return notesMap[point]; 40 | } 41 | 42 | int getValue(Point point) { 43 | return content[point.x][point.y]; 44 | } 45 | 46 | int get contentValue => content[selected.x][selected.y]; 47 | int get questionValue => question[selected.x][selected.y]; 48 | int get answerValue => answer[selected.x][selected.y]; 49 | 50 | List empty() { 51 | List points = []; 52 | for (int i = 0; i < question.length; i++) { 53 | for (int j = 0; j < question[i].length; j++) { 54 | if (question[i][j] == 0) { 55 | points.add(Point(x: i, y: j)); 56 | } 57 | } 58 | } 59 | return points; 60 | } 61 | 62 | List highlight() { 63 | if (contentValue == 0) { 64 | return []; 65 | } 66 | List points = []; 67 | for (int i = 0; i < content.length; i++) { 68 | for (int j = 0; j < content[i].length; j++) { 69 | if ((i != selected.x && j != selected.y) && contentValue == content[i][j]) { 70 | points.add(Point(x: i, y: j)); 71 | } 72 | } 73 | } 74 | return points; 75 | } 76 | 77 | Set horizontalSet() { 78 | Set result = {}; 79 | for (int i = 0; i < content.length; i++) { 80 | final int value = content[i][selected.y]; 81 | if (value != 0 && value == answer[i][selected.y]) { 82 | result.add(value); 83 | } 84 | } 85 | return result; 86 | } 87 | 88 | Set verticalSet() { 89 | Set result = {}; 90 | for (int i = 0; i < content.length; i++) { 91 | final int value = content[selected.x][i]; 92 | if (value != 0 && value == answer[selected.x][i]) { 93 | result.add(value); 94 | } 95 | } 96 | return result; 97 | } 98 | 99 | Set insideSet() { 100 | Set result = {}; 101 | ListUtil.related(selected).forEach((point) { 102 | final int value = content[point.x][point.y]; 103 | if (value != 0 && value == answer[point.x][point.y]) { 104 | result.add(value); 105 | } 106 | }); 107 | return result; 108 | } 109 | 110 | List related() { 111 | List relatedList = []; 112 | for (int i = 0; i < content.length; i++) { 113 | for (int j = 0; j < content[i].length; j++) { 114 | if (i == selected.x && j == selected.y) { 115 | continue; 116 | } 117 | if (i == selected.x || j == selected.y) { 118 | relatedList.add(Point.from(i, j)); 119 | } 120 | } 121 | } 122 | return relatedList; 123 | } 124 | 125 | List> toArray(String string) { 126 | final List firstChunk = string.chunk(9); 127 | return firstChunk.map((e) => e.split("").map((e) => e.toInt()).toList()).toList(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /lib/business/sudoku/counter_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:app_common_flutter/extension.dart'; 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | 7 | class CounterNotifier extends ChangeNotifier { 8 | bool isStart = true; 9 | int seconds = 0; 10 | Timer? timer; 11 | 12 | void init(int initSeconds) { 13 | seconds = initSeconds; 14 | 15 | timer = Timer.periodic(const Duration(seconds: 1), (_) { 16 | seconds = seconds + 1; 17 | 18 | notifyListeners(); 19 | }); 20 | } 21 | 22 | void toggle() { 23 | isStart = !isStart; 24 | 25 | if (isStart) { 26 | timer = Timer.periodic(const Duration(seconds: 1), (_) { 27 | seconds = seconds + 1; 28 | 29 | notifyListeners(); 30 | }); 31 | } else { 32 | timer?.cancel(); 33 | 34 | notifyListeners(); 35 | } 36 | } 37 | 38 | String get secondsString => seconds.timeString; 39 | 40 | void reset() { 41 | isStart = false; 42 | 43 | timer?.cancel(); 44 | notifyListeners(); 45 | } 46 | 47 | @override 48 | void dispose() { 49 | isStart = false; 50 | 51 | timer?.cancel(); 52 | super.dispose(); 53 | } 54 | } 55 | 56 | final counterProvider = ChangeNotifierProvider.autoDispose((ref) { 57 | return CounterNotifier()..init(0); 58 | }); 59 | -------------------------------------------------------------------------------- /lib/business/sudoku/sudoku_board.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 3 | import 'package:flutter_sudoku/component/sudoku_cell.dart'; 4 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 5 | 6 | class SudokuBoard extends StatelessWidget { 7 | final SudokuNotifier sudokuNotifier; 8 | 9 | const SudokuBoard(this.sudokuNotifier, {super.key}); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return Table( 14 | children: List.generate( 15 | 9, 16 | (row) => TableRow( 17 | children: List.generate(9, (column) { 18 | final Point point = Point.from(row, column); 19 | return TableCell( 20 | child: InkWell( 21 | onTap: () => sudokuNotifier.onTapped(point), 22 | child: SudokuCell( 23 | boxBorder: point.border, 24 | value: sudokuNotifier.getValue(point), 25 | noteValue: sudokuNotifier.getNoteValue(point), 26 | color: sudokuNotifier.getColor(point), 27 | textColor: sudokuNotifier.getTextColor(point), 28 | ), 29 | ), 30 | ); 31 | }), 32 | ), 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/business/sudoku/sudoku_counter.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/business/sudoku/counter_notifier.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | class SudokuCounter extends HookConsumerWidget { 6 | final int initSeconds; 7 | 8 | const SudokuCounter({super.key, required this.initSeconds}); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | final counterModel = ref.watch(counterProvider); 13 | 14 | return Text(counterModel.secondsString); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/business/sudoku/sudoku_header.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 3 | 4 | import 'sudoku_counter.dart'; 5 | 6 | class SudokuHeader extends StatelessWidget { 7 | final SudokuNotifier sudokuNotifier; 8 | 9 | const SudokuHeader(this.sudokuNotifier, {super.key}); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return Padding( 14 | padding: const EdgeInsets.all(8.0), 15 | child: Row( 16 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 17 | children: [ 18 | Text(sudokuNotifier.difficulty.label), 19 | const SudokuCounter(initSeconds: 0), 20 | Text( 21 | sudokuNotifier.retryString, 22 | style: TextStyle(color: sudokuNotifier.retryCount == 0 ? null : Colors.red), 23 | ), 24 | ], 25 | ), 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/business/sudoku/sudoku_key_pad.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/business/home/sudoku_failed_screen.dart'; 3 | import 'package:flutter_sudoku/business/home/sudoku_success_screen.dart'; 4 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 5 | import 'package:flutter_sudoku/common/context_extension.dart'; 6 | import 'package:flutter_sudoku/model/sudoku.dart'; 7 | 8 | class SudokuKeyPad extends StatelessWidget { 9 | final SudokuNotifier sudokuNotifier; 10 | 11 | const SudokuKeyPad(this.sudokuNotifier, {super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return GridView.count( 16 | physics: const NeverScrollableScrollPhysics(), 17 | shrinkWrap: true, 18 | crossAxisCount: 9, 19 | crossAxisSpacing: 10, 20 | children: List.generate( 21 | 9, 22 | (index) => NumberItem(sudokuNotifier.isEnable(index + 1), index + 1, (int num) { 23 | final GameStatus gameStatus = sudokuNotifier.onInput(num); 24 | if (gameStatus == GameStatus.success) { 25 | context.goto(SudokuSuccessScreen(sudokuNotifier)); 26 | } else if (gameStatus == GameStatus.failed) { 27 | context.goto(SudokuFailedScreen(sudokuNotifier)); 28 | } 29 | }), 30 | ), 31 | ); 32 | } 33 | } 34 | 35 | class NumberItem extends StatelessWidget { 36 | final bool isEnable; 37 | final int number; 38 | final Function(int) onPressed; 39 | 40 | const NumberItem(this.isEnable, this.number, this.onPressed, {super.key}); 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return InkWell( 45 | onTap: isEnable ? () => onPressed(number) : null, 46 | child: AspectRatio( 47 | aspectRatio: 1, 48 | child: Container( 49 | alignment: Alignment.center, 50 | decoration: BoxDecoration( 51 | borderRadius: const BorderRadius.all(Radius.circular(6)), 52 | border: Border.all(width: 1, color: Colors.grey), 53 | ), 54 | child: Text( 55 | number.toString(), 56 | style: TextStyle(fontSize: 24, color: isEnable ? Colors.green : Colors.grey), 57 | ), 58 | ), 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/business/sudoku/sudoku_operate.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_common_flutter/util.dart'; 2 | import 'package:app_common_flutter/views.dart'; 3 | import 'package:badges/badges.dart'; 4 | import 'package:badges/badges.dart' as badges; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_sudoku/business/sudoku/sudoku_notifier.dart'; 7 | 8 | class SudokuOperate extends StatelessWidget { 9 | final SudokuNotifier sudokuNotifier; 10 | 11 | const SudokuOperate(this.sudokuNotifier, {super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | final Color themeColor = Theme.of(context).colorScheme.primary; 16 | 17 | return Padding( 18 | padding: const EdgeInsets.symmetric(vertical: 20), 19 | child: Row( 20 | mainAxisAlignment: MainAxisAlignment.spaceAround, 21 | children: [ 22 | OperateItem( 23 | icon: SvgIcon(name: "operate_clear", color: sudokuNotifier.canClear ? themeColor : Colors.grey), 24 | label: "擦除", 25 | onPressed: sudokuNotifier.canClear ? () => sudokuNotifier.clear() : null, 26 | ), 27 | OperateItem( 28 | icon: badges.Badge( 29 | badgeAnimation: const BadgeAnimation.fade(), 30 | badgeStyle: const badges.BadgeStyle( 31 | padding: EdgeInsets.all(3), 32 | badgeColor: Colors.red, 33 | ), 34 | badgeContent: sudokuNotifier.enableNotes 35 | ? const Text("Y", style: TextStyle(fontSize: 8)) 36 | : const Text("N", style: TextStyle(fontSize: 8)), 37 | child: SvgIcon(name: "operate_note", color: themeColor), 38 | ), 39 | label: "笔记", 40 | onPressed: () => sudokuNotifier.toggleNote(), 41 | ), 42 | OperateItem( 43 | icon: badges.Badge( 44 | badgeAnimation: const BadgeAnimation.fade(), 45 | badgeStyle: badges.BadgeStyle( 46 | padding: const EdgeInsets.all(4), 47 | badgeColor: sudokuNotifier.canUseTip ? Colors.red : Colors.grey, 48 | ), 49 | badgeContent: Text("${sudokuNotifier.tipCount}", style: const TextStyle(fontSize: 8)), 50 | child: SvgIcon(name: "operate_tip", color: sudokuNotifier.canUseTip ? themeColor : Colors.grey), 51 | ), 52 | label: "提示", 53 | onPressed: sudokuNotifier.canUseTip ? () => useTip(sudokuNotifier) : null, 54 | ), 55 | ], 56 | ), 57 | ); 58 | } 59 | 60 | void useTip(SudokuNotifier sudokuNotifier) { 61 | if (sudokuNotifier.tipCount <= 0) { 62 | CommUtil.toast(message: "您的提示次数已经用完"); 63 | return; 64 | } 65 | sudokuNotifier.useTip(); 66 | } 67 | } 68 | 69 | class OperateItem extends StatelessWidget { 70 | final Widget icon; 71 | final String label; 72 | final VoidCallback? onPressed; 73 | 74 | const OperateItem({ 75 | super.key, 76 | required this.icon, 77 | required this.label, 78 | required this.onPressed, 79 | }); 80 | 81 | @override 82 | Widget build(BuildContext context) { 83 | return InkWell( 84 | onTap: onPressed, 85 | child: Column( 86 | children: [ 87 | icon, 88 | const SizedBox(height: 6), 89 | Text(label, style: const TextStyle(fontSize: 13)), 90 | ], 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/common/constant.dart: -------------------------------------------------------------------------------- 1 | class IconName { 2 | IconName._(); 3 | 4 | static const String add = "add"; 5 | static const String delete = "delete"; 6 | static const String done = "done"; 7 | static const String moreHor = "more_hor"; 8 | } 9 | -------------------------------------------------------------------------------- /lib/common/context_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | extension ContextExtensions on BuildContext { 4 | Future goto(Widget widget) async { 5 | return Navigator.push(this, MaterialPageRoute(builder: (_) => widget)); 6 | } 7 | 8 | Future replace(Widget widget) async { 9 | return Navigator.pushReplacement(this, MaterialPageRoute(builder: (_) => widget)); 10 | } 11 | 12 | Future pushAndRemoveUntil(Widget widget) async { 13 | return Navigator.pushAndRemoveUntil(this, MaterialPageRoute(builder: (_) => widget), (route) => false); 14 | } 15 | 16 | void pop([T? result]) { 17 | Navigator.pop(this, result); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/common/env.dart: -------------------------------------------------------------------------------- 1 | import 'package:envied/envied.dart'; 2 | 3 | part 'env.g.dart'; 4 | 5 | @Envied(path: '.env') 6 | abstract class Env { 7 | @EnviedField(varName: 'sudokuUrl', obfuscate: true) 8 | static final String sudokuUrl = _Env.sudokuUrl; 9 | } 10 | -------------------------------------------------------------------------------- /lib/common/set_extension.dart: -------------------------------------------------------------------------------- 1 | extension SetExtension on Set { 2 | Set operator +(Set other) { 3 | return {...this, ...other}; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/component/sudoku_cell.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SudokuCell extends StatelessWidget { 4 | final BoxBorder boxBorder; 5 | final List? noteValue; 6 | final int value; 7 | final Color? color; 8 | final Color? textColor; 9 | 10 | const SudokuCell({ 11 | super.key, 12 | required this.boxBorder, 13 | required this.noteValue, 14 | required this.value, 15 | this.color, 16 | this.textColor, 17 | }); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return AspectRatio( 22 | aspectRatio: 1, 23 | child: Container( 24 | decoration: BoxDecoration(border: boxBorder, color: color), 25 | alignment: Alignment.center, 26 | child: noteValue != null && noteValue!.isNotEmpty 27 | ? SudokuNoteCell(noteValue!) 28 | : SudokuNormalCell(value, textColor), 29 | ), 30 | ); 31 | } 32 | } 33 | 34 | class SudokuNoteCell extends StatelessWidget { 35 | final List values; 36 | 37 | const SudokuNoteCell(this.values, {super.key}); 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | return Text( 42 | "$values", 43 | style: const TextStyle(fontSize: 8), 44 | textAlign: TextAlign.start, 45 | ); 46 | } 47 | } 48 | 49 | class SudokuNormalCell extends StatelessWidget { 50 | final int value; 51 | final Color? color; 52 | 53 | const SudokuNormalCell(this.value, this.color, {super.key}); 54 | 55 | @override 56 | Widget build(BuildContext context) { 57 | return Text( 58 | value == 0 ? "" : value.toString(), 59 | style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16, color: color), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/model/sudoku.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class SudokuRequest extends Equatable { 4 | final DateTime dateTime; 5 | final Difficulty difficulty; 6 | 7 | const SudokuRequest({ 8 | required this.dateTime, 9 | required this.difficulty, 10 | }); 11 | 12 | Map toJson() { 13 | return { 14 | 'dateTime': dateTime, 15 | 'difficulty': difficulty.level, 16 | }; 17 | } 18 | 19 | Map toRequest() { 20 | return { 21 | 'year': dateTime.year, 22 | 'month': dateTime.month, 23 | 'day': dateTime.day, 24 | 'difficulty': difficulty.level, 25 | }; 26 | } 27 | 28 | @override 29 | List get props => [dateTime, difficulty]; 30 | } 31 | 32 | enum Difficulty { 33 | d(0, "入门"), 34 | c(1, "初级"), 35 | b(2, "中级"), 36 | a(3, "高级"), 37 | s(4, "骨灰级"); 38 | 39 | final int level; 40 | final String label; 41 | 42 | const Difficulty(this.level, this.label); 43 | 44 | static Difficulty from(int level) { 45 | return Difficulty.values.firstWhere((element) => element.level == level); 46 | } 47 | 48 | static Difficulty? next(Difficulty difficulty) { 49 | if (difficulty.level + 1 > Difficulty.s.level) { 50 | return null; 51 | } 52 | return Difficulty.from(difficulty.level + 1); 53 | } 54 | } 55 | 56 | class SudokuResponse extends Equatable { 57 | final String question; 58 | final String answer; 59 | final Difficulty difficulty; 60 | final String dateTime; 61 | 62 | const SudokuResponse({ 63 | required this.question, 64 | required this.answer, 65 | required this.difficulty, 66 | required this.dateTime, 67 | }); 68 | 69 | factory SudokuResponse.fromJson(Map json) { 70 | return SudokuResponse( 71 | question: json['question'] as String, 72 | answer: json['answer'] as String, 73 | difficulty: Difficulty.from(json['difficulty'] as int), 74 | dateTime: json['dateTime'] as String, 75 | ); 76 | } 77 | 78 | @override 79 | List get props => [question, answer, difficulty, dateTime]; 80 | } 81 | 82 | enum GameStatus { 83 | success('成功'), 84 | running('运行'), 85 | failed('失败'); 86 | 87 | final String label; 88 | 89 | const GameStatus(this.label); 90 | } 91 | -------------------------------------------------------------------------------- /lib/model/sudoku_config.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | import 'sudoku_tip.dart'; 4 | 5 | class SudokuConfig extends Equatable { 6 | final int retryCount; 7 | final int tipCount; 8 | final TipLevel tipLevel; 9 | final bool isMember; 10 | 11 | const SudokuConfig({ 12 | required this.retryCount, 13 | required this.tipCount, 14 | required this.tipLevel, 15 | required this.isMember, 16 | }); 17 | 18 | @override 19 | List get props => [retryCount, tipCount, tipLevel, isMember]; 20 | } 21 | 22 | const SudokuConfig sudokuConfig = SudokuConfig( 23 | retryCount: 3, 24 | tipCount: 3, 25 | tipLevel: TipLevel.none, 26 | isMember: true, 27 | ); 28 | -------------------------------------------------------------------------------- /lib/model/sudoku_input.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 5 | 6 | class SudokuInput extends Equatable { 7 | final Point point; 8 | final int value; 9 | final bool isCorrect; 10 | final bool useTip; 11 | final List noteValues; 12 | 13 | const SudokuInput({ 14 | required this.point, 15 | required this.value, 16 | required this.isCorrect, 17 | required this.useTip, 18 | required this.noteValues, 19 | }); 20 | 21 | factory SudokuInput.clear(Point point) { 22 | return SudokuInput( 23 | point: point, 24 | value: 0, 25 | isCorrect: false, 26 | useTip: false, 27 | noteValues: const [], 28 | ); 29 | } 30 | 31 | factory SudokuInput.note(Point point, List noteValue) { 32 | return SudokuInput( 33 | point: point, 34 | value: 0, 35 | isCorrect: false, 36 | useTip: false, 37 | noteValues: noteValue, 38 | ); 39 | } 40 | 41 | factory SudokuInput.tip(Point point, int value) { 42 | return SudokuInput( 43 | point: point, 44 | value: value, 45 | isCorrect: true, 46 | useTip: true, 47 | noteValues: const [], 48 | ); 49 | } 50 | 51 | factory SudokuInput.normal(Point point, bool isCorrect, int value) { 52 | return SudokuInput( 53 | point: point, 54 | value: value, 55 | isCorrect: isCorrect, 56 | useTip: false, 57 | noteValues: const [], 58 | ); 59 | } 60 | 61 | factory SudokuInput.fromJson(Map json) { 62 | return SudokuInput( 63 | point: Point.fromJson(jsonDecode(json['point']) as Map), 64 | value: json['value'] as int, 65 | isCorrect: json['isCorrect'] as bool, 66 | useTip: json['useTip'] as bool, 67 | noteValues: (json['noteValues'] as List).map((noteValue) => noteValue as int).toList(), 68 | ); 69 | } 70 | 71 | Map toJson() { 72 | return { 73 | 'point': jsonEncode(point.toJson()), 74 | 'value': value, 75 | 'isCorrect': isCorrect, 76 | 'useTip': useTip, 77 | 'noteValues': noteValues, 78 | }; 79 | } 80 | 81 | @override 82 | List get props => [point, value, isCorrect, useTip, noteValues]; 83 | } 84 | -------------------------------------------------------------------------------- /lib/model/sudoku_input_log.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:flutter_sudoku/model/sudoku_input.dart'; 5 | 6 | import 'sudoku.dart'; 7 | 8 | class SudokuInputLog extends Equatable { 9 | final String question; 10 | final String answer; 11 | final Difficulty difficulty; 12 | final int dateTime; 13 | final GameStatus gameStatus; 14 | final List sudokuInputs; 15 | 16 | const SudokuInputLog({ 17 | required this.question, 18 | required this.answer, 19 | required this.difficulty, 20 | required this.dateTime, 21 | required this.gameStatus, 22 | required this.sudokuInputs, 23 | }); 24 | 25 | int get totalSteps => sudokuInputs.length; 26 | 27 | int get inputSteps { 28 | return sudokuInputs.where((sudokuInput) => sudokuInput.value != 0).length; 29 | } 30 | 31 | int get noteSteps { 32 | return sudokuInputs.where((sudokuInput) => sudokuInput.noteValues.isNotEmpty).length; 33 | } 34 | 35 | Map toJson() { 36 | return { 37 | 'question': question, 38 | 'answer': answer, 39 | 'difficulty': difficulty.level, 40 | 'gameStatus': gameStatus.name, 41 | 'dateTime': dateTime, 42 | 'sudokuInputs': jsonEncode(sudokuInputs.map((sudokuInput) => sudokuInput.toJson()).toList()) 43 | }; 44 | } 45 | 46 | factory SudokuInputLog.fromJson(Map json) { 47 | return SudokuInputLog( 48 | question: json['question'] as String, 49 | answer: json['answer'] as String, 50 | difficulty: Difficulty.from(json['difficulty'] as int), 51 | gameStatus: GameStatus.values.byName(json['gameStatus'] as String), 52 | dateTime: json['dateTime'] as int, 53 | sudokuInputs: (jsonDecode(json['sudokuInputs']) as List) 54 | .map((sudokuInput) => SudokuInput.fromJson(sudokuInput as Map)) 55 | .toList(), 56 | ); 57 | } 58 | 59 | @override 60 | List get props => [question, answer, difficulty, dateTime, gameStatus, sudokuInputs]; 61 | } 62 | -------------------------------------------------------------------------------- /lib/model/sudoku_point.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class Point extends Equatable { 5 | final int x; 6 | final int y; 7 | 8 | const Point({required this.x, required this.y}); 9 | 10 | factory Point.first() { 11 | return const Point(x: 0, y: 0); 12 | } 13 | 14 | factory Point.from(int x, int y) { 15 | return Point(x: x, y: y); 16 | } 17 | 18 | BoxBorder get border { 19 | const BorderSide borderSide = BorderSide(color: Colors.blue, width: 2.0); 20 | final List columnIndexes = [0, 3, 6]; 21 | final List rowIndexes = [0, 3, 6]; 22 | BorderSide top = BorderSide.none, bottom = BorderSide.none, left = BorderSide.none, right = BorderSide.none; 23 | 24 | if (columnIndexes.contains(y)) { 25 | left = borderSide; 26 | } else { 27 | left = const BorderSide(color: Colors.grey); 28 | } 29 | 30 | if (rowIndexes.contains(x)) { 31 | top = borderSide; 32 | } else { 33 | top = const BorderSide(color: Colors.grey); 34 | } 35 | 36 | if (y == 8) { 37 | right = borderSide; 38 | } 39 | 40 | if (x == 8) { 41 | bottom = borderSide; 42 | } 43 | 44 | return Border(top: top, bottom: bottom, left: left, right: right); 45 | } 46 | 47 | factory Point.fromJson(Map json) { 48 | return Point(x: json['x'] as int, y: json['y'] as int); 49 | } 50 | 51 | Map toJson() { 52 | return {'x': x, 'y': y}; 53 | } 54 | 55 | @override 56 | List get props => [x, y]; 57 | } 58 | -------------------------------------------------------------------------------- /lib/model/sudoku_record.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:app_common_flutter/extension.dart'; 4 | import 'package:equatable/equatable.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | import 'sudoku.dart'; 8 | import 'sudoku_input_log.dart'; 9 | 10 | class SudokuRecord extends Equatable { 11 | final int? id; 12 | final int year; 13 | final int month; 14 | final int day; 15 | final Difficulty difficulty; 16 | final GameStatus gameStatus; 17 | final LogStatus logStatus; 18 | final SudokuInputLog sudokuInputLog; 19 | final int duration; 20 | final int errorCount; 21 | final int tipCount; 22 | final int startTime; 23 | final int endTime; 24 | final int createTime; 25 | 26 | const SudokuRecord({ 27 | this.id, 28 | required this.year, 29 | required this.month, 30 | required this.day, 31 | required this.difficulty, 32 | required this.gameStatus, 33 | required this.logStatus, 34 | required this.sudokuInputLog, 35 | required this.duration, 36 | required this.errorCount, 37 | required this.tipCount, 38 | required this.startTime, 39 | required this.endTime, 40 | required this.createTime, 41 | }); 42 | 43 | String get shareTitle { 44 | return "huhx://sudoku?dateTime=$dateString&difficulty=${difficulty.level}"; 45 | } 46 | 47 | String get dateString { 48 | return DateTime(year, month, day).dateString; 49 | } 50 | 51 | String get createTimeString { 52 | return createTime.dateString; 53 | } 54 | 55 | String get startString { 56 | return DateTime.fromMillisecondsSinceEpoch(startTime).dateTimeString; 57 | } 58 | 59 | String get endString { 60 | return DateTime.fromMillisecondsSinceEpoch(endTime).dateTimeString; 61 | } 62 | 63 | Color get color { 64 | if (duration > 15 * 60) { 65 | return Colors.red; 66 | } else if (duration > 5 * 60) { 67 | return Colors.blue; 68 | } else { 69 | return Colors.green; 70 | } 71 | } 72 | 73 | bool get isSuccess { 74 | return gameStatus == GameStatus.success; 75 | } 76 | 77 | bool get isFailed { 78 | return gameStatus == GameStatus.failed; 79 | } 80 | 81 | String get secondsString => duration.timeString; 82 | 83 | Map toJson() { 84 | return { 85 | 'id': id, 86 | 'year': year, 87 | 'month': month, 88 | 'day': day, 89 | 'difficulty': difficulty.level, 90 | 'gameStatus': gameStatus.name, 91 | 'logStatus': logStatus.name, 92 | 'sudokuInputLog': jsonEncode(sudokuInputLog.toJson()), 93 | 'duration': duration, 94 | 'errorCount': errorCount, 95 | 'tipCount': tipCount, 96 | 'startTime': startTime, 97 | 'endTime': endTime, 98 | 'createTime': createTime, 99 | }; 100 | } 101 | 102 | factory SudokuRecord.fromJson(Map json) { 103 | return SudokuRecord( 104 | id: json['id'] as int?, 105 | year: json['year'] as int, 106 | month: json['month'] as int, 107 | day: json['day'] as int, 108 | difficulty: Difficulty.from(json['difficulty'] as int), 109 | gameStatus: GameStatus.values.byName(json['gameStatus'] as String), 110 | logStatus: LogStatus.values.byName(json['logStatus'] as String), 111 | sudokuInputLog: SudokuInputLog.fromJson(jsonDecode(json['sudokuInputLog']) as Map), 112 | duration: json['duration'] as int, 113 | errorCount: json['errorCount'] as int, 114 | tipCount: json['tipCount'] as int, 115 | startTime: json['startTime'] as int, 116 | endTime: json['endTime'] as int, 117 | createTime: json['createTime'] as int, 118 | ); 119 | } 120 | 121 | @override 122 | List get props => [ 123 | id, 124 | year, 125 | month, 126 | day, 127 | difficulty, 128 | gameStatus, 129 | logStatus, 130 | sudokuInputLog, 131 | duration, 132 | errorCount, 133 | tipCount, 134 | startTime, 135 | endTime, 136 | createTime, 137 | ]; 138 | } 139 | 140 | enum LogStatus { normal, delete } 141 | -------------------------------------------------------------------------------- /lib/model/sudoku_tip.dart: -------------------------------------------------------------------------------- 1 | enum TipLevel { 2 | none("无"), 3 | first("初级"), 4 | second("中级"), 5 | third("高级"); 6 | 7 | final String description; 8 | 9 | const TipLevel(this.description); 10 | } 11 | -------------------------------------------------------------------------------- /lib/provider/error_count_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/util/prefs_util.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | class ErrorCountNotifier extends StateNotifier { 5 | ErrorCountNotifier() : super(PrefsUtil.getErrorCount()); 6 | 7 | void set(int errorCount) { 8 | PrefsUtil.setErrorCount(errorCount); 9 | 10 | state = errorCount; 11 | } 12 | } 13 | 14 | final errorCountProvider = StateNotifierProvider((ref) { 15 | return ErrorCountNotifier(); 16 | }); 17 | -------------------------------------------------------------------------------- /lib/provider/theme_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_sudoku/util/prefs_util.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | class AppThemeNotifier extends StateNotifier { 6 | final ThemeMode themeMode; 7 | AppThemeNotifier(this.themeMode) : super(themeMode); 8 | 9 | void setDark(bool isDark) { 10 | PrefsUtil.saveIsLightTheme(!isDark); 11 | 12 | state = isDark ? ThemeMode.dark : ThemeMode.light; 13 | } 14 | } 15 | 16 | final themeProvider = StateNotifierProvider((ref) { 17 | final bool? isLightTheme = PrefsUtil.getIsLightTheme(); 18 | 19 | if (isLightTheme == null) { 20 | return AppThemeNotifier(ThemeMode.system); 21 | } 22 | return AppThemeNotifier(isLightTheme ? ThemeMode.light : ThemeMode.dark); 23 | }); 24 | -------------------------------------------------------------------------------- /lib/provider/tip_count_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/util/prefs_util.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | class TipCountNotifier extends StateNotifier { 5 | TipCountNotifier() : super(PrefsUtil.getTipCount()); 6 | 7 | void set(int tipCount) { 8 | PrefsUtil.setTipCount(tipCount); 9 | 10 | state = tipCount; 11 | } 12 | } 13 | 14 | final tipCountProvider = StateNotifierProvider((ref) { 15 | return TipCountNotifier(); 16 | }); 17 | -------------------------------------------------------------------------------- /lib/provider/tip_level_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/model/sudoku_tip.dart'; 2 | import 'package:flutter_sudoku/util/prefs_util.dart'; 3 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 4 | 5 | class TipLevelNotifier extends StateNotifier { 6 | TipLevelNotifier() : super(PrefsUtil.getTipLevel()); 7 | 8 | void set(TipLevel tipLevel) { 9 | PrefsUtil.setTipLevel(tipLevel); 10 | 11 | state = tipLevel; 12 | } 13 | } 14 | 15 | final tipLevelProvider = StateNotifierProvider((ref) { 16 | return TipLevelNotifier(); 17 | }); 18 | -------------------------------------------------------------------------------- /lib/service/audio_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/util/prefs_util.dart'; 2 | import 'package:just_audio/just_audio.dart'; 3 | 4 | class AudioService { 5 | final AudioPlayer _player = AudioPlayer(); 6 | 7 | Future playSuccess() async { 8 | if (PrefsUtil.isPlaySound()) { 9 | await playSound('success.mp3'); 10 | } 11 | } 12 | 13 | Future playInput() async { 14 | if (PrefsUtil.isPlaySound()) { 15 | await playSound('input.mp3'); 16 | } 17 | } 18 | 19 | Future playFail() async { 20 | if (PrefsUtil.isPlaySound()) { 21 | await playSound('fail.mp3'); 22 | } 23 | } 24 | 25 | Future playOperation() async { 26 | if (PrefsUtil.isPlaySound()) { 27 | await playSound('operate.mp3'); 28 | } 29 | } 30 | 31 | Future playSound(String assetName) async { 32 | await _player.setAsset('assets/sound/$assetName'); 33 | await _player.play(); 34 | } 35 | 36 | Future playVoice(String soundUrl) async { 37 | await _player.setUrl(soundUrl); 38 | await _player.play(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/theme/color.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const Color highlightColor = Colors.greenAccent; 4 | const Color relatedColor = Colors.lightGreen; 5 | const Color inputColor = Colors.blueAccent; 6 | const Color errorColor = Colors.red; 7 | const Color selectedColor = Colors.green; 8 | -------------------------------------------------------------------------------- /lib/theme/shape.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:introduction_screen/introduction_screen.dart'; 3 | 4 | const bottomSheetBorder = RoundedRectangleBorder( 5 | borderRadius: BorderRadius.only( 6 | topLeft: Radius.circular(10), 7 | topRight: Radius.circular(10), 8 | ), 9 | ); 10 | 11 | const dialogShape = RoundedRectangleBorder( 12 | borderRadius: BorderRadius.all(Radius.circular(8.0)), 13 | ); 14 | 15 | const outlineInputBorder = OutlineInputBorder( 16 | borderRadius: BorderRadius.all(Radius.circular(20)), 17 | borderSide: BorderSide.none, 18 | ); 19 | 20 | final pageDecoration = const PageDecoration().copyWith( 21 | bodyFlex: 2, 22 | imageFlex: 4, 23 | bodyAlignment: Alignment.topCenter, 24 | imageAlignment: Alignment.bottomCenter, 25 | ); 26 | 27 | const inputDecoration = InputDecoration( 28 | fillColor: Colors.transparent, 29 | border: InputBorder.none, 30 | focusedBorder: InputBorder.none, 31 | enabledBorder: InputBorder.none, 32 | errorBorder: InputBorder.none, 33 | disabledBorder: InputBorder.none, 34 | isCollapsed: true, 35 | ); 36 | -------------------------------------------------------------------------------- /lib/theme/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_color_scheme/flex_color_scheme.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:google_fonts/google_fonts.dart'; 4 | 5 | enum AppTheme { light, dark } 6 | 7 | const ColorScheme flexSchemeLight = ColorScheme( 8 | brightness: Brightness.light, 9 | primary: Color(0xffce5b78), 10 | onPrimary: Color(0xffffffff), 11 | primaryContainer: Color(0xffe8b5ce), 12 | onPrimaryContainer: Color(0xff271f23), 13 | secondary: Color(0xfffbae9d), 14 | onSecondary: Color(0xff000000), 15 | secondaryContainer: Color(0xffffdad1), 16 | onSecondaryContainer: Color(0xff282523), 17 | tertiary: Color(0xfff39682), 18 | onTertiary: Color(0xff000000), 19 | tertiaryContainer: Color(0xffffcfc3), 20 | onTertiaryContainer: Color(0xff282321), 21 | error: Color(0xff790000), 22 | onError: Color(0xffffffff), 23 | errorContainer: Color(0xfff1d8d8), 24 | onErrorContainer: Color(0xff282525), 25 | outline: Color(0xff625c62), 26 | surface: Color(0xfffdf8f9), 27 | onSurface: Color(0xff090909), 28 | surfaceContainerHighest: Color(0xfffbf2f4), 29 | onSurfaceVariant: Color(0xff131213), 30 | inverseSurface: Color(0xff181315), 31 | onInverseSurface: Color(0xfff5f5f5), 32 | inversePrimary: Color(0xfffff4f9), 33 | shadow: Color(0xff000000), 34 | ); 35 | 36 | const ColorScheme flexSchemeDark = ColorScheme( 37 | brightness: Brightness.dark, 38 | primary: Color(0xffeec4d8), 39 | onPrimary: Color(0xff1e1d1e), 40 | primaryContainer: Color(0xffce5b78), 41 | onPrimaryContainer: Color(0xffffe5ec), 42 | secondary: Color(0xfff5d6c6), 43 | onSecondary: Color(0xff1e1e1d), 44 | secondaryContainer: Color(0xffeba689), 45 | onSecondaryContainer: Color(0xff3c2b24), 46 | tertiary: Color(0xfff7e0d4), 47 | onTertiary: Color(0xff1e1e1e), 48 | tertiaryContainer: Color(0xffeebda8), 49 | onTertiaryContainer: Color(0xff3c312c), 50 | error: Color(0xffcf6679), 51 | onError: Color(0xff1e1214), 52 | errorContainer: Color(0xffb1384e), 53 | onErrorContainer: Color(0xfff9dde2), 54 | outline: Color(0xff989898), 55 | surface: Color(0xff171516), 56 | onSurface: Color(0xfff1f1f1), 57 | surfaceContainerHighest: Color(0xff1d1a1b), 58 | onSurfaceVariant: Color(0xffe4e4e4), 59 | inverseSurface: Color(0xfffefdfd), 60 | onInverseSurface: Color(0xff0e0e0e), 61 | inversePrimary: Color(0xff726068), 62 | shadow: Color(0xff000000), 63 | ); 64 | 65 | final appThemeData = { 66 | AppTheme.light: FlexThemeData.light( 67 | scheme: FlexScheme.sakura, 68 | surfaceMode: FlexSurfaceMode.highScaffoldLowSurface, 69 | blendLevel: 20, 70 | appBarOpacity: 0.95, 71 | subThemesData: const FlexSubThemesData( 72 | blendOnLevel: 20, 73 | blendOnColors: false, 74 | ), 75 | visualDensity: FlexColorScheme.comfortablePlatformDensity, 76 | // To use the playground font, add GoogleFonts package and uncomment 77 | fontFamily: GoogleFonts.lato().fontFamily, 78 | pageTransitionsTheme: const PageTransitionsTheme( 79 | builders: { 80 | TargetPlatform.android: CupertinoPageTransitionsBuilder(), 81 | TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), 82 | }, 83 | ), 84 | ).copyWith( 85 | appBarTheme: const AppBarTheme(centerTitle: true, titleTextStyle: TextStyle(fontSize: 17)), 86 | ), 87 | AppTheme.dark: FlexThemeData.dark( 88 | scheme: FlexScheme.sakura, 89 | surfaceMode: FlexSurfaceMode.highScaffoldLowSurface, 90 | blendLevel: 15, 91 | appBarStyle: FlexAppBarStyle.background, 92 | appBarOpacity: 0.90, 93 | subThemesData: const FlexSubThemesData(blendOnLevel: 30), 94 | visualDensity: FlexColorScheme.comfortablePlatformDensity, 95 | // To use the playground font, add GoogleFonts package and uncomment 96 | fontFamily: GoogleFonts.lato().fontFamily, 97 | pageTransitionsTheme: const PageTransitionsTheme( 98 | builders: { 99 | TargetPlatform.android: CupertinoPageTransitionsBuilder(), 100 | TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), 101 | }, 102 | ), 103 | ).copyWith( 104 | appBarTheme: const AppBarTheme(centerTitle: true, titleTextStyle: TextStyle(fontSize: 17)), 105 | ), 106 | }; 107 | -------------------------------------------------------------------------------- /lib/util/common_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:vibration/vibration.dart'; 2 | 3 | class CommonUtil { 4 | static Future vibrateWarn() async { 5 | final bool? canVibration = await Vibration.hasVibrator(); 6 | if (canVibration != null && canVibration) { 7 | await Vibration.vibrate(duration: 100); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/util/date_util.dart: -------------------------------------------------------------------------------- 1 | class DateUtil { 2 | static String getWeekFromDate(DateTime dateTime) { 3 | const List list = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']; 4 | return list[dateTime.weekday - 1]; 5 | } 6 | 7 | static String getWeekFromString(String dateString) { 8 | final DateTime dateTime = DateTime.parse(dateString); 9 | return getWeekFromDate(dateTime); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/util/dio_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | class RestClient { 4 | static Dio get instance { 5 | return Dio(BaseOptions()) 6 | ..interceptors.add( 7 | LogInterceptor(requestBody: true, responseBody: true), 8 | ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/util/list_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/model/sudoku_point.dart'; 2 | 3 | class ListUtil { 4 | static const List lists = [ 5 | Point(x: 0, y: 0), 6 | Point(x: 0, y: 1), 7 | Point(x: 0, y: 2), 8 | Point(x: 1, y: 0), 9 | Point(x: 1, y: 1), 10 | Point(x: 1, y: 2), 11 | Point(x: 2, y: 0), 12 | Point(x: 2, y: 1), 13 | Point(x: 2, y: 2), 14 | ]; 15 | 16 | static Set related(Point selected) { 17 | final int timeX = (selected.x / 3).floor(); 18 | final int timeY = (selected.y / 3).floor(); 19 | 20 | return lists.map((point) => Point(x: point.x + timeX * 3, y: point.y + timeY * 3)).toSet(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/util/prefs_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_sudoku/model/sudoku_config.dart'; 2 | import 'package:flutter_sudoku/model/sudoku_tip.dart'; 3 | import 'package:shared_preferences/shared_preferences.dart'; 4 | 5 | class PrefsUtil { 6 | static late SharedPreferences prefs; 7 | static const isLightTheme = "app.theme.light"; 8 | static const cookieKey = "cookie"; 9 | static const startTimeKey = "start.time"; 10 | static const playSoundKey = "play_sound"; 11 | static const tipLevelKey = "tip_level"; 12 | static const errorCountKey = "error_count"; 13 | static const tipCountKey = "tip_count"; 14 | 15 | static Future init() async { 16 | prefs = await SharedPreferences.getInstance(); 17 | } 18 | 19 | static void setStartTime(int timestamp) async { 20 | await prefs.setInt(startTimeKey, timestamp); 21 | } 22 | 23 | static int? getStartTime() { 24 | return prefs.getInt(startTimeKey); 25 | } 26 | 27 | static void saveIsLightTheme(bool isLight) { 28 | prefs.setBool(isLightTheme, isLight); 29 | } 30 | 31 | static bool? getIsLightTheme() { 32 | return prefs.getBool(isLightTheme); 33 | } 34 | 35 | static Future removeKey(String key) async { 36 | await prefs.remove(key); 37 | } 38 | 39 | static void enablePlaySound(bool enable) { 40 | prefs.setBool(playSoundKey, enable); 41 | } 42 | 43 | static bool isPlaySound() { 44 | return prefs.getBool(playSoundKey) ?? true; 45 | } 46 | 47 | static TipLevel getTipLevel() { 48 | final String? levelString = prefs.getString(tipLevelKey); 49 | if (levelString == null) { 50 | return sudokuConfig.tipLevel; 51 | } 52 | return TipLevel.values.byName(levelString); 53 | } 54 | 55 | static void setTipLevel(TipLevel tipLevel) { 56 | prefs.setString(tipLevelKey, tipLevel.name); 57 | } 58 | 59 | static int getErrorCount() { 60 | return prefs.getInt(errorCountKey) ?? sudokuConfig.retryCount; 61 | } 62 | 63 | static void setErrorCount(int errorCount) { 64 | prefs.setInt(errorCountKey, errorCount); 65 | } 66 | 67 | static int getTipCount() { 68 | return prefs.getInt(tipCountKey) ?? sudokuConfig.tipCount; 69 | } 70 | 71 | static void setTipCount(int tipCount) { 72 | prefs.setInt(tipCountKey, tipCount); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_sudoku 2 | description: A new Flutter project of sudoku. 3 | publish_to: "none" 4 | version: 1.0.6+6 5 | 6 | environment: 7 | sdk: ">=3.0.0 <4.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | cupertino_icons: ^1.0.2 13 | hooks_riverpod: ^2.0.2 14 | flutter_hooks: ^0.20.0 15 | google_fonts: ^6.1.0 16 | double_back_to_close: ^2.0.0 17 | vibration: ^1.7.6 18 | shimmer: ^3.0.0 19 | shared_preferences: ^2.0.15 20 | path_provider: ^2.0.11 21 | modal_bottom_sheet: ^3.0.0 22 | table_calendar: ^3.0.7 23 | introduction_screen: ^3.0.2 24 | sqflite: ^2.1.0+1 25 | path: ^1.8.2 26 | just_audio: ^0.9.30 27 | logger: ^2.0.2+1 28 | envied: ^0.5.1 29 | flutter_slidable: ^3.0.0 30 | sticky_headers: ^0.3.0+2 31 | badges: ^3.0.2 32 | get_it: ^7.2.0 33 | url_launcher: ^6.1.9 34 | package_info_plus: ^8.0.0 35 | flutter_deep_links: ^0.0.2 36 | app_common_flutter: 37 | git: 38 | url: https://github.com/huhx/app_common_flutter 39 | ref: main 40 | flex_color_scheme: ^7.0.0 41 | 42 | dev_dependencies: 43 | flutter_test: 44 | sdk: flutter 45 | flutter_lints: ^4.0.0 46 | envied_generator: ^0.5.1 47 | build_runner: ^2.3.2 48 | flutter_launcher_icons: ^0.13.0 49 | 50 | flutter_icons: 51 | android: "launcher_icon" 52 | ios: true 53 | image_path: "assets/image/logo.png" 54 | min_sdk_android: 21 55 | remove_alpha_ios: true 56 | 57 | flutter: 58 | uses-material-design: true 59 | assets: 60 | - assets/image/ 61 | - assets/sound/ 62 | - assets/svg/ 63 | --------------------------------------------------------------------------------