diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..39bd9ac --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,7 @@ +version: 2 +enable-beta-ecosystems: true +updates: + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..0153fa9 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,24 @@ +name: pull_request + +on: + pull_request: + branches: + - main + +jobs: + format: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: 'Git Checkout' + uses: actions/checkout@v3 + - name: 'Install Flutter' + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - name: 'Install Tools' + run: flutter pub global activate fvm; make init; + - name: 'Format Code' + run: make fix + - name: 'Validate Formatting' + run: ./tool/validate-formatting.sh \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..702cbb1 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,17 @@ +name: push + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: jacopocarlini/action-autotag@master + with: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + package_root: "/" + tag_prefix: "v" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5850b3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ +.flutter-plugins +.flutter-plugins-dependencies + +# FVM +.fvm/ +.fvmrc diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..7344f88 --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" + channel: "stable" + +project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0d8803f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8012737 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +.PHONY: version doctor + +PANA_SCRIPT = ./tool/verify_pub_score.sh 100 +VALIDATE_SCRIPT = ./tool/validate-formatting.sh +BUMPV_VERSION_SCRIPT = ./tool/bump-version.sh + +EXAMPLE_PATH = example + +FVM = fvm +FVM_FLUTTER = $(FVM) flutter +DART = dart +FVM_DART = $(FVM) ${DART} + + +init: + make activate_fvm; $(FVM) use 3.24.3 --force; $(FVM_DART) pub global activate pana; + +activate_fvm: + ${DART} pub global activate ${FVM} + +version: + $(FVM_FLUTTER) --version; $(FVM_DART) --version; + +doctor: + $(FVM_FLUTTER) doctor; + +ifeq (bump, $(firstword $(MAKECMDGOALS))) + runargs := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS)) + $(eval $(runargs):;@true) +endif +bump: + ./tool/bump-version.sh $(filter-out $@,$(MAKECMDGOALS)) + +pub_get: + $(FVM_FLUTTER) packages get; + +clean: + $(FVM_FLUTTER) clean; + +fix: + $(FVM_DART) format .; + +analyze: + $(FVM_FLUTTER) analyze . --fatal-infos; + +pana: + $(PANA_SCRIPT); + +validate: + $(VALIDATE_SCRIPT) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f3ec078 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# gravity_box + +A Flutter library that provides a GravityBox widget for simulating gravity inside of it. + +This widget uses the [GravitySensor](https://pub.dev/packages/gravity_sensor) package to get the device's gravity sensor data. + +## Features + +- **Gravity Simulation**: Simulate gravity for widgets using the `GravityBox` widget. +- **Collision Detection**: Simple collision system between `GravityObject` and other children widgets. + +## Usage + +Import the package + +```dart +import 'package:gravity_box/gravity_box.dart'; +``` + + +Use the widget. + +```dart +GravityBox( + gravityObjects: [ + GravityObject( + size: 100, + widget: Container( + width: 42, + height: 42, + color: Colors.purple, + ), + ), + ], +); +``` + + +Provide a list of `GravityObject`s to the `gravityObjects` property. The `GravityBox` will automatically update the `GravityObject`s position and velocity based on the device's gravity sensor data.\ +The `size` used to calculate bounding box of the object. Keep in mind that the size of the object is not the same as the size of the widget.\ +The `position` is the top-left corner of the object in the `GravityBox` coordinate system (its layout contraints).\ +If you want to add rolling ability (e.g. for circle-shaped widgets), set `canRoll: true` in the `GravityObject`.\ +The `angle` is the current rotation degrees of the object.\ +The `widget` is the widget that will be displayed as the object.\ + +```dart +GravityBox( + gravityObjects: [ + GravityObject( + size: 100, + position: Vector2(50, 100), + canRoll: true, + angle: 90, + widget: Container( + width: 42, + height: 42, + color: Colors.purple, + ), + ), + ], +); +``` + + +To display debug info for the `GravityObject`, such as its position and borders, set `debugShowObjectsPosition: true` in the `GravityBox`. + +```dart +GravityBox( + debugShowObjectsPosition: true, + gravityObjects: [ + GravityObject( + child: Container( + width: 42, + height: 42, + color: Colors.purple, + ), + ), + ], +); +``` + + +To display additional widgets in `GravityBox`, provide them in the `children` property if you want them to collide with `GravityObject`s and in the `notCollidableChildren` property if you want them to not collide with `GravityObject`s. + +```dart +const GravityBox( + notCollidableChildren: [ + Positioned.fill( + child: ColoredBox(color: Color(0x80000000)), + ), + ], + children: [FlutterLogo()], + ); +``` + +## Example + +See full [Example][example] in the corresponding folder + +[example]: https://github.com/MadBrains/Gravity-Box-Flutter/tree/main/example diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..7aa453c --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +/pubspec.lock +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# 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/example/.metadata b/example/.metadata new file mode 100644 index 0000000..8ca14df --- /dev/null +++ b/example/.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: "5dcb86f68f239346676ceb1ed1ea385bd215fba1" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: android + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: ios + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: linux + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: macos + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: web + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: windows + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + + # 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/example/README.md b/example/README.md new file mode 100644 index 0000000..1b7a4e3 --- /dev/null +++ b/example/README.md @@ -0,0 +1,3 @@ +# example + +A new Flutter project. diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle new file mode 100644 index 0000000..09d53b7 --- /dev/null +++ b/example/android/app/build.gradle @@ -0,0 +1,57 @@ +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" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file("local.properties") +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader("UTF-8") { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") +if (flutterVersionCode == null) { + flutterVersionCode = "1" +} + +def flutterVersionName = localProperties.getProperty("flutter.versionName") +if (flutterVersionName == null) { + flutterVersionName = "1.0" +} + +android { + namespace = "ru.madbrains.gravity_box_example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId = "ru.madbrains.gravity_box_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.debug + } + } +} + +flutter { + source = "../.." +} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5509f85 --- /dev/null +++ b/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/example/android/app/src/main/kotlin/ru/madbrains/gravity_box_example/MainActivity.kt b/example/android/app/src/main/kotlin/ru/madbrains/gravity_box_example/MainActivity.kt new file mode 100644 index 0000000..ce734c7 --- /dev/null +++ b/example/android/app/src/main/kotlin/ru/madbrains/gravity_box_example/MainActivity.kt @@ -0,0 +1,5 @@ +package ru.madbrains.gravity_box_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle new file mode 100644 index 0000000..d2ffbff --- /dev/null +++ b/example/android/build.gradle @@ -0,0 +1,18 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = "../build" +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/example/android/gradle.properties b/example/android/gradle.properties new file mode 100644 index 0000000..3b5b324 --- /dev/null +++ b/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e1ca574 --- /dev/null +++ b/example/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-7.6.3-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle new file mode 100644 index 0000000..536165d --- /dev/null +++ b/example/android/settings.gradle @@ -0,0 +1,25 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return 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 "7.3.0" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false +} + +include ":app" diff --git a/example/ios/.gitignore b/example/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/example/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/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..7c56964 --- /dev/null +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..ec97fc6 --- /dev/null +++ b/example/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/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..c4855bf --- /dev/null +++ b/example/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/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..d97f17e --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.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! + use_modular_headers! + + 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/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..b6a700b --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,22 @@ +PODS: + - Flutter (1.0.0) + - gravity_sensor (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - gravity_sensor (from `.symlinks/plugins/gravity_sensor/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + gravity_sensor: + :path: ".symlinks/plugins/gravity_sensor/ios" + +SPEC CHECKSUMS: + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + gravity_sensor: 415641c53c754ff803efcca7dce48ce63957f089 + +PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 + +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..31e849d --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,728 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 1E24975D9B0E01C733707ADE /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43ADA8F35D57EBDFDEC3D074 /* Pods_Runner.framework */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 33B7978683207D7668783183 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F47344EA90370598F1D82E3F /* Pods_RunnerTests.framework */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.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 */ + 01D2B171B258661387F9D773 /* 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 = ""; }; + 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 = ""; }; + 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; }; + 388CDFB8F5E6AED566B93616 /* 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 = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 43ADA8F35D57EBDFDEC3D074 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 50ABABC951D6B0E66346ADCB /* 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 = ""; }; + 67FF547DB2E21030E74F7B8E /* 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 = ""; }; + 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 = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 90020F3F631EB8488E1691FD /* 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 = ""; }; + 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 = ""; }; + BFF3F2A6CEC2AFB3940317BA /* 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 = ""; }; + F47344EA90370598F1D82E3F /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6145B3D62DAFB3C2D5331785 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 33B7978683207D7668783183 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1E24975D9B0E01C733707ADE /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1B157E2829E39D20CB9C9228 /* Pods */ = { + isa = PBXGroup; + children = ( + 01D2B171B258661387F9D773 /* Pods-Runner.debug.xcconfig */, + 67FF547DB2E21030E74F7B8E /* Pods-Runner.release.xcconfig */, + 388CDFB8F5E6AED566B93616 /* Pods-Runner.profile.xcconfig */, + BFF3F2A6CEC2AFB3940317BA /* Pods-RunnerTests.debug.xcconfig */, + 50ABABC951D6B0E66346ADCB /* Pods-RunnerTests.release.xcconfig */, + 90020F3F631EB8488E1691FD /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + 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 */, + 1B157E2829E39D20CB9C9228 /* Pods */, + BE98B6581A5CEB9DF0A4AC10 /* 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 */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + BE98B6581A5CEB9DF0A4AC10 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 43ADA8F35D57EBDFDEC3D074 /* Pods_Runner.framework */, + F47344EA90370598F1D82E3F /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + E9E1BD983AECD1D922B17F86 /* [CP] Check Pods Manifest.lock */, + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + 6145B3D62DAFB3C2D5331785 /* 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 = ( + C9A10FCC5A7B24CD936D25E6 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 479D2B15D3C78594643C2E80 /* [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"; + }; + 479D2B15D3C78594643C2E80 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + 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"; + }; + C9A10FCC5A7B24CD936D25E6 /* [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; + }; + E9E1BD983AECD1D922B17F86 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 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 */, + ); + 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 = 12.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; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = ru.madbrains.gravity_box_example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = BFF3F2A6CEC2AFB3940317BA /* 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 = ru.madbrains.gravity_box_example.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 = 50ABABC951D6B0E66346ADCB /* 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 = ru.madbrains.gravity_box_example.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 = 90020F3F631EB8488E1691FD /* 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 = ru.madbrains.gravity_box_example.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 = 12.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 = 12.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; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = ru.madbrains.gravity_box_example; + PRODUCT_NAME = "$(TARGET_NAME)"; + 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; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = ru.madbrains.gravity_box_example; + PRODUCT_NAME = "$(TARGET_NAME)"; + 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/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..8e3ca5d --- /dev/null +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..6266644 --- /dev/null +++ b/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..7353c41 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..6ed2d93 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cd7b00 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fe73094 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..321773c Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..502f463 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..e9f5fea Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..8953cba Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0467bf1 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/example/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/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/example/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/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner/Base.lproj/Main.storyboard b/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist new file mode 100644 index 0000000..761b730 --- /dev/null +++ b/example/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + gravity_box_example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/example/ios/RunnerTests/RunnerTests.swift b/example/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/example/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/example/lib/main.dart b/example/lib/main.dart new file mode 100644 index 0000000..a121e66 --- /dev/null +++ b/example/lib/main.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:gravity_box/gravity_box.dart'; + +void main() { + runApp(const MainApp()); +} + +class MainApp extends StatelessWidget { + const MainApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + home: SafeArea( + child: Scaffold( + body: GravityBox( + debugShowObjectsPostion: true, + gravityObjects: [ + GravityObject( + size: 100, + position: const Vector2(200, 200), + canRoll: true, + widget: Container( + decoration: const BoxDecoration( + color: Colors.red, + shape: BoxShape.circle, + ), + width: 100, + height: 100, + child: Center( + child: Container( + color: Colors.indigo, + width: 100, + height: 10, + ), + ), + ), + ), + ], + children: [ + Container( + width: 100, + height: 100, + color: Colors.black, + ), + Align( + alignment: Alignment.topRight, + child: Container( + width: 100, + height: 100, + color: Colors.green, + ), + ), + Align( + alignment: Alignment.bottomLeft, + child: Container( + width: 100, + height: 100, + color: Colors.yellow, + ), + ), + Align( + alignment: Alignment.bottomRight, + child: Container( + width: 100, + height: 100, + color: Colors.orange, + ), + ), + Align( + alignment: Alignment.center, + child: Container( + width: 100, + height: 100, + color: Colors.purple, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..840dab3 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,23 @@ +name: example +description: "A new Flutter project." +publish_to: 'none' +version: 0.1.0 + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: '>=3.10.0' + +dependencies: + flutter: + sdk: flutter + + gravity_box: + path: ../ + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^3.0.0 + +flutter: + uses-material-design: true diff --git a/lib/gravity_box.dart b/lib/gravity_box.dart new file mode 100644 index 0000000..d2a2473 --- /dev/null +++ b/lib/gravity_box.dart @@ -0,0 +1,251 @@ +library; + +import 'dart:math' show pi; + +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +import 'src/mixins/mixins.dart'; +import 'src/models/models.dart'; +import 'src/widgets/widgets.dart'; + +export 'src/models/models.dart'; + +/// {@template GravityBox} +/// A widget that enables gravity simulation for each of its [GravityObject]. +/// +/// Also provides a simple collision system between [GravityObject] and [children]. +/// {@endtemplate} +class GravityBox extends StatefulWidget { + /// Creates a [GravityBox]. + /// + /// {@macro GravityBox} + const GravityBox({ + super.key, + this.gravityObjects = const [], + this.children = const [], + this.notCollidableChildren = const [], + this.debugShowObjectsPostion = false, + }); + + /// The list of [GravityObject] that will be affected by gravity. + /// + /// See also [GravityObject]. + final List gravityObjects; + + /// The list of widgets that will be collidable with [GravityObject]. + /// + /// See also [notCollidableChildren]. + final List children; + + /// The list of widgets that will not be collidable with [GravityObject]. + /// + /// See also [children]. + final List notCollidableChildren; + + /// If `true`, a small label will be shown at the top-left corner of each + /// [GravityObject], displaying the object's current position and rect. + /// + /// Defaults to `false`. + final bool debugShowObjectsPostion; + + @override + State createState() => _GravityBoxState(); +} + +class _GravityBoxState extends State + with SingleTickerProviderStateMixin, GravityInteractionMixin { + late final Ticker _ticker; + late final List> _gravityObjectNotifiers = + widget.gravityObjects.map((e) => ValueNotifier(e)).toList(growable: false); + + Set _childrenRects = {}; + Duration _lastElapsedDuration = const Duration(); + + @override + void initState() { + super.initState(); + + _ticker = createTicker(_onTick); + _ticker.start(); + } + + @override + void dispose() { + for (final ValueNotifier valueNotifier in _gravityObjectNotifiers) { + valueNotifier.dispose(); + } + _ticker.dispose(); + + super.dispose(); + } + + void _onTick(Duration elapsed) { + if (!canUpdate) return; + + final double dt = + (elapsed - _lastElapsedDuration).inMicroseconds / Duration.microsecondsPerSecond; + _lastElapsedDuration = elapsed; + + for (int i = 0; i < _gravityObjectNotifiers.length; i++) { + final ValueNotifier objectNotifier = _gravityObjectNotifiers[i]; + objectNotifier.value = updateObject(objectNotifier.value, dt, i); + } + } + + @override + Widget childBuilder(BuildContext context) { + return Stack( + fit: StackFit.expand, + children: [ + ...widget.notCollidableChildren, + LayoutReporterStack( + children: widget.children, + onChildrenLayoutChanged: (childrenRects) => _childrenRects = childrenRects.toSet(), + ), + for (final ValueNotifier gravityObjectNotifier in _gravityObjectNotifiers) + ValueListenableBuilder( + valueListenable: gravityObjectNotifier, + builder: (_, GravityObject info, __) { + final Widget object = Transform.rotate( + angle: info.angle * (pi / 180), + child: info.widget, + ); + + return Positioned( + left: info.position.x, + top: info.position.y, + child: widget.debugShowObjectsPostion + ? GravityObjectDebugWrapperWidget( + objectInfo: info, + child: object, + ) + : object, + ); + }, + ), + ], + ); + } + + @override + bool isObjectCollidesAtDirection( + Direction direction, { + required GravityObject object, + required int index, + }) { + final bool isCollidingWithObjects = _gravityObjectNotifiers.indexed.any( + (pair) { + if (pair.$1 == index) return false; + + return _isObjectsColliding(direction, object, pair.$2.value); + }, + ); + + final bool isCollidingWithChildren = + _childrenRects.any((e) => _isRectsColliding(direction, object.rect, e)); + + return isCollidingWithObjects || isCollidingWithChildren; + } + + Vector2 _getObjectPosition( + Direction direction, { + required GravityObject object, + }) { + final double radius = object.radius; + final Vector2 position = object.position; + + return switch (direction) { + Direction.left => Vector2(position.x, position.y + radius), + Direction.top => Vector2(position.x + radius, position.y), + Direction.right => Vector2(position.x + radius, position.y + radius), + Direction.bottom => Vector2(position.x + radius, position.y + radius) + }; + } + + Vector2 _getRectPosition( + Direction direction, { + required Rect rect, + }) { + return switch (direction) { + Direction.left => Vector2(rect.left, rect.top + rect.height / 2), + Direction.top => Vector2(rect.left + rect.width / 2, rect.top), + Direction.right => Vector2(rect.left + rect.width, rect.top + rect.height / 2), + Direction.bottom => Vector2(rect.left + rect.width / 2, rect.top + rect.height) + }; + } + + bool _isInetervalsOverlaps( + double aStart, + double bStart, + double aEnd, + double bEnd, + ) { + if (aStart <= bStart) { + return aStart + aEnd > bStart; + } else { + return bStart + bEnd > aStart; + } + } + + bool _isRectsColliding( + Direction direction, + Rect a, + Rect b, + ) { + final Vector2 posA = _getRectPosition(direction, rect: a)..rounded; + final Vector2 posB = _getRectPosition(direction.opposite, rect: b)..rounded; + final bool isHorizontal = direction.isHorizontal; + late double aStart; + late double bStart; + + aStart = isHorizontal + ? (posA.x - (direction.isRight ? a.width : 0)) + : (posA.y - (direction.isBottom ? a.height : 0)); + bStart = isHorizontal + ? (posB.x - (direction.isLeft ? b.width : 0)) + : (posB.y - (direction.isTop ? b.height : 0)); + final bool notIntersected = + direction.isLeft || direction.isTop ? aStart <= bStart : aStart >= bStart; + if (notIntersected || !_isInetervalsOverlaps(aStart, bStart, a.width, b.width)) { + return false; + } + aStart = isHorizontal ? posA.y - a.height / 2 : posA.x - a.width / 2; + bStart = isHorizontal ? posB.y - b.height / 2 : posB.x - b.width / 2; + + return _isInetervalsOverlaps( + aStart, + bStart, + isHorizontal ? a.height : a.width, + isHorizontal ? b.height : b.width, + ); + } + + bool _isObjectsColliding( + Direction direction, + GravityObject a, + GravityObject b, + ) { + final Vector2 posA = _getObjectPosition(direction, object: a)..rounded; + final Vector2 posB = _getObjectPosition(direction.opposite, object: b)..rounded; + final bool isHorizontal = direction.isHorizontal; + late double aStart; + late double bStart; + + aStart = isHorizontal + ? (posA.x - (direction.isRight ? a.size : 0)) + : (posA.y - (direction.isBottom ? a.size : 0)); + bStart = isHorizontal + ? (posB.x - (direction.isLeft ? b.size : 0)) + : (posB.y - (direction.isTop ? b.size : 0)); + final bool notIntersected = + direction.isLeft || direction.isTop ? aStart <= bStart : aStart >= bStart; + if (notIntersected || !_isInetervalsOverlaps(aStart, bStart, a.size, b.size)) { + return false; + } + aStart = isHorizontal ? posA.y - a.radius : posA.x - a.radius; + bStart = isHorizontal ? posB.y - b.radius : posB.x - b.radius; + + return _isInetervalsOverlaps(aStart, bStart, a.size, b.size); + } +} diff --git a/lib/src/extensions.dart b/lib/src/extensions.dart new file mode 100644 index 0000000..0d8c730 --- /dev/null +++ b/lib/src/extensions.dart @@ -0,0 +1,31 @@ +import 'models/models.dart'; + +extension IterableX on Iterable { + bool containsWhere(bool Function(T element) test) { + for (T e in this) { + if (test(e)) return true; + } + + return false; + } +} + +extension SetDirectionX on Set { + bool get containsHorizontal => contains(Direction.left) || contains(Direction.right); + bool get containsVertical => contains(Direction.top) || contains(Direction.bottom); + + bool get isFull => length == Direction.values.length; + bool get isNotFull => !isFull; + + bool isMovingHorizontal(Set possibleDirections) => + possibleDirections.contains(Direction.left) && contains(Direction.left) || + possibleDirections.contains(Direction.right) && contains(Direction.right); + + bool isMovingVertical(Set possibleDirections) => + possibleDirections.contains(Direction.top) && contains(Direction.top) || + possibleDirections.contains(Direction.bottom) && contains(Direction.bottom); + + bool isRollingClockwise(Set possibleDirections) => + Direction.values.any((Direction direction) => + !possibleDirections.contains(direction) && contains(direction.clockwiseAdjacent)); +} diff --git a/lib/src/mixins/gravity_interaction_mixin.dart b/lib/src/mixins/gravity_interaction_mixin.dart new file mode 100644 index 0000000..aad449e --- /dev/null +++ b/lib/src/mixins/gravity_interaction_mixin.dart @@ -0,0 +1,160 @@ +import 'dart:async'; +import 'dart:math' show pi; + +import 'package:flutter/material.dart'; +import 'package:gravity_box/gravity_box.dart'; +import 'package:gravity_box/src/extensions.dart'; +import 'package:gravity_box/src/widgets/widgets.dart'; +import 'package:gravity_sensor/gravity_sensor.dart'; + +/// A mixin that adds ablity for gravity interaction to a [StatefulWidget] +/// with its [updateObject] method, which is used to update the [GravityObject]. +/// +/// [isObjectCollidesAtDirection] should be implemented in the mixed class. +/// +/// The mixin uses the [GravitySensor] package to get the device's gravity +/// sensor data. +/// +/// See also: +/// +/// * [GravitySensor], the package used to get the device's gravity sensor data. +/// * [GravityBox], the widget that uses this mixin. +/// * [GravityObject], the model that represents an object in the [GravityBox]. +mixin GravityInteractionMixin on State { + late final StreamSubscription _gravityEventsSubscription; + + GravityEvent _lastGravityEvent = const GravityEvent(0, 0, 0); + BoxConstraints _lastConstraints = const BoxConstraints(); + + bool get canUpdate => + _lastConstraints.maxWidth.isFinite && _lastConstraints.maxHeight.isFinite && mounted; + + @override + void initState() { + super.initState(); + + _gravityEventsSubscription = GravitySensor().gravityEvents.listen(_gravityEventsListener); + } + + void _gravityEventsListener(GravityEvent event) => _lastGravityEvent = event; + + @override + void dispose() { + _gravityEventsSubscription.cancel(); + + super.dispose(); + } + + @mustCallSuper + @override + Widget build(BuildContext context) { + return LayoutListener( + onContraintsChanged: (constraints) => _lastConstraints = constraints, + child: childBuilder(context), + ); + } + + /// The proxy method for [build]. Should be used instead of [build]. + Widget childBuilder(BuildContext context); + + /// Checks if the object is colliding with any other object, + /// widget or with the screen borders at the given direction.. + bool isObjectCollidesAtDirection( + Direction direction, { + required GravityObject object, + required int index, + }); + + /// Updates the [GravityObject] position, velocity and angle based on the gravity. + /// + /// The [dt] parameter is the time difference in seconds since the last call. + /// + /// The [index] parameter is the index of the object in the list of objects. + /// + /// The method returns a new [GravityObject] with the updated values. + GravityObject updateObject( + GravityObject source, + double dt, + int index, + ) { + GravityObject object = source.copyWith( + velocity: source.velocity + Vector2(-_lastGravityEvent.x, _lastGravityEvent.y) * dt, + ); + final double size = object.size; + Vector2 velocity = object.velocity; + + final double maxPositionX = _getMaxPositionX(size); + final double maxPositionY = _getMaxPositionY(size); + + final Set possibleDirections = + _getPossibleMovingDirections(object: object, index: index).toSet(); + final Set actualDirections = _getActualMovingDirections(velocity).toSet(); + + if (!actualDirections.isMovingHorizontal(possibleDirections)) { + velocity = velocity.copyWith(x: 0); + } + if (!actualDirections.isMovingVertical(possibleDirections)) { + velocity = velocity.copyWith(y: 0); + } + + final bool isColliding = possibleDirections.isNotFull; + if (isColliding && object.canRoll) { + final double vel = ((velocity.x != 0) ? velocity.x : velocity.y).abs(); + final bool isRollingClockwise = actualDirections.isRollingClockwise(possibleDirections); + + object = object.copyWith(angularVelocity: (isRollingClockwise ? vel : -vel) / size * pi); + } + + final Vector2 min = Vector2.zero(); + final Vector2 max = Vector2(maxPositionX, maxPositionY); + final Vector2 newPosition = (object.position + velocity).clamp(min, max); + + return object.copyWith( + position: newPosition, + velocity: velocity, + angle: object.angle + object.angularVelocity, + ); + } + + double _getMaxPositionX(double objectSize) => _lastConstraints.maxWidth - objectSize; + double _getMaxPositionY(double objectSize) => _lastConstraints.maxHeight - objectSize; + + Iterable _getPossibleMovingDirections({ + required GravityObject object, + required int index, + }) sync* { + for (final Direction direction in Direction.values) { + if (_canMoveTo(direction, object: object, index: index)) yield direction; + } + } + + Iterable _getActualMovingDirections(Vector2 velocity) sync* { + if (velocity.x.isNegative) yield Direction.left; + if (velocity.y.isNegative) yield Direction.top; + if (!velocity.x.isNegative && velocity.x != 0) yield Direction.right; + if (!velocity.y.isNegative && velocity.y != 0) yield Direction.bottom; + } + + bool _canMoveTo( + Direction direction, { + required GravityObject object, + required int index, + }) { + final Vector2 position = object.position; + final double maxPositionX = _getMaxPositionX(object.size); + final double maxPositionY = _getMaxPositionY(object.size); + + switch (direction) { + case Direction.left: + if (position.x <= 0) return false; + case Direction.top: + if (position.y <= 0) return false; + case Direction.right: + if (position.x.round() >= maxPositionX.round()) return false; + case Direction.bottom: + if (position.y.round() >= maxPositionY.round()) return false; + } + + return !isObjectCollidesAtDirection(direction, object: object, index: index); + } +} diff --git a/lib/src/mixins/mixins.dart b/lib/src/mixins/mixins.dart new file mode 100644 index 0000000..dba2040 --- /dev/null +++ b/lib/src/mixins/mixins.dart @@ -0,0 +1,2 @@ +export 'gravity_interaction_mixin.dart'; +export 'stringify.dart'; diff --git a/lib/src/mixins/stringify.dart b/lib/src/mixins/stringify.dart new file mode 100644 index 0000000..7ebfca8 --- /dev/null +++ b/lib/src/mixins/stringify.dart @@ -0,0 +1,16 @@ +/// A mixin that adds a [toString] method to any class that +/// mixed with it. The [toString] method will return a string +/// in the format of '$runtimeType $mappedFields.toString()' +/// where [mappedFields] is a map of the object's fields. +mixin Stringify { + /// A map of the object's fields. + /// + /// The keys are the fields names and the values are the fields values. + /// + /// The default implementation returns an empty map. + /// You should override this method to return a map of the object's fields. + Map get mappedFields => {}; + + @override + String toString() => '$runtimeType ${mappedFields.toString()}'; +} diff --git a/lib/src/models/direction.dart b/lib/src/models/direction.dart new file mode 100644 index 0000000..81fa403 --- /dev/null +++ b/lib/src/models/direction.dart @@ -0,0 +1,55 @@ +/// A direction on a 2D plane. +/// +/// The 2D plane can be thought of as a mobile screen, where +/// [Direction.values] is the sides of the screen respectively. +enum Direction { + /// The left side of the 2D plane. + left, + + /// The top side of the 2D plane. + top, + + /// The right side of the 2D plane. + right, + + /// The bottom side of the 2D plane. + bottom; + + /// Whether this direction is [Direction.left]. + bool get isLeft => this == Direction.left; + + /// Whether this direction is [Direction.top]. + bool get isTop => this == Direction.top; + + /// Whether this direction is [Direction.right]. + bool get isRight => this == Direction.right; + + /// Whether this direction is [Direction.bottom]. + bool get isBottom => this == Direction.bottom; + + /// Whether this direction is either [Direction.left] or [Direction.right]. + bool get isHorizontal => isLeft || isRight; + + /// Whether this direction is either [Direction.top] or [Direction.bottom]. + bool get isVertical => isTop || isBottom; + + /// The opposite direction of this direction. + /// + /// For example, the opposite direction of [Direction.left] is [Direction.right]. + Direction get opposite => switch (this) { + Direction.left => Direction.right, + Direction.top => Direction.bottom, + Direction.right => Direction.left, + Direction.bottom => Direction.top + }; + + /// The adjacent direction of this direction clockwise. + /// + /// For example, the clockwise adjacent direction of [Direction.left] is [Direction.bottom]. + Direction get clockwiseAdjacent => switch (this) { + Direction.left => Direction.bottom, + Direction.top => Direction.left, + Direction.right => Direction.top, + Direction.bottom => Direction.right + }; +} diff --git a/lib/src/models/gravity_object.dart b/lib/src/models/gravity_object.dart new file mode 100644 index 0000000..b027cd2 --- /dev/null +++ b/lib/src/models/gravity_object.dart @@ -0,0 +1,104 @@ +import 'package:flutter/material.dart'; +import 'package:gravity_box/gravity_box.dart'; +import 'package:gravity_box/src/mixins/mixins.dart'; + +/// {@template GravityObject} +/// A model that represents an object in the [GravityBox]. +/// +/// It contains the info of the object such as its [size], [position], [velocity], +/// whether it [canRoll] or not, [angle] and [angularVelocity]. +/// +/// The [widget] is the widget that will be displayed as the object. +/// {@endtemplate} +class GravityObject with Stringify { + /// Creates a [GravityObject]. + /// + /// {@macro GravityObject} + const GravityObject({ + required this.size, + this.position = const Vector2(0, 0), + this.canRoll = false, + this.angle = 0, + this.angularVelocity = 0, + required this.widget, + }) : _velocity = const Vector2(0, 0); + + const GravityObject._({ + required this.size, + this.position = const Vector2(0, 0), + this.canRoll = false, + this.angle = 0, + this.angularVelocity = 0, + required this.widget, + required Vector2 velocity, + }) : _velocity = velocity; + + /// The size of the object, used to calculate its bounding box. + /// + /// The size of the [widget] is not respected. + final double size; + + /// The initial position of the object on the constraints of [GravityBox]. + final Vector2 position; + + /// Whether the object can roll or not. + final bool canRoll; + + /// The rotation angle of the object in clockwise radians. + final double angle; + + /// The angular velocity of the object. + final double angularVelocity; + + /// The widget that will be displayed as the object. + final Widget widget; + + final Vector2 _velocity; + + /// The velocity of the object. + + Vector2 get velocity => _velocity; + + /// The radius of the object. + /// + /// It is half of the [size]. + double get radius => size / 2; + + /// The bounding box of the object on the constraints of [GravityBox]. + /// + /// It is a square with the [size], starting in the [position]. + Rect get rect => Offset(position.x, position.y) & Size.square(size); + + /// Creates a new [GravityObject] with the given properties. + /// + /// Any null value will use the value from the current object. + GravityObject copyWith({ + Widget? widget, + double? size, + Vector2? position, + Vector2? velocity, + bool? canRoll, + double? angle, + double? angularVelocity, + }) => + GravityObject._( + widget: widget ?? this.widget, + size: size ?? this.size, + position: position ?? this.position, + velocity: velocity ?? this.velocity, + canRoll: canRoll ?? this.canRoll, + angle: angle ?? this.angle, + angularVelocity: angularVelocity ?? this.angularVelocity, + ); + + @override + Map get mappedFields => { + 'widget': widget, + 'size': size, + 'position': position, + 'velocity': velocity, + 'canRoll': canRoll, + 'angle': angle, + 'angularVelocity': angularVelocity, + }; +} diff --git a/lib/src/models/models.dart b/lib/src/models/models.dart new file mode 100644 index 0000000..7da8223 --- /dev/null +++ b/lib/src/models/models.dart @@ -0,0 +1,3 @@ +export 'direction.dart'; +export 'gravity_object.dart'; +export 'vector.dart'; diff --git a/lib/src/models/vector.dart b/lib/src/models/vector.dart new file mode 100644 index 0000000..ab45dd1 --- /dev/null +++ b/lib/src/models/vector.dart @@ -0,0 +1,53 @@ +import 'package:gravity_box/src/mixins/stringify.dart'; + +class Vector2 with Stringify { + const Vector2(this.x, this.y); + + factory Vector2.zero() => const Vector2(0, 0); + + final double x; + final double y; + + Vector2 get rounded => Vector2( + x.roundToDouble(), + y.roundToDouble(), + ); + + @override + Map get mappedFields => { + 'x': x, + 'y': y, + }; + + Vector2 copyWith({ + double? x, + double? y, + }) => + Vector2( + x ?? this.x, + y ?? this.y, + ); + + Vector2 clone() => copyWith(); + + Vector2 clamp( + Vector2 min, + Vector2 max, + ) => + copyWith( + x: x.clamp(min.x, max.x), + y: y.clamp(min.y, max.y), + ); + + /// Add two vectors. + Vector2 operator +(Vector2 other) => copyWith( + x: x + other.x, + y: y + other.y, + ); + + /// Scale vector. + Vector2 operator *(double scale) => copyWith( + x: x * scale, + y: y * scale, + ); +} diff --git a/lib/src/widgets/gravity_object_debug_wrapper_widget.dart b/lib/src/widgets/gravity_object_debug_wrapper_widget.dart new file mode 100644 index 0000000..72e006d --- /dev/null +++ b/lib/src/widgets/gravity_object_debug_wrapper_widget.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:gravity_box/src/models/models.dart'; + +/// {@template GravityObjectDebugWrapperWidget} +/// A widget that shows the debug info of a [GravityObject]. +/// +/// The widget will show the object's position and borders. +/// {@endtemplate} +class GravityObjectDebugWrapperWidget extends StatelessWidget { + /// Creates a [GravityObjectDebugWrapperWidget]. + /// + /// {@macro GravityObjectDebugWrapperWidget} + const GravityObjectDebugWrapperWidget({ + super.key, + required this.objectInfo, + required this.child, + }); + + /// The [GravityObject] that is being debugged. + final GravityObject objectInfo; + + /// The widget to be wrapped. + final Widget child; + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + DecoratedBox( + decoration: BoxDecoration( + border: Border.all(), + ), + child: child, + ), + Row( + children: [ + const Padding( + padding: EdgeInsets.only(right: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('x:'), + Text('y:'), + ], + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(objectInfo.position.x.toStringAsFixed(2)), + Text(objectInfo.position.y.toStringAsFixed(2)), + ], + ), + ], + ), + ], + ); + } +} diff --git a/lib/src/widgets/layout_listener.dart b/lib/src/widgets/layout_listener.dart new file mode 100644 index 0000000..f1b4e09 --- /dev/null +++ b/lib/src/widgets/layout_listener.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// {@template LayoutListener} +/// A widget that calls a [onContraintsChanged] callback +/// whenever the layout constraints change. +/// +/// Useful for debugging or testing. +/// +/// See also: +/// +/// * [LayoutBuilder], which provides a way to build a widget tree +/// based on the parent widget's layout constraints. +/// {@endtemplate} +class LayoutListener extends SingleChildRenderObjectWidget { + /// Creates a [LayoutListener]. + /// + /// {@macro LayoutListener} + const LayoutListener({ + super.key, + required this.onContraintsChanged, + super.child, + }); + + /// The callback that is called whenever the layout constraints change. + /// + /// The argument is the new [BoxConstraints]. + final ValueChanged onContraintsChanged; + + @override + RenderObject createRenderObject(context) { + return _LayoutReporterRenderProxyBox(onContraintsChanged: onContraintsChanged); + } +} + +class _LayoutReporterRenderProxyBox extends RenderProxyBox { + _LayoutReporterRenderProxyBox({ + required this.onContraintsChanged, + }); + + final ValueChanged onContraintsChanged; + + BoxConstraints? _lastContraints; + + @override + void performLayout() { + if (_lastContraints == null) { + onContraintsChanged(_lastContraints ??= constraints); + } + + if (_lastContraints != constraints) { + onContraintsChanged(constraints); + _lastContraints = constraints; + } + + return super.performLayout(); + } +} diff --git a/lib/src/widgets/layout_reporter_stack.dart b/lib/src/widgets/layout_reporter_stack.dart new file mode 100644 index 0000000..89deeaa --- /dev/null +++ b/lib/src/widgets/layout_reporter_stack.dart @@ -0,0 +1,110 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +/// {@template LayoutReporterStack} +/// A [Stack] that calls [onChildrenLayoutChanged] whenever the layout constraints change. +/// +/// The [onChildrenLayoutChanged] callback is called with the layout constraints of all +/// the children in the stack. The constraints are given as a list of [Rect]s, where +/// each [Rect] represents the position and size of a single child. +/// {@endtemplate} +class LayoutReporterStack extends Stack { + /// Creates a [LayoutReporterStack]. + /// + /// {@macro LayoutReporterStack} + const LayoutReporterStack({ + super.key, + super.children, + required this.onChildrenLayoutChanged, + }); + + /// The callback that is called when the layout constraints of the children change. + /// + /// The callback is called with a list of [Rect]s, where each [Rect] represents the + /// position and size of a single child. + final void Function(Iterable childrenRects) onChildrenLayoutChanged; + + @override + RenderStack createRenderObject(BuildContext context) { + return _LayoutReporterRenderStack( + alignment: alignment, + textDirection: textDirection ?? Directionality.maybeOf(context), + fit: fit, + clipBehavior: clipBehavior, + onChildrenLayoutChanged: onChildrenLayoutChanged, + ); + } +} + +class _LayoutReporterRenderStack extends RenderStack { + _LayoutReporterRenderStack({ + super.alignment, + super.textDirection, + super.fit, + super.clipBehavior, + required this.onChildrenLayoutChanged, + }); + + final void Function(Iterable childrenRects) onChildrenLayoutChanged; + + @override + void paint(PaintingContext context, Offset offset) { + onChildrenLayoutChanged(_getChildRects()); + + return super.paint(context, offset); + } + + Iterable _getChildRects() sync* { + RenderBox? child = firstChild; + + while (child != null) { + final StackParentData? childParentData = child.parentData as StackParentData?; + + if (!child.hasSize) { + child = childParentData?.nextSibling; + + continue; + } + + if (child is RenderPositionedBox) { + final Alignment? alignment = + child.alignment is Alignment ? (child.alignment as Alignment) : null; + final Size size = child.child?.size ?? child.size; + + final double width = size.width.isFinite ? size.width : constraints.maxWidth; + final double height = size.height.isFinite ? size.height : constraints.maxHeight; + + final rect = Rect.fromLTWH( + alignment == null ? 0 : _lerp(alignment.x, width, constraints.maxWidth), + alignment == null ? 0 : _lerp(alignment.y, height, constraints.maxHeight), + width, + height, + ); + + yield rect; + } else { + final Offset? offset = childParentData?.offset; + final Size size = child.size; + + yield Rect.fromLTWH( + offset?.dx ?? 0, + offset?.dy ?? 0, + size.width.isFinite ? size.width : constraints.maxWidth, + size.height.isFinite ? size.height : constraints.maxHeight, + ); + } + + child = childParentData?.nextSibling; + } + } + + double _lerp(double alignment, double size, double maxSize) { + if (alignment == 0) return maxSize / 2 - size / 2; + + if (alignment > 0) { + return (maxSize - size) * alignment; + } else { + return (-maxSize + size) * (1 + alignment); + } + } +} diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart new file mode 100644 index 0000000..453fb0e --- /dev/null +++ b/lib/src/widgets/widgets.dart @@ -0,0 +1,3 @@ +export 'gravity_object_debug_wrapper_widget.dart'; +export 'layout_listener.dart'; +export 'layout_reporter_stack.dart'; diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..c375eac --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,33 @@ +name: gravity_box +version: 1.0.0 +description: A Flutter library that provides a GravityBox widget for simulating gravity inside of it. +homepage: https://madbrains.ru/ +repository: https://github.com/madbrains/gravity_box +issue_tracker: https://github.com/madbrains/gravity_box/issues +dart_line_length: 100 + +platforms: + android: + ios: + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: '>=3.10.0' + +dependencies: + flutter: + sdk: flutter + + gravity_sensor: ^1.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^5.0.0 + +topics: + - widget + - ui + - flutter + - gravity + - box \ No newline at end of file diff --git a/test/gravity_box_test.dart b/test/gravity_box_test.dart new file mode 100644 index 0000000..b47dcfe --- /dev/null +++ b/test/gravity_box_test.dart @@ -0,0 +1,13 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:gravity_box/gravity_box.dart'; + +void main() { + testWidgets( + 'GravityBox() can be constructed', + (WidgetTester tester) async { + await tester.pumpWidget( + const GravityBox(), + ); + }, + ); +} diff --git a/tool/bump-version.sh b/tool/bump-version.sh new file mode 100755 index 0000000..a7b219b --- /dev/null +++ b/tool/bump-version.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $SCRIPT_DIR/.. + +NEW_VERSION="${1}" + +echo "Bumping version: ${NEW_VERSION}" + +perl -pi -e "s/^version: .*/version: $NEW_VERSION/" pubspec.yaml + +echo -e "## ${NEW_VERSION}\n\nTODO: describe new changes.\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md +echo -e "\033[32mVersion bumped to ${NEW_VERSION}\033[m" +echo -e "\033[33mDon't forget to describe the new version in CHANGELOG.md\033[m" \ No newline at end of file diff --git a/tool/validate-formatting.sh b/tool/validate-formatting.sh new file mode 100755 index 0000000..7463e10 --- /dev/null +++ b/tool/validate-formatting.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [[ $(git ls-files --modified) ]]; then + echo "" + echo "" + echo "These files are not formatted correctly:" + for f in $(git ls-files --modified); do + echo "" + echo "" + echo "-----------------------------------------------------------------" + echo "$f" + echo "-----------------------------------------------------------------" + echo "" + git --no-pager diff --unified=0 --minimal $f + echo "" + echo "-----------------------------------------------------------------" + echo "" + echo "" + done + if [[ $GITHUB_WORKFLOW ]]; then + git checkout . > /dev/null 2>&1 + fi + echo "" + echo "❌ Some files are incorrectly formatted, see above output." + echo "" + echo "To fix these locally, run: 'melos run format'." + exit 1 +else + echo "" + echo "✅ All files are formatted correctly." +fi \ No newline at end of file diff --git a/tool/verify_pub_score.sh b/tool/verify_pub_score.sh new file mode 100755 index 0000000..f1c2e36 --- /dev/null +++ b/tool/verify_pub_score.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Runs `pana . --no-warning` and verifies that the package score +# is greater or equal to the desired score. By default the desired score is +# a perfect score but it can be overridden by passing the desired score as an argument. +# +# Ensure the package has a score of at least a 100 +# `./verify_pub_score.sh 100` +# +# Ensure the package has a perfect score +# `./verify_pub_score.sh` + +PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p") +echo "score: $PANA_SCORE" +IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1] +if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi +if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi \ No newline at end of file