diff --git a/.gitignore b/.gitignore index 4a60d90..f7ae545 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ doc/api/ .classpath .project .settings/ + +# +.idea/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/flutter_bloc_devtools.iml b/.idea/flutter_bloc_devtools.iml new file mode 100644 index 0000000..011f2a8 --- /dev/null +++ b/.idea/flutter_bloc_devtools.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml new file mode 100644 index 0000000..de8d14a --- /dev/null +++ b/.idea/libraries/Dart_Packages.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml new file mode 100644 index 0000000..f531cdf --- /dev/null +++ b/.idea/libraries/Dart_SDK.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..2b96ac4 --- /dev/null +++ b/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..abb41d6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/main_dart.xml b/.idea/runConfigurations/main_dart.xml new file mode 100644 index 0000000..aab7b5c --- /dev/null +++ b/.idea/runConfigurations/main_dart.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/example/flutter_todos/.metadata b/.metadata old mode 100755 new mode 100644 similarity index 76% rename from example/flutter_todos/.metadata rename to .metadata index fd2a86f..a5584fc --- a/example/flutter_todos/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b - channel: beta + revision: 18116933e77adc82f80866c928266a5b4f1ed645 + channel: stable project_type: app diff --git a/CHANGELOG.md b/CHANGELOG.md index e53f954..20d32da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.2 (2021) + +* Update to v8.0.0 of bloc + ## 0.1.1 (2020-11-15) * Minor update to Readme. diff --git a/README.md b/README.md index 1329b37..b9f9f64 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,25 @@ # Remote Devtools for flutter_bloc +## Progress +Fork of https://github.com/andrea689/flutter_bloc_devtools, which doesn't support v8.0.0 of bloc. +This currently has rudimentary support for v8.0.0. It is a work in progress. + +NOTE: In general, I don't recommend using this devtool unless you have a large amount of blocs and messages to deal with. For a small number of blocs, it is easier just to use [BlocObserver](https://bloclibrary.dev/#/coreconcepts?id=blocobserver) to log all bloc actions, which takes about 5-10 minutes to setup. See examples in the tutorials in https://bloclibrary.dev/ + +- [x] I got `flutter_bloc_devtools` to work with the example code. (see also the git branch "null_safety_migration") +- [ ] Doesn't deal well with enumerate types. +- [ ] Works with flutter_todos tutorial, v8. +- [ ] Write tests +- [ ] Update the package in pub.dev + +Create an issue if you want to help. + + +## Original docs + Remote Devtools support for Blocs of [flutter_bloc](https://github.com/felangel/bloc/tree/master/packages/flutter_bloc). -N.B. `Cubit` is not supported +N.B. `Cubit` is *now* supported ![Devtools Demo](https://github.com/andrea689/flutter_bloc_devtools/raw/main/demo.gif) @@ -12,26 +29,30 @@ Add the library to pubspec.yaml: ```yaml dependencies: - flutter_bloc_devtools: ^0.1.0 + flutter_bloc_devtools: + git: + url: https://github.com/chonghorizons/flutter_bloc_devtools.git + ref: main ``` +Note: The version on pub.dev doesn't work with null safety and v8 of bloc. + ## BlocObserver configuration Add `RemoteDevToolsObserver` to your `Bloc.observer`: ```dart void main() async { - final observer = RemoteDevToolsObserver('192.168.1.7:8000'); - await observer.connect(); - Bloc.observer = observer; - - runApp(const CounterApp()); + BlocOverrides.runZoned( + () async => runApp(const CounterApp()), + blocObserver: RemoteDevToolsObserver('127.0.0.1:8000'), + ); } ``` ## Making your Events and States Mappable -Events and States have to implements `Mappable`: +Events and States ~~have to~~ may implement `Mappable`: ```dart class CounterState extends Equatable implements Mappable { @@ -67,4 +88,4 @@ Run your application. It will connect to the remotedev server. You can now debug ## Examples - [Counter](example/counter) -- [Todos](example/flutter_todos) + diff --git a/example/flutter_todos/android/.gitignore b/android/.gitignore old mode 100755 new mode 100644 similarity index 91% rename from example/flutter_todos/android/.gitignore rename to android/.gitignore index 0a741cb..6f56801 --- a/example/flutter_todos/android/.gitignore +++ b/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/example/flutter_todos/android/app/build.gradle b/android/app/build.gradle old mode 100755 new mode 100644 similarity index 84% rename from example/flutter_todos/android/app/build.gradle rename to android/app/build.gradle index 3aff7ed..7379693 --- a/example/flutter_todos/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,21 +26,26 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 30 - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.flutter_todos" + applicationId "com.example.flutter_bloc_devtools" minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/flutter_todos/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml old mode 100755 new mode 100644 similarity index 85% rename from example/flutter_todos/android/app/src/debug/AndroidManifest.xml rename to android/app/src/debug/AndroidManifest.xml index 5d41c03..0428507 --- a/example/flutter_todos/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.flutter_bloc_devtools"> diff --git a/example/flutter_todos/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml old mode 100755 new mode 100644 similarity index 79% rename from example/flutter_todos/android/app/src/main/AndroidManifest.xml rename to android/app/src/main/AndroidManifest.xml index 4b89fc4..c6de4c4 --- a/example/flutter_todos/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,7 @@ - - + + + + + + + + diff --git a/example/flutter_todos/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/drawable/launch_background.xml rename to android/app/src/main/res/drawable/launch_background.xml diff --git a/example/flutter_todos/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/example/flutter_todos/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/example/flutter_todos/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/example/flutter_todos/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/example/flutter_todos/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/example/flutter_todos/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values-night/styles.xml old mode 100755 new mode 100644 similarity index 86% rename from example/flutter_todos/android/app/src/main/res/values/styles.xml rename to android/app/src/main/res/values-night/styles.xml index 1f83a33..449a9f9 --- a/example/flutter_todos/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values-night/styles.xml @@ -1,6 +1,6 @@ - + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..d74aa35 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/flutter_todos/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml old mode 100755 new mode 100644 similarity index 85% rename from example/flutter_todos/android/app/src/profile/AndroidManifest.xml rename to android/app/src/profile/AndroidManifest.xml index 5d41c03..0428507 --- a/example/flutter_todos/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.flutter_bloc_devtools"> diff --git a/example/flutter_todos/android/build.gradle b/android/build.gradle old mode 100755 new mode 100644 similarity index 81% rename from example/flutter_todos/android/build.gradle rename to android/build.gradle index 3100ad2..ed45c65 --- a/example/flutter_todos/android/build.gradle +++ b/android/build.gradle @@ -2,11 +2,11 @@ buildscript { ext.kotlin_version = '1.3.50' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,15 +14,13 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { project.evaluationDependsOn(':app') } diff --git a/android/flutter_bloc_devtools_android.iml b/android/flutter_bloc_devtools_android.iml new file mode 100644 index 0000000..1899969 --- /dev/null +++ b/android/flutter_bloc_devtools_android.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/example/flutter_todos/android/gradle.properties b/android/gradle.properties old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/gradle.properties rename to android/gradle.properties diff --git a/example/flutter_todos/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties old mode 100755 new mode 100644 similarity index 93% rename from example/flutter_todos/android/gradle/wrapper/gradle-wrapper.properties rename to android/gradle/wrapper/gradle-wrapper.properties index 296b146..bc6a58a --- a/example/flutter_todos/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/example/flutter_todos/android/settings.gradle b/android/settings.gradle old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/android/settings.gradle rename to android/settings.gradle diff --git a/example/counter/analysis_options.yaml b/example/counter/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/example/counter/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/flutter_todos/android/app/src/main/kotlin/com/example/flutter_todos/MainActivity.kt b/example/counter/android/app/src/main/kotlin/com/example/counter/MainActivity.kt old mode 100755 new mode 100644 similarity index 73% rename from example/flutter_todos/android/app/src/main/kotlin/com/example/flutter_todos/MainActivity.kt rename to example/counter/android/app/src/main/kotlin/com/example/counter/MainActivity.kt index 2a86094..64a37ba --- a/example/flutter_todos/android/app/src/main/kotlin/com/example/flutter_todos/MainActivity.kt +++ b/example/counter/android/app/src/main/kotlin/com/example/counter/MainActivity.kt @@ -1,4 +1,4 @@ -package com.example.flutter_todos +package com.example.counter import io.flutter.embedding.android.FlutterActivity diff --git a/example/counter/android/app/src/main/res/drawable-v21/launch_background.xml b/example/counter/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/counter/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/counter/android/app/src/main/res/values-night/styles.xml b/example/counter/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/example/counter/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/counter/lib/counter/bloc/counter_bloc.dart b/example/counter/lib/counter/bloc/counter_bloc.dart index 3f9c71b..1eb0484 100644 --- a/example/counter/lib/counter/bloc/counter_bloc.dart +++ b/example/counter/lib/counter/bloc/counter_bloc.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; @@ -8,21 +6,37 @@ part 'counter_event.dart'; part 'counter_state.dart'; class CounterBloc extends Bloc { - CounterBloc() : super(CounterState(counter: 0)); + CounterBloc() : super(CounterState(counter: 0)) { + on(_doIncrement); + on(_doDecrement); + } - @override - Stream mapEventToState( - CounterEvent event, - ) async* { - if (event is IncrementCounterEvent) { - yield state.copyWith( - counter: state.counter + 1, - ); - } - if (event is DecrementCounterEvent) { - yield state.copyWith( - counter: state.counter - 1, - ); - } + void _doIncrement( + IncrementCounterEvent event, + Emitter emit, + ) { + emit(state.copyWith(counter: state.counter + 1)); } + + void _doDecrement( + DecrementCounterEvent event, + Emitter emit, + ) { + emit(state.copyWith(counter: state.counter - 1)); + } + + // Stream mapEventToState( + // CounterEvent event, + // ) async* { + // if (event is IncrementCounterEvent) { + // yield state.copyWith( + // counter: state.counter + 1, + // ); + // } + // if (event is DecrementCounterEvent) { + // yield state.copyWith( + // counter: state.counter - 1, + // ); + // } + // } } diff --git a/example/counter/lib/main.dart b/example/counter/lib/main.dart index a5b37b8..c412947 100755 --- a/example/counter/lib/main.dart +++ b/example/counter/lib/main.dart @@ -1,13 +1,14 @@ import 'package:bloc/bloc.dart'; +import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; import 'app.dart'; void main() async { - final observer = RemoteDevToolsObserver('192.168.1.7:8000'); - await observer.connect(); - Bloc.observer = observer; - - runApp(const CounterApp()); + BlocOverrides.runZoned( + () async => runApp(const CounterApp()), + blocObserver: RemoteDevToolsObserver('127.0.0.1:8000'), + // NOTE: 127.0.0.1 works for web builds. If you are building to the android device or emulator, you need your local ip, like 192.168.0.112. + ); } diff --git a/example/counter/pubspec.yaml b/example/counter/pubspec.yaml index 9817312..857efe5 100755 --- a/example/counter/pubspec.yaml +++ b/example/counter/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter equatable: ^1.2.5 - flutter_bloc: ^6.1.0 + flutter_bloc: ^8.0.0 flutter_bloc_devtools: path: ../../ diff --git a/example/counter/test/widget_test.dart b/example/counter/test/widget_test.dart new file mode 100644 index 0000000..94bbc85 --- /dev/null +++ b/example/counter/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:counter/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/example/counter/web/favicon.png b/example/counter/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/example/counter/web/favicon.png differ diff --git a/example/counter/web/icons/Icon-192.png b/example/counter/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/example/counter/web/icons/Icon-192.png differ diff --git a/example/counter/web/icons/Icon-512.png b/example/counter/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/example/counter/web/icons/Icon-512.png differ diff --git a/example/counter/web/icons/Icon-maskable-192.png b/example/counter/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/example/counter/web/icons/Icon-maskable-192.png differ diff --git a/example/counter/web/icons/Icon-maskable-512.png b/example/counter/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/example/counter/web/icons/Icon-maskable-512.png differ diff --git a/example/counter/web/index.html b/example/counter/web/index.html new file mode 100644 index 0000000..6b9fb6a --- /dev/null +++ b/example/counter/web/index.html @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + counter + + + + + + + diff --git a/example/counter/web/manifest.json b/example/counter/web/manifest.json new file mode 100644 index 0000000..cd67d74 --- /dev/null +++ b/example/counter/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "counter", + "short_name": "counter", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/example/flutter_todos/.flutter-plugins-dependencies b/example/flutter_todos/.flutter-plugins-dependencies deleted file mode 100644 index ec62701..0000000 --- a/example/flutter_todos/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/andrea/.pub-cache/hosted/pub.dartlang.org/path_provider-0.4.1/","dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/andrea/.pub-cache/hosted/pub.dartlang.org/path_provider-0.4.1/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":[]}],"date_created":"2020-11-15 12:52:55.520558","version":"1.22.2"} \ No newline at end of file diff --git a/example/flutter_todos/.gitignore b/example/flutter_todos/.gitignore deleted file mode 100755 index 47e0b4d..0000000 --- a/example/flutter_todos/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# Miscellaneous -*.class -*.lock -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# Visual Studio Code related -.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/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/example/flutter_todos/README.md b/example/flutter_todos/README.md deleted file mode 100755 index d8d7052..0000000 --- a/example/flutter_todos/README.md +++ /dev/null @@ -1,18 +0,0 @@ -[![build](https://github.com/felangel/bloc/workflows/build/badge.svg)](https://github.com/felangel/bloc/actions) - -# flutter_todos - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/example/flutter_todos/ios/Flutter/Debug.xcconfig b/example/flutter_todos/ios/Flutter/Debug.xcconfig deleted file mode 100755 index e8efba1..0000000 --- a/example/flutter_todos/ios/Flutter/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "Generated.xcconfig" diff --git a/example/flutter_todos/ios/Flutter/Release.xcconfig b/example/flutter_todos/ios/Flutter/Release.xcconfig deleted file mode 100755 index 399e934..0000000 --- a/example/flutter_todos/ios/Flutter/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "Generated.xcconfig" diff --git a/example/flutter_todos/ios/Podfile b/example/flutter_todos/ios/Podfile deleted file mode 100755 index 1e8c3c9..0000000 --- a/example/flutter_todos/ios/Podfile +++ /dev/null @@ -1,41 +0,0 @@ -# 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/example/flutter_todos/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/flutter_todos/ios/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100755 index 21a3cc1..0000000 --- a/example/flutter_todos/ios/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/example/flutter_todos/lib/blocs/blocs.dart b/example/flutter_todos/lib/blocs/blocs.dart deleted file mode 100755 index 13f7c63..0000000 --- a/example/flutter_todos/lib/blocs/blocs.dart +++ /dev/null @@ -1,4 +0,0 @@ -export './filtered_todos/filtered_todos.dart'; -export './stats/stats.dart'; -export './tab/tab.dart'; -export './todos/todos.dart'; diff --git a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos.dart b/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos.dart deleted file mode 100755 index f15a959..0000000 --- a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos.dart +++ /dev/null @@ -1,3 +0,0 @@ -export './filtered_todos_bloc.dart'; -export './filtered_todos_event.dart'; -export './filtered_todos_state.dart'; diff --git a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_bloc.dart b/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_bloc.dart deleted file mode 100755 index d5f14e1..0000000 --- a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_bloc.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'dart:async'; -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; -import 'package:flutter_todos/blocs/filtered_todos/filtered_todos.dart'; -import 'package:flutter_todos/blocs/todos/todos.dart'; -import 'package:flutter_todos/models/models.dart'; - -class FilteredTodosBloc extends Bloc { - final TodosBloc todosBloc; - StreamSubscription todosSubscription; - - FilteredTodosBloc({@required this.todosBloc}) - : super( - todosBloc.state is TodosLoadSuccess - ? FilteredTodosLoadSuccess( - (todosBloc.state as TodosLoadSuccess).todos, - VisibilityFilter.all, - ) - : FilteredTodosLoadInProgress(), - ) { - todosSubscription = todosBloc.listen((state) { - if (state is TodosLoadSuccess) { - add(TodosUpdated((todosBloc.state as TodosLoadSuccess).todos)); - } - }); - } - - @override - Stream mapEventToState(FilteredTodosEvent event) async* { - if (event is FilterUpdated) { - yield* _mapFilterUpdatedToState(event); - } else if (event is TodosUpdated) { - yield* _mapTodosUpdatedToState(event); - } - } - - Stream _mapFilterUpdatedToState( - FilterUpdated event, - ) async* { - if (todosBloc.state is TodosLoadSuccess) { - yield FilteredTodosLoadSuccess( - _mapTodosToFilteredTodos( - (todosBloc.state as TodosLoadSuccess).todos, - event.filter, - ), - event.filter, - ); - } - } - - Stream _mapTodosUpdatedToState( - TodosUpdated event, - ) async* { - final visibilityFilter = state is FilteredTodosLoadSuccess - ? (state as FilteredTodosLoadSuccess).activeFilter - : VisibilityFilter.all; - yield FilteredTodosLoadSuccess( - _mapTodosToFilteredTodos( - (todosBloc.state as TodosLoadSuccess).todos, - visibilityFilter, - ), - visibilityFilter, - ); - } - - List _mapTodosToFilteredTodos( - List todos, VisibilityFilter filter) { - return todos.where((todo) { - if (filter == VisibilityFilter.all) { - return true; - } else if (filter == VisibilityFilter.active) { - return !todo.complete; - } else { - return todo.complete; - } - }).toList(); - } - - @override - Future close() { - todosSubscription.cancel(); - return super.close(); - } -} diff --git a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_event.dart b/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_event.dart deleted file mode 100755 index d780d17..0000000 --- a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_event.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class FilteredTodosEvent extends Equatable implements Mappable { - const FilteredTodosEvent(); - - @override - Map toMap() => {}; -} - -class FilterUpdated extends FilteredTodosEvent { - final VisibilityFilter filter; - - const FilterUpdated(this.filter); - - @override - List get props => [filter]; - - @override - Map toMap() => { - 'filter': filter.toString().substring('VisibilityFilter.'.length), - }; -} - -class TodosUpdated extends FilteredTodosEvent { - final List todos; - - const TodosUpdated(this.todos); - - @override - List get props => [todos]; - - @override - Map toMap() => { - 'todos': todos.map((e) => e.toEntity().toJson()).toList(), - }; -} diff --git a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_state.dart b/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_state.dart deleted file mode 100755 index 1458cac..0000000 --- a/example/flutter_todos/lib/blocs/filtered_todos/filtered_todos_state.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class FilteredTodosState extends Equatable implements Mappable { - const FilteredTodosState(); - - @override - List get props => []; - - @override - Map toMap() => {}; -} - -class FilteredTodosLoadInProgress extends FilteredTodosState {} - -class FilteredTodosLoadSuccess extends FilteredTodosState { - final List filteredTodos; - final VisibilityFilter activeFilter; - - const FilteredTodosLoadSuccess( - this.filteredTodos, - this.activeFilter, - ); - - @override - List get props => [filteredTodos, activeFilter]; - - @override - Map toMap() => { - 'filteredTodos': - filteredTodos.map((e) => e.toEntity().toJson()).toList(), - 'activeFilter': - activeFilter.toString().substring('VisibilityFilter.'.length), - }; -} diff --git a/example/flutter_todos/lib/blocs/stats/stats.dart b/example/flutter_todos/lib/blocs/stats/stats.dart deleted file mode 100755 index 015a93e..0000000 --- a/example/flutter_todos/lib/blocs/stats/stats.dart +++ /dev/null @@ -1,3 +0,0 @@ -export 'stats_bloc.dart'; -export 'stats_event.dart'; -export 'stats_state.dart'; diff --git a/example/flutter_todos/lib/blocs/stats/stats_bloc.dart b/example/flutter_todos/lib/blocs/stats/stats_bloc.dart deleted file mode 100755 index b2e7bc1..0000000 --- a/example/flutter_todos/lib/blocs/stats/stats_bloc.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:async'; -import 'package:meta/meta.dart'; -import 'package:bloc/bloc.dart'; -import 'package:flutter_todos/blocs/blocs.dart'; - -class StatsBloc extends Bloc { - final TodosBloc todosBloc; - StreamSubscription todosSubscription; - - StatsBloc({@required this.todosBloc}) : super(StatsLoadInProgress()) { - void onTodosStateChanged(state) { - if (state is TodosLoadSuccess) { - add(StatsUpdated(state.todos)); - } - } - - onTodosStateChanged(todosBloc.state); - todosSubscription = todosBloc.listen(onTodosStateChanged); - } - - @override - Stream mapEventToState(StatsEvent event) async* { - if (event is StatsUpdated) { - final numActive = - event.todos.where((todo) => !todo.complete).toList().length; - final numCompleted = - event.todos.where((todo) => todo.complete).toList().length; - yield StatsLoadSuccess(numActive, numCompleted); - } - } - - @override - Future close() { - todosSubscription.cancel(); - return super.close(); - } -} diff --git a/example/flutter_todos/lib/blocs/stats/stats_event.dart b/example/flutter_todos/lib/blocs/stats/stats_event.dart deleted file mode 100755 index 7a7f1c0..0000000 --- a/example/flutter_todos/lib/blocs/stats/stats_event.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class StatsEvent extends Equatable implements Mappable { - const StatsEvent(); - - @override - Map toMap() => {}; -} - -class StatsUpdated extends StatsEvent { - final List todos; - - const StatsUpdated(this.todos); - - @override - List get props => [todos]; - - @override - Map toMap() => { - 'todos': todos.map((e) => e.toEntity().toJson()).toList(), - }; -} diff --git a/example/flutter_todos/lib/blocs/stats/stats_state.dart b/example/flutter_todos/lib/blocs/stats/stats_state.dart deleted file mode 100755 index 9b5b65a..0000000 --- a/example/flutter_todos/lib/blocs/stats/stats_state.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class StatsState extends Equatable implements Mappable { - const StatsState(); - - @override - List get props => []; - - @override - Map toMap() => {}; -} - -class StatsLoadInProgress extends StatsState {} - -class StatsLoadSuccess extends StatsState { - final int numActive; - final int numCompleted; - - const StatsLoadSuccess(this.numActive, this.numCompleted); - - @override - List get props => [numActive, numCompleted]; - - @override - Map toMap() => { - 'numActive': numActive, - 'numCompleted': numCompleted, - }; -} diff --git a/example/flutter_todos/lib/blocs/tab/tab.dart b/example/flutter_todos/lib/blocs/tab/tab.dart deleted file mode 100755 index acfc3e0..0000000 --- a/example/flutter_todos/lib/blocs/tab/tab.dart +++ /dev/null @@ -1,2 +0,0 @@ -export './tab_bloc.dart'; -export './tab_event.dart'; diff --git a/example/flutter_todos/lib/blocs/tab/tab_bloc.dart b/example/flutter_todos/lib/blocs/tab/tab_bloc.dart deleted file mode 100755 index d049d98..0000000 --- a/example/flutter_todos/lib/blocs/tab/tab_bloc.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'dart:async'; -import 'package:bloc/bloc.dart'; -import 'package:flutter_todos/blocs/tab/tab.dart'; -import 'package:flutter_todos/models/models.dart'; - -class TabBloc extends Bloc { - TabBloc() : super(AppTab.todos); - - @override - Stream mapEventToState(TabEvent event) async* { - if (event is TabUpdated) { - yield event.tab; - } - } -} diff --git a/example/flutter_todos/lib/blocs/tab/tab_event.dart b/example/flutter_todos/lib/blocs/tab/tab_event.dart deleted file mode 100755 index 52e53b4..0000000 --- a/example/flutter_todos/lib/blocs/tab/tab_event.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class TabEvent extends Equatable implements Mappable { - const TabEvent(); - - @override - Map toMap() => {}; -} - -class TabUpdated extends TabEvent { - final AppTab tab; - - const TabUpdated(this.tab); - - @override - List get props => [tab]; - - @override - Map toMap() => { - 'tab': tab.toString(), - }; -} diff --git a/example/flutter_todos/lib/blocs/todos/todos.dart b/example/flutter_todos/lib/blocs/todos/todos.dart deleted file mode 100755 index 9a1e76b..0000000 --- a/example/flutter_todos/lib/blocs/todos/todos.dart +++ /dev/null @@ -1,3 +0,0 @@ -export './todos_bloc.dart'; -export './todos_event.dart'; -export './todos_state.dart'; diff --git a/example/flutter_todos/lib/blocs/todos/todos_bloc.dart b/example/flutter_todos/lib/blocs/todos/todos_bloc.dart deleted file mode 100755 index 4c4e11a..0000000 --- a/example/flutter_todos/lib/blocs/todos/todos_bloc.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'dart:async'; -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; -import 'package:flutter_todos/blocs/todos/todos.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:todos_repository_simple/todos_repository_simple.dart'; - -class TodosBloc extends Bloc { - final TodosRepositoryFlutter todosRepository; - - TodosBloc({@required this.todosRepository}) : super(TodosLoadInProgress()); - - @override - Stream mapEventToState(TodosEvent event) async* { - if (event is TodosLoaded) { - yield* _mapTodosLoadedToState(); - } else if (event is TodoAdded) { - yield* _mapTodoAddedToState(event); - } else if (event is TodoUpdated) { - yield* _mapTodoUpdatedToState(event); - } else if (event is TodoDeleted) { - yield* _mapTodoDeletedToState(event); - } else if (event is ToggleAll) { - yield* _mapToggleAllToState(); - } else if (event is ClearCompleted) { - yield* _mapClearCompletedToState(); - } - } - - Stream _mapTodosLoadedToState() async* { - try { - final todos = await this.todosRepository.loadTodos(); - yield TodosLoadSuccess( - todos.map(Todo.fromEntity).toList(), - ); - } catch (_) { - yield TodosLoadFailure(); - } - } - - Stream _mapTodoAddedToState(TodoAdded event) async* { - if (state is TodosLoadSuccess) { - final List updatedTodos = - List.from((state as TodosLoadSuccess).todos)..add(event.todo); - yield TodosLoadSuccess(updatedTodos); - _saveTodos(updatedTodos); - } - } - - Stream _mapTodoUpdatedToState(TodoUpdated event) async* { - if (state is TodosLoadSuccess) { - final List updatedTodos = - (state as TodosLoadSuccess).todos.map((todo) { - return todo.id == event.todo.id ? event.todo : todo; - }).toList(); - yield TodosLoadSuccess(updatedTodos); - _saveTodos(updatedTodos); - } - } - - Stream _mapTodoDeletedToState(TodoDeleted event) async* { - if (state is TodosLoadSuccess) { - final updatedTodos = (state as TodosLoadSuccess) - .todos - .where((todo) => todo.id != event.todo.id) - .toList(); - yield TodosLoadSuccess(updatedTodos); - _saveTodos(updatedTodos); - } - } - - Stream _mapToggleAllToState() async* { - if (state is TodosLoadSuccess) { - final allComplete = - (state as TodosLoadSuccess).todos.every((todo) => todo.complete); - final List updatedTodos = (state as TodosLoadSuccess) - .todos - .map((todo) => todo.copyWith(complete: !allComplete)) - .toList(); - yield TodosLoadSuccess(updatedTodos); - _saveTodos(updatedTodos); - } - } - - Stream _mapClearCompletedToState() async* { - if (state is TodosLoadSuccess) { - final List updatedTodos = (state as TodosLoadSuccess) - .todos - .where((todo) => !todo.complete) - .toList(); - yield TodosLoadSuccess(updatedTodos); - _saveTodos(updatedTodos); - } - } - - Future _saveTodos(List todos) { - return todosRepository.saveTodos( - todos.map((todo) => todo.toEntity()).toList(), - ); - } -} diff --git a/example/flutter_todos/lib/blocs/todos/todos_event.dart b/example/flutter_todos/lib/blocs/todos/todos_event.dart deleted file mode 100755 index 02a8701..0000000 --- a/example/flutter_todos/lib/blocs/todos/todos_event.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class TodosEvent extends Equatable implements Mappable { - const TodosEvent(); - - @override - List get props => []; - - @override - Map toMap() => {}; -} - -class TodosLoaded extends TodosEvent {} - -class TodoAdded extends TodosEvent { - final Todo todo; - - const TodoAdded(this.todo); - - @override - List get props => [todo]; - - @override - Map toMap() => { - 'todo': todo.toEntity().toJson(), - }; -} - -class TodoUpdated extends TodosEvent { - final Todo todo; - - const TodoUpdated(this.todo); - - @override - List get props => [todo]; - - @override - Map toMap() => { - 'todo': todo.toEntity().toJson(), - }; -} - -class TodoDeleted extends TodosEvent { - final Todo todo; - - const TodoDeleted(this.todo); - - @override - List get props => [todo]; - - @override - Map toMap() => { - 'todo': todo.toEntity().toJson(), - }; -} - -class ClearCompleted extends TodosEvent {} - -class ToggleAll extends TodosEvent {} diff --git a/example/flutter_todos/lib/blocs/todos/todos_state.dart b/example/flutter_todos/lib/blocs/todos/todos_state.dart deleted file mode 100755 index bfc32e5..0000000 --- a/example/flutter_todos/lib/blocs/todos/todos_state.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -abstract class TodosState extends Equatable implements Mappable { - const TodosState(); - - @override - List get props => []; - - @override - Map toMap() => {}; -} - -class TodosLoadInProgress extends TodosState {} - -class TodosLoadSuccess extends TodosState { - final List todos; - - const TodosLoadSuccess([this.todos = const []]); - - @override - List get props => [todos]; - - @override - Map toMap() => - {'todos': todos.map((e) => e.toEntity().toJson()).toList()}; -} - -class TodosLoadFailure extends TodosState {} diff --git a/example/flutter_todos/lib/flutter_todos_keys.dart b/example/flutter_todos/lib/flutter_todos_keys.dart deleted file mode 100755 index f083140..0000000 --- a/example/flutter_todos/lib/flutter_todos_keys.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/widgets.dart'; - -class FlutterTodosKeys { - static final extraActionsPopupMenuButton = - const Key('__extraActionsPopupMenuButton__'); - static final extraActionsEmptyContainer = - const Key('__extraActionsEmptyContainer__'); - static final filteredTodosEmptyContainer = - const Key('__filteredTodosEmptyContainer__'); - static final statsLoadInProgressIndicator = - const Key('__statsLoadingIndicator__'); - static final emptyStatsContainer = const Key('__emptyStatsContainer__'); - static final emptyDetailsContainer = const Key('__emptyDetailsContainer__'); - static final detailsScreenCheckBox = const Key('__detailsScreenCheckBox__'); -} diff --git a/example/flutter_todos/lib/localization.dart b/example/flutter_todos/lib/localization.dart deleted file mode 100755 index 2e7734c..0000000 --- a/example/flutter_todos/lib/localization.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -class FlutterBlocLocalizations { - static FlutterBlocLocalizations of(BuildContext context) { - return Localizations.of( - context, - FlutterBlocLocalizations, - ); - } - - String get appTitle => "Flutter Todos"; -} - -class FlutterBlocLocalizationsDelegate - extends LocalizationsDelegate { - @override - Future load(Locale locale) => - Future(() => FlutterBlocLocalizations()); - - @override - bool shouldReload(FlutterBlocLocalizationsDelegate old) => false; - - @override - bool isSupported(Locale locale) => - locale.languageCode.toLowerCase().contains("en"); -} diff --git a/example/flutter_todos/lib/main.dart b/example/flutter_todos/lib/main.dart deleted file mode 100755 index f713426..0000000 --- a/example/flutter_todos/lib/main.dart +++ /dev/null @@ -1,80 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:bloc/bloc.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_repository_simple/todos_repository_simple.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/localization.dart'; -import 'package:flutter_todos/blocs/blocs.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_todos/screens/screens.dart'; -import 'package:flutter_bloc_devtools/flutter_bloc_devtools.dart'; - -void main() async { - final observer = RemoteDevToolsObserver('192.168.1.7:8000'); - await observer.connect(); - Bloc.observer = observer; - - runApp( - BlocProvider( - create: (context) { - return TodosBloc( - todosRepository: const TodosRepositoryFlutter( - fileStorage: const FileStorage( - '__flutter_bloc_app__', - getApplicationDocumentsDirectory, - ), - ), - )..add(TodosLoaded()); - }, - child: TodosApp(), - ), - ); -} - -class TodosApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: FlutterBlocLocalizations().appTitle, - theme: ArchSampleTheme.theme, - localizationsDelegates: [ - ArchSampleLocalizationsDelegate(), - FlutterBlocLocalizationsDelegate(), - ], - routes: { - ArchSampleRoutes.home: (context) { - return MultiBlocProvider( - providers: [ - BlocProvider( - create: (context) => TabBloc(), - ), - BlocProvider( - create: (context) => FilteredTodosBloc( - todosBloc: BlocProvider.of(context), - ), - ), - BlocProvider( - create: (context) => StatsBloc( - todosBloc: BlocProvider.of(context), - ), - ), - ], - child: HomeScreen(), - ); - }, - ArchSampleRoutes.addTodo: (context) { - return AddEditScreen( - key: ArchSampleKeys.addTodoScreen, - onSave: (task, note) { - BlocProvider.of(context).add( - TodoAdded(Todo(task, note: note)), - ); - }, - isEditing: false, - ); - }, - }, - ); - } -} diff --git a/example/flutter_todos/lib/models/app_tab.dart b/example/flutter_todos/lib/models/app_tab.dart deleted file mode 100755 index 8348dfc..0000000 --- a/example/flutter_todos/lib/models/app_tab.dart +++ /dev/null @@ -1 +0,0 @@ -enum AppTab { todos, stats } diff --git a/example/flutter_todos/lib/models/extra_action.dart b/example/flutter_todos/lib/models/extra_action.dart deleted file mode 100755 index 4ca0c02..0000000 --- a/example/flutter_todos/lib/models/extra_action.dart +++ /dev/null @@ -1 +0,0 @@ -enum ExtraAction { toggleAllComplete, clearCompleted } diff --git a/example/flutter_todos/lib/models/models.dart b/example/flutter_todos/lib/models/models.dart deleted file mode 100755 index 6921685..0000000 --- a/example/flutter_todos/lib/models/models.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'app_tab.dart'; -export 'extra_action.dart'; -export 'todo.dart'; -export 'visibility_filter.dart'; diff --git a/example/flutter_todos/lib/models/todo.dart b/example/flutter_todos/lib/models/todo.dart deleted file mode 100755 index f21faf5..0000000 --- a/example/flutter_todos/lib/models/todo.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:equatable/equatable.dart'; -import 'package:todos_repository_core/todos_repository_core.dart'; - -class Todo extends Equatable { - final bool complete; - final String id; - final String note; - final String task; - - Todo( - this.task, { - this.complete = false, - String note = '', - String id, - }) : this.note = note ?? '', - this.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 - List get props => [complete, id, note, task]; - - 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(), - ); - } -} diff --git a/example/flutter_todos/lib/models/visibility_filter.dart b/example/flutter_todos/lib/models/visibility_filter.dart deleted file mode 100755 index a47beca..0000000 --- a/example/flutter_todos/lib/models/visibility_filter.dart +++ /dev/null @@ -1 +0,0 @@ -enum VisibilityFilter { all, active, completed } diff --git a/example/flutter_todos/lib/screens/add_edit_screen.dart b/example/flutter_todos/lib/screens/add_edit_screen.dart deleted file mode 100755 index cafc43b..0000000 --- a/example/flutter_todos/lib/screens/add_edit_screen.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/models/models.dart'; - -typedef OnSaveCallback = Function(String task, String note); - -class AddEditScreen extends StatefulWidget { - final bool isEditing; - final OnSaveCallback onSave; - final Todo todo; - - AddEditScreen({ - Key key, - @required this.onSave, - @required this.isEditing, - this.todo, - }) : super(key: key ?? ArchSampleKeys.addTodoScreen); - - @override - _AddEditScreenState createState() => _AddEditScreenState(); -} - -class _AddEditScreenState extends State { - static final GlobalKey _formKey = GlobalKey(); - - String _task; - String _note; - - bool get isEditing => widget.isEditing; - - @override - Widget build(BuildContext context) { - final localizations = ArchSampleLocalizations.of(context); - final textTheme = Theme.of(context).textTheme; - - return Scaffold( - appBar: AppBar( - title: Text( - isEditing ? localizations.editTodo : localizations.addTodo, - ), - ), - body: Padding( - padding: EdgeInsets.all(16.0), - child: Form( - key: _formKey, - child: ListView( - children: [ - TextFormField( - initialValue: isEditing ? widget.todo.task : '', - key: ArchSampleKeys.taskField, - autofocus: !isEditing, - style: textTheme.headline5, - decoration: InputDecoration( - hintText: localizations.newTodoHint, - ), - validator: (val) { - return val.trim().isEmpty - ? localizations.emptyTodoError - : null; - }, - onSaved: (value) => _task = value, - ), - TextFormField( - initialValue: isEditing ? widget.todo.note : '', - key: ArchSampleKeys.noteField, - maxLines: 10, - style: textTheme.subtitle1, - decoration: InputDecoration( - hintText: localizations.notesHint, - ), - onSaved: (value) => _note = value, - ) - ], - ), - ), - ), - floatingActionButton: FloatingActionButton( - key: - isEditing ? ArchSampleKeys.saveTodoFab : ArchSampleKeys.saveNewTodo, - tooltip: isEditing ? localizations.saveChanges : localizations.addTodo, - child: Icon(isEditing ? Icons.check : Icons.add), - onPressed: () { - if (_formKey.currentState.validate()) { - _formKey.currentState.save(); - widget.onSave(_task, _note); - Navigator.pop(context); - } - }, - ), - ); - } -} diff --git a/example/flutter_todos/lib/screens/details_screen.dart b/example/flutter_todos/lib/screens/details_screen.dart deleted file mode 100755 index 19a417b..0000000 --- a/example/flutter_todos/lib/screens/details_screen.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/blocs/todos/todos.dart'; -import 'package:flutter_todos/screens/screens.dart'; -import 'package:flutter_todos/flutter_todos_keys.dart'; - -class DetailsScreen extends StatelessWidget { - final String id; - - DetailsScreen({Key key, @required this.id}) - : super(key: key ?? ArchSampleKeys.todoDetailsScreen); - - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - final todo = (state as TodosLoadSuccess) - .todos - .firstWhere((todo) => todo.id == id, orElse: () => null); - final localizations = ArchSampleLocalizations.of(context); - return Scaffold( - appBar: AppBar( - title: Text(localizations.todoDetails), - actions: [ - IconButton( - tooltip: localizations.deleteTodo, - key: ArchSampleKeys.deleteTodoButton, - icon: Icon(Icons.delete), - onPressed: () { - BlocProvider.of(context).add(TodoDeleted(todo)); - Navigator.pop(context, todo); - }, - ) - ], - ), - body: todo == null - ? Container(key: FlutterTodosKeys.emptyDetailsContainer) - : Padding( - padding: EdgeInsets.all(16.0), - child: ListView( - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(right: 8.0), - child: Checkbox( - key: FlutterTodosKeys.detailsScreenCheckBox, - value: todo.complete, - onChanged: (_) { - BlocProvider.of(context).add( - TodoUpdated( - todo.copyWith(complete: !todo.complete), - ), - ); - }), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Hero( - tag: '${todo.id}__heroTag', - child: Container( - width: MediaQuery.of(context).size.width, - 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( - key: ArchSampleKeys.editTodoFab, - tooltip: localizations.editTodo, - child: Icon(Icons.edit), - onPressed: todo == null - ? null - : () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) { - return AddEditScreen( - key: ArchSampleKeys.editTodoScreen, - onSave: (task, note) { - BlocProvider.of(context).add( - TodoUpdated( - todo.copyWith(task: task, note: note), - ), - ); - }, - isEditing: true, - todo: todo, - ); - }, - ), - ); - }, - ), - ); - }, - ); - } -} diff --git a/example/flutter_todos/lib/screens/home_screen.dart b/example/flutter_todos/lib/screens/home_screen.dart deleted file mode 100755 index 59c22c4..0000000 --- a/example/flutter_todos/lib/screens/home_screen.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_todos/blocs/blocs.dart'; -import 'package:flutter_todos/widgets/widgets.dart'; -import 'package:flutter_todos/localization.dart'; -import 'package:flutter_todos/models/models.dart'; - -class HomeScreen extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, activeTab) { - return Scaffold( - appBar: AppBar( - title: Text(FlutterBlocLocalizations.of(context).appTitle), - actions: [ - FilterButton(visible: activeTab == AppTab.todos), - ExtraActions(), - ], - ), - body: activeTab == AppTab.todos ? FilteredTodos() : Stats(), - floatingActionButton: FloatingActionButton( - key: ArchSampleKeys.addTodoFab, - onPressed: () { - Navigator.pushNamed(context, ArchSampleRoutes.addTodo); - }, - child: Icon(Icons.add), - tooltip: ArchSampleLocalizations.of(context).addTodo, - ), - bottomNavigationBar: TabSelector( - activeTab: activeTab, - onTabSelected: (tab) => - BlocProvider.of(context).add(TabUpdated(tab)), - ), - ); - }, - ); - } -} diff --git a/example/flutter_todos/lib/screens/screens.dart b/example/flutter_todos/lib/screens/screens.dart deleted file mode 100755 index bc26a60..0000000 --- a/example/flutter_todos/lib/screens/screens.dart +++ /dev/null @@ -1,3 +0,0 @@ -export './add_edit_screen.dart'; -export './details_screen.dart'; -export './home_screen.dart'; diff --git a/example/flutter_todos/lib/widgets/delete_todo_snack_bar.dart b/example/flutter_todos/lib/widgets/delete_todo_snack_bar.dart deleted file mode 100755 index b82ef40..0000000 --- a/example/flutter_todos/lib/widgets/delete_todo_snack_bar.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/models/models.dart'; - -class DeleteTodoSnackBar extends SnackBar { - final ArchSampleLocalizations localizations; - - DeleteTodoSnackBar({ - Key key, - @required Todo todo, - @required VoidCallback onUndo, - @required this.localizations, - }) : super( - key: key, - content: Text( - localizations.todoDeleted(todo.task), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - duration: Duration(seconds: 2), - action: SnackBarAction( - label: localizations.undo, - onPressed: onUndo, - ), - ); -} diff --git a/example/flutter_todos/lib/widgets/extra_actions.dart b/example/flutter_todos/lib/widgets/extra_actions.dart deleted file mode 100755 index a1d4366..0000000 --- a/example/flutter_todos/lib/widgets/extra_actions.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/blocs/todos/todos.dart'; -import 'package:flutter_todos/models/models.dart'; -import 'package:flutter_todos/flutter_todos_keys.dart'; - -class ExtraActions extends StatelessWidget { - ExtraActions({Key key}) : super(key: ArchSampleKeys.extraActionsButton); - - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is TodosLoadSuccess) { - bool allComplete = - (BlocProvider.of(context).state as TodosLoadSuccess) - .todos - .every((todo) => todo.complete); - return PopupMenuButton( - key: FlutterTodosKeys.extraActionsPopupMenuButton, - onSelected: (action) { - switch (action) { - case ExtraAction.clearCompleted: - BlocProvider.of(context).add(ClearCompleted()); - break; - case ExtraAction.toggleAllComplete: - BlocProvider.of(context).add(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, - ), - ), - ], - ); - } - return Container(key: FlutterTodosKeys.extraActionsEmptyContainer); - }, - ); - } -} diff --git a/example/flutter_todos/lib/widgets/filter_button.dart b/example/flutter_todos/lib/widgets/filter_button.dart deleted file mode 100755 index 314951e..0000000 --- a/example/flutter_todos/lib/widgets/filter_button.dart +++ /dev/null @@ -1,96 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/blocs/filtered_todos/filtered_todos.dart'; -import 'package:flutter_todos/models/models.dart'; - -class FilterButton extends StatelessWidget { - final bool visible; - - FilterButton({this.visible, Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final defaultStyle = Theme.of(context).textTheme.bodyText2; - final activeStyle = Theme.of(context) - .textTheme - .bodyText2 - .copyWith(color: Theme.of(context).accentColor); - return BlocBuilder( - builder: (context, state) { - final button = _Button( - onSelected: (filter) { - BlocProvider.of(context) - .add(FilterUpdated(filter)); - }, - activeFilter: state is FilteredTodosLoadSuccess - ? state.activeFilter - : VisibilityFilter.all, - activeStyle: activeStyle, - defaultStyle: defaultStyle, - ); - return AnimatedOpacity( - opacity: visible ? 1.0 : 0.0, - duration: Duration(milliseconds: 150), - child: visible ? button : IgnorePointer(child: button), - ); - }); - } -} - -class _Button extends StatelessWidget { - const _Button({ - Key key, - @required this.onSelected, - @required this.activeFilter, - @required this.activeStyle, - @required this.defaultStyle, - }) : super(key: key); - - final PopupMenuItemSelected onSelected; - final VisibilityFilter activeFilter; - final TextStyle activeStyle; - final TextStyle defaultStyle; - - @override - Widget build(BuildContext context) { - return PopupMenuButton( - key: ArchSampleKeys.filterButton, - tooltip: ArchSampleLocalizations.of(context).filterTodos, - onSelected: onSelected, - 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/example/flutter_todos/lib/widgets/filtered_todos.dart b/example/flutter_todos/lib/widgets/filtered_todos.dart deleted file mode 100755 index 48b7855..0000000 --- a/example/flutter_todos/lib/widgets/filtered_todos.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/blocs/blocs.dart'; -import 'package:flutter_todos/widgets/widgets.dart'; -import 'package:flutter_todos/screens/screens.dart'; -import 'package:flutter_todos/flutter_todos_keys.dart'; - -class FilteredTodos extends StatelessWidget { - FilteredTodos({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final localizations = ArchSampleLocalizations.of(context); - - return BlocBuilder( - builder: (context, state) { - if (state is FilteredTodosLoadInProgress) { - return LoadingIndicator(key: ArchSampleKeys.todosLoading); - } else if (state is FilteredTodosLoadSuccess) { - final todos = state.filteredTodos; - return ListView.builder( - key: ArchSampleKeys.todoList, - itemCount: todos.length, - itemBuilder: (BuildContext context, int index) { - final todo = todos[index]; - return TodoItem( - todo: todo, - onDismissed: (direction) { - BlocProvider.of(context).add(TodoDeleted(todo)); - Scaffold.of(context).showSnackBar(DeleteTodoSnackBar( - key: ArchSampleKeys.snackbar, - todo: todo, - onUndo: () => BlocProvider.of(context) - .add(TodoAdded(todo)), - localizations: localizations, - )); - }, - onTap: () async { - final removedTodo = await Navigator.of(context).push( - MaterialPageRoute(builder: (_) { - return DetailsScreen(id: todo.id); - }), - ); - if (removedTodo != null) { - Scaffold.of(context).showSnackBar(DeleteTodoSnackBar( - key: ArchSampleKeys.snackbar, - todo: todo, - onUndo: () => BlocProvider.of(context) - .add(TodoAdded(todo)), - localizations: localizations, - )); - } - }, - onCheckboxChanged: (_) { - BlocProvider.of(context).add( - TodoUpdated(todo.copyWith(complete: !todo.complete)), - ); - }, - ); - }, - ); - } else { - return Container(key: FlutterTodosKeys.filteredTodosEmptyContainer); - } - }, - ); - } -} diff --git a/example/flutter_todos/lib/widgets/loading_indicator.dart b/example/flutter_todos/lib/widgets/loading_indicator.dart deleted file mode 100755 index 2ecef34..0000000 --- a/example/flutter_todos/lib/widgets/loading_indicator.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; - -class LoadingIndicator extends StatelessWidget { - LoadingIndicator({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Center( - child: CircularProgressIndicator(), - ); - } -} diff --git a/example/flutter_todos/lib/widgets/stats.dart b/example/flutter_todos/lib/widgets/stats.dart deleted file mode 100755 index cb144aa..0000000 --- a/example/flutter_todos/lib/widgets/stats.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/blocs/stats/stats.dart'; -import 'package:flutter_todos/widgets/widgets.dart'; -import 'package:flutter_todos/flutter_todos_keys.dart'; - -class Stats extends StatelessWidget { - Stats({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is StatsLoadInProgress) { - return LoadingIndicator( - key: FlutterTodosKeys.statsLoadInProgressIndicator, - ); - } else if (state is StatsLoadSuccess) { - 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( - '${state.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( - "${state.numActive}", - key: ArchSampleKeys.statsNumActive, - style: Theme.of(context).textTheme.subtitle1, - ), - ) - ], - ), - ); - } else { - return Container(key: FlutterTodosKeys.emptyStatsContainer); - } - }, - ); - } -} diff --git a/example/flutter_todos/lib/widgets/tab_selector.dart b/example/flutter_todos/lib/widgets/tab_selector.dart deleted file mode 100755 index a973627..0000000 --- a/example/flutter_todos/lib/widgets/tab_selector.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/models/models.dart'; - -class TabSelector extends StatelessWidget { - final AppTab activeTab; - final Function(AppTab) onTabSelected; - - TabSelector({ - Key key, - @required this.activeTab, - @required this.onTabSelected, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return BottomNavigationBar( - key: ArchSampleKeys.tabs, - currentIndex: AppTab.values.indexOf(activeTab), - onTap: (index) => onTabSelected(AppTab.values[index]), - items: AppTab.values.map((tab) { - return BottomNavigationBarItem( - icon: Icon( - tab == AppTab.todos ? Icons.list : Icons.show_chart, - key: tab == AppTab.todos - ? ArchSampleKeys.todoTab - : ArchSampleKeys.statsTab, - ), - label: tab == AppTab.stats - ? ArchSampleLocalizations.of(context).stats - : ArchSampleLocalizations.of(context).todos, - ); - }).toList(), - ); - } -} diff --git a/example/flutter_todos/lib/widgets/todo_item.dart b/example/flutter_todos/lib/widgets/todo_item.dart deleted file mode 100755 index 4a7a161..0000000 --- a/example/flutter_todos/lib/widgets/todo_item.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:todos_app_core/todos_app_core.dart'; -import 'package:flutter_todos/models/models.dart'; - -class TodoItem extends StatelessWidget { - final DismissDirectionCallback onDismissed; - final GestureTapCallback onTap; - final ValueChanged onCheckboxChanged; - final Todo todo; - - TodoItem({ - Key key, - @required this.onDismissed, - @required this.onTap, - @required this.onCheckboxChanged, - @required this.todo, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Dismissible( - key: ArchSampleKeys.todoItem(todo.id), - onDismissed: onDismissed, - child: ListTile( - onTap: onTap, - leading: Checkbox( - key: ArchSampleKeys.todoItemCheckbox(todo.id), - value: todo.complete, - onChanged: onCheckboxChanged, - ), - title: Hero( - tag: '${todo.id}__heroTag', - child: Container( - width: MediaQuery.of(context).size.width, - child: 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/example/flutter_todos/lib/widgets/widgets.dart b/example/flutter_todos/lib/widgets/widgets.dart deleted file mode 100755 index 69b76c4..0000000 --- a/example/flutter_todos/lib/widgets/widgets.dart +++ /dev/null @@ -1,8 +0,0 @@ -export './delete_todo_snack_bar.dart'; -export './extra_actions.dart'; -export './filter_button.dart'; -export './filtered_todos.dart'; -export './loading_indicator.dart'; -export './stats.dart'; -export './tab_selector.dart'; -export './todo_item.dart'; diff --git a/example/flutter_todos/pubspec.yaml b/example/flutter_todos/pubspec.yaml deleted file mode 100755 index 57ad66a..0000000 --- a/example/flutter_todos/pubspec.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: flutter_todos -description: A new Flutter project. - -version: 1.0.0+1 - -environment: - sdk: ">=2.6.0 <3.0.0" - -dependencies: - flutter: - sdk: flutter - meta: ^1.1.8 - equatable: ^1.2.5 - flutter_bloc: ^6.1.0 - flutter_bloc_devtools: - path: ../../ - -dependency_overrides: - todos_app_core: - git: - url: https://github.com/felangel/flutter_architecture_samples - path: todos_app_core - ref: rxdart/0.23.0 - todos_repository_core: - git: - url: https://github.com/felangel/flutter_architecture_samples - path: todos_repository_core - ref: rxdart/0.23.0 - todos_repository_simple: - git: - url: https://github.com/felangel/flutter_architecture_samples - path: todos_repository_simple - ref: rxdart/0.23.0 - -flutter: - uses-material-design: true diff --git a/flutter_bloc_devtools.iml b/flutter_bloc_devtools.iml new file mode 100644 index 0000000..e5c8371 --- /dev/null +++ b/flutter_bloc_devtools.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/flutter_todos/ios/.gitignore b/ios/.gitignore old mode 100755 new mode 100644 similarity index 95% rename from example/flutter_todos/ios/.gitignore rename to ios/.gitignore index 057eda4..7a7f987 --- a/example/flutter_todos/ios/.gitignore +++ b/ios/.gitignore @@ -1,3 +1,4 @@ +**/dgph *.mode1v3 *.mode2v3 *.moved-aside @@ -18,11 +19,11 @@ Flutter/App.framework Flutter/Flutter.framework Flutter/Flutter.podspec Flutter/Generated.xcconfig +Flutter/ephemeral/ Flutter/app.flx Flutter/app.zip Flutter/flutter_assets/ Flutter/flutter_export_environment.sh -Flutter/.last_build_id ServiceDefinitions.json Runner/GeneratedPluginRegistrant.* diff --git a/example/flutter_todos/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist old mode 100755 new mode 100644 similarity index 94% rename from example/flutter_todos/ios/Flutter/AppFrameworkInfo.plist rename to ios/Flutter/AppFrameworkInfo.plist index f2872cf..8d4492f --- a/example/flutter_todos/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable App CFBundleIdentifier diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/example/flutter_todos/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj old mode 100755 new mode 100644 similarity index 80% rename from example/flutter_todos/ios/Runner.xcodeproj/project.pbxproj rename to ios/Runner.xcodeproj/project.pbxproj index f34ec94..0b8b376 --- a/example/flutter_todos/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 6AB7E0C54FDFA48B7EB5166B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E6E55DA74D7A462C203030B3 /* Pods_Runner.framework */; }; 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 */; }; @@ -33,7 +32,6 @@ 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 = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3FD4544ABAA83CAE9D791B6C /* 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 = ""; }; 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 = ""; }; @@ -44,9 +42,6 @@ 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 = ""; }; - B8FCE8FE4C1AB133DC4B33F6 /* 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 = ""; }; - E6E55DA74D7A462C203030B3 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - FA2C08DB26D6FC9488C9BE16 /* 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 */ @@ -54,32 +49,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6AB7E0C54FDFA48B7EB5166B /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 191B184B80FC3AF9165B7F1D /* Pods */ = { - isa = PBXGroup; - children = ( - B8FCE8FE4C1AB133DC4B33F6 /* Pods-Runner.debug.xcconfig */, - FA2C08DB26D6FC9488C9BE16 /* Pods-Runner.release.xcconfig */, - 3FD4544ABAA83CAE9D791B6C /* Pods-Runner.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - 3C7FE602A9D9EF7E9DA3EA2F /* Frameworks */ = { - isa = PBXGroup; - children = ( - E6E55DA74D7A462C203030B3 /* Pods_Runner.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -97,8 +72,6 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - 191B184B80FC3AF9165B7F1D /* Pods */, - 3C7FE602A9D9EF7E9DA3EA2F /* Frameworks */, ); sourceTree = ""; }; @@ -132,14 +105,12 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - C04888AD4014C4EFEEC28C9B /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 0AA9887FC699B316904D5E50 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -198,26 +169,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0AA9887FC699B316904D5E50 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../Flutter/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -246,28 +197,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - C04888AD4014C4EFEEC28C9B /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -360,17 +289,9 @@ 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.flutterTodos; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlocDevtools; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -492,17 +413,9 @@ 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.flutterTodos; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlocDevtools; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -519,17 +432,9 @@ 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.flutterTodos; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlocDevtools; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/example/flutter_todos/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/example/flutter_todos/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/example/flutter_todos/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/example/flutter_todos/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/AppDelegate.swift rename to ios/Runner/AppDelegate.swift diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/example/flutter_todos/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/example/flutter_todos/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Base.lproj/Main.storyboard rename to ios/Runner/Base.lproj/Main.storyboard diff --git a/example/flutter_todos/ios/Runner/Info.plist b/ios/Runner/Info.plist old mode 100755 new mode 100644 similarity index 97% rename from example/flutter_todos/ios/Runner/Info.plist rename to ios/Runner/Info.plist index 2b35cac..6948ea5 --- a/example/flutter_todos/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - flutter_todos + flutter_bloc_devtools CFBundlePackageType APPL CFBundleShortVersionString diff --git a/example/flutter_todos/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h old mode 100755 new mode 100644 similarity index 100% rename from example/flutter_todos/ios/Runner/Runner-Bridging-Header.h rename to ios/Runner/Runner-Bridging-Header.h diff --git a/lib/flutter_bloc_devtools.dart b/lib/flutter_bloc_devtools.dart index 4d39c2c..a84a14f 100644 --- a/lib/flutter_bloc_devtools.dart +++ b/lib/flutter_bloc_devtools.dart @@ -1,7 +1,7 @@ library flutter_bloc_devtools; import 'package:bloc/bloc.dart'; -import 'package:socketcluster_client/socketcluster_client.dart'; +import 'package:socketcluster_client/socketcluster_client.dart' as socket_cc; import 'dart:convert'; import 'dart:async'; diff --git a/lib/src/remote_devtools_middleware.dart b/lib/src/remote_devtools_middleware.dart index fc976a9..61502d8 100644 --- a/lib/src/remote_devtools_middleware.dart +++ b/lib/src/remote_devtools_middleware.dart @@ -33,6 +33,7 @@ class RemoteDevToolsObserver extends BlocObserver { SocketClusterWrapper socket; String _channel; RemoteDevToolsStatus _status = RemoteDevToolsStatus.notConnected; + RemoteDevToolsStatus get status => _status; final Map> _blocs = {}; @@ -49,12 +50,15 @@ class RemoteDevToolsObserver extends BlocObserver { }) { socket ??= SocketClusterWrapper('ws://$_host/socketcluster/'); instanceName ??= 'flutter'; + connect(); } Future connect() async { _status = RemoteDevToolsStatus.connecting; + print('trying to connect to socket at $_host'); await socket.connect(); _status = RemoteDevToolsStatus.connected; + print('connected to socket at $_host'); _channel = await _login(); _status = RemoteDevToolsStatus.starting; _relay('START'); @@ -82,7 +86,7 @@ class RemoteDevToolsObserver extends BlocObserver { return c.future; } - String _getBlocName(Cubit bloc) { + String _getBlocName(BlocBase bloc) { final blocName = bloc.runtimeType.toString(); final blocHash = bloc.hashCode; if (_blocs.containsKey(blocName)) { @@ -96,7 +100,7 @@ class RemoteDevToolsObserver extends BlocObserver { return _blocs[blocName][blocHash]; } - void _removeBlocName(Cubit bloc) { + void _removeBlocName(BlocBase bloc) { final blocName = bloc.runtimeType.toString(); final blocHash = bloc.hashCode; if (_blocs.containsKey(blocName) && @@ -106,7 +110,7 @@ class RemoteDevToolsObserver extends BlocObserver { } void _relay(String type, - [Cubit bloc, Object state, dynamic action, String nextActionId]) { + [BlocBase bloc, Object state, dynamic action, String nextActionId]) { final message = {'type': type, 'id': socket.id, 'name': instanceName}; final blocName = _getBlocName(bloc); @@ -138,7 +142,7 @@ class RemoteDevToolsObserver extends BlocObserver { } @override - void onTransition(Bloc bloc, Transition transition) { + void onTransition(BlocBase bloc, Transition transition) { super.onTransition(bloc, transition); if (status == RemoteDevToolsStatus.started) { _relay('ACTION', bloc, transition.nextState, transition.event); @@ -146,18 +150,18 @@ class RemoteDevToolsObserver extends BlocObserver { } @override - void onCreate(Cubit cubit) { - super.onCreate(cubit); + void onCreate(BlocBase bloc) { + super.onCreate(bloc); if (status == RemoteDevToolsStatus.started) { - _relay('ACTION', cubit, cubit.state, 'OnCreate'); + _relay('ACTION', bloc, bloc.state, 'OnCreate'); } } @override - void onClose(Cubit cubit) { - super.onClose(cubit); + void onClose(BlocBase bloc) { + super.onClose(bloc); if (status == RemoteDevToolsStatus.started) { - _relay('ACTION', cubit, null, 'OnClose'); + _relay('ACTION', bloc, null, 'OnClose'); } } diff --git a/lib/src/socketcluster_wrapper.dart b/lib/src/socketcluster_wrapper.dart index c424d25..1834ab9 100644 --- a/lib/src/socketcluster_wrapper.dart +++ b/lib/src/socketcluster_wrapper.dart @@ -1,20 +1,22 @@ part of flutter_bloc_devtools; class SocketClusterWrapper { - Socket _socket; + socket_cc.Socket _socket; Function socketFactory; String url; - SocketClusterWrapper(this.url, {this.socketFactory = Socket.connect}); + + SocketClusterWrapper(this.url, + {this.socketFactory = socket_cc.Socket.connect}); Future connect() async { _socket = await socketFactory(url); } - Emitter on(String event, Function func) { + socket_cc.Emitter on(String event, Function func) { return _socket.on(event, func); } - void emit(String event, Object data, [AckCall ack]) { + void emit(String event, Object data, [socket_cc.AckCall ack]) { _socket.emit(event, data, ack); } diff --git a/pubspec.yaml b/pubspec.yaml index ae8a3af..93ffe2f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,14 +1,14 @@ name: flutter_bloc_devtools description: Remote DevTools for flutter_bloc. This package connects all Bloc to the Remote Devtools Server, allowing the developer to inspect changes to the Blocs during runtime. homepage: https://github.com/andrea689/flutter_bloc_devtools/ -version: 0.1.1 +version: 0.2.0 environment: sdk: '>=2.0.0 <3.0.0' dependencies: - bloc: ^6.1.0 - socketcluster_client: ^0.2.0 + bloc: ^8.0.0 + socketcluster_client: ^0.3.0 dev_dependencies: pedantic: ^1.9.0 diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..d673b94 --- /dev/null +++ b/web/index.html @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + flutter_bloc_devtools + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..fa6cd93 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "flutter_bloc_devtools", + "short_name": "flutter_bloc_devtools", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}