├── .gitignore
├── LICENSE
├── README.md
├── examples
└── 2048
│ ├── README.md
│ ├── android.iml
│ ├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── yourcompany
│ │ │ │ └── flutterplayground
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
│ ├── flutter_playground.iml
│ ├── flutter_playground_android.iml
│ ├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── main.m
│ ├── lib
│ ├── animation_spec.dart
│ ├── main.dart
│ ├── redux.dart
│ ├── state.dart
│ └── ui.dart
│ ├── pubspec.yaml
│ └── test
│ ├── animation_spec_test.dart
│ └── state_test.dart
├── lib
└── indux.dart
├── pubspec.yaml
└── test
└── indux_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .atom/
3 | .idea
4 | .packages
5 | .pub/
6 | build/
7 | ios/.generated/
8 | packages
9 | pubspec.lock
10 | .flutter-plugins
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Chromium Authors. All rights reserved.
2 | //
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are
5 | // met:
6 | //
7 | // * Redistributions of source code must retain the above copyright
8 | // notice, this list of conditions and the following disclaimer.
9 | // * Redistributions in binary form must reproduce the above
10 | // copyright notice, this list of conditions and the following disclaimer
11 | // in the documentation and/or other materials provided with the
12 | // distribution.
13 | // * Neither the name of Google Inc. nor the names of its
14 | // contributors may be used to endorse or promote products derived from
15 | // this software without specific prior written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Indux
2 | **In**heritedWidget based Re**dux** for Flutter
3 |
4 | **WARNING: This is highly experimental, I'm mainly looking for feedback on this
5 | approach**
6 |
7 | **DISCLAIMER: This is a personal experiment. This is not an official Google
8 | product.**
9 |
--------------------------------------------------------------------------------
/examples/2048/README.md:
--------------------------------------------------------------------------------
1 | # 2048 example with indux
2 |
--------------------------------------------------------------------------------
/examples/2048/android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/2048/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | GeneratedPluginRegistrant.java
10 |
--------------------------------------------------------------------------------
/examples/2048/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withInputStream { stream ->
5 | localProperties.load(stream)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | apply plugin: 'com.android.application'
15 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
16 |
17 | android {
18 | compileSdkVersion 25
19 | buildToolsVersion '25.0.3'
20 |
21 | lintOptions {
22 | disable 'InvalidPackage'
23 | }
24 |
25 | defaultConfig {
26 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
27 | applicationId "com.yourcompany.flutterplayground"
28 | minSdkVersion 16
29 | targetSdkVersion 25
30 | versionCode 1
31 | versionName "1.0"
32 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
33 | }
34 |
35 | buildTypes {
36 | release {
37 | // TODO: Add your own signing config for the release build.
38 | // Signing with the debug keys for now, so `flutter run --release` works.
39 | signingConfig signingConfigs.debug
40 | }
41 | }
42 | }
43 |
44 | flutter {
45 | source '../..'
46 | }
47 |
48 | dependencies {
49 | androidTestCompile 'com.android.support:support-annotations:25.4.0'
50 | androidTestCompile 'com.android.support.test:runner:0.5'
51 | androidTestCompile 'com.android.support.test:rules:0.5'
52 | }
53 |
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
15 |
19 |
26 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/java/com/yourcompany/flutterplayground/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yourcompany.flutterplayground;
2 |
3 | import android.os.Bundle;
4 |
5 | import io.flutter.app.FlutterActivity;
6 | import io.flutter.plugins.GeneratedPluginRegistrant;
7 |
8 | public class MainActivity extends FlutterActivity {
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | GeneratedPluginRegistrant.registerWith(this);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/2048/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/2048/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | maven {
5 | url "https://maven.google.com"
6 | }
7 | }
8 |
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:2.3.3'
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | maven {
18 | url "https://maven.google.com"
19 | }
20 | }
21 | }
22 |
23 | rootProject.buildDir = '../build'
24 | subprojects {
25 | project.buildDir = "${rootProject.buildDir}/${project.name}"
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/examples/2048/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 |
--------------------------------------------------------------------------------
/examples/2048/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/2048/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/examples/2048/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/examples/2048/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/2048/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withInputStream { stream -> plugins.load(stream) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/examples/2048/flutter_playground.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/2048/flutter_playground_android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/2048/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | *.pbxuser
16 | *.mode1v3
17 | *.mode2v3
18 | *.perspectivev3
19 |
20 | !default.pbxuser
21 | !default.mode1v3
22 | !default.mode2v3
23 | !default.perspectivev3
24 |
25 | xcuserdata
26 |
27 | *.moved-aside
28 |
29 | *.pyc
30 | *sync/
31 | Icon?
32 | .tags*
33 |
34 | /Flutter/app.flx
35 | /Flutter/app.zip
36 | /Flutter/App.framework
37 | /Flutter/Flutter.framework
38 | /Flutter/Generated.xcconfig
39 | /ServiceDefinitions.json
40 |
41 | Pods/
42 |
--------------------------------------------------------------------------------
/examples/2048/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | UIRequiredDeviceCapabilities
24 |
25 | arm64
26 |
27 | MinimumOSVersion
28 | 8.0
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/2048/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/examples/2048/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
15 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
16 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
17 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; };
18 | 9740EEBB1CF902C7004384FC /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB71CF902C7004384FC /* app.flx */; };
19 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
20 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
21 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
22 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
23 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
24 | /* End PBXBuildFile section */
25 |
26 | /* Begin PBXCopyFilesBuildPhase section */
27 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
28 | isa = PBXCopyFilesBuildPhase;
29 | buildActionMask = 2147483647;
30 | dstPath = "";
31 | dstSubfolderSpec = 10;
32 | files = (
33 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
34 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
35 | );
36 | name = "Embed Frameworks";
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXCopyFilesBuildPhase section */
40 |
41 | /* Begin PBXFileReference section */
42 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
43 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
44 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
45 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
46 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
47 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
48 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
49 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
50 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
51 | 9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = ""; };
52 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
53 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
54 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
55 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
56 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
57 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
58 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
59 | /* End PBXFileReference section */
60 |
61 | /* Begin PBXFrameworksBuildPhase section */
62 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
63 | isa = PBXFrameworksBuildPhase;
64 | buildActionMask = 2147483647;
65 | files = (
66 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
67 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | /* End PBXFrameworksBuildPhase section */
72 |
73 | /* Begin PBXGroup section */
74 | 9740EEB11CF90186004384FC /* Flutter */ = {
75 | isa = PBXGroup;
76 | children = (
77 | 9740EEB71CF902C7004384FC /* app.flx */,
78 | 3B80C3931E831B6300D905FE /* App.framework */,
79 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
80 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
81 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
82 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
83 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
84 | );
85 | name = Flutter;
86 | sourceTree = "";
87 | };
88 | 97C146E51CF9000F007C117D = {
89 | isa = PBXGroup;
90 | children = (
91 | 9740EEB11CF90186004384FC /* Flutter */,
92 | 97C146F01CF9000F007C117D /* Runner */,
93 | 97C146EF1CF9000F007C117D /* Products */,
94 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
95 | );
96 | sourceTree = "";
97 | };
98 | 97C146EF1CF9000F007C117D /* Products */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 97C146EE1CF9000F007C117D /* Runner.app */,
102 | );
103 | name = Products;
104 | sourceTree = "";
105 | };
106 | 97C146F01CF9000F007C117D /* Runner */ = {
107 | isa = PBXGroup;
108 | children = (
109 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
110 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
111 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
112 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
113 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
114 | 97C147021CF9000F007C117D /* Info.plist */,
115 | 97C146F11CF9000F007C117D /* Supporting Files */,
116 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
117 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
118 | );
119 | path = Runner;
120 | sourceTree = "";
121 | };
122 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
123 | isa = PBXGroup;
124 | children = (
125 | 97C146F21CF9000F007C117D /* main.m */,
126 | );
127 | name = "Supporting Files";
128 | sourceTree = "";
129 | };
130 | /* End PBXGroup section */
131 |
132 | /* Begin PBXNativeTarget section */
133 | 97C146ED1CF9000F007C117D /* Runner */ = {
134 | isa = PBXNativeTarget;
135 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
136 | buildPhases = (
137 | 9740EEB61CF901F6004384FC /* Run Script */,
138 | 97C146EA1CF9000F007C117D /* Sources */,
139 | 97C146EB1CF9000F007C117D /* Frameworks */,
140 | 97C146EC1CF9000F007C117D /* Resources */,
141 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
142 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
143 | );
144 | buildRules = (
145 | );
146 | dependencies = (
147 | );
148 | name = Runner;
149 | productName = Runner;
150 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
151 | productType = "com.apple.product-type.application";
152 | };
153 | /* End PBXNativeTarget section */
154 |
155 | /* Begin PBXProject section */
156 | 97C146E61CF9000F007C117D /* Project object */ = {
157 | isa = PBXProject;
158 | attributes = {
159 | LastUpgradeCheck = 0830;
160 | ORGANIZATIONNAME = "The Chromium Authors";
161 | TargetAttributes = {
162 | 97C146ED1CF9000F007C117D = {
163 | CreatedOnToolsVersion = 7.3.1;
164 | };
165 | };
166 | };
167 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
168 | compatibilityVersion = "Xcode 3.2";
169 | developmentRegion = English;
170 | hasScannedForEncodings = 0;
171 | knownRegions = (
172 | en,
173 | Base,
174 | );
175 | mainGroup = 97C146E51CF9000F007C117D;
176 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
177 | projectDirPath = "";
178 | projectRoot = "";
179 | targets = (
180 | 97C146ED1CF9000F007C117D /* Runner */,
181 | );
182 | };
183 | /* End PBXProject section */
184 |
185 | /* Begin PBXResourcesBuildPhase section */
186 | 97C146EC1CF9000F007C117D /* Resources */ = {
187 | isa = PBXResourcesBuildPhase;
188 | buildActionMask = 2147483647;
189 | files = (
190 | 9740EEBB1CF902C7004384FC /* app.flx in Resources */,
191 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
192 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
193 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
194 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
195 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
196 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
197 | );
198 | runOnlyForDeploymentPostprocessing = 0;
199 | };
200 | /* End PBXResourcesBuildPhase section */
201 |
202 | /* Begin PBXShellScriptBuildPhase section */
203 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
204 | isa = PBXShellScriptBuildPhase;
205 | buildActionMask = 2147483647;
206 | files = (
207 | );
208 | inputPaths = (
209 | );
210 | name = "Thin Binary";
211 | outputPaths = (
212 | );
213 | runOnlyForDeploymentPostprocessing = 0;
214 | shellPath = /bin/sh;
215 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
216 | };
217 | 9740EEB61CF901F6004384FC /* Run Script */ = {
218 | isa = PBXShellScriptBuildPhase;
219 | buildActionMask = 2147483647;
220 | files = (
221 | );
222 | inputPaths = (
223 | );
224 | name = "Run Script";
225 | outputPaths = (
226 | );
227 | runOnlyForDeploymentPostprocessing = 0;
228 | shellPath = /bin/sh;
229 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
230 | };
231 | /* End PBXShellScriptBuildPhase section */
232 |
233 | /* Begin PBXSourcesBuildPhase section */
234 | 97C146EA1CF9000F007C117D /* Sources */ = {
235 | isa = PBXSourcesBuildPhase;
236 | buildActionMask = 2147483647;
237 | files = (
238 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
239 | 97C146F31CF9000F007C117D /* main.m in Sources */,
240 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
241 | );
242 | runOnlyForDeploymentPostprocessing = 0;
243 | };
244 | /* End PBXSourcesBuildPhase section */
245 |
246 | /* Begin PBXVariantGroup section */
247 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
248 | isa = PBXVariantGroup;
249 | children = (
250 | 97C146FB1CF9000F007C117D /* Base */,
251 | );
252 | name = Main.storyboard;
253 | sourceTree = "";
254 | };
255 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
256 | isa = PBXVariantGroup;
257 | children = (
258 | 97C147001CF9000F007C117D /* Base */,
259 | );
260 | name = LaunchScreen.storyboard;
261 | sourceTree = "";
262 | };
263 | /* End PBXVariantGroup section */
264 |
265 | /* Begin XCBuildConfiguration section */
266 | 97C147031CF9000F007C117D /* Debug */ = {
267 | isa = XCBuildConfiguration;
268 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
269 | buildSettings = {
270 | ALWAYS_SEARCH_USER_PATHS = NO;
271 | CLANG_ANALYZER_NONNULL = YES;
272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
273 | CLANG_CXX_LIBRARY = "libc++";
274 | CLANG_ENABLE_MODULES = YES;
275 | CLANG_ENABLE_OBJC_ARC = YES;
276 | CLANG_WARN_BOOL_CONVERSION = YES;
277 | CLANG_WARN_CONSTANT_CONVERSION = YES;
278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
279 | CLANG_WARN_EMPTY_BODY = YES;
280 | CLANG_WARN_ENUM_CONVERSION = YES;
281 | CLANG_WARN_INFINITE_RECURSION = YES;
282 | CLANG_WARN_INT_CONVERSION = YES;
283 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
284 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
285 | CLANG_WARN_UNREACHABLE_CODE = YES;
286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
288 | COPY_PHASE_STRIP = NO;
289 | DEBUG_INFORMATION_FORMAT = dwarf;
290 | ENABLE_STRICT_OBJC_MSGSEND = YES;
291 | ENABLE_TESTABILITY = YES;
292 | GCC_C_LANGUAGE_STANDARD = gnu99;
293 | GCC_DYNAMIC_NO_PIC = NO;
294 | GCC_NO_COMMON_BLOCKS = YES;
295 | GCC_OPTIMIZATION_LEVEL = 0;
296 | GCC_PREPROCESSOR_DEFINITIONS = (
297 | "DEBUG=1",
298 | "$(inherited)",
299 | );
300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
302 | GCC_WARN_UNDECLARED_SELECTOR = YES;
303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
304 | GCC_WARN_UNUSED_FUNCTION = YES;
305 | GCC_WARN_UNUSED_VARIABLE = YES;
306 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
307 | MTL_ENABLE_DEBUG_INFO = YES;
308 | ONLY_ACTIVE_ARCH = YES;
309 | SDKROOT = iphoneos;
310 | TARGETED_DEVICE_FAMILY = "1,2";
311 | };
312 | name = Debug;
313 | };
314 | 97C147041CF9000F007C117D /* Release */ = {
315 | isa = XCBuildConfiguration;
316 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
317 | buildSettings = {
318 | ALWAYS_SEARCH_USER_PATHS = NO;
319 | CLANG_ANALYZER_NONNULL = YES;
320 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
321 | CLANG_CXX_LIBRARY = "libc++";
322 | CLANG_ENABLE_MODULES = YES;
323 | CLANG_ENABLE_OBJC_ARC = YES;
324 | CLANG_WARN_BOOL_CONVERSION = YES;
325 | CLANG_WARN_CONSTANT_CONVERSION = YES;
326 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
327 | CLANG_WARN_EMPTY_BODY = YES;
328 | CLANG_WARN_ENUM_CONVERSION = YES;
329 | CLANG_WARN_INFINITE_RECURSION = YES;
330 | CLANG_WARN_INT_CONVERSION = YES;
331 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
332 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
333 | CLANG_WARN_UNREACHABLE_CODE = YES;
334 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
335 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
336 | COPY_PHASE_STRIP = NO;
337 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
338 | ENABLE_NS_ASSERTIONS = NO;
339 | ENABLE_STRICT_OBJC_MSGSEND = YES;
340 | GCC_C_LANGUAGE_STANDARD = gnu99;
341 | GCC_NO_COMMON_BLOCKS = YES;
342 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
343 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
344 | GCC_WARN_UNDECLARED_SELECTOR = YES;
345 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
346 | GCC_WARN_UNUSED_FUNCTION = YES;
347 | GCC_WARN_UNUSED_VARIABLE = YES;
348 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
349 | MTL_ENABLE_DEBUG_INFO = NO;
350 | SDKROOT = iphoneos;
351 | TARGETED_DEVICE_FAMILY = "1,2";
352 | VALIDATE_PRODUCT = YES;
353 | };
354 | name = Release;
355 | };
356 | 97C147061CF9000F007C117D /* Debug */ = {
357 | isa = XCBuildConfiguration;
358 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
359 | buildSettings = {
360 | ARCHS = arm64;
361 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
362 | ENABLE_BITCODE = NO;
363 | FRAMEWORK_SEARCH_PATHS = (
364 | "$(inherited)",
365 | "$(PROJECT_DIR)/Flutter",
366 | );
367 | INFOPLIST_FILE = Runner/Info.plist;
368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
369 | LIBRARY_SEARCH_PATHS = (
370 | "$(inherited)",
371 | "$(PROJECT_DIR)/Flutter",
372 | );
373 | PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterPlayground;
374 | PRODUCT_NAME = "$(TARGET_NAME)";
375 | };
376 | name = Debug;
377 | };
378 | 97C147071CF9000F007C117D /* Release */ = {
379 | isa = XCBuildConfiguration;
380 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
381 | buildSettings = {
382 | ARCHS = arm64;
383 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
384 | ENABLE_BITCODE = NO;
385 | FRAMEWORK_SEARCH_PATHS = (
386 | "$(inherited)",
387 | "$(PROJECT_DIR)/Flutter",
388 | );
389 | INFOPLIST_FILE = Runner/Info.plist;
390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
391 | LIBRARY_SEARCH_PATHS = (
392 | "$(inherited)",
393 | "$(PROJECT_DIR)/Flutter",
394 | );
395 | PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterPlayground;
396 | PRODUCT_NAME = "$(TARGET_NAME)";
397 | };
398 | name = Release;
399 | };
400 | /* End XCBuildConfiguration section */
401 |
402 | /* Begin XCConfigurationList section */
403 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
404 | isa = XCConfigurationList;
405 | buildConfigurations = (
406 | 97C147031CF9000F007C117D /* Debug */,
407 | 97C147041CF9000F007C117D /* Release */,
408 | );
409 | defaultConfigurationIsVisible = 0;
410 | defaultConfigurationName = Release;
411 | };
412 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
413 | isa = XCConfigurationList;
414 | buildConfigurations = (
415 | 97C147061CF9000F007C117D /* Debug */,
416 | 97C147071CF9000F007C117D /* Release */,
417 | );
418 | defaultConfigurationIsVisible = 0;
419 | defaultConfigurationName = Release;
420 | };
421 | /* End XCConfigurationList section */
422 | };
423 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
424 | }
425 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
7 | [GeneratedPluginRegistrant registerWithRegistry:self];
8 | // Override point for customization after application launch.
9 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
10 | }
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | }
111 | ],
112 | "info" : {
113 | "version" : 1,
114 | "author" : "xcode"
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amirh/indux/3c559b529d7341d8b4f34fddf1877085412de1eb/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_playground
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | arm64
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 | UIViewControllerBasedStatusBarAppearance
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/examples/2048/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char * argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/2048/lib/animation_spec.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_playground/state.dart';
2 | import 'package:flutter_playground/redux.dart';
3 |
4 | class TileMotionSpec {
5 | final int fromI;
6 | final int fromJ;
7 | final int toI;
8 | final int toJ;
9 | final bool fadeIn;
10 |
11 | TileMotionSpec(this.fromI, this.fromJ, this.toI, this.toJ, {this.fadeIn = false});
12 |
13 | @override
14 | String toString() {
15 | return 'MotionSpec: from ($fromI, $fromJ) to ($toI, $toJ) fadeIn: $fadeIn';
16 | }
17 |
18 | }
19 |
20 | List buildMotionSpec(BoardState fromState, Action action, BoardState toState) {
21 | if (action?.type == ActionType.moveRight) {
22 | return _buildMoveRightSpec(fromState, toState);
23 | } else if (action?.type == ActionType.moveLeft) {
24 | return _buildMoveLeftSpec(fromState, toState);
25 | } else if (action?.type == ActionType.moveUp) {
26 | return _buildMoveUpSpec(fromState, toState);
27 | } else if (action?.type == ActionType.moveDown) {
28 | return _buildMoveDownSpec(fromState, toState);
29 | }
30 |
31 | return _buildFixedMotionSpec(toState);
32 | }
33 |
34 | List _buildMoveRightSpec(BoardState fromState, BoardState toState) {
35 | int dimen = toState.dimension;
36 | List motionSpec = new List();
37 | for (int i = 0; i < dimen; i += 1) {
38 | int prevJ = dimen - 1;
39 | for (int j = dimen -1 ; j >= 0; j -= 1) {
40 | if(toState.tiles[i][j] == 0)
41 | continue;
42 |
43 | while (prevJ > 0 && fromState.tiles[i][prevJ] == 0) {
44 | prevJ -= 1;
45 | }
46 |
47 | if (i == toState.lastTileAdded?.x && j == toState.lastTileAdded?.y) {
48 | continue;
49 | }
50 |
51 | motionSpec.add(new TileMotionSpec(i, prevJ, i, j));
52 |
53 | if (toState.tiles[i][j] != fromState.tiles[i][prevJ]) {
54 | prevJ -= 1;
55 | while (prevJ > 0 && fromState.tiles[i][prevJ] == 0) {
56 | prevJ -= 1;
57 | }
58 | motionSpec.add(new TileMotionSpec(i, prevJ, i, j));
59 | motionSpec.add(new TileMotionSpec(i, j, i, j, fadeIn: true));
60 | }
61 |
62 | prevJ -= 1;
63 | }
64 | }
65 |
66 | return motionSpec;
67 | }
68 |
69 | List _buildMoveLeftSpec(BoardState fromState, BoardState toState) {
70 | int dimen = toState.dimension;
71 | List motionSpec = new List();
72 | for (int i = 0; i < dimen; i += 1) {
73 | int prevJ = 0;
74 | for (int j = 0 ; j < dimen; j += 1) {
75 | if(toState.tiles[i][j] == 0)
76 | continue;
77 |
78 | while (prevJ < dimen && fromState.tiles[i][prevJ] == 0) {
79 | prevJ += 1;
80 | }
81 |
82 | if (i == toState.lastTileAdded?.x && j == toState.lastTileAdded?.y) {
83 | continue;
84 | }
85 |
86 | motionSpec.add(new TileMotionSpec(i, prevJ, i, j));
87 |
88 | if (toState.tiles[i][j] != fromState.tiles[i][prevJ]) {
89 | prevJ += 1;
90 | while (prevJ < dimen && fromState.tiles[i][prevJ] == 0) {
91 | prevJ += 1;
92 | }
93 | motionSpec.add(new TileMotionSpec(i, prevJ, i, j));
94 | motionSpec.add(new TileMotionSpec(i, j, i, j, fadeIn: true));
95 | }
96 |
97 | prevJ += 1;
98 | }
99 | }
100 |
101 | return motionSpec;
102 | }
103 |
104 | List _buildMoveUpSpec(BoardState fromState, BoardState toState) {
105 | int dimen = toState.dimension;
106 | List motionSpec = new List();
107 | for (int j = 0; j < dimen; j += 1) {
108 | int prevI = 0;
109 | for (int i = 0 ; i < dimen; i += 1) {
110 | if(toState.tiles[i][j] == 0)
111 | continue;
112 |
113 | while (prevI < dimen && fromState.tiles[prevI][j] == 0) {
114 | prevI += 1;
115 | }
116 |
117 | if (i == toState.lastTileAdded?.x && j == toState.lastTileAdded?.y) {
118 | continue;
119 | }
120 |
121 | motionSpec.add(new TileMotionSpec(prevI, j, i, j));
122 |
123 | if (toState.tiles[i][j] != fromState.tiles[prevI][j]) {
124 | prevI += 1;
125 | while (prevI < dimen && fromState.tiles[prevI][j] == 0) {
126 | prevI += 1;
127 | }
128 | motionSpec.add(new TileMotionSpec(prevI, j, i, j));
129 | motionSpec.add(new TileMotionSpec(i, j, i, j, fadeIn: true));
130 | }
131 |
132 | prevI += 1;
133 | }
134 | }
135 |
136 | return motionSpec;
137 | }
138 |
139 | List _buildMoveDownSpec(BoardState fromState, BoardState toState) {
140 | int dimen = toState.dimension;
141 | List motionSpec = new List();
142 | for (int j = 0; j < dimen; j += 1) {
143 | int prevI = dimen - 1;
144 | for (int i = dimen - 1 ; i >= 0; i -= 1) {
145 | if(toState.tiles[i][j] == 0)
146 | continue;
147 |
148 | while (prevI >= 0 && fromState.tiles[prevI][j] == 0) {
149 | prevI -= 1;
150 | }
151 |
152 | if (i == toState.lastTileAdded?.x && j == toState.lastTileAdded?.y) {
153 | continue;
154 | }
155 |
156 | motionSpec.add(new TileMotionSpec(prevI, j, i, j));
157 |
158 | if (toState.tiles[i][j] != fromState.tiles[prevI][j]) {
159 | prevI -= 1;
160 | while (prevI >= 0 && fromState.tiles[prevI][j] == 0) {
161 | prevI -= 1;
162 | }
163 | motionSpec.add(new TileMotionSpec(prevI, j, i, j));
164 | motionSpec.add(new TileMotionSpec(i, j, i, j, fadeIn: true));
165 | }
166 |
167 | prevI -= 1;
168 | }
169 | }
170 |
171 | return motionSpec;
172 | }
173 |
174 | List _buildFixedMotionSpec(BoardState toState) {
175 | List motionSpec = new List();
176 | for (int i = 0; i < toState.dimension; i += 1) {
177 | for (int j = 0; j < toState.dimension; j++) {
178 | if (toState.tiles[i][j] != 0)
179 | motionSpec.add(new TileMotionSpec(i, j, i, j));
180 | }
181 | }
182 | return motionSpec;
183 | }
184 |
--------------------------------------------------------------------------------
/examples/2048/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_playground/redux.dart';
3 | import 'package:flutter_playground/ui.dart';
4 |
5 | void main() {
6 | runApp(new App2048());
7 | }
8 |
9 | class App2048 extends StatelessWidget {
10 | // This widget is the root of your application.
11 | @override
12 | Widget build(BuildContext context) {
13 | return new GameRedux(
14 | child: new MaterialApp(
15 | title: '2048',
16 | theme: new ThemeData(
17 | primarySwatch: Colors.blue,
18 | ),
19 | home: new Scaffold(
20 | body: new Center(
21 | child: _addBackgroundColor(new Game()),
22 | ),
23 | ),
24 | ),
25 | );
26 | }
27 | }
28 |
29 | class Game extends StatelessWidget {
30 | @override
31 | Widget build(BuildContext context) {
32 | return new GestureDetector(
33 | behavior: HitTestBehavior.opaque,
34 | onHorizontalDragEnd: (DragEndDetails d) {
35 | if (d.primaryVelocity > 0) {
36 | GameRedux.dispatch(context, moveRight());
37 | } else {
38 | GameRedux.dispatch(context, moveLeft());
39 | }
40 | },
41 | onVerticalDragEnd: (DragEndDetails d) {
42 | if (d.primaryVelocity > 0) {
43 | GameRedux.dispatch(context, moveDown());
44 | } else {
45 | GameRedux.dispatch(context, moveUp());
46 | }
47 | },
48 | child: const GameGrid(),
49 | );
50 | }
51 | }
52 |
53 | Widget _addBackgroundColor(Widget child) {
54 | return new Container(
55 | child: child,
56 | color: Colors.indigo,
57 | );
58 | }
59 |
--------------------------------------------------------------------------------
/examples/2048/lib/redux.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math' show Random;
2 |
3 | import 'package:collection/collection.dart';
4 | import 'package:flutter/widgets.dart';
5 | import 'package:flutter_playground/state.dart';
6 | import 'package:indux/indux.dart';
7 |
8 | enum ActionType {
9 | moveLeft,
10 | moveUp,
11 | moveRight,
12 | moveDown
13 | }
14 |
15 | class Action {
16 | final ActionType type;
17 | final int randomInt;
18 |
19 | Action(this.type, {this.randomInt});
20 | }
21 |
22 | class GameRedux extends StatelessWidget {
23 | final Widget child;
24 |
25 | GameRedux({this.child});
26 |
27 | @override
28 | Widget build(BuildContext context) {
29 | return new Store(
30 | child: child,
31 | initialState: new BoardState([
32 | [2, 0, 2, 0],
33 | [0, 0, 0, 0],
34 | [0, 0, 4, 0],
35 | [0, 0, 0, 0],
36 | ]),
37 | reducer: reduce,
38 | );
39 | }
40 |
41 | static BoardState reduce(BoardState state, Action action) {
42 | switch (action.type) {
43 | case ActionType.moveLeft:
44 | return _addNewTileIfMoved(state.moveLeft(), state, action.randomInt);
45 | case ActionType.moveUp:
46 | return _addNewTileIfMoved(state.moveUp(), state, action.randomInt);
47 | case ActionType.moveRight:
48 | return _addNewTileIfMoved(state.moveRight(), state, action.randomInt);
49 | case ActionType.moveDown:
50 | return _addNewTileIfMoved(state.moveDown(), state, action.randomInt);
51 | }
52 | return state;
53 | }
54 |
55 | static BoardState _addNewTileIfMoved(BoardState newState, BoardState prevState, int randomInt) {
56 | if (const DeepCollectionEquality().equals(prevState.tiles, newState.tiles)) {
57 | return new BoardState(prevState.tiles);
58 | }
59 | return newState.addNewTile(randomInt, _maxRand);
60 | }
61 |
62 | static StoreUpdate stateOf(BuildContext context) {
63 | return Store?.storeStateOf(context);
64 | }
65 |
66 | static void dispatch(BuildContext context, Action action) {
67 | Store?.dispatch(context, action);
68 | }
69 | }
70 |
71 | const int _maxRand = 1000;
72 | Random _rand = new Random.secure();
73 |
74 | Action moveUp() {
75 | return new Action(ActionType.moveUp, randomInt: _rand.nextInt(_maxRand));
76 | }
77 |
78 | Action moveRight() {
79 | return new Action(ActionType.moveRight, randomInt: _rand.nextInt(_maxRand));
80 | }
81 |
82 | Action moveDown() {
83 | return new Action(ActionType.moveDown, randomInt: _rand.nextInt(_maxRand));
84 | }
85 |
86 | Action moveLeft() {
87 | return new Action(ActionType.moveLeft, randomInt: _rand.nextInt(_maxRand));
88 | }
89 |
--------------------------------------------------------------------------------
/examples/2048/lib/state.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math' show Point;
2 |
3 | class BoardState {
4 | final List> tiles;
5 | final Point lastTileAdded;
6 | final int dimension;
7 |
8 | BoardState(this.tiles, {this.lastTileAdded}) : dimension = tiles.length {
9 | tiles.forEach((row) { assert(row.length == dimension); });
10 | }
11 |
12 | BoardState moveRight() {
13 | List> result = new List>(dimension);
14 | for (int i = 0; i < dimension; i += 1) {
15 | List row = tiles[i];
16 | List newRow = new List.filled(dimension, 0);
17 | result[i] = newRow;
18 | int rightMostModifable = dimension - 1;
19 | for (int j = dimension - 1; j >= 0; j--) {
20 | if (row[j] == 0)
21 | continue;
22 |
23 | if (row[j] == newRow[rightMostModifable]) {
24 | newRow[rightMostModifable] *= 2;
25 | rightMostModifable--;
26 | continue;
27 | }
28 |
29 | if (newRow[rightMostModifable] == 0) {
30 | newRow[rightMostModifable] = row[j];
31 | continue;
32 | }
33 |
34 | rightMostModifable -= 1;
35 | newRow[rightMostModifable] = row[j];
36 | }
37 | }
38 | return new BoardState(result);
39 | }
40 |
41 | BoardState moveUp() {
42 | return _rotateClockWise()
43 | .moveRight()
44 | ._rotateClockWise()
45 | ._rotateClockWise()
46 | ._rotateClockWise();
47 | }
48 |
49 | BoardState moveLeft() {
50 | return _rotateClockWise()
51 | ._rotateClockWise()
52 | .moveRight()
53 | ._rotateClockWise()
54 | ._rotateClockWise();
55 | }
56 |
57 | BoardState moveDown() {
58 | return _rotateClockWise()
59 | ._rotateClockWise()
60 | ._rotateClockWise()
61 | .moveRight()
62 | ._rotateClockWise();
63 | }
64 |
65 | BoardState addNewTile(int randomValue, int maxValue) {
66 | List> emptyCells = new List>();
67 | List> newTiles = new List>(dimension);
68 | for (int i = 0; i < dimension; i++) {
69 | newTiles[i] = new List(dimension);
70 | for (int j = 0; j < dimension; j++) {
71 | if (tiles[i][j] == 0) {
72 | emptyCells.add(new Point(i, j));
73 | }
74 | newTiles[i][j] = tiles[i][j];
75 | }
76 | }
77 |
78 | Point selectedPosition = emptyCells[randomValue % emptyCells.length];
79 | int newValue = maxValue * 0.4 < randomValue ? 4 : 2;
80 | newTiles[selectedPosition.x][selectedPosition.y] = newValue;
81 | return new BoardState(newTiles, lastTileAdded: selectedPosition);
82 | }
83 |
84 | BoardState _rotateClockWise() {
85 | List> result = new List>(dimension);
86 | for (int i = 0; i < dimension; i++) {
87 | result[i] = new List(dimension);
88 | for (int j = 0; j < dimension; j++) {
89 | result[i][j] = tiles[dimension - 1 - j][i];
90 | }
91 | }
92 | return new BoardState(result);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/examples/2048/lib/ui.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui' show lerpDouble;
2 |
3 | import 'package:flutter/foundation.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:flutter_playground/animation_spec.dart';
6 | import 'package:flutter_playground/redux.dart';
7 | import 'package:flutter_playground/state.dart';
8 | import 'package:indux/indux.dart';
9 |
10 | class GameGrid extends StatefulWidget {
11 | const GameGrid({Key key}) : super(key: key);
12 |
13 | @override
14 | State createState() => new GameGridState();
15 | }
16 |
17 | class GameGridState extends State with TickerProviderStateMixin {
18 |
19 | AnimationController _slideController;
20 | AnimationController _fadeController;
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | _recycleAnimationControllers();
25 |
26 | StoreUpdate update = GameRedux.stateOf(context);
27 |
28 | List motionSpec =
29 | buildMotionSpec(update.previousState, update.lastAction, update.state);
30 |
31 | var tiles = _animatedTilesForSpec(motionSpec, update);
32 |
33 | return new AspectRatio(
34 | aspectRatio: 1.0,
35 | child: new Stack(
36 | children: tiles
37 | )
38 | );
39 | }
40 |
41 | List _animatedTilesForSpec(List motionSpec, StoreUpdate update) {
42 | List tiles = new List();
43 | var prevTiles = update?.previousState?.tiles ?? update.state.tiles;
44 | for (int i = 0; i < motionSpec.length; i += 1) {
45 | TileMotionSpec spec = motionSpec[i];
46 | int value;
47 | if (spec.fadeIn)
48 | value = update.state.tiles[spec.toI][spec.toJ];
49 | else
50 | value = prevTiles[spec.fromI][spec.fromJ];
51 | tiles.add(new AnimatedTile(
52 | spec.fromI,
53 | spec.fromJ,
54 | spec.toI,
55 | spec.toJ,
56 | value,
57 | update.state.dimension,
58 | slideController: _slideController,
59 | fadeController: _fadeController,
60 | fadeIn: spec.fadeIn,
61 | ));
62 | }
63 | if (update.state.lastTileAdded != null) {
64 | tiles.add(new AnimatedTile(
65 | update.state.lastTileAdded.x,
66 | update.state.lastTileAdded.y,
67 | update.state.lastTileAdded.x,
68 | update.state.lastTileAdded.y,
69 | update.state.tiles[update.state.lastTileAdded.x][update.state.lastTileAdded.y],
70 | update.state.dimension,
71 | slideController: _slideController,
72 | fadeController: _fadeController,
73 | fadeIn: true
74 | ));
75 | }
76 | return tiles;
77 | }
78 |
79 | void _recycleAnimationControllers() {
80 | _slideController?.dispose();
81 | _fadeController?.dispose();
82 |
83 | _slideController = new AnimationController(
84 | duration: new Duration(milliseconds: 150),
85 | vsync: this,
86 | );
87 | _fadeController = new AnimationController(
88 | duration: new Duration(milliseconds: 300),
89 | vsync: this,
90 | );
91 | }
92 |
93 | @override
94 | void dispose() {
95 | _slideController?.dispose();
96 | _fadeController?.dispose();
97 | super.dispose();
98 | }
99 |
100 | }
101 |
102 | class AnimatedTile extends StatelessWidget {
103 | final int prevI;
104 | final int prevJ;
105 | final int i;
106 | final int j;
107 | final int value;
108 | final int boardDimension;
109 | final bool fadeIn;
110 | final AnimationController slideController;
111 | final AnimationController fadeController;
112 |
113 | AnimatedTile(this.prevI, this.prevJ, this.i, this.j, this.value, this.boardDimension, {
114 | this.fadeIn = false,
115 | this.slideController,
116 | this.fadeController,
117 | });
118 |
119 | @override
120 | Widget build(BuildContext context) {
121 | double sizeFraction = 1.0 / boardDimension.toDouble();
122 |
123 | double maxTileIndex = (boardDimension -1 ).toDouble();
124 | double toXPosition = lerpDouble(-1.0, 1.0, j.toDouble() / maxTileIndex);
125 | double fromXPosition = lerpDouble(-1.0, 1.0, prevJ.toDouble() / maxTileIndex);
126 | double toYPosition = lerpDouble(-1.0, 1.0, i.toDouble() / maxTileIndex);
127 | double fromYPosition = lerpDouble(-1.0, 1.0, prevI.toDouble() / maxTileIndex);
128 |
129 | Animation alignment = new AlignmentTween(
130 | begin: new Alignment(fromXPosition, fromYPosition),
131 | end: new Alignment(toXPosition, toYPosition)
132 | ).animate(new CurvedAnimation(
133 | curve: Curves.easeOut,
134 | parent: slideController,
135 | ));
136 | slideController.forward();
137 |
138 |
139 | Animation fadeAnimation;
140 | if (fadeIn) {
141 | fadeAnimation =
142 | new CurvedAnimation(parent: fadeController, curve: Curves.easeOut);
143 | fadeController.forward();
144 | } else {
145 | fadeAnimation = new AlwaysStoppedAnimation(1.0);
146 | }
147 | return new AlignTransition(
148 | child: new FractionallySizedBox(
149 | widthFactor: sizeFraction,
150 | heightFactor: sizeFraction,
151 | child: new FadeTransition(
152 | opacity: fadeAnimation,
153 | child: new Tile(value),
154 | ),
155 | ),
156 | alignment: alignment
157 | );
158 | }
159 |
160 | @override
161 | void debugFillProperties(DiagnosticPropertiesBuilder description) {
162 | super.debugFillProperties(description);
163 | description.add(new DiagnosticsProperty('value', value));
164 | description.add(new DiagnosticsProperty('prevI', prevI));
165 | description.add(new DiagnosticsProperty('prevJ', prevJ));
166 | description.add(new DiagnosticsProperty('i', i));
167 | description.add(new DiagnosticsProperty('j', j));
168 | }
169 |
170 | }
171 |
172 | const Map _tileColors = const {
173 | 2: const Color(0xfff4bc42),
174 | 4: Colors.lightGreen,
175 | 8: Colors.blue,
176 | 16: Colors.amber,
177 | 32: Colors.cyan,
178 | 64: Colors.orange,
179 | 128: Colors.deepOrange,
180 | 256: Colors.brown,
181 | 512: Colors.blueGrey,
182 | 1024: Colors.pink,
183 | 2048: Colors.green,
184 | };
185 |
186 | class Tile extends StatelessWidget {
187 | final int value;
188 |
189 | Tile(this.value) : super(key: new Key(value.toString()));
190 |
191 | @override
192 | Widget build(BuildContext context) {
193 | return new Padding(
194 | padding: new EdgeInsets.all(4.0),
195 | child: new Container(
196 | child: new Center(
197 | child: new Text(
198 | value.toString(),
199 | style: const TextStyle(
200 | fontSize: 26.0,
201 | color: Colors.white,
202 | ),
203 | ),
204 | ),
205 | decoration: new ShapeDecoration(
206 | color: _tileColors[value] ?? Colors.black,
207 | shape: new RoundedRectangleBorder(
208 | borderRadius: new BorderRadius.circular(6.0),
209 | ),
210 | ),
211 | ),
212 | );
213 | }
214 | }
215 |
--------------------------------------------------------------------------------
/examples/2048/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_playground
2 | description: A new Flutter project.
3 |
4 | dependencies:
5 | flutter:
6 | sdk: flutter
7 | indux:
8 | path: ../../
9 |
10 | dev_dependencies:
11 | flutter_test:
12 | sdk: flutter
13 |
14 |
15 | # For information on the generic Dart part of this file, see the
16 | # following page: https://www.dartlang.org/tools/pub/pubspec
17 |
18 | # The following section is specific to Flutter.
19 | flutter:
20 |
21 | # The following line ensures that the Material Icons font is
22 | # included with your application, so that you can use the icons in
23 | # the Icons class.
24 | uses-material-design: true
25 |
26 | # To add assets to your application, add an assets section, like this:
27 | # assets:
28 | # - images/a_dot_burr.jpeg
29 | # - images/a_dot_ham.jpeg
30 |
31 | # An image asset can refer to one or more resolution-specific "variants", see
32 | # https://flutter.io/assets-and-images/#resolution-aware.
33 |
34 | # For details regarding adding assets from package dependencies, see
35 | # https://flutter.io/assets-and-images/#from-packages
36 |
37 | # To add custom fonts to your application, add a fonts section here,
38 | # in this "flutter" section. Each entry in this list should have a
39 | # "family" key with the font family name, and a "fonts" key with a
40 | # list giving the asset and other descriptors for the font. For
41 | # example:
42 | # fonts:
43 | # - family: Schyler
44 | # fonts:
45 | # - asset: fonts/Schyler-Regular.ttf
46 | # - asset: fonts/Schyler-Italic.ttf
47 | # style: italic
48 | # - family: Trajan Pro
49 | # fonts:
50 | # - asset: fonts/TrajanPro.ttf
51 | # - asset: fonts/TrajanPro_Bold.ttf
52 | # weight: 700
53 | #
54 | # For details regarding fonts from package dependencies,
55 | # see https://flutter.io/custom-fonts/#from-packages
56 |
--------------------------------------------------------------------------------
/examples/2048/test/animation_spec_test.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math' show Point;
2 |
3 | import 'package:test/test.dart';
4 | import 'package:flutter_playground/state.dart';
5 | import 'package:flutter_playground/redux.dart';
6 | import 'package:flutter_playground/animation_spec.dart';
7 |
8 | main() {
9 | test('move right', () {
10 | BoardState fromState = new BoardState([
11 | [0, 2, 0, 0],
12 | [0, 2, 0, 2],
13 | [8, 0, 4, 4],
14 | [2, 2, 0, 2],
15 | ]);
16 |
17 | BoardState toState = new BoardState(
18 | [
19 | [0, 2, 0, 2],
20 | [0, 0, 0, 4],
21 | [0, 0, 8, 8],
22 | [0, 0, 2, 4],
23 | ],
24 | lastTileAdded: new Point(0,1),
25 | );
26 |
27 | List motionSpec =
28 | buildMotionSpec(fromState, new Action(ActionType.moveRight), toState);
29 | expect(motionSpec.toString(), [
30 | new TileMotionSpec(0, 1, 0, 3),
31 | new TileMotionSpec(1, 3, 1, 3),
32 | new TileMotionSpec(1, 1, 1, 3),
33 | new TileMotionSpec(1, 3, 1, 3, fadeIn: true),
34 | new TileMotionSpec(2, 3, 2, 3),
35 | new TileMotionSpec(2, 2, 2, 3),
36 | new TileMotionSpec(2, 3, 2, 3, fadeIn: true),
37 | new TileMotionSpec(2, 0, 2, 2),
38 | new TileMotionSpec(3, 3, 3, 3),
39 | new TileMotionSpec(3, 1, 3, 3),
40 | new TileMotionSpec(3, 3, 3, 3, fadeIn: true),
41 | new TileMotionSpec(3, 0, 3, 2),
42 | ].toString());
43 | });
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/examples/2048/test/state_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:test/test.dart';
2 | import 'package:flutter_playground/state.dart';
3 |
4 | main () {
5 | test('move right', () {
6 | BoardState bs = new BoardState([
7 | [0, 2, 0, 0],
8 | [0, 2, 0, 2],
9 | [8, 0, 4, 4],
10 | [2, 2, 0, 2],
11 | ]);
12 |
13 | expect(bs.moveRight().tiles, [
14 | [0, 0, 0, 2],
15 | [0, 0, 0, 4],
16 | [0, 0, 8, 8],
17 | [0, 0, 2, 4],
18 | ]);
19 | });
20 |
21 | test('move up', () {
22 | BoardState bs = new BoardState([
23 | [0, 2, 0, 0],
24 | [0, 2, 0, 2],
25 | [8, 0, 4, 4],
26 | [2, 2, 0, 2],
27 | ]);
28 |
29 | expect(bs.moveUp().tiles, [
30 | [8, 4, 4, 2],
31 | [2, 2, 0, 4],
32 | [0, 0, 0, 2],
33 | [0, 0, 0, 0],
34 | ]);
35 | });
36 |
37 | test('move left', () {
38 | BoardState bs = new BoardState([
39 | [0, 2, 0, 0],
40 | [0, 2, 0, 2],
41 | [8, 0, 4, 4],
42 | [2, 2, 0, 2],
43 | ]);
44 |
45 | expect(bs.moveLeft().tiles, [
46 | [2, 0, 0, 0],
47 | [4, 0, 0, 0],
48 | [8, 8, 0, 0],
49 | [4, 2, 0, 0],
50 | ]);
51 | });
52 |
53 | test('move down', () {
54 | BoardState bs = new BoardState([
55 | [0, 2, 0, 0],
56 | [0, 2, 0, 2],
57 | [8, 0, 4, 4],
58 | [2, 2, 0, 2],
59 | ]);
60 |
61 | expect(bs.moveDown().tiles, [
62 | [0, 0, 0, 0],
63 | [0, 0, 0, 2],
64 | [8, 2, 0, 4],
65 | [2, 4, 4, 2],
66 | ]);
67 | });
68 | }
69 |
--------------------------------------------------------------------------------
/lib/indux.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Chromium Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import 'dart:async';
6 | import 'package:flutter/widgets.dart';
7 | import 'package:meta/meta.dart';
8 |
9 | /// A Redux store widget.
10 | ///
11 | /// A Widget hierarchy can only have a single [Store] object.
12 | ///
13 | /// Widgets down the tree can dispatch actions by calling [Store.dispatch].
14 |
15 | /// Widgets down the tree canand depend on the store's state by fetching it with
16 | /// [Store.storeStateOf], as this is using [InheritedWidget], widgets that
17 | /// depend on the store's state will get rebuilt when the state changes.
18 | class Store extends StatefulWidget {
19 |
20 | final Widget child;
21 |
22 | final Reducer reducer;
23 |
24 | final StateType initialState;
25 |
26 | final List> middleware;
27 |
28 | Store({
29 | @required this.child,
30 | @required this.initialState,
31 | @required this.reducer,
32 | this.middleware = const[]
33 | });
34 |
35 | @override
36 | State createState() => new _StoreState();
37 |
38 | /// Returns the [StoreUpdate] of the Store.
39 | ///
40 | /// The context of the calling widget is be used to fetch the store from the
41 | /// widget tree.
42 | static StoreUpdate storeStateOf(BuildContext context) {
43 | final _StoreScope storeScope = context.inheritFromWidgetOfExactType(_StoreScope);
44 | return storeScope?.state?.update;
45 | }
46 |
47 | /// Dispatches an action to the Store.
48 | ///
49 | /// The context of the calling widget is be used to fetch the store from the
50 | /// widget tree.
51 | static void dispatch(BuildContext context, ActionType action) {
52 | final _StoreScope storeScope = context.inheritFromWidgetOfExactType(_StoreScope);
53 | storeScope.state.dispatch(action);
54 | }
55 | }
56 |
57 | typedef StateType Reducer(StateType state, ActionType action);
58 |
59 | /// The current state of the store.
60 | ///
61 | /// This class bundles the last action and the previous state as well, which is
62 | /// usually the information needed for figuring out which transition to show.
63 | class StoreUpdate {
64 | final StateType state;
65 | final ActionType lastAction;
66 | final StateType previousState;
67 |
68 | const StoreUpdate(this.state, this.lastAction, this.previousState);
69 |
70 | @override
71 | String toString() {
72 | return '($state, $lastAction, $previousState)';
73 | }
74 |
75 | @override
76 | bool operator==(other) =>
77 | other is StoreUpdate
78 | && other.state == state
79 | && other.lastAction == lastAction
80 | && other.previousState == previousState;
81 |
82 | @override
83 | int get hashCode => hashValues(state, lastAction, previousState);
84 | }
85 |
86 | typedef void Dispatch(ActionType action);
87 |
88 | typedef void OnStoreUpdate(StoreUpdate update, Dispatch dispatcher);
89 |
90 | class _StoreState extends State> {
91 | StoreUpdate update;
92 |
93 | void dispatch(ActionType action) {
94 | StateType newState = widget.reducer(update.state, action);
95 | update = new StoreUpdate(
96 | newState,
97 | action,
98 | update.state
99 | );
100 | setState(() {});
101 | new Future(() {
102 | widget.middleware.forEach((m) { m(update, dispatch); });
103 | });
104 | }
105 |
106 | @override
107 | Widget build(BuildContext context) {
108 | return new _StoreScope(this, child: widget.child);
109 | }
110 |
111 | @override
112 | void initState() {
113 | super.initState();
114 | update = new StoreUpdate(widget.initialState, null, null);
115 | new Future(() {
116 | widget.middleware.forEach((m) { m(update, dispatch); });
117 | });
118 | }
119 | }
120 |
121 | class _StoreScope extends InheritedWidget {
122 | final _StoreState state;
123 |
124 | _StoreScope(this.state, {Widget child}) : super(child: child);
125 |
126 | @override
127 | bool updateShouldNotify(_StoreScope old) {
128 | return true;
129 | }
130 | }
131 |
132 |
133 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: indux
2 | version: 0.0.1
3 | authors:
4 | - Amir Hardon
5 | description: InheritedWidget based Redux implementation for Flutter (experimental).
6 | homepage: https://github.com/amirh/indux
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 | meta: ">=1.1.1 <2.0.0"
12 |
13 | dev_dependencies:
14 | flutter_test:
15 | sdk: flutter
16 |
--------------------------------------------------------------------------------
/test/indux_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:indux/indux.dart';
2 | import 'package:flutter/widgets.dart';
3 | import 'package:flutter_test/flutter_test.dart';
4 |
5 | class Action {
6 | final String type;
7 | const Action(this.type);
8 | }
9 |
10 | class StoreListener extends StatelessWidget {
11 | final List> storeUpdate = [];
12 |
13 | @override
14 | Widget build(BuildContext buildContext) {
15 | storeUpdate.add(Store.storeStateOf(buildContext));
16 | return new Container();
17 | }
18 | }
19 |
20 | void main() {
21 | testWidgets('Initial state passed to middleware and listeners', (WidgetTester tester) async {
22 | StoreListener storeListener = new StoreListener();
23 | List stateUpdates = [];
24 | await tester.pumpWidget(
25 | new Store(
26 | initialState: 'initialState',
27 | child: storeListener,
28 | reducer: (String state, String action) => action,
29 | middleware: > [
30 | (StoreUpdate update, Dispatch dispatcher) {
31 | stateUpdates.add(update.state);
32 | }
33 | ]
34 | )
35 | );
36 | await tester.pump(new Duration(milliseconds: 1));
37 | expect(stateUpdates, ['initialState']);
38 | expect(storeListener.storeUpdate, [new StoreUpdate('initialState', null, null)]);
39 | });
40 | }
41 |
--------------------------------------------------------------------------------