diff --git a/.cirrus.yml b/.cirrus.yml index b5c29eca..db029a1f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -23,6 +23,7 @@ task: EMULATOR_API_LEVEL: 28 ANDROID_ABI: "default;x86" matrix: + app_arch: binder app_arch: bloc_flutter app_arch: bloc_library app_arch: built_redux @@ -66,6 +67,7 @@ task: skip: '!changesInclude(".cirrus.yml", "$app_arch/*", "$app_arch/**/*")' env: matrix: + app_arch: binder app_arch: bloc_flutter app_arch: bloc_library app_arch: built_redux diff --git a/.travis.yml b/.travis.yml index d09dd464..08beea45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -341,6 +341,16 @@ jobs: env: states_rebuilder_ios before_install: *before_install_osx script: travis_retry ./scripts/ci.sh ./states_rebuilder + - <<: *integration-test + os: linux + env: binder_android + script: travis_retry ./scripts/ci.sh ./binder + - <<: *integration-test + os: osx + osx_image: xcode11.3 + env: binder_ios + before_install: *before_install_osx + script: travis_retry ./scripts/ci.sh ./binder allow_failures: # - env: diff --git a/README.md b/README.md index fe2edd8f..c51bc13b 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ a simple UI. - [MVU Example](mvu) - Uses the [dartea](https://pub.dartlang.org/packages/dartea) library to manage app state and update Widgets. - [MVC Example](mvc) - Uses the [MVC](https://pub.dartlang.org/packages/mvc_pattern) library to implement the traditional MVC design pattern. - [Frideos Example](frideos_library) - Uses the [Frideos](https://pub.dartlang.org/packages/frideos) library to manage app state and update widgets using streams. +- [Binder Example](binder) - Uses the [binder](https://pub.dartlang.org/packages/binder) library to manage app state. ### Supporting Code @@ -136,6 +137,7 @@ projects: - [Kushagra Saxena](https://github.com/kush3107) - [Shakib Hossain](https://github.com/shakib609) - [Mellati Fatah](https://github.com/GIfatahTH) +- [Romain Rastel](https://github.com/letsar) I'd like to thank all of the folks who have helped write new samples, improve the current implementations, and added documentation! You're amazing! :) diff --git a/binder/.gitignore b/binder/.gitignore new file mode 100644 index 00000000..2ddde2a5 --- /dev/null +++ b/binder/.gitignore @@ -0,0 +1,73 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/binder/.metadata b/binder/.metadata new file mode 100644 index 00000000..1b5cec02 --- /dev/null +++ b/binder/.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: 27321ebbad34b0a3fafe99fac037102196d655ff + channel: stable + +project_type: app diff --git a/binder/README.md b/binder/README.md new file mode 100644 index 00000000..f47c6fa1 --- /dev/null +++ b/binder/README.md @@ -0,0 +1,10 @@ +# binder example + +This sample makes use of the [binder][https://github.com/letsar/binder] library to manage state. + +## Key Concepts + + * States are referenced through `StateRef` instances. + * Logics are referenced through `LogicRef` instances. + * States can only be updated through business logic components (aka logics). + * More information on how binder works [here][https://github.com/letsar/binder]. diff --git a/binder/android/.gitignore b/binder/android/.gitignore new file mode 100644 index 00000000..0a741cb4 --- /dev/null +++ b/binder/android/.gitignore @@ -0,0 +1,11 @@ +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 diff --git a/vanilla/android/app/build.gradle b/binder/android/app/build.gradle similarity index 82% rename from vanilla/android/app/build.gradle rename to binder/android/app/build.gradle index 7489a6f9..3f146df3 100644 --- a/vanilla/android/app/build.gradle +++ b/binder/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 29 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -38,12 +38,11 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.vanilla" + applicationId "com.example.binder" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -61,7 +60,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/vanilla/android/app/src/profile/AndroidManifest.xml b/binder/android/app/src/debug/AndroidManifest.xml similarity index 89% rename from vanilla/android/app/src/profile/AndroidManifest.xml rename to binder/android/app/src/debug/AndroidManifest.xml index d1bf7acd..e0c22651 100644 --- a/vanilla/android/app/src/profile/AndroidManifest.xml +++ b/binder/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.binder"> diff --git a/binder/android/app/src/main/AndroidManifest.xml b/binder/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..7f2e3a0e --- /dev/null +++ b/binder/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/binder/android/app/src/main/kotlin/com/example/binder/MainActivity.kt b/binder/android/app/src/main/kotlin/com/example/binder/MainActivity.kt new file mode 100644 index 00000000..72459bbc --- /dev/null +++ b/binder/android/app/src/main/kotlin/com/example/binder/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.binder + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/vanilla/android/app/src/main/res/drawable/launch_background.xml b/binder/android/app/src/main/res/drawable/launch_background.xml similarity index 86% rename from vanilla/android/app/src/main/res/drawable/launch_background.xml rename to binder/android/app/src/main/res/drawable/launch_background.xml index 304732f8..f74085f3 100644 --- a/vanilla/android/app/src/main/res/drawable/launch_background.xml +++ b/binder/android/app/src/main/res/drawable/launch_background.xml @@ -1,7 +1,7 @@ - + + + + + diff --git a/binder/android/app/src/main/res/values/styles.xml b/binder/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..d74aa35c --- /dev/null +++ b/binder/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/vanilla/android/app/src/debug/AndroidManifest.xml b/binder/android/app/src/profile/AndroidManifest.xml similarity index 89% rename from vanilla/android/app/src/debug/AndroidManifest.xml rename to binder/android/app/src/profile/AndroidManifest.xml index d1bf7acd..e0c22651 100644 --- a/vanilla/android/app/src/debug/AndroidManifest.xml +++ b/binder/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.binder"> diff --git a/vanilla/android/build.gradle b/binder/android/build.gradle similarity index 100% rename from vanilla/android/build.gradle rename to binder/android/build.gradle diff --git a/vanilla/android/gradle.properties b/binder/android/gradle.properties similarity index 100% rename from vanilla/android/gradle.properties rename to binder/android/gradle.properties index 38c8d454..a6738207 100644 --- a/vanilla/android/gradle.properties +++ b/binder/android/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true +android.enableR8=true diff --git a/vanilla/android/gradle/wrapper/gradle-wrapper.properties b/binder/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from vanilla/android/gradle/wrapper/gradle-wrapper.properties rename to binder/android/gradle/wrapper/gradle-wrapper.properties diff --git a/binder/android/settings.gradle b/binder/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/binder/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/binder/ios/.gitignore b/binder/ios/.gitignore new file mode 100644 index 00000000..e96ef602 --- /dev/null +++ b/binder/ios/.gitignore @@ -0,0 +1,32 @@ +*.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/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/binder/ios/Flutter/.last_build_id b/binder/ios/Flutter/.last_build_id new file mode 100644 index 00000000..45ae2511 --- /dev/null +++ b/binder/ios/Flutter/.last_build_id @@ -0,0 +1 @@ +eba03d3217ec49a9a36963d850effc24 \ No newline at end of file diff --git a/binder/ios/Flutter/AppFrameworkInfo.plist b/binder/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..6b4c0f78 --- /dev/null +++ b/binder/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 8.0 + + diff --git a/binder/ios/Flutter/Debug.xcconfig b/binder/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..e8efba11 --- /dev/null +++ b/binder/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/binder/ios/Flutter/Release.xcconfig b/binder/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..399e9340 --- /dev/null +++ b/binder/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/binder/ios/Podfile b/binder/ios/Podfile new file mode 100644 index 00000000..1e8c3c90 --- /dev/null +++ b/binder/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.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__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/binder/ios/Podfile.lock b/binder/ios/Podfile.lock new file mode 100644 index 00000000..42642067 --- /dev/null +++ b/binder/ios/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - Flutter (1.0.0) + - key_value_store_flutter (0.0.1): + - Flutter + - path_provider (0.0.1): + - Flutter + - shared_preferences (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - key_value_store_flutter (from `.symlinks/plugins/key_value_store_flutter/ios`) + - path_provider (from `.symlinks/plugins/path_provider/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + key_value_store_flutter: + :path: ".symlinks/plugins/key_value_store_flutter/ios" + path_provider: + :path: ".symlinks/plugins/path_provider/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + key_value_store_flutter: 17757389b11f4df6461c3a63b7a996062c74b13c + path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c + shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.10.0 diff --git a/binder/ios/Runner.xcodeproj/project.pbxproj b/binder/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..a3aa7412 --- /dev/null +++ b/binder/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,563 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0F93D42AC7C909024F1AADBD /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C52BA454AC653A389A0D47E4 /* Pods_Runner.framework */; }; + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 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 PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 18C110AF97520BAF7361499A /* 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 = ""; }; + 1A770E3ABBFC5706CA987721 /* 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + C52BA454AC653A389A0D47E4 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CED4CD2DD34C35C2210C6E86 /* 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 = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0F93D42AC7C909024F1AADBD /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 450FAC9C9026F2CF91B4DC6A /* Pods */ = { + isa = PBXGroup; + children = ( + 18C110AF97520BAF7361499A /* Pods-Runner.debug.xcconfig */, + CED4CD2DD34C35C2210C6E86 /* Pods-Runner.release.xcconfig */, + 1A770E3ABBFC5706CA987721 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 7FCB98D300806A8B2DF7DC07 /* Frameworks */ = { + isa = PBXGroup; + children = ( + C52BA454AC653A389A0D47E4 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 450FAC9C9026F2CF91B4DC6A /* Pods */, + 7FCB98D300806A8B2DF7DC07 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + 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 = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 3A209879AA2EC91F0D018CED /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 1A50CEA03E268E150A2166A1 /* [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 = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 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 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 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 */ + 1A50CEA03E268E150A2166A1 /* [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; + }; + 3A209879AA2EC91F0D018CED /* [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; + }; + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + 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"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase 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; + 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; + 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 = 9.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; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.binder; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + 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 = 9.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; + 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; + 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 = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + 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; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.binder; + 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; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.binder; + 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 */ + 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/binder/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/binder/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/binder/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/binder/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/binder/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/binder/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..a28140cf --- /dev/null +++ b/binder/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/binder/ios/Runner.xcworkspace/contents.xcworkspacedata b/binder/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..21a3cc14 --- /dev/null +++ b/binder/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/binder/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/binder/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/binder/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/binder/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/binder/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/binder/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/binder/ios/Runner/AppDelegate.swift b/binder/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..70693e4a --- /dev/null +++ b/binder/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@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/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/binder/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/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..28c6bf03 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..2ccbfd96 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..f091b6b0 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cde1211 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..d0ef06e7 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..dcdc2306 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..2ccbfd96 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..c8f9ed8f Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..a6d6b860 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..a6d6b860 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..75b2d164 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..c4df70d3 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..6a84f41e Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..d0e1f585 Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/binder/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/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/binder/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/binder/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/binder/ios/Runner/Base.lproj/LaunchScreen.storyboard b/binder/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/binder/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/binder/ios/Runner/Base.lproj/Main.storyboard b/binder/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/binder/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/binder/ios/Runner/Info.plist b/binder/ios/Runner/Info.plist new file mode 100644 index 00000000..1b28b204 --- /dev/null +++ b/binder/ios/Runner/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + binder + 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 + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/binder/ios/Runner/Runner-Bridging-Header.h b/binder/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/binder/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/binder/lib/app.dart b/binder/lib/app.dart new file mode 100644 index 00000000..090aecd1 --- /dev/null +++ b/binder/lib/app.dart @@ -0,0 +1,42 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/localization.dart'; +import 'package:binder_sample/refs.dart'; +import 'package:binder_sample/screens/add_edit_screen.dart'; +import 'package:binder_sample/screens/home_screen.dart'; +import 'package:binder_sample/widgets/todos_logic_loader.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +class BinderApp extends StatelessWidget { + const BinderApp({Key key, @required this.repository}) : super(key: key); + + final TodosRepository repository; + + @override + Widget build(BuildContext context) { + return BinderScope( + overrides: [todosRepositoryRef.overrideWith((scope) => repository)], + child: TodosLogicLoader( + child: MaterialApp( + onGenerateTitle: (context) => + BinderLocalizations.of(context).appTitle, + theme: ArchSampleTheme.theme, + localizationsDelegates: [ + ArchSampleLocalizationsDelegate(), + BinderLocalizationsDelegate(), + ], + routes: { + ArchSampleRoutes.home: (_) => const HomeScreen(), + ArchSampleRoutes.addTodo: (_) => const AddEditScreen(), + }, + ), + ), + ); + } +} diff --git a/binder/lib/extensions.dart b/binder/lib/extensions.dart new file mode 100644 index 00000000..3d162a05 --- /dev/null +++ b/binder/lib/extensions.dart @@ -0,0 +1,30 @@ +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter/material.dart'; +import 'package:binder/binder.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +extension ScaffoldMessengerStateX on ScaffoldMessengerState { + void showDeleteTodoSnackBar(Todo todo) { + hideCurrentSnackBar(); + showSnackBar(createDeleteTodoSnackBar(context, todo)); + } +} + +SnackBar createDeleteTodoSnackBar(BuildContext context, Todo todo) { + final todosLogic = context.use(todosLogicRef); + return SnackBar( + key: ArchSampleKeys.snackbar, + duration: const Duration(seconds: 2), + content: Text( + ArchSampleLocalizations.of(context).todoDeleted(todo.task), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + action: SnackBarAction( + key: ArchSampleKeys.snackbarAction(todo.id), + label: ArchSampleLocalizations.of(context).undo, + onPressed: () => todosLogic.add(todo), + ), + ); +} diff --git a/binder/lib/localization.dart b/binder/lib/localization.dart new file mode 100644 index 00000000..6bfe9560 --- /dev/null +++ b/binder/lib/localization.dart @@ -0,0 +1,29 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/material.dart'; + +class BinderLocalizations { + static BinderLocalizations of(BuildContext context) { + return Localizations.of(context, BinderLocalizations); + } + + String get appTitle => 'Binder Example'; +} + +class BinderLocalizationsDelegate + extends LocalizationsDelegate { + @override + Future load(Locale locale) => + Future(() => BinderLocalizations()); + + @override + bool shouldReload(BinderLocalizationsDelegate old) => false; + + @override + bool isSupported(Locale locale) => + locale.languageCode.toLowerCase().contains('en'); +} diff --git a/binder/lib/logics/add_edit_screen.dart b/binder/lib/logics/add_edit_screen.dart new file mode 100644 index 00000000..443e9d6a --- /dev/null +++ b/binder/lib/logics/add_edit_screen.dart @@ -0,0 +1,34 @@ +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; + +final addEditScreenLogicRef = LogicRef((scope) => AddEditScreenLogic(scope)); + +final taskRef = StateRef(''); +final noteRef = StateRef(''); + +final taskIsValidRef = Computed((watch) => watch(taskRef).trim().isNotEmpty); +final canBeSubmittedRef = Computed((watch) => watch(taskIsValidRef)); + +class AddEditScreenLogic with Logic { + const AddEditScreenLogic(this.scope); + + @override + final Scope scope; + + TodosLogic get _todosLogic => use(todosLogicRef); + + String get task => read(taskRef); + set task(String value) => write(taskRef, value); + + String get note => read(noteRef); + set note(String value) => write(noteRef, value); + + Future put(Todo todo) { + if (todo != null) { + return _todosLogic.edit(todo.copyWith(task: task, note: note)); + } else { + return _todosLogic.add(Todo(task, note: note)); + } + } +} diff --git a/binder/lib/logics/home_screen.dart b/binder/lib/logics/home_screen.dart new file mode 100644 index 00000000..19cdaf03 --- /dev/null +++ b/binder/lib/logics/home_screen.dart @@ -0,0 +1,36 @@ +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; + +final activeFilterRef = StateRef(VisibilityFilter.all); +final homeScreenLogicRef = LogicRef((scope) => HomeScreenLogic(scope)); + +class HomeScreenLogic with Logic { + const HomeScreenLogic(this.scope); + + @override + final Scope scope; + + TodosLogic get _todosLogic => use(todosLogicRef); + + VisibilityFilter get filter => read(activeFilterRef); + set filter(VisibilityFilter value) => write(activeFilterRef, value); + + Future clearCompleted() { + final futures = >[]; + read(todosRef).where((todo) => todo.complete).forEach((todo) { + futures.add(_todosLogic.delete(todo)); + }); + return Future.wait(futures); + } + + Future toggleAll() { + final futures = >[]; + final todos = read(todosRef); + final allComplete = todos.every((todo) => todo.complete); + todos.map((todo) => todo.copyWith(complete: !allComplete)).forEach((todo) { + futures.add(_todosLogic.edit(todo)); + }); + return Future.wait(futures); + } +} diff --git a/binder/lib/logics/todos.dart b/binder/lib/logics/todos.dart new file mode 100644 index 00000000..4f466810 --- /dev/null +++ b/binder/lib/logics/todos.dart @@ -0,0 +1,46 @@ +import 'package:binder/binder.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/refs.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +final todosLogicRef = LogicRef((scope) => TodosLogic(scope)); +final todosRef = StateRef(const []); +final isLoadedRef = StateRef(false); + +class TodosLogic with Logic { + const TodosLogic(this.scope); + + @override + final Scope scope; + + TodosRepository get _todosRepository => use(todosRepositoryRef); + + List get todos => read(todosRef); + set todos(List value) => write(todosRef, value); + + Future init() async { + final entities = await _todosRepository.loadTodos(); + todos = entities.map((entity) => Todo.fromEntity(entity)).toList(); + write(isLoadedRef, true); + } + + Future add(Todo todo) { + todos = [...todos, todo]; + return _save(); + } + + Future delete(Todo todo) { + todos = todos.where((t) => t.id != todo.id).toList(); + return _save(); + } + + Future edit(Todo todo) { + todos = todos.map((t) => t.id == todo.id ? todo : t).toList(); + return _save(); + } + + Future _save() { + final entities = todos.map((todo) => todo.toEntity()).toList(); + return _todosRepository.saveTodos(entities); + } +} diff --git a/binder/lib/main.dart b/binder/lib/main.dart new file mode 100644 index 00000000..d690ca57 --- /dev/null +++ b/binder/lib/main.dart @@ -0,0 +1,24 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder_sample/app.dart'; +import 'package:flutter/material.dart'; +import 'package:key_value_store_flutter/key_value_store_flutter.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:todos_repository_local_storage/todos_repository_local_storage.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + + runApp( + BinderApp( + repository: LocalStorageRepository( + localStorage: KeyValueStorage( + 'binder', + FlutterKeyValueStore(await SharedPreferences.getInstance()), + ), + ), + ), + ); +} diff --git a/binder/lib/main_web.dart b/binder/lib/main_web.dart new file mode 100644 index 00000000..6f637c8e --- /dev/null +++ b/binder/lib/main_web.dart @@ -0,0 +1,25 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'dart:html'; + +import 'package:binder_sample/app.dart'; +import 'package:flutter/material.dart'; +import 'package:key_value_store_web/key_value_store_web.dart'; +import 'package:todos_repository_local_storage/todos_repository_local_storage.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + + runApp( + BinderApp( + repository: LocalStorageRepository( + localStorage: KeyValueStorage( + 'binder', + WebKeyValueStore(window.localStorage), + ), + ), + ), + ); +} diff --git a/binder/lib/models.dart b/binder/lib/models.dart new file mode 100644 index 00000000..6b4e8511 --- /dev/null +++ b/binder/lib/models.dart @@ -0,0 +1,63 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:todos_app_core/todos_app_core.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +enum AppTab { todos, stats } + +enum ExtraAction { toggleAllComplete, clearCompleted } + +class Todo { + bool complete; + String id; + String note; + String task; + + Todo(this.task, {this.complete = false, this.note = '', String id}) + : id = id ?? Uuid().generateV4(); + + Todo copyWith({bool complete, String id, String note, String task}) { + return Todo( + task ?? this.task, + complete: complete ?? this.complete, + id: id ?? this.id, + note: note ?? this.note, + ); + } + + @override + int get hashCode => + complete.hashCode ^ task.hashCode ^ note.hashCode ^ id.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Todo && + runtimeType == other.runtimeType && + complete == other.complete && + task == other.task && + note == other.note && + id == other.id; + + @override + String toString() { + return 'Todo{complete: $complete, task: $task, note: $note, id: $id}'; + } + + TodoEntity toEntity() { + return TodoEntity(task, id, note, complete); + } + + static Todo fromEntity(TodoEntity entity) { + return Todo( + entity.task, + complete: entity.complete ?? false, + note: entity.note, + id: entity.id ?? Uuid().generateV4(), + ); + } +} + +enum VisibilityFilter { all, active, completed } diff --git a/binder/lib/refs.dart b/binder/lib/refs.dart new file mode 100644 index 00000000..42506e5f --- /dev/null +++ b/binder/lib/refs.dart @@ -0,0 +1,4 @@ +import 'package:binder/binder.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +final todosRepositoryRef = LogicRef((scope) => null); diff --git a/binder/lib/screens/add_edit_screen.dart b/binder/lib/screens/add_edit_screen.dart new file mode 100644 index 00000000..6b369fb0 --- /dev/null +++ b/binder/lib/screens/add_edit_screen.dart @@ -0,0 +1,88 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/add_edit_screen.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class AddEditScreen extends StatelessWidget { + const AddEditScreen({Key key, this.todo}) + : super(key: key ?? ArchSampleKeys.addTodoScreen); + + final Todo todo; + + @override + Widget build(BuildContext context) { + return BinderScope( + overrides: [ + taskRef.overrideWith(todo?.task ?? ''), + noteRef.overrideWith(todo?.note ?? ''), + addEditScreenLogicRef.overrideWithSelf(), + ], + child: Builder( + builder: (context) { + return Scaffold( + appBar: AppBar( + title: Text(isEditing + ? ArchSampleLocalizations.of(context).editTodo + : ArchSampleLocalizations.of(context).addTodo), + ), + body: Padding( + padding: EdgeInsets.all(16.0), + child: ListView( + children: [ + TextFormField( + initialValue: todo != null ? todo.task : '', + key: ArchSampleKeys.taskField, + autofocus: isEditing ? false : true, + style: Theme.of(context).textTheme.headline5, + decoration: InputDecoration( + hintText: ArchSampleLocalizations.of(context).newTodoHint, + errorText: context.watch(taskIsValidRef) + ? null + : ArchSampleLocalizations.of(context).emptyTodoError, + ), + onChanged: (value) => + context.use(addEditScreenLogicRef).task = value, + ), + TextFormField( + initialValue: todo != null ? todo.note : '', + key: ArchSampleKeys.noteField, + maxLines: 10, + style: Theme.of(context).textTheme.subtitle1, + decoration: InputDecoration( + hintText: ArchSampleLocalizations.of(context).notesHint, + ), + onChanged: (value) => + context.use(addEditScreenLogicRef).note = value, + ) + ], + ), + ), + floatingActionButton: FloatingActionButton( + key: isEditing + ? ArchSampleKeys.saveTodoFab + : ArchSampleKeys.saveNewTodo, + tooltip: isEditing + ? ArchSampleLocalizations.of(context).saveChanges + : ArchSampleLocalizations.of(context).addTodo, + child: Icon(isEditing ? Icons.check : Icons.add), + onPressed: context.watch(canBeSubmittedRef) + ? () { + context.use(addEditScreenLogicRef).put(todo); + Navigator.pop(context); + } + : null, + ), + ); + }, + ), + ); + } + + bool get isEditing => todo != null; +} diff --git a/binder/lib/screens/detail_screen.dart b/binder/lib/screens/detail_screen.dart new file mode 100644 index 00000000..749c32b9 --- /dev/null +++ b/binder/lib/screens/detail_screen.dart @@ -0,0 +1,108 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/extensions.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/screens/add_edit_screen.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class DetailScreen extends StatelessWidget { + DetailScreen({@required this.id}) + : super(key: ArchSampleKeys.todoDetailsScreen); + + final String id; + + @override + Widget build(BuildContext context) { + final todo = context.watch(todosRef.select( + (todos) => todos.firstWhere((todo) => todo.id == id, orElse: () => null), + )); + + return Scaffold( + appBar: AppBar( + title: Text(ArchSampleLocalizations.of(context).todoDetails), + actions: [ + IconButton( + key: ArchSampleKeys.deleteTodoButton, + tooltip: ArchSampleLocalizations.of(context).deleteTodo, + icon: Icon(Icons.delete), + onPressed: () { + Navigator.pop(context, todo); + context.use(todosLogicRef).delete(todo); + ScaffoldMessenger.of(context).showDeleteTodoSnackBar(todo); + }, + ) + ], + ), + body: todo == null + ? const SizedBox() + : Padding( + padding: EdgeInsets.all(16.0), + child: ListView( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(right: 8.0), + child: Checkbox( + value: todo.complete, + key: ArchSampleKeys.detailsTodoItemCheckbox, + onChanged: (complete) { + context + .use(todosLogicRef) + .edit(todo.copyWith(complete: complete)); + }, + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 8.0, + bottom: 16.0, + ), + child: Text( + todo.task, + key: ArchSampleKeys.detailsTodoItemTask, + style: Theme.of(context).textTheme.headline5, + ), + ), + Text( + todo.note, + key: ArchSampleKeys.detailsTodoItemNote, + style: Theme.of(context).textTheme.subtitle1, + ) + ], + ), + ), + ], + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + tooltip: ArchSampleLocalizations.of(context).editTodo, + child: Icon(Icons.edit), + key: ArchSampleKeys.editTodoFab, + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) { + return AddEditScreen( + key: ArchSampleKeys.editTodoScreen, + todo: todo, + ); + }, + ), + ); + }, + ), + ); + } +} diff --git a/binder/lib/screens/home_screen.dart b/binder/lib/screens/home_screen.dart new file mode 100644 index 00000000..12baa147 --- /dev/null +++ b/binder/lib/screens/home_screen.dart @@ -0,0 +1,75 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/localization.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/widgets/extra_actions_button.dart'; +import 'package:binder_sample/widgets/filter_button.dart'; +import 'package:binder_sample/widgets/stats_counter.dart'; +import 'package:binder_sample/widgets/todo_list.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +final activeTabRef = StateRef(AppTab.todos); + +final tabSelectorLogicRef = LogicRef((scope) => TabSelectorLogic(scope)); + +class TabSelectorLogic with Logic { + const TabSelectorLogic(this.scope); + + @override + final Scope scope; + + AppTab get activeTab => read(activeTabRef); + set activeTab(AppTab value) => write(activeTabRef, value); +} + +class HomeScreen extends StatelessWidget { + const HomeScreen() : super(key: ArchSampleKeys.homeScreen); + + @override + Widget build(BuildContext context) { + final activeTab = context.watch(activeTabRef); + + return Scaffold( + appBar: AppBar( + title: Text(BinderLocalizations.of(context).appTitle), + actions: [ + FilterButton(isActive: activeTab == AppTab.todos), + const ExtraActionsButton() + ], + ), + body: activeTab == AppTab.todos ? const TodoList() : const StatsCounter(), + floatingActionButton: FloatingActionButton( + key: ArchSampleKeys.addTodoFab, + onPressed: () { + Navigator.pushNamed(context, ArchSampleRoutes.addTodo); + }, + child: Icon(Icons.add), + tooltip: ArchSampleLocalizations.of(context).addTodo, + ), + bottomNavigationBar: BottomNavigationBar( + key: ArchSampleKeys.tabs, + currentIndex: AppTab.values.indexOf(activeTab), + onTap: (index) { + context.use(tabSelectorLogicRef).activeTab = AppTab.values[index]; + }, + items: AppTab.values.map((tab) { + return BottomNavigationBarItem( + icon: Icon( + tab == AppTab.todos ? Icons.list : Icons.show_chart, + key: tab == AppTab.stats + ? ArchSampleKeys.statsTab + : ArchSampleKeys.todoTab, + ), + label: tab == AppTab.stats + ? ArchSampleLocalizations.of(context).stats + : ArchSampleLocalizations.of(context).todos, + ); + }).toList(), + ), + ); + } +} diff --git a/binder/lib/widgets/extra_actions_button.dart b/binder/lib/widgets/extra_actions_button.dart new file mode 100644 index 00000000..647daf2b --- /dev/null +++ b/binder/lib/widgets/extra_actions_button.dart @@ -0,0 +1,47 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/home_screen.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class ExtraActionsButton extends StatelessWidget { + const ExtraActionsButton({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final allComplete = context.watch( + todosRef.select((todos) => todos.every((todo) => todo.complete))); + return PopupMenuButton( + key: ArchSampleKeys.extraActionsButton, + onSelected: (action) { + switch (action) { + case ExtraAction.clearCompleted: + context.use(homeScreenLogicRef).clearCompleted(); + break; + case ExtraAction.toggleAllComplete: + context.use(homeScreenLogicRef).toggleAll(); + break; + } + }, + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + key: ArchSampleKeys.toggleAll, + value: ExtraAction.toggleAllComplete, + child: Text(allComplete + ? ArchSampleLocalizations.of(context).markAllIncomplete + : ArchSampleLocalizations.of(context).markAllComplete), + ), + PopupMenuItem( + key: ArchSampleKeys.clearCompleted, + value: ExtraAction.clearCompleted, + child: Text(ArchSampleLocalizations.of(context).clearCompleted), + ), + ], + ); + } +} diff --git a/binder/lib/widgets/filter_button.dart b/binder/lib/widgets/filter_button.dart new file mode 100644 index 00000000..3b6aa89b --- /dev/null +++ b/binder/lib/widgets/filter_button.dart @@ -0,0 +1,84 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/home_screen.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class FilterButton extends StatelessWidget { + FilterButton({Key key, this.isActive}) : super(key: key); + + final bool isActive; + + @override + Widget build(BuildContext context) { + final defaultStyle = Theme.of(context).textTheme.bodyText2; + final activeStyle = + defaultStyle.copyWith(color: Theme.of(context).accentColor); + final button = + _Button(activeStyle: activeStyle, defaultStyle: defaultStyle); + + return AnimatedOpacity( + opacity: isActive ? 1.0 : 0.0, + duration: Duration(milliseconds: 150), + child: isActive ? button : IgnorePointer(child: button), + ); + } +} + +class _Button extends StatelessWidget { + const _Button({ + Key key, + @required this.activeStyle, + @required this.defaultStyle, + }) : super(key: key); + + final TextStyle activeStyle; + final TextStyle defaultStyle; + + @override + Widget build(BuildContext context) { + final activeFilter = context.watch(activeFilterRef); + return PopupMenuButton( + key: ArchSampleKeys.filterButton, + tooltip: ArchSampleLocalizations.of(context).filterTodos, + onSelected: (filter) => context.use(homeScreenLogicRef).filter = filter, + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + key: ArchSampleKeys.allFilter, + value: VisibilityFilter.all, + child: Text( + ArchSampleLocalizations.of(context).showAll, + style: activeFilter == VisibilityFilter.all + ? activeStyle + : defaultStyle, + ), + ), + PopupMenuItem( + key: ArchSampleKeys.activeFilter, + value: VisibilityFilter.active, + child: Text( + ArchSampleLocalizations.of(context).showActive, + style: activeFilter == VisibilityFilter.active + ? activeStyle + : defaultStyle, + ), + ), + PopupMenuItem( + key: ArchSampleKeys.completedFilter, + value: VisibilityFilter.completed, + child: Text( + ArchSampleLocalizations.of(context).showCompleted, + style: activeFilter == VisibilityFilter.completed + ? activeStyle + : defaultStyle, + ), + ), + ], + icon: Icon(Icons.filter_list), + ); + } +} diff --git a/binder/lib/widgets/stats_counter.dart b/binder/lib/widgets/stats_counter.dart new file mode 100644 index 00000000..65ecbdb7 --- /dev/null +++ b/binder/lib/widgets/stats_counter.dart @@ -0,0 +1,61 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class StatsCounter extends StatelessWidget { + const StatsCounter() : super(key: ArchSampleKeys.statsCounter); + + @override + Widget build(BuildContext context) { + final numActive = context.watch( + todosRef.select((todos) => todos.where((todo) => !todo.complete).length), + ); + final numCompleted = context.watch( + todosRef.select((todos) => todos.where((todo) => todo.complete).length), + ); + + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 8.0), + child: Text( + ArchSampleLocalizations.of(context).completedTodos, + style: Theme.of(context).textTheme.headline6, + ), + ), + Padding( + padding: EdgeInsets.only(bottom: 24.0), + child: Text( + '$numCompleted', + key: ArchSampleKeys.statsNumCompleted, + style: Theme.of(context).textTheme.subtitle1, + ), + ), + Padding( + padding: EdgeInsets.only(bottom: 8.0), + child: Text( + ArchSampleLocalizations.of(context).activeTodos, + style: Theme.of(context).textTheme.headline6, + ), + ), + Padding( + padding: EdgeInsets.only(bottom: 24.0), + child: Text( + '$numActive', + key: ArchSampleKeys.statsNumActive, + style: Theme.of(context).textTheme.subtitle1, + ), + ) + ], + ), + ); + } +} diff --git a/binder/lib/widgets/todo_item.dart b/binder/lib/widgets/todo_item.dart new file mode 100644 index 00000000..ae674ab9 --- /dev/null +++ b/binder/lib/widgets/todo_item.dart @@ -0,0 +1,61 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/extensions.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/screens/detail_screen.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +final todoItemRef = StateRef(null); + +class TodoItem extends StatelessWidget { + const TodoItem({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final todo = context.watch(todoItemRef); + return Dismissible( + key: ArchSampleKeys.todoItem(todo.id), + onDismissed: (_) { + context.use(todosLogicRef).delete(todo); + ScaffoldMessenger.of(context).showDeleteTodoSnackBar(todo); + }, + child: ListTile( + onTap: () async { + final removedTodo = await Navigator.of(context).push( + MaterialPageRoute(builder: (_) => DetailScreen(id: todo.id)), + ); + if (removedTodo != null) { + ScaffoldMessenger.of(context).showDeleteTodoSnackBar(todo); + } + }, + leading: Checkbox( + key: ArchSampleKeys.todoItemCheckbox(todo.id), + value: todo.complete, + onChanged: (complete) => context + .use(todosLogicRef) + .edit(todo.copyWith(complete: complete)), + ), + title: Text( + todo.task, + key: ArchSampleKeys.todoItemTask(todo.id), + style: Theme.of(context).textTheme.headline6, + ), + subtitle: todo.note.isNotEmpty + ? Text( + todo.note, + key: ArchSampleKeys.todoItemNote(todo.id), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.subtitle1, + ) + : null, + ), + ); + } +} diff --git a/binder/lib/widgets/todo_list.dart b/binder/lib/widgets/todo_list.dart new file mode 100644 index 00000000..e3f6b8aa --- /dev/null +++ b/binder/lib/widgets/todo_list.dart @@ -0,0 +1,53 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/home_screen.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/widgets/todo_item.dart'; +import 'package:flutter/material.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +final filteredTodosRef = Computed((watch) { + final filter = watch(activeFilterRef); + return watch(todosRef).where((todo) { + switch (filter) { + case VisibilityFilter.active: + return !todo.complete; + case VisibilityFilter.completed: + return todo.complete; + default: + return true; + } + }).toList(); +}); + +class TodoList extends StatelessWidget { + const TodoList() : super(key: ArchSampleKeys.todoList); + + @override + Widget build(BuildContext context) { + final loading = !context.watch(isLoadedRef); + final filteredTodos = context.watch(filteredTodosRef); + + return Container( + child: loading + ? Center( + child: CircularProgressIndicator( + key: ArchSampleKeys.todosLoading, + )) + : ListView.builder( + key: ArchSampleKeys.todoList, + itemCount: filteredTodos.length, + itemBuilder: (BuildContext context, int index) { + return BinderScope( + overrides: [todoItemRef.overrideWith(filteredTodos[index])], + child: const TodoItem(), + ); + }, + ), + ); + } +} diff --git a/binder/lib/widgets/todos_logic_loader.dart b/binder/lib/widgets/todos_logic_loader.dart new file mode 100644 index 00000000..62960468 --- /dev/null +++ b/binder/lib/widgets/todos_logic_loader.dart @@ -0,0 +1,29 @@ +import 'dart:async'; + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:flutter/material.dart'; + +class TodosLogicLoader extends StatefulWidget { + const TodosLogicLoader({Key key, @required this.child}) + : assert(child != null), + super(key: key); + + final Widget child; + + @override + _TodosLogicLoaderState createState() => _TodosLogicLoaderState(); +} + +class _TodosLogicLoaderState extends State { + @override + void initState() { + super.initState(); + Future.microtask(() => context.use(todosLogicRef).init()); + } + + @override + Widget build(BuildContext context) { + return widget.child; + } +} diff --git a/binder/pubspec.yaml b/binder/pubspec.yaml new file mode 100644 index 00000000..a8c283f4 --- /dev/null +++ b/binder/pubspec.yaml @@ -0,0 +1,76 @@ +name: binder_sample +description: A new Flutter project. + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.7.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + todos_app_core: + path: ../todos_app_core + todos_repository_local_storage: + path: ../todos_repository_local_storage + binder: ^0.1.5 + key_value_store_flutter: + key_value_store_web: + shared_preferences: + +dev_dependencies: + flutter_driver: + sdk: flutter + flutter_test: + sdk: flutter + integration_tests: + path: ../integration_tests + mockito: + test: + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/binder/test/logics/add_edit_screen_test.dart b/binder/test/logics/add_edit_screen_test.dart new file mode 100644 index 00000000..5660415b --- /dev/null +++ b/binder/test/logics/add_edit_screen_test.dart @@ -0,0 +1,56 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/add_edit_screen.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; + +class MockScope extends Mock implements Scope {} + +class MockTodosLogic extends Mock implements TodosLogic {} + +void main() { + AddEditScreenLogic addEditScreenLogic; + Scope mockScope; + TodosLogic mockTodosLogic; + + setUp(() { + mockScope = MockScope(); + mockTodosLogic = MockTodosLogic(); + addEditScreenLogic = AddEditScreenLogic(mockScope); + + when(mockScope.use(todosLogicRef)).thenReturn(mockTodosLogic); + }); + + group('AddEditScreenLogic', () { + test('put() should call TodosLogic.edit() when todo is not null', () async { + when(mockScope.read(noteRef)).thenReturn('my_note'); + when(mockScope.read(taskRef)).thenReturn('my_task'); + final todo = Todo('hello', complete: true, id: 'id'); + await addEditScreenLogic.put(todo); + + verify(mockTodosLogic.edit(Todo( + 'my_task', + note: 'my_note', + complete: true, + id: 'id', + ))); + }); + + test('put() should call TodosLogic.add() when todo is null', () async { + when(mockScope.read(noteRef)).thenReturn('my_note'); + when(mockScope.read(taskRef)).thenReturn('my_task'); + await addEditScreenLogic.put(null); + + final captured = verify(mockTodosLogic.add(captureAny)).captured; + final todo = captured.first as Todo; + expect(todo.task, 'my_task'); + expect(todo.note, 'my_note'); + expect(todo.complete, false); + }); + }); +} diff --git a/binder/test/logics/home_screen_test.dart b/binder/test/logics/home_screen_test.dart new file mode 100644 index 00000000..612e18ad --- /dev/null +++ b/binder/test/logics/home_screen_test.dart @@ -0,0 +1,77 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/home_screen.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; + +class MockScope extends Mock implements Scope {} + +class MockTodosLogic extends Mock implements TodosLogic {} + +void main() { + HomeScreenLogic homeScreenLogic; + Scope mockScope; + TodosLogic mockTodosLogic; + + setUp(() { + mockScope = MockScope(); + mockTodosLogic = MockTodosLogic(); + homeScreenLogic = HomeScreenLogic(mockScope); + + when(mockScope.use(todosLogicRef)).thenReturn(mockTodosLogic); + }); + + group('HomeScreenLogic', () { + test('clearCompleted() should correctly delete completed todos', () async { + when(mockTodosLogic.delete(any)).thenAnswer((_) async {}); + when(mockScope.read(todosRef)).thenReturn([ + Todo('t1', id: '1', complete: true), + Todo('t2', id: '2', complete: false), + Todo('t3', id: '3', complete: true), + Todo('t4', id: '4', complete: false), + Todo('t5', id: '5', complete: false), + ]); + await homeScreenLogic.clearCompleted(); + + final captured = verify(mockTodosLogic.delete(captureAny)).captured; + final capturedIds = captured.map((e) => e.id).toList(); + expect(capturedIds, ['1', '3']); + }); + + test('toggleAll() should make all todos completed if one is not completed', + () async { + when(mockTodosLogic.edit(any)).thenAnswer((_) async {}); + when(mockScope.read(todosRef)).thenReturn([ + Todo('t1', id: '1', complete: true), + Todo('t2', id: '2', complete: false), + Todo('t3', id: '3', complete: true), + ]); + await homeScreenLogic.toggleAll(); + + final captured = verify(mockTodosLogic.edit(captureAny)).captured; + final capturedIds = captured.map((e) => e.complete).toList(); + expect(capturedIds, [true, true, true]); + }); + + test( + 'toggleAll() should make all todos not completed if all are completed', + () async { + when(mockTodosLogic.edit(any)).thenAnswer((_) async {}); + when(mockScope.read(todosRef)).thenReturn([ + Todo('t1', id: '1', complete: true), + Todo('t2', id: '2', complete: true), + Todo('t3', id: '3', complete: true), + ]); + await homeScreenLogic.toggleAll(); + + final captured = verify(mockTodosLogic.edit(captureAny)).captured; + final capturedIds = captured.map((e) => e.complete).toList(); + expect(capturedIds, [false, false, false]); + }); + }); +} diff --git a/binder/test/logics/todos_test.dart b/binder/test/logics/todos_test.dart new file mode 100644 index 00000000..31d39436 --- /dev/null +++ b/binder/test/logics/todos_test.dart @@ -0,0 +1,91 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder/binder.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/refs.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +class MockScope extends Mock implements Scope {} + +class MockTodosRepository extends Mock implements TodosRepository {} + +void main() { + TodosLogic todosLogic; + Scope mockScope; + TodosRepository mockTodosRepository; + + setUp(() { + mockScope = MockScope(); + mockTodosRepository = MockTodosRepository(); + todosLogic = TodosLogic(mockScope); + + when(mockScope.use(todosRepositoryRef)).thenReturn(mockTodosRepository); + }); + + group('TodosLogic', () { + test('should correctly update todosRef and save todos when add is called', + () async { + when(mockScope.read(todosRef)).thenReturn([]); + final todo = Todo('hello', complete: false); + await todosLogic.add(todo); + + verify(mockScope.write(todosRef, [todo])); + verify(mockScope.read(todosRef)).called(2); + verify(mockTodosRepository.saveTodos(any)); + }); + + test( + 'should correctly update todosRef and save todos when delete is called', + () async { + final todo = Todo('hello', complete: false); + when(mockScope.read(todosRef)).thenReturn([todo]); + await todosLogic.delete(todo); + + verify(mockScope.write(todosRef, [])); + verify(mockScope.read(todosRef)).called(2); + verify(mockTodosRepository.saveTodos(any)); + }); + + test('should correctly update todosRef and save todos when edit is called', + () async { + final todo = Todo('hello', complete: false); + when(mockScope.read(todosRef)).thenReturn([todo]); + + final newTodo = todo.copyWith(task: 'hi'); + await todosLogic.edit(newTodo); + + verify(mockScope.write(todosRef, [newTodo])); + verify(mockScope.read(todosRef)).called(2); + verify(mockTodosRepository.saveTodos(any)); + }); + + test('should correctly init todosRef when init is called', () async { + when(mockTodosRepository.loadTodos()).thenAnswer( + (_) async => [ + TodoEntity( + 'todo', + 'id', + 'note', + false, + ) + ], + ); + await todosLogic.init(); + + verify(mockScope.write(todosRef, [ + Todo( + 'todo', + id: 'id', + note: 'note', + complete: false, + ) + ])); + verify(mockScope.write(isLoadedRef, true)); + }); + }); +} diff --git a/binder/test/models_test.dart b/binder/test/models_test.dart new file mode 100644 index 00000000..cbd69b24 --- /dev/null +++ b/binder/test/models_test.dart @@ -0,0 +1,18 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:binder_sample/models.dart'; +import 'package:todos_repository_core/todos_repository_core.dart'; + +void main() { + group('Todo', () { + test('is correctly generated from TodoEntity', () { + expect( + Todo.fromEntity(TodoEntity('task', 'id', 'note', true)), + Todo('task', id: 'id', note: 'note', complete: true), + ); + }); + }); +} diff --git a/binder/test/screens/detail_screen_test.dart b/binder/test/screens/detail_screen_test.dart new file mode 100644 index 00000000..b8dbaa33 --- /dev/null +++ b/binder/test/screens/detail_screen_test.dart @@ -0,0 +1,81 @@ +import 'package:binder/binder.dart'; +import 'package:binder_sample/localization.dart'; +import 'package:binder_sample/logics/todos.dart'; +import 'package:binder_sample/models.dart'; +import 'package:binder_sample/screens/detail_screen.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:todos_app_core/todos_app_core.dart'; + +class MockTodosLogic extends Mock implements TodosLogic {} + +TodosLogic mockTodosLogic; + +void main() { + setUp(() { + mockTodosLogic = MockTodosLogic(); + }); + + group('DetailScreen', () { + testWidgets('renders properly with todos', (tester) async { + await tester.pumpWidget(DetailScreenTester( + todos: [ + Todo('t1', id: '1'), + Todo('t2', id: '2'), + Todo('t3', id: '3'), + ], + id: '2', + )); + + await tester.pumpAndSettle(); + expect(find.byKey(ArchSampleKeys.detailsTodoItemTask), findsOneWidget); + expect(find.text('t2'), findsOneWidget); + }); + + testWidgets('can delete the todo', (tester) async { + await tester.pumpWidget(DetailScreenTester( + todos: [ + Todo('t1', id: '1'), + Todo('t2', id: '2'), + Todo('t3', id: '3'), + ], + id: '2', + )); + + await tester.pumpAndSettle(); + await tester.tap(find.byKey(ArchSampleKeys.deleteTodoButton)); + verify(mockTodosLogic.delete(Todo('t2', id: '2'))); + }); + }); +} + +class DetailScreenTester extends StatelessWidget { + const DetailScreenTester({ + Key key, + @required this.id, + @required this.todos, + }) : super(key: key); + + final String id; + final List todos; + + @override + Widget build(BuildContext context) { + return BinderScope( + overrides: [ + todosLogicRef.overrideWith((scope) => mockTodosLogic), + todosRef.overrideWith(todos), + ], + child: MaterialApp( + theme: ArchSampleTheme.theme, + localizationsDelegates: [ + ArchSampleLocalizationsDelegate(), + BinderLocalizationsDelegate(), + ], + home: DetailScreen(id: id), + ), + ); + } +} diff --git a/binder/test_driver/todo_app.dart b/binder/test_driver/todo_app.dart new file mode 100644 index 00000000..4095f297 --- /dev/null +++ b/binder/test_driver/todo_app.dart @@ -0,0 +1,13 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:binder_sample/main.dart' as app; +// This line imports the extension +import 'package:flutter_driver/driver_extension.dart'; + +void main() { + enableFlutterDriverExtension(); + + app.main(); +} diff --git a/binder/test_driver/todo_app_test.dart b/binder/test_driver/todo_app_test.dart new file mode 100644 index 00000000..ad93f5a5 --- /dev/null +++ b/binder/test_driver/todo_app_test.dart @@ -0,0 +1,9 @@ +// Copyright 2018 The Flutter Architecture Sample Authors. All rights reserved. +// Use of this source code is governed by the MIT license that can be found +// in the LICENSE file. + +import 'package:integration_tests/integration_tests.dart' as integration_tests; + +void main() { + integration_tests.main(); +} diff --git a/binder/web/favicon.png b/binder/web/favicon.png new file mode 100644 index 00000000..8aaa46ac Binary files /dev/null and b/binder/web/favicon.png differ diff --git a/binder/web/icons/Icon-192.png b/binder/web/icons/Icon-192.png new file mode 100644 index 00000000..b749bfef Binary files /dev/null and b/binder/web/icons/Icon-192.png differ diff --git a/binder/web/icons/Icon-512.png b/binder/web/icons/Icon-512.png new file mode 100644 index 00000000..88cfd48d Binary files /dev/null and b/binder/web/icons/Icon-512.png differ diff --git a/binder/web/index.html b/binder/web/index.html new file mode 100644 index 00000000..6215e093 --- /dev/null +++ b/binder/web/index.html @@ -0,0 +1,10 @@ + + + + + vanilla + + + + + diff --git a/binder/web/manifest.json b/binder/web/manifest.json new file mode 100644 index 00000000..e8747655 --- /dev/null +++ b/binder/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "binder", + "short_name": "binder", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/line_count.md b/line_count.md index 06c94c66..73410c0d 100644 --- a/line_count.md +++ b/line_count.md @@ -15,21 +15,22 @@ samples to make them smaller, unless doing so improves the application overall. | *Sample* | *LOC (no comments)* | |--------|-------------------| -| scoped_model | 778 | -| mobx | 815 | -| change_notifier_provider | 830 | -| inherited_widget | 832 | +| binder | 774 | +| scoped_model | 780 | +| mobx | 824 | +| change_notifier_provider | 825 | +| inherited_widget | 837 | | mvc | 842 | -| vanilla | 842 | +| vanilla | 843 | | frideos_library | 878 | -| simple blocs | 1076 | -| built_redux | 1172 | +| simple blocs | 1071 | +| built_redux | 1173 | | mvu | 1191 | -| bloc | 1194 | -| bloc library | 1214 | -| mvi | 1244 | -| redux | 1362 | -| firestore_redux | 1429 | +| bloc | 1192 | +| bloc library | 1219 | +| mvi | 1243 | +| redux | 1371 | +| firestore_redux | 1430 | -Note: This file was generated on 2020-01-10 14:59:25.151846Z using `scripts/line_counter.dart`. +Note: This file was generated on 2020-11-03 21:12:13.779404Z using `scripts/line_counter.dart`. diff --git a/scripts/line_counter.dart b/scripts/line_counter.dart index 99b7bac0..5e12c85f 100644 --- a/scripts/line_counter.dart +++ b/scripts/line_counter.dart @@ -22,6 +22,7 @@ class Output { void main() { final samples = [ + Sample('binder', ['binder']), Sample('change_notifier_provider', ['change_notifier_provider']), Sample('bloc', ['bloc_flutter', 'blocs']), Sample('bloc library', ['bloc_library']), diff --git a/vanilla/android/.gitignore b/vanilla/android/.gitignore deleted file mode 100644 index bc2100d8..00000000 --- a/vanilla/android/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -gradle-wrapper.jar -/.gradle -/captures/ -/gradlew -/gradlew.bat -/local.properties -GeneratedPluginRegistrant.java diff --git a/vanilla/android/app/src/main/AndroidManifest.xml b/vanilla/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 7ee3bec6..00000000 --- a/vanilla/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - diff --git a/vanilla/android/app/src/main/res/values/styles.xml b/vanilla/android/app/src/main/res/values/styles.xml deleted file mode 100644 index 00fa4417..00000000 --- a/vanilla/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - -