diff --git a/.github/workflows/elementary_analysis.yaml b/.github/workflows/elementary_analysis.yaml index b3060e82..aad16dea 100644 --- a/.github/workflows/elementary_analysis.yaml +++ b/.github/workflows/elementary_analysis.yaml @@ -6,14 +6,14 @@ on: - main paths: - "packages/elementary/**" - - ".github/workflows/elementary.yaml" + - ".github/workflows/elementary_analysis.yaml" push: branches: - main paths: - "packages/elementary/**" - - ".github/workflows/elementary.yaml" + - ".github/workflows/elementary_analysis.yaml" jobs: analysis: @@ -23,7 +23,6 @@ jobs: shell: bash working-directory: packages/elementary - steps: - name: Checkout uses: actions/checkout@v2 @@ -33,8 +32,8 @@ jobs: with: channel: "stable" - - name: Content - id: check_license + - name: Check Files + id: check_files uses: andstor/file-existence-action@v1 with: files: "LICENSE, README.md, example, CHANGELOG.md" @@ -43,15 +42,6 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' run: echo Content is ok! - - name: Check Description - run: echo | grep -q Description README.md ; echo $? - - - name: Check Overview - run: echo | grep -q Overview README.md ; echo $? - - - name: Check Technical Overview - run: echo | grep -q 'Technical Overview' README.md ; echo $? - - name: Install dependencies run: flutter pub get @@ -59,11 +49,12 @@ jobs: run: | dart pub global activate dependency_validator dart pub global run dependency_validator:dependency_validator + - name: Run analyzer run: flutter analyze --fatal-warnings --fatal-infos . - name: Run formatter - run: flutter format --set-exit-if-changed . + run: dart format --set-exit-if-changed . - name: Run package analyzer uses: axel-op/dart-package-analyzer@v3 diff --git a/.github/workflows/elementary_helper_analysis.yaml b/.github/workflows/elementary_helper_analysis.yaml new file mode 100644 index 00000000..0051d6e5 --- /dev/null +++ b/.github/workflows/elementary_helper_analysis.yaml @@ -0,0 +1,146 @@ +name: elementary helper analysis + +on: + pull_request: + branches: + - main + paths: + - "packages/elementary_helper/**" + - ".github/workflows/elementary_helper_analysis.yaml" + + push: + branches: + - main + paths: + - "packages/elementary_helper/**" + - ".github/workflows/elementary_helper_analysis.yaml" + +jobs: + analysis: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: packages/elementary_helper + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + + - name: Check Files + id: check_files + uses: andstor/file-existence-action@v1 + with: + files: "LICENSE, README.md, example, CHANGELOG.md" + + - name: File exists + if: steps.check_files.outputs.files_exists == 'true' + run: echo Content is ok! + + - name: Install dependencies + run: flutter pub get + + - name: Run dependency validator + run: | + dart pub global activate dependency_validator + dart pub global run dependency_validator:dependency_validator + + - name: Run analyzer + run: flutter analyze --fatal-warnings --fatal-infos . + + - name: Run formatter + run: dart format --set-exit-if-changed . + + - name: Run package analyzer + uses: axel-op/dart-package-analyzer@v3 + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + relativePath: packages/elementary_helper/ + + testing: + needs: analysis + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: packages/elementary_helper + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + + - name: Install dependencies + run: flutter pub get + + - name: Run tests + env: + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + if: success() + run: | + flutter test --coverage + bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info -F elementary_helper + + build_android_example: + needs: analysis + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: packages/elementary_helper + + steps: + # Setup Java environment in order to build the Android app. + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: "12.x" + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + + - name: Install dependencies + run: flutter pub get + + - name: Build Android + run: | + cd example + flutter pub get + flutter build apk + + build_ios_example: + needs: analysis + runs-on: macos-latest + defaults: + run: + shell: bash + working-directory: packages/elementary_helper + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + + - name: Install dependencies + run: flutter pub get + + - name: Build iOS + run: | + cd example + flutter pub get + flutter build ios --release --no-codesign diff --git a/README.md b/README.md index 32f8390d..7536fd1e 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,97 @@ # Flutter Elementary repository +### +

+ Elementary Logo +

-Elementary Logo +### -[![Pub Version](https://img.shields.io/pub/v/elementary?logo=dart&logoColor=white)](https://pub.dev/packages/elementary) -[![Coverage Status](https://img.shields.io/codecov/c/github/Elementary-team/flutter-elementary?flag=elementary&logo=codecov&logoColor=white)](https://app.codecov.io/gh/Elementary-team/flutter-elementary) -[![Pub points](https://badgen.net/pub/points/elementary)](https://pub.dev/packages/elementary) -[![Pub Likes](https://badgen.net/pub/likes/elementary)](https://pub.dev/packages/elementary) -[![Pub popularity](https://badgen.net/pub/popularity/elementary)](https://pub.dev/packages/elementary) -[![Contributors](https://badgen.net/github/contributors/Elementary-team/flutter-elementary)](https://github.com/Elementary-team/flutter-elementary/graphs/contributors) -[![License](https://badgen.net/github/license/Elementary-team/flutter-elementary)](https://github.com/Elementary-team/flutter-elementary/blob/main/LICENSE) +

+ Owner + Pub Version + Coverage Status + Pub points + Pub Likes + Pub popularity + Contributors + License +

## Description -This is a home to a family of Elementary library packages. +This repository is a home to packages and tools from the Elementary library family. -| Package | Version | -| --------------|:-------------:| -| [elementary](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary) | [![Pub Version](https://img.shields.io/pub/v/elementary?logo=dart&logoColor=white)](https://pub.dev/packages/elementary) | -| [elementary_test](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_test) | [![Pub Version](https://img.shields.io/pub/v/elementary_test?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_test) | -| [elementary_cli](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_tools/elementary_cli) | [![Pub Version](https://img.shields.io/pub/v/elementary_cli?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_cli) | +| Package | Version | +|----------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------:| +| [elementary](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary) | [![Pub Version](https://img.shields.io/pub/v/elementary?logo=dart&logoColor=white)](https://pub.dev/packages/elementary) | +| [elementary_helper](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_helper) | [![Pub Version](https://img.shields.io/pub/v/elementary_helper?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_helper) | +| [elementary_test](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_test) | [![Pub Version](https://img.shields.io/pub/v/elementary_test?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_test) | +| [elementary_cli](https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_tools/elementary_cli) | [![Pub Version](https://img.shields.io/pub/v/elementary_cli?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_cli) | ## Elementary overview -The primary goal of this library is to split code into different responsibility layers, thus making it clearer, -simpler as well as more readable and testable. This approach is based on an architectural pattern called MVVM and -the fundamentals of Clean Architecture. +Elementary is a simple and reliable way to build applications with MVVM in Flutter. +Benefits from using: -## Sponsor +- maximum Flutter-like, you don't need to spend a lot of time learning the library if you are already familiar with the + standard Flutter approaches; +- splitting code into different layers by responsibility, that bring low coupling, make code simpler as well as more + readable; +- high testability of all layers from widgets to business logic; +- speed boost for a team consisting of more than one person, due to the easy sharing of independent task-parts among + team members. -Our main sponsor is [Surf](https://surf.ru/). +## Environment + +For reduce amount of boilerplate and the manual work, for Elementary there are few options: + +- [elementary_cli](https://pub.dev/packages/elementary_cli) - command line util helps with boilerplate generation; +- [plugin for IntelliJ](https://plugins.jetbrains.com/plugin/18099-elementary) - plugin for IntelliJ IDE family, +based on elementary_cli; +- [plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=ElementaryTeam.elementary) - plugin for VSCode, +based on elementary_cli; +- [elementary brick](https://brickhub.dev/bricks/elementary) - command line util helps with boilerplate generation, +based on mason. + +## Examples + +[Country](https://github.com/Elementary-team/flutter-elementary/tree/main/examples/country) - general example how to use elementary for development; + +[Elementary with Redux](https://github.com/Elementary-team/flutter-elementary/tree/main/examples/elementary_redux) - example how to use elementary + redux; + +[Profile](https://github.com/Elementary-team/flutter-elementary/tree/main/examples/profile) - example shows the feature with the process that spread by separate screens, and also how to use elementary + bloc; ## Maintainer -[Mikhail Zotyev](https://github.com/MbIXjkee) + +
+ Maintainer avatar +

Mikhail Zotyev

+
+
+ +## Contributors thanks + +Big thanks to all these people, who put their effort to help the project. + +![contributors](https://contributors-img.firebaseapp.com/image?repo=Elementary-team/flutter-elementary) + + +Special thanks to: + +[Dmitry Krutskikh](https://github.com/dkrutskikh), [Konoshenko Vlad](https://github.com/vlkonoshenko), +[Denis Grafov](https://github.com/grafovdenis) for the early adoption and the first production feedback; + +[Alex Bukin](https://github.com/AlexeyBukin) for IDE plugins; + +All members of the Surf Flutter Team for actively using and providing feedback. + +## Sponsorship + +Special sponsor of the project: + + +Surf + + +For all questions regarding sponsorship/collaboration connect with [Mikhail Zotyev](https://github.com/MbIXjkee). diff --git a/examples/country/ios/Flutter/AppFrameworkInfo.plist b/examples/country/ios/Flutter/AppFrameworkInfo.plist index 8d4492f9..9625e105 100644 --- a/examples/country/ios/Flutter/AppFrameworkInfo.plist +++ b/examples/country/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/examples/country/ios/Runner.xcodeproj/project.pbxproj b/examples/country/ios/Runner.xcodeproj/project.pbxproj index fd24ab6d..7a407f08 100644 --- a/examples/country/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/country/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -171,10 +171,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -185,6 +187,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -272,7 +275,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -288,10 +291,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.example.country; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.example.country; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -346,7 +353,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -395,7 +402,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -412,10 +419,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.example.country; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.example.country; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -431,10 +442,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.example.country; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.example.country; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/examples/country/ios/Runner/Info.plist b/examples/country/ios/Runner/Info.plist index 52f427f1..c0317768 100644 --- a/examples/country/ios/Runner/Info.plist +++ b/examples/country/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +24,8 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,7 +45,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - diff --git a/examples/country/lib/ui/app/app_dependencies.dart b/examples/country/lib/ui/app/app_dependencies.dart index a4279bf8..f55322cd 100644 --- a/examples/country/lib/ui/app/app_dependencies.dart +++ b/examples/country/lib/ui/app/app_dependencies.dart @@ -4,7 +4,7 @@ import 'package:country/ui/app/app.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_model.dart'; import 'package:country/utils/error/default_error_handler.dart'; import 'package:dio/dio.dart'; -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/examples/country/lib/ui/screen/country_list_screen/country_list_screen.dart b/examples/country/lib/ui/screen/country_list_screen/country_list_screen.dart index a8223b17..29b2e5de 100644 --- a/examples/country/lib/ui/screen/country_list_screen/country_list_screen.dart +++ b/examples/country/lib/ui/screen/country_list_screen/country_list_screen.dart @@ -1,6 +1,7 @@ import 'package:country/domain/country/country.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_widget_model.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; /// Widget screen with list of countries. diff --git a/examples/country/lib/ui/screen/country_list_screen/country_list_screen_widget_model.dart b/examples/country/lib/ui/screen/country_list_screen/country_list_screen_widget_model.dart index cc64ea2d..2015b700 100644 --- a/examples/country/lib/ui/screen/country_list_screen/country_list_screen_widget_model.dart +++ b/examples/country/lib/ui/screen/country_list_screen/country_list_screen_widget_model.dart @@ -4,6 +4,8 @@ import 'package:country/ui/screen/country_list_screen/country_list_screen.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_model.dart'; import 'package:dio/dio.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -24,7 +26,7 @@ class CountryListScreenWidgetModel final _countryListState = EntityStateNotifier>(); @override - ListenableState>> get countryListState => + ValueListenable>> get countryListState => _countryListState; @override @@ -50,16 +52,16 @@ class CountryListScreenWidgetModel void onErrorHandle(Object error) { super.onErrorHandle(error); - if (error is DioError && - (error.type == DioErrorType.connectTimeout || - error.type == DioErrorType.receiveTimeout)) { + if (error is DioException && + (error.type == DioExceptionType.connectionTimeout || + error.type == DioExceptionType.receiveTimeout)) { ScaffoldMessenger.of(context) .showSnackBar(const SnackBar(content: Text('Connection troubles'))); } } Future _loadCountryList() async { - final previousData = _countryListState.value?.data; + final previousData = _countryListState.value.data; _countryListState.loading(previousData); try { @@ -72,8 +74,8 @@ class CountryListScreenWidgetModel } /// Interface of [CountryListScreenWidgetModel] -abstract class ICountryListWidgetModel extends IWidgetModel { - ListenableState>> get countryListState; +abstract interface class ICountryListWidgetModel implements IWidgetModel { + ValueListenable>> get countryListState; TextStyle get countryNameStyle; } diff --git a/examples/country/pubspec.yaml b/examples/country/pubspec.yaml index d0a5cdb8..49e7e590 100644 --- a/examples/country/pubspec.yaml +++ b/examples/country/pubspec.yaml @@ -4,13 +4,15 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: sdk: flutter - elementary: ^2.0.0 + elementary: ^3.0.0 + elementary_helper: ^1.0.1 cupertino_icons: ^1.0.5 dio: ^5.0.3 retrofit: ^4.0.1 @@ -30,11 +32,11 @@ dev_dependencies: # golden tests golden_toolkit: ^0.15.0 # mocking - mocktail: ^0.3.0 + mocktail: ^1.0.0 # analyzer - mjk_lint_rules: ^1.0.1 + mjk_lint_rules: ^2.0.0 # testing elementary - elementary_test: ^1.1.3 + elementary_test: ^2.0.0 flutter: uses-material-design: true diff --git a/examples/country/test/golden/golden_helper.dart b/examples/country/test/golden/golden_helper.dart index 309269ff..bc33de70 100644 --- a/examples/country/test/golden/golden_helper.dart +++ b/examples/country/test/golden/golden_helper.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/foundation.dart'; import 'package:mocktail/mocktail.dart'; @@ -10,7 +10,7 @@ abstract class MockWM extends Mock with Diagnosticable {} class ListenableStateMock extends Mock implements ListenableState {} class ListenableEntityStateMock extends Mock - implements ListenableState> {} + implements ValueListenable> {} // Реализация подмены http клиента для загрузки Image.network R provideMockedNetworkImages(R Function() body, {List? imageBytes}) { diff --git a/examples/country/test/golden/screen/country_list_screen/country_list_screen_test.dart b/examples/country/test/golden/screen/country_list_screen/country_list_screen_test.dart index e1ad2175..fc540001 100644 --- a/examples/country/test/golden/screen/country_list_screen/country_list_screen_test.dart +++ b/examples/country/test/golden/screen/country_list_screen/country_list_screen_test.dart @@ -2,7 +2,7 @@ import 'package:country/domain/country/country.dart'; import 'package:country/res/theme/app_typography.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_widget_model.dart'; -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:mocktail/mocktail.dart'; @@ -34,7 +34,7 @@ void main() { testGoldens('CountryListScreen loading test', (tester) async { when(() => countryListStateMock.value).thenReturn( - const EntityState.loading(), + EntityState.loading(), ); await tester.pumpWidgetBuilder( @@ -46,7 +46,7 @@ void main() { testGoldens('CountryListScreen error test', (tester) async { when(() => countryListStateMock.value).thenReturn( - const EntityState.error(), + EntityState.error(), ); await tester.pumpWidgetBuilder( diff --git a/examples/country/test/wm_test/screen/country_list_screen/country_list_screen_wm_test.dart b/examples/country/test/wm_test/screen/country_list_screen/country_list_screen_wm_test.dart index 46347ade..9a495ebe 100644 --- a/examples/country/test/wm_test/screen/country_list_screen/country_list_screen_wm_test.dart +++ b/examples/country/test/wm_test/screen/country_list_screen/country_list_screen_wm_test.dart @@ -4,7 +4,7 @@ import 'package:country/res/theme/app_typography.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_model.dart'; import 'package:country/ui/screen/country_list_screen/country_list_screen_widget_model.dart'; -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:elementary_test/elementary_test.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/examples/elementary_redux/ios/Flutter/AppFrameworkInfo.plist b/examples/elementary_redux/ios/Flutter/AppFrameworkInfo.plist index 8d4492f9..9625e105 100644 --- a/examples/elementary_redux/ios/Flutter/AppFrameworkInfo.plist +++ b/examples/elementary_redux/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/examples/elementary_redux/ios/Podfile b/examples/elementary_redux/ios/Podfile index 1e8c3c90..88359b22 100644 --- a/examples/elementary_redux/ios/Podfile +++ b/examples/elementary_redux/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/examples/elementary_redux/ios/Runner.xcodeproj/project.pbxproj b/examples/elementary_redux/ios/Runner.xcodeproj/project.pbxproj index 81ac269f..adf3bc41 100644 --- a/examples/elementary_redux/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/elementary_redux/ios/Runner.xcodeproj/project.pbxproj @@ -3,12 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* 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 */; }; + 737C90B8AB9C04455C0ED58D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9240C223D4D5C910379668D3 /* 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 */; }; @@ -31,10 +32,12 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 22C7094FB05991E3513B743C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9240C223D4D5C910379668D3 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -42,6 +45,8 @@ 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 = ""; }; + B33E7A66CC1716989A42C4DD /* 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 = ""; }; + E32BF495AF44554AF3A712E8 /* 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 */ @@ -49,12 +54,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 737C90B8AB9C04455C0ED58D /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3D3B1BF29DB968258F0BD23C /* Frameworks */ = { + isa = PBXGroup; + children = ( + 9240C223D4D5C910379668D3 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +86,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + BB866231AE561DB88FB8B0E8 /* Pods */, + 3D3B1BF29DB968258F0BD23C /* Frameworks */, ); sourceTree = ""; }; @@ -98,6 +114,17 @@ path = Runner; sourceTree = ""; }; + BB866231AE561DB88FB8B0E8 /* Pods */ = { + isa = PBXGroup; + children = ( + B33E7A66CC1716989A42C4DD /* Pods-Runner.debug.xcconfig */, + E32BF495AF44554AF3A712E8 /* Pods-Runner.release.xcconfig */, + 22C7094FB05991E3513B743C /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 749C1432B40EF539F2AA7A4D /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + F54773AE5F31E5DC16CA5185 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -171,10 +200,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -183,8 +214,31 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 749C1432B40EF539F2AA7A4D /* [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; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -197,6 +251,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + F54773AE5F31E5DC16CA5185 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -272,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -350,7 +421,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -399,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/examples/elementary_redux/ios/Runner.xcworkspace/contents.xcworkspacedata b/examples/elementary_redux/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16..21a3cc14 100644 --- a/examples/elementary_redux/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/examples/elementary_redux/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/examples/elementary_redux/ios/Runner/Info.plist b/examples/elementary_redux/ios/Runner/Info.plist index dbd15bd1..28523a2b 100644 --- a/examples/elementary_redux/ios/Runner/Info.plist +++ b/examples/elementary_redux/ios/Runner/Info.plist @@ -43,5 +43,9 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/examples/elementary_redux/pubspec.yaml b/examples/elementary_redux/pubspec.yaml index b680ae93..0ef6ddf9 100644 --- a/examples/elementary_redux/pubspec.yaml +++ b/examples/elementary_redux/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: cached_network_image: ^3.2.0 cupertino_icons: ^1.0.2 dio: ^5.0.3 - elementary: ^1.6.0 + elementary: ^3.0.0 fast_immutable_collections: ^7.2.1 flutter: sdk: flutter @@ -27,7 +27,7 @@ dependencies: shared_preferences: ^2.0.6 dev_dependencies: - mocktail: ^0.3.0 + mocktail: ^1.0.0 build_runner: ^2.2.1 flutter_lints: ^1.0.0 flutter_test: diff --git a/examples/profile/ios/Flutter/AppFrameworkInfo.plist b/examples/profile/ios/Flutter/AppFrameworkInfo.plist index 8d4492f9..9625e105 100644 --- a/examples/profile/ios/Flutter/AppFrameworkInfo.plist +++ b/examples/profile/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/examples/profile/ios/Podfile b/examples/profile/ios/Podfile index 252d9ec7..313ea4a1 100644 --- a/examples/profile/ios/Podfile +++ b/examples/profile/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '9.0' +platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/examples/profile/ios/Runner.xcodeproj/project.pbxproj b/examples/profile/ios/Runner.xcodeproj/project.pbxproj index b45b18dd..88153d5a 100644 --- a/examples/profile/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/profile/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -200,10 +200,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -236,6 +238,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -417,7 +420,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -466,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/examples/profile/ios/Runner/Info.plist b/examples/profile/ios/Runner/Info.plist index 717dea98..65ab0af9 100644 --- a/examples/profile/ios/Runner/Info.plist +++ b/examples/profile/ios/Runner/Info.plist @@ -43,5 +43,9 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/examples/profile/lib/features/common/widgets/di_scope/di_scope.dart b/examples/profile/lib/features/common/widgets/di_scope/di_scope.dart index 20315e8a..e4966758 100644 --- a/examples/profile/lib/features/common/widgets/di_scope/di_scope.dart +++ b/examples/profile/lib/features/common/widgets/di_scope/di_scope.dart @@ -21,7 +21,7 @@ class DiScope extends StatefulWidget { }) : super(key: key); @override - DiScopeState createState() => DiScopeState(); + DiScopeState createState() => DiScopeState(); } /// State for the [DiScope]. diff --git a/examples/profile/lib/features/navigation/service/coordinator.dart b/examples/profile/lib/features/navigation/service/coordinator.dart index 94ddd16c..276d5e8d 100644 --- a/examples/profile/lib/features/navigation/service/coordinator.dart +++ b/examples/profile/lib/features/navigation/service/coordinator.dart @@ -22,7 +22,7 @@ class Coordinator extends ChangeNotifier { Map get coordinates => _coordinates; /// [Page]s list. - List get pages => List.of(_pages); + List> get pages => List.of(_pages); /// Initial screens route. String? get initialRoute => _coordinates[initialCoordinate]?.path; diff --git a/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen.dart b/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen.dart index e22ddf02..568514fe 100644 --- a/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen.dart +++ b/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen.dart @@ -1,4 +1,5 @@ import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/colors/colors.dart'; import 'package:profile/assets/strings/about_me_screen_strings.dart'; diff --git a/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen_widget_model.dart b/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen_widget_model.dart index b88a02a7..4c483b93 100644 --- a/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen_widget_model.dart +++ b/examples/profile/lib/features/profile/screens/about_me_screen/about_me_screen_widget_model.dart @@ -1,6 +1,8 @@ import 'dart:async'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/strings/about_me_screen_strings.dart'; import 'package:profile/features/app/di/app_scope.dart'; @@ -56,7 +58,7 @@ class AboutMeScreenWidgetModel ListenableState get buttonState => _buttonState; @override - ListenableState> get saveEntityState => _saveEntityState; + ValueListenable> get saveEntityState => _saveEntityState; String? _initialInfo; @@ -151,7 +153,7 @@ class AboutMeScreenWidgetModel } /// Interface of [AboutMeScreenWidgetModel]. -abstract class IAboutMeScreenWidgetModel extends IWidgetModel { +abstract class IAboutMeScreenWidgetModel implements IWidgetModel { /// Focus node. FocusNode get focusNode; @@ -162,7 +164,7 @@ abstract class IAboutMeScreenWidgetModel extends IWidgetModel { ListenableState get buttonState; /// Save state. - ListenableState> get saveEntityState; + ValueListenable> get saveEntityState; /// Function to save user info in [Profile]. void updateAboutMe(); diff --git a/examples/profile/lib/features/profile/screens/interests_screen/interests_screen.dart b/examples/profile/lib/features/profile/screens/interests_screen/interests_screen.dart index 06093c28..17a3bddd 100644 --- a/examples/profile/lib/features/profile/screens/interests_screen/interests_screen.dart +++ b/examples/profile/lib/features/profile/screens/interests_screen/interests_screen.dart @@ -1,4 +1,5 @@ import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/colors/colors.dart'; import 'package:profile/assets/strings/interests_screen_strings.dart'; @@ -53,7 +54,7 @@ class InterestsScreen extends ElementaryWidget { class _ContentWidget extends StatelessWidget { final List? listInterests; final ListenableState> listUserInterestsState; - final Function({required String interest}) onChanged; + final void Function({required String interest}) onChanged; const _ContentWidget({ required this.listInterests, @@ -92,7 +93,7 @@ class _ContentWidget extends StatelessWidget { class _ItemInterest extends StatelessWidget { final String interest; final ListenableState> state; - final Function({required String interest}) onChanged; + final void Function({required String interest}) onChanged; const _ItemInterest({ required this.interest, diff --git a/examples/profile/lib/features/profile/screens/interests_screen/interests_screen_widget_model.dart b/examples/profile/lib/features/profile/screens/interests_screen/interests_screen_widget_model.dart index c8a51e67..2086bca1 100644 --- a/examples/profile/lib/features/profile/screens/interests_screen/interests_screen_widget_model.dart +++ b/examples/profile/lib/features/profile/screens/interests_screen/interests_screen_widget_model.dart @@ -1,4 +1,6 @@ import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/strings/interests_screen_strings.dart'; import 'package:profile/features/app/di/app_scope.dart'; @@ -48,7 +50,7 @@ class InterestsScreenWidgetModel _listUserInterestsState; @override - ListenableState>> get listAllInterestsEntityState => + ValueListenable>> get listAllInterestsEntityState => _listAllInterestsEntityState; /// Create an instance [InterestsScreenWidgetModel]. @@ -124,9 +126,9 @@ class InterestsScreenWidgetModel } /// Interface of [IInterestsScreenWidgetModel]. -abstract class IInterestsScreenWidgetModel extends IWidgetModel { +abstract class IInterestsScreenWidgetModel implements IWidgetModel { /// All interest list state. - ListenableState>> get listAllInterestsEntityState; + ValueListenable>> get listAllInterestsEntityState; /// Status of selected checkboxes. ListenableState> get listUserInterestsState; diff --git a/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen.dart b/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen.dart index b9984bd5..26a9b4c4 100644 --- a/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen.dart +++ b/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen.dart @@ -1,4 +1,5 @@ import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/colors/colors.dart'; import 'package:profile/assets/strings/personal_data_screen_strings.dart'; @@ -133,7 +134,7 @@ class _FullNameWidget extends StatelessWidget { final TextEditingController secondNameEditingController; final TextEditingController birthdayEditingController; final GlobalKey formKey; - final Function(BuildContext) onDateTap; + final void Function(BuildContext) onDateTap; final VoidCallback nextButtonCallback; final String? Function(String?) surnameValidator; final String? Function(String?) nameValidator; @@ -203,7 +204,7 @@ class _FullNameWidget extends StatelessWidget { class _DateWidget extends StatelessWidget { final TextEditingController controller; final String? Function(String?) validator; - final Function(BuildContext) onDateTap; + final void Function(BuildContext) onDateTap; const _DateWidget({ required this.controller, diff --git a/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen_widget_model.dart b/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen_widget_model.dart index f81c3ca2..a8004070 100644 --- a/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen_widget_model.dart +++ b/examples/profile/lib/features/profile/screens/personal_data_screen/personal_data_screen_widget_model.dart @@ -1,6 +1,8 @@ import 'dart:async'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:profile/features/app/di/app_scope.dart'; import 'package:profile/features/navigation/domain/entity/app_coordinate.dart'; @@ -53,7 +55,7 @@ class PersonalDataScreenWidgetModel GlobalKey get formKey => _formKey; @override - ListenableState> get profileEntityState => + ValueListenable> get profileEntityState => _profileEntityState; @override @@ -192,7 +194,7 @@ class PersonalDataScreenWidgetModel } /// Interface of [PersonalDataScreenWidgetModel]. -abstract class IPersonalDataWidgetModel extends IWidgetModel { +abstract class IPersonalDataWidgetModel implements IWidgetModel { /// Validation form key for surname. GlobalKey get formKey; @@ -209,7 +211,7 @@ abstract class IPersonalDataWidgetModel extends IWidgetModel { TextEditingController get birthdayEditingController; /// State of state. - ListenableState> get profileEntityState; + ValueListenable> get profileEntityState; /// Function to open DatePicker. Future onDateTap(BuildContext context); diff --git a/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen.dart b/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen.dart index 9cdc0973..df3f5185 100644 --- a/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen.dart +++ b/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen.dart @@ -62,9 +62,10 @@ class PlaceResidenceScreen class _MapOpenButton extends StatelessWidget { final FocusNode focusNode; - final Function({required WidgetBuilder builder, required ShapeBorder shape}) - showBottomSheet; - final Function(Point) getMockCityByCoordinates; + final void Function( + {required WidgetBuilder builder, + required ShapeBorder shape}) showBottomSheet; + final void Function(Point) getMockCityByCoordinates; final VoidCallback updateSelectedCityOnMap; const _MapOpenButton({ @@ -103,7 +104,7 @@ class _MapOpenButton extends StatelessWidget { } class _BottomSheetWithMapWidget extends StatelessWidget { - final Function(Point) onMapTap; + final void Function(Point) onMapTap; final VoidCallback saveCity; const _BottomSheetWithMapWidget({ @@ -135,7 +136,7 @@ class _BottomSheetWithMapWidget extends StatelessWidget { } class _MapWidget extends StatefulWidget { - final Function(Point) onMapTap; + final void Function(Point) onMapTap; const _MapWidget({ required this.onMapTap, @@ -147,7 +148,7 @@ class _MapWidget extends StatefulWidget { } class _MapWidgetState extends State<_MapWidget> { - List mapObject = []; + List> mapObject = []; YandexMapController? controller; @override diff --git a/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen_widget_model.dart b/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen_widget_model.dart index aad99f24..6b3db6b7 100644 --- a/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen_widget_model.dart +++ b/examples/profile/lib/features/profile/screens/place_residence/place_residence_screen_widget_model.dart @@ -136,7 +136,7 @@ class PlaceResidenceScreenWidgetModel } /// Interface of [PlaceResidenceScreenWidgetModel]. -abstract class IPlaceResidenceScreenWidgetModel extends IWidgetModel { +abstract class IPlaceResidenceScreenWidgetModel implements IWidgetModel { /// Text Editing controller for [FieldWithSuggestionsWidget]. TextEditingController get controller; diff --git a/examples/profile/lib/features/profile/screens/place_residence/utils/overlay_entry_controller.dart b/examples/profile/lib/features/profile/screens/place_residence/utils/overlay_entry_controller.dart index 17663f3f..9cf0abaf 100644 --- a/examples/profile/lib/features/profile/screens/place_residence/utils/overlay_entry_controller.dart +++ b/examples/profile/lib/features/profile/screens/place_residence/utils/overlay_entry_controller.dart @@ -1,4 +1,5 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:profile/assets/strings/place_residence_screen_strings.dart'; import 'package:profile/features/profile/widgets/error_widget.dart'; @@ -10,8 +11,8 @@ class OverlayEntryController { /// Create [OverlayEntry]. OverlayEntry createOverlayEntry( - ListenableState>> listSuggestionsState, - Function(String) onSelected, + ValueListenable>> listSuggestionsState, + void Function(String) onSelected, LayerLink link, ) { return OverlayEntry( @@ -27,8 +28,8 @@ class OverlayEntryController { } class _SuggestionWidget extends StatelessWidget { - final ListenableState>> listSuggestionsState; - final Function(String) onSelected; + final ValueListenable>> listSuggestionsState; + final void Function(String) onSelected; final LayerLink layerLink; const _SuggestionWidget({ diff --git a/examples/profile/lib/features/profile/screens/place_residence/widgets/field_with_suggestions_widget/field_with_suggestions_widget_model.dart b/examples/profile/lib/features/profile/screens/place_residence/widgets/field_with_suggestions_widget/field_with_suggestions_widget_model.dart index 33adac09..6d4544b6 100644 --- a/examples/profile/lib/features/profile/screens/place_residence/widgets/field_with_suggestions_widget/field_with_suggestions_widget_model.dart +++ b/examples/profile/lib/features/profile/screens/place_residence/widgets/field_with_suggestions_widget/field_with_suggestions_widget_model.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:async/async.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:profile/features/app/di/app_scope.dart'; import 'package:profile/features/profile/screens/place_residence/utils/overlay_entry_controller.dart'; @@ -38,7 +40,7 @@ class FieldWithSuggestionsWidgetModel FocusNode get focusNode => _focusNode; @override - ListenableState>> get listSuggestionsState => + ValueListenable>> get listSuggestionsState => _listSuggestionsState; @override @@ -133,8 +135,7 @@ class FieldWithSuggestionsWidgetModel bool _shouldShowOptions() { return _focusNode.hasFocus && _selection == null && - _controller.text.isNotEmpty && - _listSuggestionsState.value != null; + _controller.text.isNotEmpty; } void _onSelected(String value) { @@ -149,7 +150,7 @@ class FieldWithSuggestionsWidgetModel } /// Interface of [FieldWithSuggestionsWidgetModel]. -abstract class IFieldWithSuggestionsWidgetModel extends IWidgetModel { +abstract class IFieldWithSuggestionsWidgetModel implements IWidgetModel { /// Text editing controller. TextEditingController get controller; @@ -157,7 +158,7 @@ abstract class IFieldWithSuggestionsWidgetModel extends IWidgetModel { FocusNode get focusNode; /// Suggestions state. - ListenableState>> get listSuggestionsState; + ValueListenable>> get listSuggestionsState; /// Layer link for list suggestion. LayerLink get optionsLayerLink; diff --git a/examples/profile/lib/features/profile/widgets/cancel_button/cancel_button_widget_model.dart b/examples/profile/lib/features/profile/widgets/cancel_button/cancel_button_widget_model.dart index 1489c9da..efed95f6 100644 --- a/examples/profile/lib/features/profile/widgets/cancel_button/cancel_button_widget_model.dart +++ b/examples/profile/lib/features/profile/widgets/cancel_button/cancel_button_widget_model.dart @@ -42,7 +42,7 @@ class CancelButtonWidgetModel } /// Interface of [CancelButtonWidgetModel]. -abstract class ICancelButtonWidgetModel extends IWidgetModel { +abstract class ICancelButtonWidgetModel implements IWidgetModel { /// Cancel editing. void cancel(); } diff --git a/examples/profile/pubspec.yaml b/examples/profile/pubspec.yaml index 8f18b8fa..ce9c3187 100644 --- a/examples/profile/pubspec.yaml +++ b/examples/profile/pubspec.yaml @@ -6,7 +6,8 @@ publish_to: none dependencies: async: ^2.8.2 bloc: ^8.0.2 - elementary: ^1.0.0 + elementary: ^3.0.0 + elementary_helper: ^1.0.1 equatable: ^2.0.3 flutter: sdk: flutter @@ -19,10 +20,10 @@ dependencies: dev_dependencies: build_runner: ^2.1.5 dart_code_metrics: ^5.5.1 - elementary_test: ^1.0.1 + elementary_test: ^2.0.0 flutter_test: sdk: flutter - mjk_lint_rules: ^1.0.1 + mjk_lint_rules: ^2.0.0 environment: sdk: ">=2.14.0-0 <3.0.0" diff --git a/packages/elementary/CHANGELOG.md b/packages/elementary/CHANGELOG.md index c502494d..ce53eed7 100644 --- a/packages/elementary/CHANGELOG.md +++ b/packages/elementary/CHANGELOG.md @@ -2,6 +2,31 @@ ## Unreleased +## 3.1.0 +### Added +* [BREAKING CHANGE] support dart 3 version: + - IWidgetModel now is abstract interface; + - ErrorHandler now is abstract interface; + - EntityState has become sealed. +* More detailed dartdoc for classes and methods. +* Alias for EntityStateNotifier's interface. +### Changed +* Supported mocktail 1.0.0 version. +* Updated documentation in repository. +* [BREAKING CHANGE] all custom pub-sub implementation, builders and wrapper moved to +separate package - elementary_helper. + +## 3.0.0-dev +### Added +* [BREAKING CHANGE] support dart 3 version: + - IWidgetModel now is abstract interface; + - ErrorHandler now is abstract interface; + - EntityState has become sealed; +* More detailed dartdoc for classes and methods. + +### Changed +* [BREAKING CHANGE] EntityStateNotifier now extends ValueNotifier; + ## 2.0.0 ### Added * [BREAKING CHANGE] supported breaking changes for noSuchMethod in dart 2.19; diff --git a/packages/elementary/README.md b/packages/elementary/README.md index 5f96f0a7..b772c5a5 100644 --- a/packages/elementary/README.md +++ b/packages/elementary/README.md @@ -1,92 +1,134 @@ # Elementary - -Elementary Logo - -[![Pub Version](https://img.shields.io/pub/v/elementary?logo=dart&logoColor=white)](https://pub.dev/packages/elementary) -[![Coverage Status](https://img.shields.io/codecov/c/github/Elementary-team/flutter-elementary?flag=elementary&logo=codecov&logoColor=white)](https://app.codecov.io/gh/Elementary-team/flutter-elementary) -[![Pub points](https://badgen.net/pub/points/elementary)](https://pub.dev/packages/elementary) -[![Pub Likes](https://badgen.net/pub/likes/elementary)](https://pub.dev/packages/elementary) -[![Pub popularity](https://badgen.net/pub/popularity/elementary)](https://pub.dev/packages/elementary) +### +

+ Elementary Logo +

+ +### + +

+ Owner + Pub Version + Coverage Status + Pub points + Pub Likes + Pub popularity + Contributors + License +

## Description -The primary goal of this library is to split code into different responsibility layers, thus making it clearer, simpler -as well as more readable and testable. This approach is based on an architectural pattern called MVVM and the -fundamentals of Clean Architecture. +The primary goal of the library is to help write application in a simple and reliable way, as well as make the codebase +easier readable and more testable. This approach is based on splitting code into different layers depends on +responsibilities, those as business logic, presentation logic and declarative description for UI. +Due to this layer separation, the library brings additional performance boost for teams, because a few persons can +work on the same feature at the same time but on different layers. This library was inspired by Flutter itself, +MVVM architecture pattern, Business Logic Component architecture pattern, as well by fundamental principles +of Clean Architecture. ## Overview -Thanks to its elaborately separated concerns, Elementary makes it easier to manage whatever is displayed at a particular -moment and bind it with the business logic of your app. Now, before we get into detail about its structure, let's look -at the graph so that you can see for yourself how easy it is to work with Elementary. +Thanks to elaborately separated responsibilities, Elementary makes it easier to manage whatever is displayed at a +particular moment based on concrete conditions and business logic state of the app. Let's check the graphic schema +of how it works internally for a simple screen, and what the user sees every moment. Elementary scheme ## Technical Overview -This library applies a classic principle of an MVVM pattern, which is layering. In it, we have Widget acting as a View -layer, WidgetModel as a ViewModel layer, and Model as a Model layer. +Elementary uses a classical layers from the MVVM pattern, such as View, View Model, and Model. There are special +entities which represent these layers: ElementaryWidget as a View layer, WidgetModel as a View Mode layer, and +ElementaryModel as a Model layer. -And all of that put together works pretty similar to Flutter itself. +At the same time Elementary follows the Flutter-similar approach, so all these things are managed by Element. Elementary scheme ### WidgetModel -The key part in this chain of responsibility is the WidgetModel layer that connects the rest of the layers together and -describes state to Widget via a set of parameters. Moreover, it is the only source of truth when you build an image. By -the time build is called on the widget, the WidgetModel should provide it with all the data needed for a build. The -class representing this layer in the library has the same name – WidgetModel. You can describe a state to be rendered as -a set of various properties. You can use changeNotifiers (like a valueNotifier or stateNotifier, etc.), streams, getters -or something else as properties. In order to determine the properties required, you should specify them in the -IWidgetModel interface, the subclasses of which, in turn, determine what properties are used in this or that situation. +The key part in the chain of responsibilities is the WidgetModel layer that connects all other layers together and +provides to ElementaryWidget a set of parameters which are describe the current presentation state. It is a working +horse of the internal processes of Elementary, and the only source of truth for building a presentation +(by the MVVM concept). -Due to this, the WidgetModel is the only place where presentation logic is described: what interaction took place and -what occurred as a result. +#### WidgetModel's properties -For example, when data is loaded from the network, the WidgetModel looks like this: +MVVM is very efficient when possible to use binding properties. It is easy with Flutter, and Elementary does it. +Elementary is sharped to use one side binding properties, which based on the design pattern Publisher-Subscriber. +There is no mandatory requirement which one to use - you can decide based on circumstances for your concrete case. +You can use ChangeNotifiers (like a ValueNotifier or StateNotifier, etc.), Streams, or any other. +For properties which are not supposed to change, or initiate a visual change when they are changed, common getters also +appropriate. -```dart -/// Widget Model for [CountryListScreen] -class CountryListScreenWidgetModel extends WidgetModel - implements ICountryListWidgetModel { - final _countryListState = EntityStateNotifier>(); +#### Lifecycle - @override - ListenableState>> get countryListState => - _countryListState; +Due to Widget Model is a central entity that binds all layers between and at the same time connected with Element, +Widget Model has its own lifecycle. If you are familiar with the State lifecycle for StatefulWidget it should be +as well simple for you. - /// Some special wm working code this - /// ............................................................... +`initWidgetModel` is called only once for lifecycle of the WidgetModel in the really beginning before the first build. +It can be used for initiate a starting state of the WidgetModel. - Future _loadCountryList() async { - final previousData = _countryListState.value?.data; - _countryListState.loading(previousData); +`didUpdateWidget` called whenever widget instance in the tree has been updated. Common case where rebuild comes from +the top. This method is a good place for update state of the WidgetModel based on the new configuration of widget. +When this method is called is just a signal for decide what exactly should be updated or rebuilt. The fact of update +doesn't mean that build method of the widget will be called. Set new values to publishers for rebuild concrete +parts of the UI. - try { - final res = await model.loadCountries(); - _countryListState.content(res); - } on Exception catch (e) { - _countryListState.error(e, previousData); - } - } -} -``` +`didChangeDependencies` called whenever dependencies which WidgetModel subscribed with BuildContext change. When this +method is called is just a signal for decide what exactly should be updated or rebuilt. The fact of the call doesn't +mean that build method of the widget will be called. Set new values to publishers for rebuild concrete parts of the UI. + +`deactivate` called when the WidgetModel with Element removed from the tree. + +`activate` called when WidgetModel with Elementary are reinserted into the tree after having been removed via deactivate. + +`dispose` called when WidgetModel is going to be permanently destroyed. -Interface for this WidgetModel looks like this: +`reassemble` called whenever the application is reassembled during debugging, for example during the hot reload. + +`onErrorHandle` called when the ElementaryModel handle error with the ElementaryModel.handleError method. +Can be useful for general handling errors such as showing snack-bars. + +#### Contract + +It is a good to use an interface for a Widget Model, to make the code more testable and describe the contract +in explicit way. ```dart -/// Interface of [CountryListScreenWidgetModel] -abstract class ICountryListWidgetModel extends IWidgetModel { - ListenableState>> get countryListState; +/// An interface for [ExampleScreenWidgetModel] +abstract interface class IExampleScreenWidgetModel implements IWidgetModel { + ListenableState> get exampleState; } ``` -_The only place where we have access to BuildContext and need to interact with it is WidgetModel._ +#### I = f(S) or a discrete state of UI + +A bit scary name of the section, but really simple meaning. In Flutter, we target to use declarative description of UI. +We use to have a `build` method for component style widgets to describe a part of UI when Flutter needs it. +Elementary Widget isn't an exception, but to describe a part of UI it uses Widget Model as a source of truth. +A Widget Model instance is provided right into the build method and guaranty by its interface (contract) that everything +that is needed to describe UI part is provided by Widget Model's properties. + +#### Context + +_The only place where we have access to BuildContext and need to interact with it is Widget Model._ + +There are a few reasons to this. +- ElementaryModel is already a business logic layer. Business logic should be pure and independent. BuildContext is not +appropriate here. +- ElementaryWidget has source of truth in form of WidgetModel. Using context there, we spread responsibilities +and break the fact of being a source of truth for WidgetModel. +- WidgetModel has tight bound with the Element. -WidgetModel has access to Widget at any time, e.g. for using its properties like a configuration. It can be useful for -initiate or update WidgetModel's properties like this: +It is important to note that this fact applies only to the triad of entities ElementaryWidget-WidgetModel-ElementaryModel, +widgets which are used by ElementaryWidget in the build method can have access to context. +#### Widget - base immutable configuration + +Based on general Flutter approach, widget is an immutable configuration. WidgetModel has access to ElementaryWidget +at any time. It can be useful for initiate or update WidgetModel's properties: ```dart @override @@ -106,19 +148,59 @@ void didUpdateWidget(TestPageWidget oldWidget) { } ``` +#### Example + +This is a simple example shows loading data from the network with providing previous data while loading: + +```dart +/// Widget Model for [ExampleScreen] +class ExampleWidgetModel extends WidgetModel implements IExampleWidgetModel { + final _exampleState = EntityStateNotifier(); + + @override + ListenableState> get exampleState => _countryListState; + + @override + void initWidgetModel() { + super.initWidgetModel(); + + _loadData(); + } + + Future _loadData() async { + final previousData = _exampleState.value?.data; + _exampleState.loading(previousData); + + try { + final res = await model.loadData(); + _exampleState.content(res); + } on Exception catch (e) { + _exampleState.error(e, previousData); + } + } +} + +/// An interface for [ExampleWidgetModel] +abstract interface class IExampleWidgetModel implements IWidgetModel { + ListenableState> get exampleState; +} +``` + ### Model -The only WidgetModel dependency related to business logic is Model. The class representing this layer in the library is -called ElementaryModel. There is no declared way to define this one, meaning you can choose whichever way works best for -your project. One of the reasons behind that is to provide an easy way to combine _elementary_ with other approaches -related specifically to business logic. +ElementaryModel is the only point of interaction with business logic for WidgetModel. It provides a contract of +available business logic interaction in one entity. Based on this ElementaryModel is the only WidgetModel's dependency +related to business logic. ElementaryModel can be implemented in a free style: as a bunch of simple methods, +proxy that redirect to internal implementations, or combine with any other approaches. ### Widget -Since all logic is already described in the WidgetModel and Model, Widget only needs to declare what a certain part of -the interface should look like at a particular moment based on the WidgetModel properties. The class representing the -Widget layer in the library is called ElementaryWidget. The build method called to display a widget only has one -argument – the IWidgetModel interface. +For Elementary as well as for Flutter, Widget is a simple configuration firstly. It describes the starting params, +provides the factory for Widget Model and is a delegate for describe UI part represented by this Widget. The main +difference from other composition widgets is the simplified build process - since business logic and presentation +logic are encapsulated in the Model and Widget Model, it is only left to the widget to follow the UI=f(s) principle and +describe this UI based on the Widget Model contract. Therefore, the build method doesn't have context and accepts only +Widget Model contract as an argument. It looks like this: @@ -149,169 +231,47 @@ Since the layers are well-separated from each other, they are easy to test with * Use unit tests for Model layer; * Use widget and golden tests for Widget layer; -* Use widget model test from elementary_test library for WidgetModel. - -## Tooling - -To make Elementary easier to use, some tools have been added. - -### StateNotifier - -In order to establish a quicker response to any changes in properties of a state object, you can use a StateNotifier. It -is a subclass of ChangeNotifier. StateNotifier's subscribers are notified whenever a state change occurs. Also, the -subscriber will be called for the first time at the moment of subscription. The initialization of the StateNotifier does -not require an initial value to be specified, for this reason the value returned by it may be null. - -```dart - -final _somePropertyWithIntegerValue = StateNotifier(); - -void someFunctionChangeValue() { - // do something, get new value - // ............................................................... - final newValue = 10; - // and then change value of property - _somePropertyWithIntegerValue.accept(10); -} -``` +* Use widget-model tests from elementary_test library for WidgetModel. +* Use integration tests to check all together. -### EntityStateNotifier +## Utils -Variant of StateNotifier that uses a special EntityState object as the state value. EntityState has three states: -content, loading, error. +To make Elementary easier to use, some helpers have been added. As it was mentioned previously, you can use any +types of properties follows the Publisher-Subscriber pattern. Additionally, to available by default in Dart and Flutter +Elementary contains a bunch of personal and builders for them. +Check [elementary_helper](https://pub.dev/packages/elementary_helper) to find more. -```dart - -final _countryListState = EntityStateNotifier>(); - -Future _loadCountryList() async { - final previousData = _countryListState.value?.data; - - // set property to loading state and use previous data for this state - _countryListState.loading(previousData); - - try { - // await the result - final res = await model.loadCountries(); - // set property to content state, use new data - _countryListState.content(res); - } on Exception catch (e) { - // set property to error state - _countryListState.error(e, previousData); - } -} -``` - -### StateNotifierBuilder - -The StateNotifierBuilder is a widget that uses a StateNotifier as its data source. A builder function of the -StateNotifierBuilder must return the widget based on the current value passed. - -```dart -void somewhereInTheBuildFunction() { - // ...... - StateNotifierBuilder( - listenableState: someListenableState, - builder: (ctx, value) { - return Text(value); - }, - ); - // ...... -} -``` - -### EntityStateNotifierBuilder +## Maintainer -The EntityStateNotifierBuilder is a widget that uses a EntityStateNotifier as its data source. -Depending on the state, different builders will be called. It will be errorBuilder for error, loadingBuilder for error, -builder for content. + +
+ Maintainer avatar +

Mikhail Zotyev

+
+
-```dart -@override -Widget build(ICountryListWidgetModel wm) { - return Scaffold( - appBar: AppBar( - title: const Text('Country List'), - ), - body: EntityStateNotifierBuilder>( - listenableEntityState: wm.countryListState, - loadingBuilder: (_, __) => const _LoadingWidget(), - errorBuilder: (_, __, ___) => const _ErrorWidget(), - builder: (_, countries) => - _CountryList( - countries: countries, - nameStyle: wm.countryNameStyle, - ), - ), - ); -} -``` +## Contributors thanks -### DoubleSourceBuilder -One of the multi-sources builders. It uses two ListenableStates as sources of data. -The builder function will be called when any of the ListenableStates changes. +Big thanks to all these people, who put their effort to help the project. -```dart -void somewhereInTheBuildFunction() { - // ...... - DoubleSourceBuilder( - firstSource: captionListenableState, - secondSource: captionStyleListenableState, - builder: (ctx, value, style) { - return Text(value, style: style); - }, - ); - // ...... -} -``` +![contributors](https://contributors-img.firebaseapp.com/image?repo=Elementary-team/flutter-elementary) + -### TripleSourceBuilder -One of the multi-sources builders. It uses three ListenableStates as sources of data. -The builder function will be called when any of the ListenableStates changes. +Special thanks to: -```dart -void somewhereInTheBuildFunction() { - // ...... - TripleSourceBuilder( - firstSource: captionListenableState, - secondSource: valueListenableState, - thirdSource: captionStyleListenableState, - builder: (ctx, title, value, style) { - return Text('$title: ${value ?? 0}', style: style); - }, - ); - // ...... -} -``` +[Dmitry Krutskikh](https://github.com/dkrutskikh), [Konoshenko Vlad](https://github.com/vlkonoshenko), +[Denis Grafov](https://github.com/grafovdenis) for the early adoption and the first production feedback; -### MultiListenerRebuilder -Widget that rebuild part of the ui when one of Listenable changes. The builder function in this widget has no values, -and you need to get the values directly in function's body. +[Alex Bukin](https://github.com/AlexeyBukin) for IDE plugins; -```dart -void somewhereInTheBuildFunction() { - // ...... - MultiListenerRebuilder( - listenableList: [ - firstListenable, - secondListenable, - thirdListenable, - ], - builder: (ctx) { - final title = firstListenable.value; - final value = secondListenable.value; - final style = thirdListenable.value; - return Text('$title: ${value ?? 0}', style: style); - }, - ); - // ...... -} -``` +All members of the Surf Flutter Team for actively using and providing feedback. -## Sponsor +## Sponsorship -Our main sponsor is [Surf](https://surf.ru/). +Special sponsor of the project: -## Maintainer + +Surf + -[Mikhail Zotyev](https://github.com/MbIXjkee) +For all questions regarding sponsorship/collaboration connect with [Mikhail Zotyev](https://github.com/MbIXjkee). diff --git a/packages/elementary/documentation/quick_start.md b/packages/elementary/documentation/quick_start.md new file mode 100644 index 00000000..c78a332b --- /dev/null +++ b/packages/elementary/documentation/quick_start.md @@ -0,0 +1,82 @@ +# Document describes a simple guideline how to start with Elementary [WIP] + +### Choose tooling: + +Depends on your IDE and personal preferences choose and install one of those tools: + +- [plugin for IntelliJ](https://plugins.jetbrains.com/plugin/18099-elementary) +- [plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=ElementaryTeam.elementary) +- [elementary brick](https://brickhub.dev/bricks/elementary) +- [elementary_cli](https://pub.dev/packages/elementary_cli); + +Or can skip this step and create Widgets, Widget Models, Models manually further. + +### Depend on elementary: + +Run this command + +```flutter pub add elementary``` + +or manually add dependency to your project pubspec.yaml + +``` +dependencies: + elementary: $actual_version +``` +### Depend on elementary_helper: + +Run this command + +```flutter pub add elementary_helper``` + +or manually add dependency to your project pubspec.yaml + +``` +dependencies: + elementary_helper: $actual_version +``` + +### Depend on elementary_test: + +Run this command + +```flutter pub add elementary_test``` + +or manually add dependency to your project pubspec.yaml + +``` +dependencies: + elementary_test: $actual_version +``` + +### Create classes: + +Using a chosen tool create classes for ElementaryModel, WidgetModel, ElementaryWidget. + +TODO: describe manual creation. + +### ElementaryModel: + +Implement all business logic for current feature in model, free style. + +TODO: more details, examples. + +### WidgetModel: + +Implement all presentation logic for current feature in widget model. + +TODO: more details, examples. + +### ElementaryWidget: + +Based on the contract of Widget Model, describe UI. + +TODO: more details, examples. + +### Testing: + +Write unit tests for Model. +Write tests for Widget Model using elementary_test. +Write widget test, golden tests for ElementaryWidget. + +TODO: more details, examples. \ No newline at end of file diff --git a/packages/elementary/example/ios/Runner.xcodeproj/project.pbxproj b/packages/elementary/example/ios/Runner.xcodeproj/project.pbxproj index d7afaaed..d3db3781 100644 --- a/packages/elementary/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/elementary/example/ios/Runner.xcodeproj/project.pbxproj @@ -176,6 +176,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/elementary/example/lib/impl/screen/test_page_widget.dart b/packages/elementary/example/lib/impl/screen/test_page_widget.dart index a4e31cdf..01b7fded 100644 --- a/packages/elementary/example/lib/impl/screen/test_page_widget.dart +++ b/packages/elementary/example/lib/impl/screen/test_page_widget.dart @@ -1,5 +1,6 @@ import 'package:counter/impl/screen/test_page_widget_model.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; /// Widget for demo. diff --git a/packages/elementary/example/lib/impl/screen/test_page_widget_model.dart b/packages/elementary/example/lib/impl/screen/test_page_widget_model.dart index 5bb3fbfe..37679734 100644 --- a/packages/elementary/example/lib/impl/screen/test_page_widget_model.dart +++ b/packages/elementary/example/lib/impl/screen/test_page_widget_model.dart @@ -4,6 +4,8 @@ import 'package:counter/impl/screen/test_page_model.dart'; import 'package:counter/impl/screen/test_page_widget.dart'; import 'package:counter/main.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -17,7 +19,7 @@ TestPageWidgetModel testPageWidgetModelFactory(BuildContext context) { class TestPageWidgetModel extends WidgetModel implements ITestPageWidgetModel { @override - ListenableState> get valueState => _valueController; + ValueListenable> get valueState => _valueController; late EntityStateNotifier _valueController; @@ -47,8 +49,8 @@ class TestPageWidgetModel extends WidgetModel } } -abstract class ITestPageWidgetModel extends IWidgetModel { - ListenableState> get valueState; +abstract interface class ITestPageWidgetModel implements IWidgetModel { + ValueListenable> get valueState; Future increment(); } diff --git a/packages/elementary/example/pubspec.yaml b/packages/elementary/example/pubspec.yaml index 3586a8f7..3a21905b 100644 --- a/packages/elementary/example/pubspec.yaml +++ b/packages/elementary/example/pubspec.yaml @@ -4,18 +4,20 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: elementary: path: ../ + elementary_helper: + path: ../../elementary_helper flutter: sdk: flutter provider: ^6.0.2 dev_dependencies: - mjk_lint_rules: ^1.0.1 + mjk_lint_rules: ^2.0.0 flutter: uses-material-design: true diff --git a/packages/elementary/lib/elementary.dart b/packages/elementary/lib/elementary.dart index 8322ef14..c5c5c229 100644 --- a/packages/elementary/lib/elementary.dart +++ b/packages/elementary/lib/elementary.dart @@ -3,12 +3,4 @@ library elementary; export 'package:elementary/src/core.dart' hide Elementary; export 'package:elementary/src/error/error_handler.dart'; export 'package:elementary/src/keep_alive/automatic_keep_alive_widget_model_mixin.dart'; -export 'package:elementary/src/relations/builder/multi_sources/double_source_builder.dart'; -export 'package:elementary/src/relations/builder/multi_sources/double_value_listenable_builder.dart'; -export 'package:elementary/src/relations/builder/multi_sources/multi_listener_rebuilder.dart'; -export 'package:elementary/src/relations/builder/multi_sources/triple_source_builder.dart'; -export 'package:elementary/src/relations/builder/multi_sources/triple_value_listenable_builder.dart'; -export 'package:elementary/src/relations/builder/state_notifier_builder.dart'; -export 'package:elementary/src/relations/notifier/state_notifier.dart'; export 'package:elementary/src/ticker/ticker_providers.dart'; -export 'package:elementary/src/wrappers/theme_wrapper.dart'; diff --git a/packages/elementary/lib/src/core.dart b/packages/elementary/lib/src/core.dart index 61f54b10..36d3df54 100644 --- a/packages/elementary/lib/src/core.dart +++ b/packages/elementary/lib/src/core.dart @@ -2,63 +2,303 @@ import 'package:elementary/elementary.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -/// Factory function for creating Widget Model. +/// Type for a factory function that is used to create +/// an instance of [WidgetModel]. +/// +/// ## The part of Elementary Lifecycle +/// The [WidgetModel] instance is created for the [ElementaryWidget] when it +/// instantiate into the tree. Only in this moment the factory is called once(*) +/// to get the instance of the [WidgetModel] and associate it with +/// the [Elementary]. After this the [WidgetModel] will alive while +/// the [Elementary] is alive. If [Elementary] updates the widget associated +/// with it, the [WidgetModel] will not be recreated and continue work with +/// the same state that has before the update. But the [WidgetModel] will be +/// notified about the update by calling the method +/// [WidgetModel.didUpdateWidget]. All needed state adjustments can be +/// handle inside this method. +/// +/// (*) Once per insert into the tree. As all other widgets, an instance of +/// [ElementaryWidget] can be inserted many times. Every time the element and +/// separate [WidgetModel] will be created for manage different state for every +/// concrete inserts. +/// +/// ## Examples +/// {@tool snippet} +/// +/// The following is a an example for the top-level factory function +/// that creates dependencies right on the spot. +/// +/// ```dart +/// ExampleWidgetModel exampleWidgetModelFactory(BuildContext context) { +/// final modelDependency = ModelDependency(); +/// final exampleModel = ExampleModel(modelDependency); +/// return ExampleWidgetModel(exampleModel); +/// } +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// +/// The following is a an example for the top-level factory function +/// that creates dependencies using one of the DI containers. +/// +/// ```dart +/// ExampleWidgetModel exampleWidgetModelFactory(BuildContext context) { +/// final exampleModel = ContainerInstance.createExampleModel(); +/// return ExampleWidgetModel(exampleModel); +/// } +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// +/// The following is a an example for the top-level factory function +/// that get dependencies using passed BuildContext. +/// +/// ```dart +/// ExampleWidgetModel exampleWidgetModelFactory(BuildContext context) { +/// final modelDependency = ModelDependency(); +/// final exampleModel = ExampleModel(modelDependency); +/// final widgetModelAnotherDependency = SomeWidget.of(context).getSomething; +/// return ExampleWidgetModel(exampleModel, widgetModelAnotherDependency); +/// } +/// ``` +/// {@end-tool} typedef WidgetModelFactory = T Function( BuildContext context, ); -/// Base interface for all Widget Model. -abstract class IWidgetModel {} - -/// A widget that use WidgetModel for build. +/// A basic interface for every [WidgetModel]. +/// +/// The general approach for the [WidgetModel] is implement interface that +/// expanded from [IWidgetModel]. This expanded interface describes the contract +/// which the inheritor of the [WidgetModel] implemented this interface +/// is providing for the [ElementaryWidget]. The contract includes all +/// properties and methods which the [ElementaryWidget] can use for build a +/// part of the tree it describes. +/// +/// {@tool snippet} +/// +/// The following is a an example for the top-level factory function +/// that get dependencies using passed BuildContext. +/// +/// ```dart +/// abstract interface class IExampleWidgetModel implements IWidgetModel { +/// ListenableState get somePublisher; +/// Stream get anotherPublisher; +/// Color get justProperty; +/// +/// Future doSomething(); +/// Future anotherOptionOfInteract(); +/// } +/// ``` +/// {@end-tool} +abstract interface class IWidgetModel {} + +/// A widget that uses state of [WidgetModel] properties to +/// build a part of the user interface described by this widget. +/// +/// For inheritors of this widget is common to be parameterized by +/// the interface expanded from [IWidgetModel] that provides all special +/// information which needed for this widget for correctly describe the subtree. +/// +/// Only one thing should be implemented in inheritors of this widget is a +/// build method. Build method in this case is pure function which gets the +/// [WidgetModel] as argument and based on this [WidgetModel] returns +/// the [Widget]. There isn't additional interactions with anything external, +/// everything needed for describe should be provided by [WidgetModel]. +/// +/// {@tool snippet} +/// +/// The following widget shows a default example of Flutter app, which created +/// with a new Flutter project. +/// +/// ```dart +/// class ExampleWidget extends ElementaryWidget { +/// const ExampleWidget({ +/// Key? key, +/// WidgetModelFactory wmFactory = exampleWidgetModelFactory, +/// }) : super(wmFactory, key: key); +/// +/// @override +/// Widget build(IExampleWidgetModel wm) { +/// return Scaffold( +/// appBar: AppBar( +/// title: const Text('Test'), +/// ), +/// body: Center( +/// child: Column( +/// mainAxisAlignment: MainAxisAlignment.center, +/// children: [ +/// const Text('You have pushed the button this many times:'), +/// ValueListenableBuilder( +/// valueListenable: wm.pressCountPublisher, +/// builder: (_, value, __) { +/// return Text(value.toString()); +/// }, +/// ), +/// ], +/// ), +/// ), +/// floatingActionButton: FloatingActionButton( +/// onPressed: wm.increment, +/// tooltip: 'Increment', +/// child: const Icon(Icons.add), +/// ), +/// ); +/// } +/// } +/// ``` +/// {@end-tool} /// -/// You must provide [wmFactory] factory function to the constructor -/// to instantiate WidgetModel. For testing, you can replace -/// this function for returning mock. +/// ## wmFactory +/// An instance of the [WidgetModelFactory] must be provided to the widget +/// constructor as [wmFactory] property. This is required to create +/// the [WidgetModel] instance for this widget. +/// You can use additional factories for different purpose. For example create +/// a special one that returns a mock [WidgetModel] for the tests. +/// +/// ## The part of Elementary Lifecycle +/// This widget is a starting and updating configuration for the [WidgetModel]. +/// More details about using it while life cycle see in the methods docs of the +/// [WidgetModel]. +/// +/// ## Internal details +/// This widget doesn't have its own [RenderObject], and just describes a part +/// of the user interface using other widgets. It is a common approach for the +/// widgets those inflate to [ComponentElement]. +/// +/// See also: [StatelessWidget], [StatefulWidget], [InheritedWidget]. abstract class ElementaryWidget extends Widget { - /// Factory-function for creating WidgetModel + /// The factory function used to create a [WidgetModel]. final WidgetModelFactory wmFactory; - /// Create an instance of ElementaryWidget. + /// Creates an instance of ElementaryWidget. const ElementaryWidget( this.wmFactory, { Key? key, }) : super(key: key); - /// Creates a [Elementary] to manage this widget's location - /// in the tree. + /// Creates a [Elementary] to manage this widget's location in the tree. /// /// It is uncommon for subclasses to override this method. @override - Element createElement() { + Elementary createElement() { return Elementary(this); } - /// Describes the part of the user interface represented by this widget. + /// Describes the part of the user interface represented by this widget, + /// based on the state of the [WidgetModel] passed to the [wm] argument. /// - /// You can use all properties and methods provided by Widget Model. - /// You should not use [BuildContext] or something else, all you need - /// must contains in Widget Model. + /// There is no access to the [BuildContext] in this method, + /// because all needed in this method should be provided by + /// [WidgetModel] which has direct access to the [BuildContext]. + /// It is uncommon to use [BuildContext] here, possibly in this case you need + /// to improve implementation of the [WidgetModel]. + /// But [BuildContext] CAN be used in all builder functions and all widgets + /// used here. Widget build(I wm); } -/// Entity that contains all presentation logic of the widget. +/// The basic implementation of the entity responsible for all +/// presentation logic, providing properties and data for the widget, +/// and keep relations with the business logic. Business logic represented in +/// the form of [ElementaryModel]. +/// +/// [WidgetModel] is a working horse of the Elementary library. It unites the +/// trio of 'widget - widget model - model'. So the inheritors of [WidgetModel] +/// parameterized by an inheritor of the ElementaryWidget and an inheritor +/// of the ElementaryModel. This mean that this WidgetModel subclass encapsulate +/// all required logic for the concrete ElementaryWidget subclass that +/// mentioned as parameter and only for it. Also this WidgetModel subclass uses +/// exactly the mentioned ElementaryModel subclass as an available contract of +/// business logic. +/// +/// It is common for inheritors to implement the expanded from [IWidgetModel] +/// interface that describes special contract for the relevant +/// [ElementaryWidget] subclass. Moreover using the contract is preferable way +/// because this interface explicitly shows available properties and methods +/// for declarative part (for ElementaryWidget). +/// +/// ## Approach to update +/// It is a rare case when [ElementaryWidget] completely rebuild. The most +/// common case is a partial rebuild of UI parts. In order to get this, using +/// publishers can be helpful. Declare any publishers which you prefer and +/// update their values in suitable conditions. In the declarative part just +/// use these publishers for describe parts of the UI, which depends on them. +/// Here is a far from complete list of options for use as publishers: +/// [Stream], [ChangeNotifier], StateNotifier, EntityStateNotifier. +/// +/// ## The part of Elementary Lifecycle +/// Base class contains all internal mechanisms and process that need to +/// guarantee the conceived behavior for the Elementary library. +/// +/// [initWidgetModel] is called only once for lifecycle +/// of the [WidgetModel] in the really beginning before the first build. +/// It can be used for initiate a starting state of the [WidgetModel]. +/// +/// [didUpdateWidget] called whenever widget instance in the tree has been +/// updated. Common case where rebuild comes from the top. This method is a good +/// place for update state of the [WidgetModel] based on the new configuration +/// of widget. When this method is called is just a signal for decide what +/// exactly should be updated or rebuilt. The fact of update doesn't mean that +/// build method of the widget will be called. Set new values to publishers +/// for rebuild concrete parts of the UI. +/// +/// [didChangeDependencies] called whenever dependencies which [WidgetModel] +/// subscribed with [BuildContext] change. +/// When this method is called is just a signal for decide what +/// exactly should be updated or rebuilt. The fact of the call doesn't mean that +/// build method of the widget will be called. Set new values to publishers +/// for rebuild concrete parts of the UI. +/// +/// [deactivate] called when the [WidgetModel] with [Elementary] removed from +/// the tree. +/// +/// [activate] called when [WidgetModel] with [Elementary] are reinserted into +/// the tree after having been removed via [deactivate]. +/// +/// [dispose] called when [WidgetModel] is going to be permanently destroyed. +/// +/// [reassemble] called whenever the application is reassembled during +/// debugging, for example during the hot reload. +/// +/// [onErrorHandle] called when the [ElementaryModel] handle error with the +/// [ElementaryModel.handleError] method. Can be useful for general handling +/// errors such as showing snack-bars. abstract class WidgetModel with Diagnosticable implements IWidgetModel { final M _model; - /// [ElementaryModel] for this WidgetModel. - /// Only one of business-logic dependencies, that WidgetModel needs. + /// Instance of [ElementaryModel] for this [WidgetModel]. + /// + /// The only business logic dependency that is needed for the [WidgetModel]. @protected @visibleForTesting M get model => _model; - /// Widget that use WidgetModel for build. + /// Widget that uses this [WidgetModel] for building part of the user interface. + /// + /// The [WidgetModel] has an associated [ElementaryWidget]. + /// This relation is managed by [Elementary], and in every time of lifecycle + /// in this property is an actual widget. Before the first update this field + /// contains a widget that created this [WidgetModel]. This instance can be + /// changed during the lifecycle, and [didUpdateWidget] will be called each + /// time it is changed. @protected @visibleForTesting W get widget => _widget!; - /// A handle to the location of a WidgetModel in the tree. + /// The location in the tree where this widget builds. + /// + /// The [WidgetModel] will be associated with the [BuildContext] by + /// [Elementary] after creating and before calling [initWidgetModel]. + /// The association is permanent: the [WidgetModel] object will never + /// change its [BuildContext]. However, the [BuildContext] itself can be + /// moved around the tree. + /// + /// After calling [dispose] the association between the [WidgetModel] and + /// the [BuildContext] will be broken. @protected @visibleForTesting BuildContext get context { @@ -71,18 +311,21 @@ abstract class WidgetModel _element != null; - Elementary? _element; + BuildContext? _element; W? _widget; - /// Create an instance of WidgetModel. + /// Creates an instance of the [WidgetModel]. WidgetModel(this._model); - /// Called at first build for initialization of this Widget Model. + /// Called while the first build for initialization of this [WidgetModel]. + /// + /// This method is called only ones for the instance of [WidgetModel] + /// during its lifecycle. @protected @mustCallSuper @visibleForTesting @@ -92,33 +335,30 @@ abstract class WidgetModel super.widget as ElementaryWidget; @@ -293,16 +534,22 @@ class Elementary extends ComponentElement { } } -/// Class that contains a business logic for Widget. +/// The base class for an entity that contains a business logic required for +/// a specific inheritor of [ElementaryWidget]. +/// +/// You can implement this class freestyle. It may be a bunch of methods, +/// streams or something else. Also it is not a mandatory for business logic +/// to be implemented right inside the class, this model can be proxy for other +/// responsible entities with business logic. /// -/// You can write this freestyle. It may be collection of methods, -/// streams or something else. +/// This class can take [ErrorHandler] as dependency for centralize handling +/// error (for example logging). The [handleError] method can be used for it. +/// When the [handleError] is called passed [ErrorHandler] handles exception. +/// Also the [WidgetModel] is notified about this exception with +/// [WidgetModel.onErrorHandle] method. +/// +/// ## The part of Elementary Lifecycle /// -/// This class can take [ErrorHandler] for handling caught error -/// like a logging or something else. This realize by using -/// [handleError] method. This method also notifies the Widget Model about the -/// error that has occurred. You can use onErrorHandle method of Widget Model -/// to handle on UI like show snackbar or something else. abstract class ElementaryModel { final ErrorHandler? _errorHandler; void Function(Object)? _wmHandler; @@ -310,8 +557,8 @@ abstract class ElementaryModel { /// Create an instance of ElementaryModel. ElementaryModel({ErrorHandler? errorHandler}) : _errorHandler = errorHandler; - /// Should be used for report error Error Handler if it was set and notify - /// Widget Model about error. + /// Can be used for send [error] to [ErrorHandler] if it defined and notify + /// [WidgetModel]. @protected @mustCallSuper @visibleForTesting @@ -320,36 +567,41 @@ abstract class ElementaryModel { _wmHandler?.call(error); } - /// Method for initialize this Model. + /// Initializes [ElementaryModel]. /// - /// Will be call at first build when Widget Model created. + /// Called once before the first build of the [ElementaryWidget]. void init() {} - /// Called when Widget Model disposing. + /// Prepares the [ElementaryModel] to be completely destroyed. + /// + /// Called once when [Elementary] going to be destroyed. Should be used for + /// clearing links, subscriptions, and preparation to be garbage collected. void dispose() {} /// Method for setup ElementaryModel for testing. /// This method can be used to WidgetModels error handler. @visibleForTesting // ignore: use_setters_to_change_properties - void setupWmHandler(Function(Object)? function) { + void setupWmHandler(void Function(Object)? function) { _wmHandler = function; } } -/// Mock that helps to prevent [NoSuchMethodError] exception when we mock ElementaryModel +/// Mock that helps to prevent [NoSuchMethodError] exception when the +/// ElementaryModel is mocked. @visibleForTesting mixin MockElementaryModelMixin implements ElementaryModel { @override - set _wmHandler(Function(Object)? _) {} + set _wmHandler(void Function(Object)? _) {} } -/// Mock that helps to prevent [NoSuchMethodError] exception when we mock WidgetModel +/// Mock that helps to prevent [NoSuchMethodError] exception when the +/// WidgetModel is mocked. @visibleForTesting mixin MockWidgetModelMixin implements WidgetModel { @override - set _element(Elementary? _) {} + set _element(BuildContext? _) {} @override set _widget(W? _) {} diff --git a/packages/elementary/lib/src/error/error_handler.dart b/packages/elementary/lib/src/error/error_handler.dart index bd41189a..c6e2bc37 100644 --- a/packages/elementary/lib/src/error/error_handler.dart +++ b/packages/elementary/lib/src/error/error_handler.dart @@ -1,8 +1,23 @@ +import 'package:flutter/foundation.dart'; + /// Interface for handle error in business logic. /// It may be something like write log or else. /// -/// !!! This not for Presentation Layer handling. -abstract class ErrorHandler { +/// !!! This is not meant to be used in the presentation layer for handling +/// errors. +abstract interface class ErrorHandler { /// This method have to handle of passed error and optional [StackTrace]. void handleError(Object error, {StackTrace? stackTrace}); } + +/// The simplest error handler that just prints error to the console in +/// debug mode. +class DefaultDebugErrorHandler implements ErrorHandler { + @override + void handleError(Object error, {StackTrace? stackTrace}) { + debugPrint(error.toString()); + if (stackTrace != null) { + debugPrintStack(stackTrace: stackTrace); + } + } +} diff --git a/packages/elementary/lib/src/relations/builder/state_notifier_builder.dart b/packages/elementary/lib/src/relations/builder/state_notifier_builder.dart deleted file mode 100644 index c7bc66b5..00000000 --- a/packages/elementary/lib/src/relations/builder/state_notifier_builder.dart +++ /dev/null @@ -1,130 +0,0 @@ -import 'package:elementary/src/relations/notifier/state_notifier.dart'; -import 'package:flutter/material.dart'; - -/// Builder for presentation ui part by [StateNotifier] property. -class StateNotifierBuilder extends StatefulWidget { - /// State that used to detect change and rebuild. - final ListenableState listenableState; - - /// Function that used to describe the part of the user interface - /// represented by this widget. - final Widget Function(BuildContext context, T? value) builder; - - /// Create an instance of StateNotifierBuilder. - const StateNotifierBuilder({ - Key? key, - required this.listenableState, - required this.builder, - }) : super(key: key); - - @override - StateNotifierBuilderState createState() => StateNotifierBuilderState(); -} - -/// State for the [StateNotifierBuilder]. -class StateNotifierBuilderState extends State> { - /// Value defining the state. - T? value; - - @override - void initState() { - super.initState(); - value = widget.listenableState.value; - widget.listenableState.addListener(_valueChanged); - } - - @override - void didUpdateWidget(StateNotifierBuilder oldWidget) { - if (oldWidget.listenableState != widget.listenableState) { - oldWidget.listenableState.removeListener(_valueChanged); - value = widget.listenableState.value; - widget.listenableState.addListener(_valueChanged); - } - super.didUpdateWidget(oldWidget); - } - - @override - void dispose() { - widget.listenableState.removeListener(_valueChanged); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return widget.builder(context, value); - } - - void _valueChanged() { - setState(() { - value = widget.listenableState.value; - }); - } -} - -/// Builder for presentation ui part by [EntityStateNotifier] property. -class EntityStateNotifierBuilder extends StatelessWidget { - /// State that used to detect change and rebuild. - final ListenableState> listenableEntityState; - - /// Builder that used to describe user interface when get data. - final DataWidgetBuilder builder; - - /// Builder that used to describe user interface when loading. - final LoadingWidgetBuilder? loadingBuilder; - - /// Builder that used to describe user interface when get error. - final ErrorWidgetBuilder? errorBuilder; - - /// Create an instance of EntityStateNotifierBuilder. - const EntityStateNotifierBuilder({ - Key? key, - required this.listenableEntityState, - required this.builder, - this.loadingBuilder, - this.errorBuilder, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return StateNotifierBuilder>( - listenableState: listenableEntityState, - builder: (ctx, state) { - final entity = state!; - - final eBuilder = errorBuilder; - if (entity.hasError && eBuilder != null) { - return eBuilder(ctx, entity.error, entity.data); - } - - final lBuilder = loadingBuilder; - if (entity.isLoading && lBuilder != null) { - return lBuilder(ctx, entity.data); - } - - return builder(ctx, entity.data); - }, - ); - } -} - -/// Builder function for loading state. -/// See also: -/// [EntityState] - State of some logical entity. -typedef LoadingWidgetBuilder = Widget Function( - BuildContext context, - T? data, -); - -/// Builder function for content state. -/// See also: -/// [EntityState] - State of some logical entity. -typedef DataWidgetBuilder = Widget Function(BuildContext context, T? data); - -/// Builder function for error state. -/// See also: -/// [EntityState] - State of some logical entity. -typedef ErrorWidgetBuilder = Widget Function( - BuildContext context, - Exception? e, - T? data, -); diff --git a/packages/elementary/lib/src/relations/notifier/state_notifier.dart b/packages/elementary/lib/src/relations/notifier/state_notifier.dart deleted file mode 100644 index 4b027b42..00000000 --- a/packages/elementary/lib/src/relations/notifier/state_notifier.dart +++ /dev/null @@ -1,102 +0,0 @@ -import 'package:flutter/material.dart'; - -/// Source of some listenable property. -/// -/// You can set initial value by pass initValue to constructor. -class StateNotifier extends ChangeNotifier implements ListenableState { - @override - T? get value => _value; - - T? _value; - - /// Create an instance of StateNotifier. - StateNotifier({T? initValue}) : _value = initValue; - - @override - void addListener(VoidCallback listener) { - super.addListener(listener); - - listener.call(); - } - - /// Accept new value. - void accept(T? newValue) { - if (_value == newValue) return; - - _value = newValue; - notifyListeners(); - } -} - -/// An interface that can be listened and return current value. -abstract class ListenableState extends Listenable { - /// Return current state - T? get value; -} - -/// Change notifier with value that presented by [EntityState]. -/// -/// Empty initial value create empty EntityState for initial value. -class EntityStateNotifier extends StateNotifier> { - /// Create an instance of EntityStateNotifier. - EntityStateNotifier([EntityState? initialData]) - : super(initValue: initialData ?? EntityState()); - - /// Constructor for easy set initial value. - EntityStateNotifier.value(T initialData) - : super( - initValue: EntityState(data: initialData), - ); - - /// Accept state with content. - void content(T data) => super.accept(EntityState.content(data)); - - /// Accept state with error. - void error([Exception? exception, T? data]) => - super.accept(EntityState.error(exception, data)); - - /// Accept loading state. - void loading([T? previousData]) => - super.accept(EntityState.loading(previousData)); -} - -/// State of some logical entity. -class EntityState { - /// Data of entity. - final T? data; - - /// State is loading. - final bool isLoading; - - /// State has error. - final bool hasError; - - /// Exception from state. - final Exception? error; - - /// Create an instance of EntityState. - const EntityState({ - this.data, - this.isLoading = false, - this.hasError = false, - this.error, - }) : assert(error == null || hasError), - assert(!hasError && !isLoading || hasError != isLoading); - - /// Loading constructor - const EntityState.loading([this.data]) - : isLoading = true, - hasError = false, - error = null; - - /// Error constructor - const EntityState.error([this.error, this.data]) - : isLoading = false, - hasError = true; - - /// Content constructor - const EntityState.content(this.data) - : isLoading = false, - hasError = false, - error = null; -} diff --git a/packages/elementary/pubspec.yaml b/packages/elementary/pubspec.yaml index 79bf2f9b..e40d087a 100644 --- a/packages/elementary/pubspec.yaml +++ b/packages/elementary/pubspec.yaml @@ -1,13 +1,13 @@ name: elementary description: This is architecture library with the main goal to split code between different responsibility layers, make code clear, simple, readable and easy testable. -version: 2.0.0 +version: 3.0.0 repository: "https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary" issue_tracker: "https://github.com/Elementary-team/flutter-elementary/issues" homepage: "https://github.com/Elementary-team/flutter-elementary" environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.17.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: @@ -18,8 +18,8 @@ dev_dependencies: flutter_test: sdk: flutter - mocktail: ^0.3.0 - mjk_lint_rules: ^1.0.1 + mocktail: ^1.0.0 + mjk_lint_rules: ^2.0.0 flutter: uses-material-design: true \ No newline at end of file diff --git a/packages/elementary/test/automatic_keep_alive_widget_model_mixin/automatic_keep_alive_widget_model_mixin_test.dart b/packages/elementary/test/automatic_keep_alive_widget_model_mixin/automatic_keep_alive_widget_model_mixin_test.dart index 875f787a..af6dab53 100644 --- a/packages/elementary/test/automatic_keep_alive_widget_model_mixin/automatic_keep_alive_widget_model_mixin_test.dart +++ b/packages/elementary/test/automatic_keep_alive_widget_model_mixin/automatic_keep_alive_widget_model_mixin_test.dart @@ -257,7 +257,7 @@ void main() { ); } -class IElementaryWidgetModelTest extends IWidgetModel {} +class IElementaryWidgetModelTest implements IWidgetModel {} class TestWidgetModel extends WidgetModel diff --git a/packages/elementary/test/core/elementary_test.dart b/packages/elementary/test/core/elementary_test.dart index 10171f53..677a2ffb 100644 --- a/packages/elementary/test/core/elementary_test.dart +++ b/packages/elementary/test/core/elementary_test.dart @@ -163,8 +163,8 @@ void main() { widget, ], ), - Row( - key: const ValueKey('secondRow'), + const Row( + key: ValueKey('secondRow'), ), ], ), @@ -174,8 +174,8 @@ void main() { MaterialApp( home: Column( children: [ - Row( - key: const ValueKey('firstRow'), + const Row( + key: ValueKey('firstRow'), ), Row( key: const ValueKey('secondRow'), @@ -303,7 +303,7 @@ class ElementaryWidgetTest } } -class IElementaryWidgetModelMock extends IWidgetModel {} +class IElementaryWidgetModelMock implements IWidgetModel {} class ElementaryWidgetModelMock extends DiagnosticableMock with MockWidgetModelMixin diff --git a/packages/elementary/test/core/widget_model_test.dart b/packages/elementary/test/core/widget_model_test.dart index c8e8deba..3225ca09 100644 --- a/packages/elementary/test/core/widget_model_test.dart +++ b/packages/elementary/test/core/widget_model_test.dart @@ -199,7 +199,7 @@ class ElementaryWidgetTest } } -class IElementaryWidgetModelTest extends IWidgetModel {} +class IElementaryWidgetModelTest implements IWidgetModel {} class ElementaryWidgetModelTest extends WidgetModel diff --git a/packages/elementary/test/error/error_handler_test.dart b/packages/elementary/test/error/error_handler_test.dart new file mode 100644 index 00000000..7b7d94a4 --- /dev/null +++ b/packages/elementary/test/error/error_handler_test.dart @@ -0,0 +1,37 @@ +import 'package:elementary/elementary.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +/// Tests for [DefaultDebugErrorHandler]. +void main() { + late DefaultDebugErrorHandler debugErrorHandler; + late MockDebugPrintCallback callback; + + setUp(() { + debugErrorHandler = DefaultDebugErrorHandler(); + callback = MockDebugPrintCallback(); + debugPrint = callback.call; + }); + + test('Call handing error should not throw exception', () { + expect( + () => debugErrorHandler.handleError( + Exception('test'), + stackTrace: StackTrace.empty, + ), + returnsNormally, + ); + }); + + test('Call handing error should print debug', () { + final exception = Exception('test'); + debugErrorHandler.handleError(exception); + + verify(() => callback.call(exception.toString())).called(1); + }); +} + +class MockDebugPrintCallback extends Mock { + void call(String? message, {int? wrapWidth}); +} diff --git a/packages/elementary/test/relations/notifier/entity_state_test.dart b/packages/elementary/test/relations/notifier/entity_state_test.dart deleted file mode 100644 index 2527f277..00000000 --- a/packages/elementary/test/relations/notifier/entity_state_test.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'package:elementary/elementary.dart'; -import 'package:flutter_test/flutter_test.dart'; - -/// Tests for [EntityState]. -void main() { - test('Data should be equal to init data', () { - const data = 1; - const state = EntityState(data: data); - expect(state.data, equals(data)); - }); - - test('Error should be equal to init error', () { - final error = Exception('test'); - final state = EntityState(error: error, hasError: true); - expect(state.error, equals(error)); - }); - - test('Has error should be equal to init has error', () { - const state = EntityState(hasError: true); - expect(state.hasError, isTrue); - }); - - test('Loading should be equal to init loading', () { - const state = EntityState(isLoading: true); - expect(state.isLoading, isTrue); - }); - - test('Data should be equal to init data', () { - const state = EntityState(data: 1); - expect(state.data, 1); - }); - - test('Data should be null if not init', () { - const state = EntityState(); - expect(state.data, isNull); - }); - - test('Error should be null if not init', () { - const state = EntityState(); - expect(state.error, isNull); - }); - - test('Loading should be false if not init', () { - const state = EntityState(); - expect(state.isLoading, isFalse); - }); - - test('Has error should be false if not init', () { - const state = EntityState(); - expect(state.hasError, isFalse); - }); - - test('Error without hasError should throw assert exception', () { - final error = Exception('test'); - expect(() => EntityState(error: error), throwsAssertionError); - }); - - test('Loading and Error in same time should throw assert exception', () { - expect( - () => EntityState(hasError: true, isLoading: true), - throwsAssertionError, - ); - }); - - test('Loading constructor should create correct entity', () { - const state = EntityState.loading(); - expect(state.isLoading, isTrue); - expect(state.hasError, isFalse); - expect(state.error, isNull); - }); - - test('Error constructor should create correct entity', () { - const state = EntityState.error(); - expect(state.isLoading, isFalse); - expect(state.hasError, isTrue); - }); - - test('Content constructor should create correct entity', () { - const state = EntityState.content(1); - expect(state.isLoading, isFalse); - expect(state.hasError, isFalse); - expect(state.data, 1); - }); -} diff --git a/packages/elementary/test/ticker_providers/single_ticker_provider_widget_model_mixin_test.dart b/packages/elementary/test/ticker_providers/single_ticker_provider_widget_model_mixin_test.dart index 8be1be10..db3055f1 100644 --- a/packages/elementary/test/ticker_providers/single_ticker_provider_widget_model_mixin_test.dart +++ b/packages/elementary/test/ticker_providers/single_ticker_provider_widget_model_mixin_test.dart @@ -129,7 +129,7 @@ void main() { ); } -class IElementaryWidgetModelTest extends IWidgetModel {} +class IElementaryWidgetModelTest implements IWidgetModel {} class TestWidgetModel extends WidgetModel diff --git a/packages/elementary/test/ticker_providers/ticker_provider_widget_model_mixin_test.dart b/packages/elementary/test/ticker_providers/ticker_provider_widget_model_mixin_test.dart index 004a7f12..1cadf484 100644 --- a/packages/elementary/test/ticker_providers/ticker_provider_widget_model_mixin_test.dart +++ b/packages/elementary/test/ticker_providers/ticker_provider_widget_model_mixin_test.dart @@ -96,7 +96,7 @@ void main() { ); } -class IElementaryWidgetModelTest extends IWidgetModel {} +class IElementaryWidgetModelTest implements IWidgetModel {} class TestWidgetModel extends WidgetModel diff --git a/packages/elementary_helper/.gitignore b/packages/elementary_helper/.gitignore new file mode 100644 index 00000000..761d64cb --- /dev/null +++ b/packages/elementary_helper/.gitignore @@ -0,0 +1,78 @@ +# Miscellaneous +*.class +*.lock +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.classpath +.project +.settings/ +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.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/flutter_export_environment.sh +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Coverage +coverage/ + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 diff --git a/packages/elementary_helper/CHANGELOG.md b/packages/elementary_helper/CHANGELOG.md new file mode 100644 index 00000000..010d54cd --- /dev/null +++ b/packages/elementary_helper/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +## Unreleased + +## 1.0.1 +### Changed +* documentation improvement; + +## 1.0.0 +### Added +* implementations have been moved from the main package; \ No newline at end of file diff --git a/packages/elementary_helper/LICENSE b/packages/elementary_helper/LICENSE new file mode 100644 index 00000000..65004d32 --- /dev/null +++ b/packages/elementary_helper/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Mikhail Zotyev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/elementary_helper/README.md b/packages/elementary_helper/README.md new file mode 100644 index 00000000..769dc526 --- /dev/null +++ b/packages/elementary_helper/README.md @@ -0,0 +1,245 @@ +# Elementary-helper +### +

+ Elementary Logo +

+ +### + +

+ Owner + Pub Version + Coverage Status + Pub points + Pub Likes + Pub popularity + Contributors + License +

+ +## Description + +To make Elementary easier to use, some helpers have been added. Among them are custom implementations of +the Pub-Sub pattern and wrappers to make easier testable interaction with Flutter from Widget Model + +### StateNotifier + +Behaviour is similar to ValueNotifier, but with no requirement to set initial value. +Due to this the returned value is Nullable. StateNotifier's subscribers are notified whenever a state change occurs. +Also, the subscriber is called first time at the moment of subscription. For emit new value there is a method accept. + +```dart +final _somePropertyWithIntegerValue = StateNotifier(); + +void someFunctionChangeValue() { + // do something, get new value + // ............................................................... + final newValue = 10; + // and then change value of property + _somePropertyWithIntegerValue.accept(10); +} +``` + +### EntityStateNotifier + +Variant of ValueNotifier that uses a special EntityState object as the state value. EntityState has three states: +content, loading, error. All states can contain data, for cases when you want to keep previous values, e.g. pagination. + +```dart +final _countryListState = EntityStateNotifier>(); + +Future _loadCountryList() async { + final previousData = _countryListState.value?.data; + + // set property to loading state and use previous data for this state + _countryListState.loading(previousData); + + try { + // await the result + final res = await model.loadCountries(); + // set property to content state, use new data + _countryListState.content(res); + } on Exception catch (e) { + // set property to error state + _countryListState.error(e, previousData); + } +} +``` + +### StateNotifierBuilder + +The StateNotifierBuilder is a widget that uses a StateNotifier as its data source. A builder function of the +StateNotifierBuilder must return the widget based on the current value passed. + +```dart +void somewhereInTheBuildFunction() { + // ...... + StateNotifierBuilder( + listenableState: someListenableState, + builder: (ctx, value) { + return Text(value); + }, + ); + // ...... +} +``` + +### EntityStateNotifierBuilder + +The EntityStateNotifierBuilder is a widget that uses a EntityStateNotifier as its data source. +Depending on the state, different builders are called: errorBuilder for error, loadingBuilder for error, +builder for content. + +```dart +@override +Widget build(ICountryListWidgetModel wm) { + return Scaffold( + appBar: AppBar( + title: const Text('Country List'), + ), + body: EntityStateNotifierBuilder>( + listenableEntityState: wm.countryListState, + loadingBuilder: (_, __) => const _LoadingWidget(), + errorBuilder: (_, __, ___) => const _ErrorWidget(), + builder: (_, countries) => + _CountryList( + countries: countries, + nameStyle: wm.countryNameStyle, + ), + ), + ); +} +``` + +### DoubleSourceBuilder +One of the multi-sources builders. It uses two ListenableStates as sources of data. +The builder function is called when any of sources changes. + +```dart +void somewhereInTheBuildFunction() { + // ...... + DoubleSourceBuilder( + firstSource: captionListenableState, + secondSource: captionStyleListenableState, + builder: (ctx, value, style) { + return Text(value, style: style); + }, + ); + // ...... +} +``` + +### DoubleValueListenableBuilder +One of the multi-sources builders. It uses two ValueListenable as sources of data. +The builder function is called when any of sources changes. + +```dart +void somewhereInTheBuildFunction() { + // ...... + DoubleValueListenableBuilder( + firstValue: captionListenableState, + secondValue: captionStyleListenableState, + builder: (ctx, value, style) { + return Text(value, style: style); + }, + ); + // ...... +} +``` + +### TripleSourceBuilder +One of the multi-sources builders. It uses three ListenableStates as sources of data. +The builder function is called when any of sources changes. + +```dart +void somewhereInTheBuildFunction() { + // ...... + TripleSourceBuilder( + firstSource: captionListenableState, + secondSource: valueListenableState, + thirdSource: captionStyleListenableState, + builder: (ctx, title, value, style) { + return Text('$title: ${value ?? 0}', style: style); + }, + ); + // ...... +} +``` + +### TripleValueListenableBuilder +One of the multi-sources builders. It uses three ValueListenable as sources of data. +The builder function is called when any of sources changes. + +```dart +void somewhereInTheBuildFunction() { + // ...... + TripleSourceBuilder( + firstSource: captionListenableState, + secondSource: valueListenableState, + thirdSource: captionStyleListenableState, + builder: (ctx, title, value, style) { + return Text('$title: ${value ?? 0}', style: style); + }, + ); + // ...... +} +``` + +### MultiListenerRebuilder +Widget that rebuild part of the ui when one of Listenable changes. The builder function in this widget has no values, +and you need to get the values directly in function's body. + +```dart +void somewhereInTheBuildFunction() { + // ...... + MultiListenerRebuilder( + listenableList: [ + firstListenable, + secondListenable, + thirdListenable, + ], + builder: (ctx) { + final title = firstListenable.value; + final value = secondListenable.value; + final style = thirdListenable.value; + return Text('$title: ${value ?? 0}', style: style); + }, + ); + // ...... +} +``` + +## Maintainer + + +
+ Maintainer avatar +

Mikhail Zotyev

+
+
+ +## Contributors thanks + +Big thanks to all these people, who put their effort to help the project. + +![contributors](https://contributors-img.firebaseapp.com/image?repo=Elementary-team/flutter-elementary) + + +Special thanks to: + +[Dmitry Krutskikh](https://github.com/dkrutskikh), [Konoshenko Vlad](https://github.com/vlkonoshenko), +[Denis Grafov](https://github.com/grafovdenis) for the early adoption and the first production feedback; + +[Alex Bukin](https://github.com/AlexeyBukin) for IDE plugins; + +All members of the Surf Flutter Team for actively using and providing feedback. + +## Sponsorship + +Special sponsor of the project: + + +Surf + + +For all questions regarding sponsorship/collaboration connect with [Mikhail Zotyev](https://github.com/MbIXjkee). diff --git a/packages/elementary_helper/analysis_options.yaml b/packages/elementary_helper/analysis_options.yaml new file mode 100644 index 00000000..446c8c3d --- /dev/null +++ b/packages/elementary_helper/analysis_options.yaml @@ -0,0 +1,7 @@ +include: package:mjk_lint_rules/mjk_lint_rules.yaml + +linter: + rules: + always_put_required_named_parameters_first: false + sort_pub_dependencies: false + public_member_api_docs: true \ No newline at end of file diff --git a/packages/elementary_helper/example/.gitignore b/packages/elementary_helper/example/.gitignore new file mode 100644 index 00000000..24476c5d --- /dev/null +++ b/packages/elementary_helper/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/packages/elementary_helper/example/.metadata b/packages/elementary_helper/example/.metadata new file mode 100644 index 00000000..de745e4a --- /dev/null +++ b/packages/elementary_helper/example/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: android + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: ios + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: linux + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: macos + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: web + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: windows + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/elementary_helper/example/README.md b/packages/elementary_helper/example/README.md new file mode 100644 index 00000000..0c47cf9a --- /dev/null +++ b/packages/elementary_helper/example/README.md @@ -0,0 +1,16 @@ +# helper_example + +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://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/packages/elementary_helper/example/analysis_options.yaml b/packages/elementary_helper/example/analysis_options.yaml new file mode 100644 index 00000000..61b6c4de --- /dev/null +++ b/packages/elementary_helper/example/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/packages/elementary_helper/example/android/.gitignore b/packages/elementary_helper/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/packages/elementary_helper/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/packages/elementary_helper/example/android/app/build.gradle b/packages/elementary_helper/example/android/app/build.gradle new file mode 100644 index 00000000..846a9b63 --- /dev/null +++ b/packages/elementary_helper/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + namespace "mjk.elementary.example.helper_example" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + applicationId "mjk.elementary.example.helper_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/packages/elementary_helper/example/android/app/src/debug/AndroidManifest.xml b/packages/elementary_helper/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/elementary_helper/example/android/app/src/main/AndroidManifest.xml b/packages/elementary_helper/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3da1e819 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/android/app/src/main/kotlin/mjk/elementary/example/helper_example/MainActivity.kt b/packages/elementary_helper/example/android/app/src/main/kotlin/mjk/elementary/example/helper_example/MainActivity.kt new file mode 100644 index 00000000..389380ff --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/kotlin/mjk/elementary/example/helper_example/MainActivity.kt @@ -0,0 +1,6 @@ +package mjk.elementary.example.helper_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/packages/elementary_helper/example/android/app/src/main/res/drawable-v21/launch_background.xml b/packages/elementary_helper/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/elementary_helper/example/android/app/src/main/res/drawable/launch_background.xml b/packages/elementary_helper/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/elementary_helper/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/elementary_helper/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..db77bb4b Binary files /dev/null and b/packages/elementary_helper/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/packages/elementary_helper/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/elementary_helper/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..17987b79 Binary files /dev/null and b/packages/elementary_helper/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/packages/elementary_helper/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..09d43914 Binary files /dev/null and b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..d5f1c8d3 Binary files /dev/null and b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..4d6372ee Binary files /dev/null and b/packages/elementary_helper/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/packages/elementary_helper/example/android/app/src/main/res/values-night/styles.xml b/packages/elementary_helper/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/elementary_helper/example/android/app/src/main/res/values/styles.xml b/packages/elementary_helper/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/elementary_helper/example/android/app/src/profile/AndroidManifest.xml b/packages/elementary_helper/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/packages/elementary_helper/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/elementary_helper/example/android/build.gradle b/packages/elementary_helper/example/android/build.gradle new file mode 100644 index 00000000..f7eb7f63 --- /dev/null +++ b/packages/elementary_helper/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/packages/elementary_helper/example/android/gradle.properties b/packages/elementary_helper/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/packages/elementary_helper/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/packages/elementary_helper/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/elementary_helper/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3c472b99 --- /dev/null +++ b/packages/elementary_helper/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/packages/elementary_helper/example/android/settings.gradle b/packages/elementary_helper/example/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/packages/elementary_helper/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/packages/elementary_helper/example/ios/.gitignore b/packages/elementary_helper/example/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/packages/elementary_helper/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/packages/elementary_helper/example/ios/Flutter/AppFrameworkInfo.plist b/packages/elementary_helper/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..9625e105 --- /dev/null +++ b/packages/elementary_helper/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/packages/elementary_helper/example/ios/Flutter/Debug.xcconfig b/packages/elementary_helper/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..592ceee8 --- /dev/null +++ b/packages/elementary_helper/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/packages/elementary_helper/example/ios/Flutter/Release.xcconfig b/packages/elementary_helper/example/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..592ceee8 --- /dev/null +++ b/packages/elementary_helper/example/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/packages/elementary_helper/example/ios/Runner.xcodeproj/project.pbxproj b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..f72c3f9d --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,612 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 4WYG5TTA75; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/elementary_helper/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..e42adcb3 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/elementary_helper/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/elementary_helper/example/ios/Runner/AppDelegate.swift b/packages/elementary_helper/example/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..70693e4a --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..7353c41e Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..6ed2d933 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cd7b009 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..fe730945 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..321773cd Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..502f463a Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..e9f5fea2 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..84ac32ae Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..8953cba0 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..0467bf12 Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/packages/elementary_helper/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/elementary_helper/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/ios/Runner/Base.lproj/Main.storyboard b/packages/elementary_helper/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/ios/Runner/Info.plist b/packages/elementary_helper/example/ios/Runner/Info.plist new file mode 100644 index 00000000..9acd7e79 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Helper Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + helper_example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/packages/elementary_helper/example/ios/Runner/Runner-Bridging-Header.h b/packages/elementary_helper/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/packages/elementary_helper/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/packages/elementary_helper/example/ios/RunnerTests/RunnerTests.swift b/packages/elementary_helper/example/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..86a7c3b1 --- /dev/null +++ b/packages/elementary_helper/example/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/packages/elementary_helper/example/lib/main.dart b/packages/elementary_helper/example/lib/main.dart new file mode 100644 index 00000000..a35451a5 --- /dev/null +++ b/packages/elementary_helper/example/lib/main.dart @@ -0,0 +1,101 @@ +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), + home: const MyHomePage(), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key}); + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + final _counterNotifier = ValueNotifier(0); + final _colorNotifier = ValueNotifier(Colors.red); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: const Text('Helper example'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + DoubleValueListenableBuilder( + firstValue: _counterNotifier, + secondValue: _colorNotifier, + builder: (_, value, color) { + return Text( + '$value', + style: Theme.of(context) + .textTheme + .headlineMedium + ?.copyWith(color: color), + ); + }, + ), + ], + ), + ), + floatingActionButton: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + FloatingActionButton( + onPressed: () { + _counterNotifier.value++; + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + const SizedBox(height: 8), + FloatingActionButton( + onPressed: () { + _colorNotifier.value = Colors.red; + }, + tooltip: 'Change color red', + child: const Icon( + Icons.color_lens_outlined, + color: Colors.red, + ), + ), + const SizedBox(height: 8), + FloatingActionButton( + onPressed: () { + _colorNotifier.value = Colors.green; + }, + tooltip: 'Change color green', + child: const Icon( + Icons.color_lens_outlined, + color: Colors.green, + ), + ), + ], + ), + ); + } +} diff --git a/packages/elementary_helper/example/linux/.gitignore b/packages/elementary_helper/example/linux/.gitignore new file mode 100644 index 00000000..d3896c98 --- /dev/null +++ b/packages/elementary_helper/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/packages/elementary_helper/example/linux/CMakeLists.txt b/packages/elementary_helper/example/linux/CMakeLists.txt new file mode 100644 index 00000000..1b8d90bf --- /dev/null +++ b/packages/elementary_helper/example/linux/CMakeLists.txt @@ -0,0 +1,139 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "helper_example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "mjk.elementary.example.helper_example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/packages/elementary_helper/example/linux/flutter/CMakeLists.txt b/packages/elementary_helper/example/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000..d5bd0164 --- /dev/null +++ b/packages/elementary_helper/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.cc b/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..e71a16d2 --- /dev/null +++ b/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.h b/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..e0f0a47b --- /dev/null +++ b/packages/elementary_helper/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/elementary_helper/example/linux/flutter/generated_plugins.cmake b/packages/elementary_helper/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 00000000..2e1de87a --- /dev/null +++ b/packages/elementary_helper/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/packages/elementary_helper/example/linux/main.cc b/packages/elementary_helper/example/linux/main.cc new file mode 100644 index 00000000..e7c5c543 --- /dev/null +++ b/packages/elementary_helper/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/packages/elementary_helper/example/linux/my_application.cc b/packages/elementary_helper/example/linux/my_application.cc new file mode 100644 index 00000000..79c2ddc5 --- /dev/null +++ b/packages/elementary_helper/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "helper_example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "helper_example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/packages/elementary_helper/example/linux/my_application.h b/packages/elementary_helper/example/linux/my_application.h new file mode 100644 index 00000000..72271d5e --- /dev/null +++ b/packages/elementary_helper/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/packages/elementary_helper/example/macos/.gitignore b/packages/elementary_helper/example/macos/.gitignore new file mode 100644 index 00000000..746adbb6 --- /dev/null +++ b/packages/elementary_helper/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/packages/elementary_helper/example/macos/Flutter/Flutter-Debug.xcconfig b/packages/elementary_helper/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 00000000..c2efd0b6 --- /dev/null +++ b/packages/elementary_helper/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/elementary_helper/example/macos/Flutter/Flutter-Release.xcconfig b/packages/elementary_helper/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 00000000..c2efd0b6 --- /dev/null +++ b/packages/elementary_helper/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/elementary_helper/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/elementary_helper/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..cccf817a --- /dev/null +++ b/packages/elementary_helper/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/packages/elementary_helper/example/macos/Runner.xcodeproj/project.pbxproj b/packages/elementary_helper/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..73b3d63b --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,695 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* helper_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "helper_example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* helper_example.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* helper_example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/helper_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/helper_example"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/helper_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/helper_example"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/helper_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/helper_example"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/packages/elementary_helper/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/elementary_helper/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/elementary_helper/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/elementary_helper/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..037e2a57 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/packages/elementary_helper/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/elementary_helper/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/elementary_helper/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/elementary_helper/example/macos/Runner/AppDelegate.swift b/packages/elementary_helper/example/macos/Runner/AppDelegate.swift new file mode 100644 index 00000000..d53ef643 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..a2ec33f1 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 00000000..82b6f9d9 Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 00000000..13b35eba Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 00000000..0a3f5fa4 Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 00000000..bdb57226 Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 00000000..f083318e Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 00000000..326c0e72 Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 00000000..2f1632cf Binary files /dev/null and b/packages/elementary_helper/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/packages/elementary_helper/example/macos/Runner/Base.lproj/MainMenu.xib b/packages/elementary_helper/example/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..80e867a4 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/macos/Runner/Configs/AppInfo.xcconfig b/packages/elementary_helper/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 00000000..1108464b --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = helper_example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = mjk.elementary.example.helperExample + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2023 mjk.elementary.example. All rights reserved. diff --git a/packages/elementary_helper/example/macos/Runner/Configs/Debug.xcconfig b/packages/elementary_helper/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 00000000..36b0fd94 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/packages/elementary_helper/example/macos/Runner/Configs/Release.xcconfig b/packages/elementary_helper/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 00000000..dff4f495 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/packages/elementary_helper/example/macos/Runner/Configs/Warnings.xcconfig b/packages/elementary_helper/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 00000000..42bcbf47 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/packages/elementary_helper/example/macos/Runner/DebugProfile.entitlements b/packages/elementary_helper/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 00000000..dddb8a30 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/packages/elementary_helper/example/macos/Runner/Info.plist b/packages/elementary_helper/example/macos/Runner/Info.plist new file mode 100644 index 00000000..4789daa6 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/packages/elementary_helper/example/macos/Runner/MainFlutterWindow.swift b/packages/elementary_helper/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 00000000..3cc05eb2 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/packages/elementary_helper/example/macos/Runner/Release.entitlements b/packages/elementary_helper/example/macos/Runner/Release.entitlements new file mode 100644 index 00000000..852fa1a4 --- /dev/null +++ b/packages/elementary_helper/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/packages/elementary_helper/example/macos/RunnerTests/RunnerTests.swift b/packages/elementary_helper/example/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..5418c9f5 --- /dev/null +++ b/packages/elementary_helper/example/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/packages/elementary_helper/example/pubspec.yaml b/packages/elementary_helper/example/pubspec.yaml new file mode 100644 index 00000000..77a7d6ec --- /dev/null +++ b/packages/elementary_helper/example/pubspec.yaml @@ -0,0 +1,20 @@ +name: helper_example +description: A new Flutter project. +publish_to: 'none' + +version: 1.0.0+1 + +environment: + sdk: ">=3.0.0 <4.0.0" + +dependencies: + flutter: + sdk: flutter + elementary_helper: + path: ../ + +dev_dependencies: + mjk_lint_rules: ^2.0.0 + +flutter: + uses-material-design: true \ No newline at end of file diff --git a/packages/elementary_helper/example/test/widget_test.dart b/packages/elementary_helper/example/test/widget_test.dart new file mode 100644 index 00000000..ab73b3a2 --- /dev/null +++ b/packages/elementary_helper/example/test/widget_test.dart @@ -0,0 +1 @@ +void main() {} diff --git a/packages/elementary_helper/example/web/favicon.png b/packages/elementary_helper/example/web/favicon.png new file mode 100644 index 00000000..8aaa46ac Binary files /dev/null and b/packages/elementary_helper/example/web/favicon.png differ diff --git a/packages/elementary_helper/example/web/icons/Icon-192.png b/packages/elementary_helper/example/web/icons/Icon-192.png new file mode 100644 index 00000000..b749bfef Binary files /dev/null and b/packages/elementary_helper/example/web/icons/Icon-192.png differ diff --git a/packages/elementary_helper/example/web/icons/Icon-512.png b/packages/elementary_helper/example/web/icons/Icon-512.png new file mode 100644 index 00000000..88cfd48d Binary files /dev/null and b/packages/elementary_helper/example/web/icons/Icon-512.png differ diff --git a/packages/elementary_helper/example/web/icons/Icon-maskable-192.png b/packages/elementary_helper/example/web/icons/Icon-maskable-192.png new file mode 100644 index 00000000..eb9b4d76 Binary files /dev/null and b/packages/elementary_helper/example/web/icons/Icon-maskable-192.png differ diff --git a/packages/elementary_helper/example/web/icons/Icon-maskable-512.png b/packages/elementary_helper/example/web/icons/Icon-maskable-512.png new file mode 100644 index 00000000..d69c5669 Binary files /dev/null and b/packages/elementary_helper/example/web/icons/Icon-maskable-512.png differ diff --git a/packages/elementary_helper/example/web/index.html b/packages/elementary_helper/example/web/index.html new file mode 100644 index 00000000..f88bd53a --- /dev/null +++ b/packages/elementary_helper/example/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + helper_example + + + + + + + + + + diff --git a/packages/elementary_helper/example/web/manifest.json b/packages/elementary_helper/example/web/manifest.json new file mode 100644 index 00000000..73b1ae67 --- /dev/null +++ b/packages/elementary_helper/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "helper_example", + "short_name": "helper_example", + "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/packages/elementary_helper/example/windows/.gitignore b/packages/elementary_helper/example/windows/.gitignore new file mode 100644 index 00000000..d492d0d9 --- /dev/null +++ b/packages/elementary_helper/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/packages/elementary_helper/example/windows/CMakeLists.txt b/packages/elementary_helper/example/windows/CMakeLists.txt new file mode 100644 index 00000000..295d43bf --- /dev/null +++ b/packages/elementary_helper/example/windows/CMakeLists.txt @@ -0,0 +1,102 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(helper_example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "helper_example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/packages/elementary_helper/example/windows/flutter/CMakeLists.txt b/packages/elementary_helper/example/windows/flutter/CMakeLists.txt new file mode 100644 index 00000000..930d2071 --- /dev/null +++ b/packages/elementary_helper/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.cc b/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..8b6d4680 --- /dev/null +++ b/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.h b/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..dc139d85 --- /dev/null +++ b/packages/elementary_helper/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/packages/elementary_helper/example/windows/flutter/generated_plugins.cmake b/packages/elementary_helper/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 00000000..b93c4c30 --- /dev/null +++ b/packages/elementary_helper/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/packages/elementary_helper/example/windows/runner/CMakeLists.txt b/packages/elementary_helper/example/windows/runner/CMakeLists.txt new file mode 100644 index 00000000..394917c0 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/packages/elementary_helper/example/windows/runner/Runner.rc b/packages/elementary_helper/example/windows/runner/Runner.rc new file mode 100644 index 00000000..a2f905ff --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "mjk.elementary.example" "\0" + VALUE "FileDescription", "helper_example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "helper_example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 mjk.elementary.example. All rights reserved." "\0" + VALUE "OriginalFilename", "helper_example.exe" "\0" + VALUE "ProductName", "helper_example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/packages/elementary_helper/example/windows/runner/flutter_window.cpp b/packages/elementary_helper/example/windows/runner/flutter_window.cpp new file mode 100644 index 00000000..b25e363e --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/flutter_window.cpp @@ -0,0 +1,66 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/packages/elementary_helper/example/windows/runner/flutter_window.h b/packages/elementary_helper/example/windows/runner/flutter_window.h new file mode 100644 index 00000000..6da0652f --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/packages/elementary_helper/example/windows/runner/main.cpp b/packages/elementary_helper/example/windows/runner/main.cpp new file mode 100644 index 00000000..08c27740 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"helper_example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/packages/elementary_helper/example/windows/runner/resource.h b/packages/elementary_helper/example/windows/runner/resource.h new file mode 100644 index 00000000..66a65d1e --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/packages/elementary_helper/example/windows/runner/resources/app_icon.ico b/packages/elementary_helper/example/windows/runner/resources/app_icon.ico new file mode 100644 index 00000000..c04e20ca Binary files /dev/null and b/packages/elementary_helper/example/windows/runner/resources/app_icon.ico differ diff --git a/packages/elementary_helper/example/windows/runner/runner.exe.manifest b/packages/elementary_helper/example/windows/runner/runner.exe.manifest new file mode 100644 index 00000000..a42ea768 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/packages/elementary_helper/example/windows/runner/utils.cpp b/packages/elementary_helper/example/windows/runner/utils.cpp new file mode 100644 index 00000000..b2b08734 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/packages/elementary_helper/example/windows/runner/utils.h b/packages/elementary_helper/example/windows/runner/utils.h new file mode 100644 index 00000000..3879d547 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/packages/elementary_helper/example/windows/runner/win32_window.cpp b/packages/elementary_helper/example/windows/runner/win32_window.cpp new file mode 100644 index 00000000..60608d0f --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/packages/elementary_helper/example/windows/runner/win32_window.h b/packages/elementary_helper/example/windows/runner/win32_window.h new file mode 100644 index 00000000..e901dde6 --- /dev/null +++ b/packages/elementary_helper/example/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/packages/elementary_helper/lib/elementary_helper.dart b/packages/elementary_helper/lib/elementary_helper.dart new file mode 100644 index 00000000..f6eb54a1 --- /dev/null +++ b/packages/elementary_helper/lib/elementary_helper.dart @@ -0,0 +1,12 @@ +library elementary_helper; + +export 'package:elementary_helper/src/relations/builder/entity_state_notifier_builder.dart'; +export 'package:elementary_helper/src/relations/builder/multi_sources/double_source_builder.dart'; +export 'package:elementary_helper/src/relations/builder/multi_sources/double_value_listenable_builder.dart'; +export 'package:elementary_helper/src/relations/builder/multi_sources/multi_listener_rebuilder.dart'; +export 'package:elementary_helper/src/relations/builder/multi_sources/triple_source_builder.dart'; +export 'package:elementary_helper/src/relations/builder/multi_sources/triple_value_listenable_builder.dart'; +export 'package:elementary_helper/src/relations/builder/state_notifier_builder.dart'; +export 'package:elementary_helper/src/relations/notifier/entity_state_notifier.dart'; +export 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; +export 'package:elementary_helper/src/wrappers/theme_wrapper.dart'; diff --git a/packages/elementary_helper/lib/src/relations/builder/entity_state_notifier_builder.dart b/packages/elementary_helper/lib/src/relations/builder/entity_state_notifier_builder.dart new file mode 100644 index 00000000..2de9d8ea --- /dev/null +++ b/packages/elementary_helper/lib/src/relations/builder/entity_state_notifier_builder.dart @@ -0,0 +1,93 @@ +import 'package:elementary_helper/src/relations/notifier/entity_state_notifier.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// A builder that uses [ValueListenable] parameterized by [EntityState] as +/// a source of data. +/// This builder is usually helpful with the [EntityStateNotifier]. +/// +/// This builder supports three possible builder functions: +/// +/// * [errorBuilder] - used when [listenableEntityState] value +/// represents an error state of [EntityState.error]. +/// * [loadingBuilder] - used when [listenableEntityState] value represents +/// a loading state of [EntityState.loading]. +/// * [builder] - the default builder that encompasses the previous two +/// cases when [errorBuilder] and [loadingBuilder] are not set, +/// and is used for the content state of [EntityState]. +class EntityStateNotifierBuilder extends StatelessWidget { + /// Source that used to detect change and rebuild. + final ValueListenable> listenableEntityState; + + /// Default builder that is used for the content state and all other states if + /// no special builders are specified. + final DataWidgetBuilder builder; + + /// Builder that used for the loading state. + /// + /// See also: + /// * [EntityState] + /// * [LoadingEntityState] + final LoadingWidgetBuilder? loadingBuilder; + + /// Builder that used for the error state. + /// + /// See also: + /// * [EntityState] + /// * [LoadingEntityState] + final ErrorWidgetBuilder? errorBuilder; + + /// Creates an instance of [EntityStateNotifierBuilder]. + const EntityStateNotifierBuilder({ + Key? key, + required this.listenableEntityState, + required this.builder, + this.loadingBuilder, + this.errorBuilder, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder>( + valueListenable: listenableEntityState, + builder: (ctx, entity, _) { + final eBuilder = errorBuilder; + if (entity.isErrorState && eBuilder != null) { + return eBuilder(ctx, entity.errorOrNull, entity.data); + } + + final lBuilder = loadingBuilder; + if (entity.isLoadingState && lBuilder != null) { + return lBuilder(ctx, entity.data); + } + + return builder(ctx, entity.data); + }, + ); + } +} + +/// Builder function for loading state. +/// +/// See also: +/// * [EntityState] - State of some logical entity. +typedef LoadingWidgetBuilder = Widget Function( + BuildContext context, + T? data, +); + +/// Builder function for content state. +/// +/// See also: +/// * [EntityState] - State of some logical entity. +typedef DataWidgetBuilder = Widget Function(BuildContext context, T? data); + +/// Builder function for error state. +/// +/// See also: +/// * [EntityState] - State of some logical entity. +typedef ErrorWidgetBuilder = Widget Function( + BuildContext context, + Exception? e, + T? data, +); diff --git a/packages/elementary/lib/src/relations/builder/multi_sources/double_source_builder.dart b/packages/elementary_helper/lib/src/relations/builder/multi_sources/double_source_builder.dart similarity index 78% rename from packages/elementary/lib/src/relations/builder/multi_sources/double_source_builder.dart rename to packages/elementary_helper/lib/src/relations/builder/multi_sources/double_source_builder.dart index 4b54a78a..a3bbea61 100644 --- a/packages/elementary/lib/src/relations/builder/multi_sources/double_source_builder.dart +++ b/packages/elementary_helper/lib/src/relations/builder/multi_sources/double_source_builder.dart @@ -1,20 +1,24 @@ -import 'package:elementary/src/relations/notifier/state_notifier.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter/material.dart'; -/// Builder for presentation ui part using two listenable states. +/// Builder that uses two [ListenableState] sources of data. class DoubleSourceBuilder extends StatefulWidget { /// State that used to detect change and rebuild. + /// + /// {@macro state_notifier.short_description} final ListenableState firstSource; /// State that used to detect change and rebuild. + /// + /// {@macro state_notifier.short_description} final ListenableState secondSource; - /// Function that used to describe the part of the user interface + /// Function that is used to describe the part of the user interface /// represented by this widget. final Widget Function(BuildContext context, F? firstValue, S? secondValue) builder; - /// Create an instance of DoubleSourceBuilder. + /// Creates an instance of [DoubleSourceBuilder]. const DoubleSourceBuilder({ Key? key, required this.firstSource, @@ -23,11 +27,11 @@ class DoubleSourceBuilder extends StatefulWidget { }) : super(key: key); @override - DoubleSourceBuilderState createState() => DoubleSourceBuilderState(); + State> createState() => + _DoubleSourceBuilderState(); } -/// State for the [DoubleSourceBuilder]. -class DoubleSourceBuilderState extends State> { +class _DoubleSourceBuilderState extends State> { F? _firstValue; S? _secondValue; diff --git a/packages/elementary/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart b/packages/elementary_helper/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart similarity index 94% rename from packages/elementary/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart rename to packages/elementary_helper/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart index faa597f8..2c9d96e8 100644 --- a/packages/elementary/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart +++ b/packages/elementary_helper/lib/src/relations/builder/multi_sources/double_value_listenable_builder.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -/// Builder for UI part presentation using two [ValueListenable]. +/// Builder that uses two [ValueListenable] sources of data. class DoubleValueListenableBuilder extends StatefulWidget { /// State that is used to detect change and rebuild. final ValueListenable firstValue; @@ -14,7 +14,7 @@ class DoubleValueListenableBuilder extends StatefulWidget { final Widget Function(BuildContext context, F firstValue, S secondValue) builder; - /// Create an instance of DoubleValueListenableBuilder. + /// Creates an instance of [DoubleValueListenableBuilder]. const DoubleValueListenableBuilder({ Key? key, required this.firstValue, diff --git a/packages/elementary/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart b/packages/elementary_helper/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart similarity index 81% rename from packages/elementary/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart rename to packages/elementary_helper/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart index fe78ae0c..43b55620 100644 --- a/packages/elementary/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart +++ b/packages/elementary_helper/lib/src/relations/builder/multi_sources/multi_listener_rebuilder.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -/// Widget which rebuild when anyone of the listeners -/// in the [listenableList] changed. +/// Builder that initiates a rebuild when any of the listeners in the +/// [listenableList] changes. class MultiListenerRebuilder extends StatefulWidget { /// A collection of Listenable elements whose changes are to be listened for. final Iterable listenableList; @@ -9,7 +9,7 @@ class MultiListenerRebuilder extends StatefulWidget { /// Builder which build a widget when any listened get update. final Widget Function(BuildContext context) builder; - /// Create an instance of [MultiListenerRebuilder] + /// Creates an instance of [MultiListenerRebuilder] const MultiListenerRebuilder({ Key? key, required this.listenableList, @@ -17,11 +17,10 @@ class MultiListenerRebuilder extends StatefulWidget { }) : super(key: key); @override - MultiListenerRebuilderState createState() => MultiListenerRebuilderState(); + State createState() => _MultiListenerRebuilderState(); } -/// State for the [MultiListenerRebuilder]. -class MultiListenerRebuilderState extends State { +class _MultiListenerRebuilderState extends State { @override void initState() { super.initState(); diff --git a/packages/elementary/lib/src/relations/builder/multi_sources/triple_source_builder.dart b/packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_source_builder.dart similarity index 88% rename from packages/elementary/lib/src/relations/builder/multi_sources/triple_source_builder.dart rename to packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_source_builder.dart index 46a181a6..9d565836 100644 --- a/packages/elementary/lib/src/relations/builder/multi_sources/triple_source_builder.dart +++ b/packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_source_builder.dart @@ -1,7 +1,7 @@ -import 'package:elementary/src/relations/notifier/state_notifier.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter/material.dart'; -/// Builder for presentation ui part using two listenable states. +/// Builder that uses three [ListenableState] sources of data. class TripleSourceBuilder extends StatefulWidget { /// State that used to detect change and rebuild. final ListenableState firstSource; @@ -21,7 +21,7 @@ class TripleSourceBuilder extends StatefulWidget { T? thirdValue, ) builder; - /// Create an instance of DoubleSourceBuilder. + /// Creates an instance of [TripleSourceBuilder]. const TripleSourceBuilder({ Key? key, required this.firstSource, @@ -31,12 +31,11 @@ class TripleSourceBuilder extends StatefulWidget { }) : super(key: key); @override - TripleSourceBuilderState createState() => - TripleSourceBuilderState(); + State> createState() => + _TripleSourceBuilderState(); } -/// State for the [TripleSourceBuilder]. -class TripleSourceBuilderState +class _TripleSourceBuilderState extends State> { F? _firstValue; S? _secondValue; diff --git a/packages/elementary/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart b/packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart similarity index 96% rename from packages/elementary/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart rename to packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart index 98e49ccf..2b3f9874 100644 --- a/packages/elementary/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart +++ b/packages/elementary_helper/lib/src/relations/builder/multi_sources/triple_value_listenable_builder.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -/// Builder for UI part presentation using two [ValueListenable]. +/// Builder that uses three [ValueListenable] sources of data. class TripleValueListenableBuilder extends StatefulWidget { /// State that is used to detect change and rebuild. final ValueListenable firstValue; @@ -21,7 +21,7 @@ class TripleValueListenableBuilder extends StatefulWidget { T thirdValue, ) builder; - /// Create an instance of TripleValueListenableBuilder. + /// Creates an instance of [TripleValueListenableBuilder]. const TripleValueListenableBuilder({ Key? key, required this.firstValue, diff --git a/packages/elementary_helper/lib/src/relations/builder/state_notifier_builder.dart b/packages/elementary_helper/lib/src/relations/builder/state_notifier_builder.dart new file mode 100644 index 00000000..a6e15cc9 --- /dev/null +++ b/packages/elementary_helper/lib/src/relations/builder/state_notifier_builder.dart @@ -0,0 +1,62 @@ +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; +import 'package:flutter/material.dart'; + +/// Builder that uses [ListenableState] as a source of data. +/// Usually can be helpful with the [StateNotifier]. +class StateNotifierBuilder extends StatefulWidget { + /// Source that used to detect change and rebuild. + final ListenableState listenableState; + + /// Function that used to describe the part of the user interface + /// represented by this widget. + final Widget Function(BuildContext context, T? value) builder; + + /// Creates an instance of [StateNotifierBuilder]. + const StateNotifierBuilder({ + Key? key, + required this.listenableState, + required this.builder, + }) : super(key: key); + + @override + State> createState() => + _StateNotifierBuilderState(); +} + +class _StateNotifierBuilderState extends State> { + T? _value; + + @override + void initState() { + super.initState(); + _value = widget.listenableState.value; + widget.listenableState.addListener(_valueChanged); + } + + @override + void didUpdateWidget(StateNotifierBuilder oldWidget) { + if (oldWidget.listenableState != widget.listenableState) { + oldWidget.listenableState.removeListener(_valueChanged); + _value = widget.listenableState.value; + widget.listenableState.addListener(_valueChanged); + } + super.didUpdateWidget(oldWidget); + } + + @override + void dispose() { + widget.listenableState.removeListener(_valueChanged); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return widget.builder(context, _value); + } + + void _valueChanged() { + setState(() { + _value = widget.listenableState.value; + }); + } +} diff --git a/packages/elementary_helper/lib/src/relations/notifier/entity_state_notifier.dart b/packages/elementary_helper/lib/src/relations/notifier/entity_state_notifier.dart new file mode 100644 index 00000000..c9852077 --- /dev/null +++ b/packages/elementary_helper/lib/src/relations/notifier/entity_state_notifier.dart @@ -0,0 +1,119 @@ +import 'package:flutter/foundation.dart'; + +/// Publisher that uses [EntityState] to describe concrete state of stored data. +class EntityStateNotifier extends ValueNotifier> + implements EntityValueListenable { + /// Creates an instance of [EntityStateNotifier]. + EntityStateNotifier([EntityState? initialData]) + : super(initialData ?? EntityState.content()); + + /// Creates an instance of [EntityStateNotifier] with initial value. + EntityStateNotifier.value(T initialData) + : super( + EntityState.content(initialData), + ); + + /// Sets current state to content. + void content(T data) { + value = EntityState.content(data); + } + + /// Sets current state to error. + void error([Exception? exception, T? data]) { + value = EntityState.error(exception, data); + } + + /// Sets current state to loading. + void loading([T? previousData]) { + value = EntityState.loading(previousData); + } +} + +/// Describes the state of the stored value. It can be helpful when +/// interacting with values over the network or other options involving +/// long asynchronous operations. +/// +/// It can be in one of three possible states: +/// ## Loading +/// This state indicates that the value is currently being loaded. +/// This state doesn't exclude the existence of a value while the actual value +/// is being in loading, such as the previous value. +/// Concrete implementation for this state is [LoadingEntityState]. +/// ## error +/// This state indicates that there is a problem with the value, +/// such as an exception occurring during the loading process. +/// This state doesn't exclude the existence of a value, for example +/// it can refer to the previous value, but emphasizes the presence of problems. +/// Concrete implementation for this state is [ErrorEntityState]. +/// ## content +/// This state means some value is stored, without highlight additional aspects. +/// Concrete implementation for this state is [ContentEntityState]. +sealed class EntityState { + /// Data of entity. + final T? data; + + /// Create an instance of EntityState. + const EntityState({ + this.data, + }); + + /// Loading constructor. + factory EntityState.loading([T? data]) { + return LoadingEntityState(data: data); + } + + /// Error constructor. + factory EntityState.error([Exception? error, T? data]) { + return ErrorEntityState(error: error, data: data); + } + + /// Content constructor. + factory EntityState.content([T? data]) { + return ContentEntityState(data: data); + } + + /// Is it error state. + bool get isErrorState => switch (this) { + ErrorEntityState() => true, + _ => false, + }; + + /// Is it error state. + bool get isLoadingState => switch (this) { + LoadingEntityState() => true, + _ => false, + }; + + /// Returns error if exist or null otherwise. + Exception? get errorOrNull => switch (this) { + final ErrorEntityState errorState => errorState.error, + _ => null, + }; +} + +/// Entity that describes general state of data storing. +final class ContentEntityState extends EntityState { + /// Creates an instance of [ContentEntityState]. + const ContentEntityState({super.data}); +} + +/// Entity that describes state of loading data or long interaction. +final class LoadingEntityState extends ContentEntityState { + /// Creates an instance of [LoadingEntityState]. + const LoadingEntityState({super.data}); +} + +/// Entity that describes state with data problems. +final class ErrorEntityState extends ContentEntityState { + /// Describes exact problems with data + final Exception? error; + + /// Creates an instance of [ErrorEntityState]. + const ErrorEntityState({this.error, super.data}); +} + +/// Alias for [EntityStateNotifier] interface. +/// +/// Can be useful for simplify description of Widget Model interface. +abstract interface class EntityValueListenable + implements ValueListenable> {} diff --git a/packages/elementary_helper/lib/src/relations/notifier/state_notifier.dart b/packages/elementary_helper/lib/src/relations/notifier/state_notifier.dart new file mode 100644 index 00000000..cf5f147b --- /dev/null +++ b/packages/elementary_helper/lib/src/relations/notifier/state_notifier.dart @@ -0,0 +1,53 @@ +import 'package:flutter/foundation.dart'; + +/// Publisher that can store a value. Whenever the value changes, +/// all subscribers will be notified. When a listener is added, it also +/// initiates a notification specifically for that listener. +/// +/// ## Limitation +/// This publisher behaves almost the same as [ValueNotifier], +/// except that it is not required to be initialized with a value +/// during creation. +/// This allows you to emit the first value later, but it also makes the +/// value nullable. +/// If you don't need this behavior for the publisher, [ValueNotifier] +/// is likely more suitable. +/// +/// See also: +/// * [ValueNotifier] +/// * [ChangeNotifier] +class StateNotifier extends ChangeNotifier implements ListenableState { + @override + T? get value => _value; + + T? _value; + + /// Create an instance of [StateNotifier]. + StateNotifier({T? initValue}) : _value = initValue; + + @override + void addListener(VoidCallback listener) { + super.addListener(listener); + + listener.call(); + } + + /// Accept a new value. + void accept(T? newValue) { + if (_value == newValue) return; + + _value = newValue; + notifyListeners(); + } +} + +/// An interface for instances that can be listened and return current value. +/// +/// {@template state_notifier.short_description} +/// Basically, it is the state that is used to detect changes and +/// trigger a rebuild. +/// {@endtemplate} +abstract interface class ListenableState extends Listenable { + /// Returns current state. + T? get value; +} diff --git a/packages/elementary/lib/src/wrappers/theme_wrapper.dart b/packages/elementary_helper/lib/src/wrappers/theme_wrapper.dart similarity index 100% rename from packages/elementary/lib/src/wrappers/theme_wrapper.dart rename to packages/elementary_helper/lib/src/wrappers/theme_wrapper.dart diff --git a/packages/elementary_helper/pubspec.yaml b/packages/elementary_helper/pubspec.yaml new file mode 100644 index 00000000..c7fd9327 --- /dev/null +++ b/packages/elementary_helper/pubspec.yaml @@ -0,0 +1,21 @@ +name: elementary_helper +description: A library with a bunch of helpers for elementary library, such as publisher-subscriber implementations, wrappers, etc. +version: 1.0.1 +repository: "https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_helper" +issue_tracker: "https://github.com/Elementary-team/flutter-elementary/issues" +homepage: "https://github.com/Elementary-team/flutter-elementary" + +environment: + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + + mocktail: ^1.0.0 + mjk_lint_rules: ^2.0.0 diff --git a/packages/elementary/test/relations/builder/entity_state_notifier_builder_test.dart b/packages/elementary_helper/test/relations/builder/entity_state_notifier_builder_test.dart similarity index 65% rename from packages/elementary/test/relations/builder/entity_state_notifier_builder_test.dart rename to packages/elementary_helper/test/relations/builder/entity_state_notifier_builder_test.dart index 674b7202..e7751e31 100644 --- a/packages/elementary/test/relations/builder/entity_state_notifier_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/entity_state_notifier_builder_test.dart @@ -1,4 +1,6 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/entity_state_notifier_builder.dart'; +import 'package:elementary_helper/src/relations/notifier/entity_state_notifier.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; @@ -38,7 +40,7 @@ void main() { 'When state with content should call build method', (tester) async { final testData = TestEntity(); - testEntity = EntityState(data: testData); + testEntity = EntityState.content(testData); when(() => listenableState.value).thenReturn(testEntity); await tester.pumpWidget(testingWidget); @@ -73,10 +75,45 @@ void main() { verify(() => errorBuilder.call(any(), exception, testData)).called(1); }, ); + + testWidgets( + 'Default builder should be called for error state when errorBuilder is not set', + (tester) async { + final testData = TestEntity(); + final exception = Exception('test'); + testEntity = EntityState.error(exception, testData); + when(() => listenableState.value).thenReturn(testEntity); + testingWidget = EntityStateNotifierBuilder( + listenableEntityState: listenableState, + builder: builder.call, + ); + + await tester.pumpWidget(testingWidget); + + verify(() => builder.call(any(), testData)).called(1); + }, + ); + + testWidgets( + 'Default builder should be called for loading state when loadingBuilder is not set', + (tester) async { + final testData = TestEntity(); + testEntity = EntityState.loading(testData); + when(() => listenableState.value).thenReturn(testEntity); + testingWidget = EntityStateNotifierBuilder( + listenableEntityState: listenableState, + builder: builder.call, + ); + + await tester.pumpWidget(testingWidget); + + verify(() => builder.call(any(), testData)).called(1); + }, + ); } class ListenableEntityStateMock extends Mock - implements ListenableState> {} + implements ValueListenable> {} class MockBuilder extends Mock { Widget call(BuildContext context, T? value); diff --git a/packages/elementary/test/relations/builder/multi_sources/double_source_builder_test.dart b/packages/elementary_helper/test/relations/builder/multi_sources/double_source_builder_test.dart similarity index 98% rename from packages/elementary/test/relations/builder/multi_sources/double_source_builder_test.dart rename to packages/elementary_helper/test/relations/builder/multi_sources/double_source_builder_test.dart index d7a4a30f..cc52b428 100644 --- a/packages/elementary/test/relations/builder/multi_sources/double_source_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/multi_sources/double_source_builder_test.dart @@ -1,4 +1,5 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/multi_sources/double_source_builder.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/elementary/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart b/packages/elementary_helper/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart similarity index 98% rename from packages/elementary/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart rename to packages/elementary_helper/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart index ceb21b82..27e717c1 100644 --- a/packages/elementary/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/multi_sources/double_value_listenable_builder_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/multi_sources/double_value_listenable_builder.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/elementary/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart b/packages/elementary_helper/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart similarity index 97% rename from packages/elementary/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart rename to packages/elementary_helper/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart index ed14a975..5fc66693 100644 --- a/packages/elementary/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart +++ b/packages/elementary_helper/test/relations/builder/multi_sources/multi_listener_rebuilder_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/multi_sources/multi_listener_rebuilder.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/elementary/test/relations/builder/multi_sources/triple_source_builder_test.dart b/packages/elementary_helper/test/relations/builder/multi_sources/triple_source_builder_test.dart similarity index 98% rename from packages/elementary/test/relations/builder/multi_sources/triple_source_builder_test.dart rename to packages/elementary_helper/test/relations/builder/multi_sources/triple_source_builder_test.dart index 80bb9908..c505eaba 100644 --- a/packages/elementary/test/relations/builder/multi_sources/triple_source_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/multi_sources/triple_source_builder_test.dart @@ -1,4 +1,5 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/multi_sources/triple_source_builder.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/elementary/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart b/packages/elementary_helper/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart similarity index 99% rename from packages/elementary/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart rename to packages/elementary_helper/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart index 49383fe9..9080dddb 100644 --- a/packages/elementary/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/multi_sources/triple_value_listenable_builder_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/multi_sources/triple_value_listenable_builder.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/elementary/test/relations/builder/state_notifier_builder_test.dart b/packages/elementary_helper/test/relations/builder/state_notifier_builder_test.dart similarity index 96% rename from packages/elementary/test/relations/builder/state_notifier_builder_test.dart rename to packages/elementary_helper/test/relations/builder/state_notifier_builder_test.dart index 07e61ca7..ae1b427c 100644 --- a/packages/elementary/test/relations/builder/state_notifier_builder_test.dart +++ b/packages/elementary_helper/test/relations/builder/state_notifier_builder_test.dart @@ -1,4 +1,5 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/builder/state_notifier_builder.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/packages/elementary/test/relations/notifier/entity_state_notifier_test.dart b/packages/elementary_helper/test/relations/notifier/entity_state_notifier_test.dart similarity index 64% rename from packages/elementary/test/relations/notifier/entity_state_notifier_test.dart rename to packages/elementary_helper/test/relations/notifier/entity_state_notifier_test.dart index 5546171f..1938a3f5 100644 --- a/packages/elementary/test/relations/notifier/entity_state_notifier_test.dart +++ b/packages/elementary_helper/test/relations/notifier/entity_state_notifier_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter_test/flutter_test.dart'; /// Tests for [EntityStateNotifier] @@ -12,11 +12,11 @@ void main() { test('Create without init value should create empty value', () { final testNotifier = EntityStateNotifier(); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.data, isNull); + expect(testNotifier.value.data, isNull); }); test('Create with init value should set passed value', () { - const value = EntityState(); + final value = EntityState.content(); final testNotifier = EntityStateNotifier(value); expect(testNotifier.value, same(value)); }); @@ -24,19 +24,19 @@ void main() { test('Create by value constructor should set correct value', () { final testNotifier = EntityStateNotifier.value(100); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.data, 100); + expect(testNotifier.value.data, 100); }); test('Content should set correct entity', () { testNotifier.content(200); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.data, 200); + expect(testNotifier.value.data, 200); testNotifier.content(1); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.data, 1); + expect(testNotifier.value.data, 1); }); test('Error should set correct entity', () { @@ -44,19 +44,19 @@ void main() { testNotifier.error(exception, 3); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.hasError, isTrue); - expect(testNotifier.value!.isLoading, isFalse); - expect(testNotifier.value!.error, same(exception)); - expect(testNotifier.value!.data, 3); + expect(testNotifier.value.isErrorState, isTrue); + expect(testNotifier.value.isLoadingState, isFalse); + expect(testNotifier.value.errorOrNull, same(exception)); + expect(testNotifier.value.data, 3); }); test('Error should set correct entity', () { testNotifier.loading(5); expect(testNotifier.value, isNotNull); - expect(testNotifier.value!.isLoading, isTrue); - expect(testNotifier.value!.hasError, isFalse); - expect(testNotifier.value!.error, isNull); - expect(testNotifier.value!.data, 5); + expect(testNotifier.value.isLoadingState, isTrue); + expect(testNotifier.value.isErrorState, isFalse); + expect(testNotifier.value.errorOrNull, isNull); + expect(testNotifier.value.data, 5); }); } diff --git a/packages/elementary_helper/test/relations/notifier/entity_state_test.dart b/packages/elementary_helper/test/relations/notifier/entity_state_test.dart new file mode 100644 index 00000000..56585d47 --- /dev/null +++ b/packages/elementary_helper/test/relations/notifier/entity_state_test.dart @@ -0,0 +1,87 @@ +import 'package:elementary_helper/src/relations/notifier/entity_state_notifier.dart'; +import 'package:flutter_test/flutter_test.dart'; + +/// Tests for [EntityState]. +void main() { + test('Data for every type of states should be equal to init data', () { + const data = 1; + final state = EntityState.content(data); + final loadingState = EntityState.loading(data); + final errorState = EntityState.error(null, data); + + expect(state.data, equals(data)); + expect(loadingState.data, equals(data)); + expect(errorState.data, equals(data)); + }); + + test('Data for every type should be null if is not init', () { + final state = EntityState.content(); + final loadingState = EntityState.loading(); + final errorState = EntityState.error(); + + expect(state.data, isNull); + expect(loadingState.data, isNull); + expect(errorState.data, isNull); + }); + + test('Content factory should return ContentEntityState instance', () { + const data = 1; + final state = EntityState.content(data); + + expect(state, const TypeMatcher>()); + }); + + test('Error factory should return ErrorEntityState instance', () { + final error = Exception('test'); + final state = EntityState.error(error); + + expect(state, const TypeMatcher>()); + }); + + test('Loading factory should return LoadingEntityState instance', () { + const data = 1; + final state = EntityState.loading(data); + + expect(state, const TypeMatcher>()); + }); + + test('Error for error state should be equal to init error', () { + final error = Exception('test'); + final state = EntityState.error(error); + + expect((state as ErrorEntityState).error, equals(error)); + }); + + test('isErrorState should return correct result', () { + final state = EntityState.content(1); + final loadingState = EntityState.loading(1); + final errorState = EntityState.error(null, 1); + + expect(state.isErrorState, isFalse); + expect(loadingState.isErrorState, isFalse); + expect(errorState.isErrorState, isTrue); + }); + + test('isLoadingState should return correct result', () { + final state = EntityState.content(1); + final loadingState = EntityState.loading(1); + final errorState = EntityState.error(null, 1); + + expect(state.isLoadingState, isFalse); + expect(loadingState.isLoadingState, isTrue); + expect(errorState.isLoadingState, isFalse); + }); + + test('errorOrNull should return correct result', () { + final error = Exception('test'); + final state = EntityState.content(1); + final loadingState = EntityState.loading(1); + final errorState = EntityState.error(error, 1); + final errorStateWithoutError = EntityState.error(null, 1); + + expect(state.errorOrNull, isNull); + expect(loadingState.errorOrNull, isNull); + expect(errorStateWithoutError.errorOrNull, isNull); + expect(errorState.errorOrNull, equals(error)); + }); +} diff --git a/packages/elementary/test/relations/notifier/state_notifier_test.dart b/packages/elementary_helper/test/relations/notifier/state_notifier_test.dart similarity index 96% rename from packages/elementary/test/relations/notifier/state_notifier_test.dart rename to packages/elementary_helper/test/relations/notifier/state_notifier_test.dart index 80fe33f5..9116d401 100644 --- a/packages/elementary/test/relations/notifier/state_notifier_test.dart +++ b/packages/elementary_helper/test/relations/notifier/state_notifier_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/relations/notifier/state_notifier.dart'; import 'package:flutter_test/flutter_test.dart'; /// Tests for [StateNotifier] diff --git a/packages/elementary/test/wrapper/theme_wrapper_test.dart b/packages/elementary_helper/test/wrapper/theme_wrapper_test.dart similarity index 94% rename from packages/elementary/test/wrapper/theme_wrapper_test.dart rename to packages/elementary_helper/test/wrapper/theme_wrapper_test.dart index e70f59e5..469a7865 100644 --- a/packages/elementary/test/wrapper/theme_wrapper_test.dart +++ b/packages/elementary_helper/test/wrapper/theme_wrapper_test.dart @@ -1,4 +1,4 @@ -import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/src/wrappers/theme_wrapper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/elementary_test/CHANGELOG.md b/packages/elementary_test/CHANGELOG.md index 9aaba9ec..9162c6a0 100644 --- a/packages/elementary_test/CHANGELOG.md +++ b/packages/elementary_test/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +## 2.0.0 +* supported `elementary` version increased to `^3.0.0`; + +## 2.0.0-dev +### Changed +* supported `elementary` version increased to `^3.0.0-dev`; + ## 1.1.3 ### Changed * supported `elementary` version increased to `^2.0.0`; diff --git a/packages/elementary_test/README.md b/packages/elementary_test/README.md index 3ae425c3..cbdde118 100644 --- a/packages/elementary_test/README.md +++ b/packages/elementary_test/README.md @@ -1,16 +1,23 @@ # Elementary-test +### +

+ Elementary Logo +

-Elementary Logo +### + +

+ Owner + Pub Version + Pub points + Pub Likes + Pub popularity +

-[![Pub Version](https://img.shields.io/pub/v/elementary_test?logo=dart&logoColor=white)](https://pub.dev/packages/elementary_test) -[![Pub points](https://badgen.net/pub/points/elementary_test)](https://pub.dev/packages/elementary_test) -[![Pub Likes](https://badgen.net/pub/likes/elementary_test)](https://pub.dev/packages/elementary_test) -[![Pub popularity](https://badgen.net/pub/popularity/elementary_test)](https://pub.dev/packages/elementary_test) ## Description A handy testing library for the apps built with Elementary. -This one’s helpful when used with the Elementary architecture package. ## Overview @@ -88,10 +95,37 @@ void main() { } ``` -## Sponsor +## Maintainer -Our main sponsor is [Surf](https://surf.ru/). + +
+ Maintainer avatar +

Mikhail Zotyev

+
+
-## Maintainer +## Contributors thanks + +Big thanks to all these people, who put their effort to help the project. + +![contributors](https://contributors-img.firebaseapp.com/image?repo=Elementary-team/flutter-elementary) + + +Special thanks to: + +[Dmitry Krutskikh](https://github.com/dkrutskikh), [Konoshenko Vlad](https://github.com/vlkonoshenko), +[Denis Grafov](https://github.com/grafovdenis) for the early adoption and the first production feedback; + +[Alex Bukin](https://github.com/AlexeyBukin) for IDE plugins; + +All members of the Surf Flutter Team for actively using and providing feedback. + +## Sponsorship + +Special sponsor of the project: + + +Surf + -[Mikhail Zotyev](https://github.com/MbIXjkee) +For all questions regarding sponsorship/collaboration connect with [Mikhail Zotyev](https://github.com/MbIXjkee). diff --git a/packages/elementary_test/example/lib/impl/screen/test_page_widget.dart b/packages/elementary_test/example/lib/impl/screen/test_page_widget.dart index 800ad7d8..e5f17a1a 100644 --- a/packages/elementary_test/example/lib/impl/screen/test_page_widget.dart +++ b/packages/elementary_test/example/lib/impl/screen/test_page_widget.dart @@ -1,5 +1,6 @@ import 'package:counter/impl/screen/test_page_widget_model.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; class TestPageWidget extends ElementaryWidget { diff --git a/packages/elementary_test/example/lib/impl/screen/test_page_widget_model.dart b/packages/elementary_test/example/lib/impl/screen/test_page_widget_model.dart index d7ea0212..871df552 100644 --- a/packages/elementary_test/example/lib/impl/screen/test_page_widget_model.dart +++ b/packages/elementary_test/example/lib/impl/screen/test_page_widget_model.dart @@ -3,6 +3,8 @@ import 'dart:async'; import 'package:counter/impl/screen/test_page_model.dart'; import 'package:counter/impl/screen/test_page_widget.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -17,7 +19,7 @@ class TestPageWidgetModel extends WidgetModel final ThemeWrapper _themeWrapper; @override - ListenableState> get valueState => _valueController; + ValueListenable> get valueState => _valueController; @override TextStyle get counterStyle => _counterStyle; @@ -62,8 +64,8 @@ class TestPageWidgetModel extends WidgetModel } } -abstract class ITestPageWidgetModel extends IWidgetModel { - ListenableState> get valueState; +abstract interface class ITestPageWidgetModel implements IWidgetModel { + ValueListenable> get valueState; TextStyle get counterStyle; diff --git a/packages/elementary_test/example/lib/main.dart b/packages/elementary_test/example/lib/main.dart index 23af3a88..dfa44040 100644 --- a/packages/elementary_test/example/lib/main.dart +++ b/packages/elementary_test/example/lib/main.dart @@ -1,6 +1,7 @@ import 'package:counter/impl/screen/test_page_model.dart'; import 'package:counter/impl/screen/test_page_widget.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/packages/elementary_test/example/pubspec.yaml b/packages/elementary_test/example/pubspec.yaml index b6bbbec2..a143e734 100644 --- a/packages/elementary_test/example/pubspec.yaml +++ b/packages/elementary_test/example/pubspec.yaml @@ -4,10 +4,11 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: - elementary: ^2.0.0 + elementary: ^3.0.0 + elementary_helper: ^1.0.1 flutter: sdk: flutter @@ -19,8 +20,8 @@ dev_dependencies: flutter_test: sdk: flutter - mocktail: ^0.3.0 - mjk_lint_rules: ^1.0.1 + mocktail: ^1.0.0 + mjk_lint_rules: ^2.0.0 flutter: uses-material-design: true diff --git a/packages/elementary_test/example/test/country_list_screen_wm_test.dart b/packages/elementary_test/example/test/country_list_screen_wm_test.dart index 6967f481..850746f0 100644 --- a/packages/elementary_test/example/test/country_list_screen_wm_test.dart +++ b/packages/elementary_test/example/test/country_list_screen_wm_test.dart @@ -6,6 +6,7 @@ import 'package:counter/impl/screen/test_page_model.dart'; import 'package:counter/impl/screen/test_page_widget.dart'; import 'package:counter/impl/screen/test_page_widget_model.dart'; import 'package:elementary/elementary.dart'; +import 'package:elementary_helper/elementary_helper.dart'; import 'package:elementary_test/elementary_test.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -75,7 +76,7 @@ void main() { final value = wm.valueState.value; expect(value, isNotNull); - expect(value!.isLoading, isTrue); + expect(value.isLoadingState, isTrue); }, ); } diff --git a/packages/elementary_test/lib/src/widget_model_test.dart b/packages/elementary_test/lib/src/widget_model_test.dart index 3de4be73..31810e4a 100644 --- a/packages/elementary_test/lib/src/widget_model_test.dart +++ b/packages/elementary_test/lib/src/widget_model_test.dart @@ -1,6 +1,6 @@ -// ignore_for_file: avoid_implementing_value_types, implementation_imports, invalid_use_of_visible_for_testing_member, invalid_use_of_protected_member +// ignore_for_file: invalid_use_of_visible_for_testing_member, invalid_use_of_protected_member -import 'package:elementary/src/core.dart'; +import 'package:elementary/elementary.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -96,9 +96,7 @@ abstract class WMTester { } class _WMTestableElement - extends WMContext - with Diagnosticable - implements Elementary, WMTester { + extends WMContext with Diagnosticable implements WMTester { final WM _wm; _WMTestableElement(this._wm); diff --git a/packages/elementary_test/pubspec.yaml b/packages/elementary_test/pubspec.yaml index a606c231..ff6763bd 100644 --- a/packages/elementary_test/pubspec.yaml +++ b/packages/elementary_test/pubspec.yaml @@ -1,22 +1,22 @@ name: elementary_test description: A testing library which makes it easy to test elementary used apps. Built to be used with the elementary architecture package. -version: 1.1.3 +version: 2.0.0 repository: "https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_test" issue_tracker: "https://github.com/Elementary-team/flutter-elementary/issues" homepage: "https://github.com/Elementary-team/flutter-elementary" environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.17.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: sdk: flutter flutter_test: sdk: flutter - elementary: ^2.0.0 - mocktail: ^0.3.0 + elementary: ^3.0.0 + mocktail: ^1.0.0 meta: ^1.8.0 dev_dependencies: - mjk_lint_rules: ^1.0.1 + mjk_lint_rules: ^2.0.0 diff --git a/packages/elementary_tools/elementary_bricks/elementary/CHANGELOG.md b/packages/elementary_tools/elementary_bricks/elementary/CHANGELOG.md index 64cc9699..a7df3ba9 100644 --- a/packages/elementary_tools/elementary_bricks/elementary/CHANGELOG.md +++ b/packages/elementary_tools/elementary_bricks/elementary/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Unreleased +## 0.0.3 +### Added +* support Elementary 3.0.0 changes ## 0.0.2 ### Added diff --git a/packages/elementary_tools/elementary_bricks/elementary/__brick__/{{widget_file}}/{{widget_model_file}}.dart b/packages/elementary_tools/elementary_bricks/elementary/__brick__/{{widget_file}}/{{widget_model_file}}.dart index e5ce097c..ece3a7f6 100644 --- a/packages/elementary_tools/elementary_bricks/elementary/__brick__/{{widget_file}}/{{widget_model_file}}.dart +++ b/packages/elementary_tools/elementary_bricks/elementary/__brick__/{{widget_file}}/{{widget_model_file}}.dart @@ -7,7 +7,7 @@ import '{{widget_file}}.dart'; import '{{model_file}}.dart'; /// Public contract of [{{widget_model_class}}] -abstract class {{widget_model_interface}} extends IWidgetModel { +abstract interface class {{widget_model_interface}} implements IWidgetModel { } /// Default factory for [{{widget_model_class}}] diff --git a/packages/elementary_tools/elementary_bricks/elementary/brick.yaml b/packages/elementary_tools/elementary_bricks/elementary/brick.yaml index c87988ae..572f3fa5 100644 --- a/packages/elementary_tools/elementary_bricks/elementary/brick.yaml +++ b/packages/elementary_tools/elementary_bricks/elementary/brick.yaml @@ -2,7 +2,7 @@ name: elementary description: Brick to generate template code for Elementary entities. repository: https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_tools/elementary_bricks/elementary -version: 0.0.2 +version: 0.0.3 environment: mason: ">=0.1.0-dev.40 <0.1.0" diff --git a/packages/elementary_tools/elementary_cli/CHANGELOG.md b/packages/elementary_tools/elementary_cli/CHANGELOG.md index 71e4094c..0b927f0d 100644 --- a/packages/elementary_tools/elementary_cli/CHANGELOG.md +++ b/packages/elementary_tools/elementary_cli/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +## 2.0.0 +### Add +* support elementary 3.0.0 changes in templates + ## 1.1.0 ### Add * support of the new analyzer plugin diff --git a/packages/elementary_tools/elementary_cli/lib/templates/test_wm.dart.tp b/packages/elementary_tools/elementary_cli/lib/templates/test_wm.dart.tp index 3050a086..a3be8bfd 100644 --- a/packages/elementary_tools/elementary_cli/lib/templates/test_wm.dart.tp +++ b/packages/elementary_tools/elementary_cli/lib/templates/test_wm.dart.tp @@ -32,4 +32,5 @@ void main() { } class ClassNameModelMock extends Mock + with MockElementaryModelMixin implements ClassNameModel {} diff --git a/packages/elementary_tools/elementary_cli/lib/templates/widget_model.dart.tp b/packages/elementary_tools/elementary_cli/lib/templates/widget_model.dart.tp index bdc082d9..96a0b623 100644 --- a/packages/elementary_tools/elementary_cli/lib/templates/widget_model.dart.tp +++ b/packages/elementary_tools/elementary_cli/lib/templates/widget_model.dart.tp @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'filename_model.dart'; import 'filename_widget.dart'; -abstract class IClassNameWidgetModel extends IWidgetModel { +abstract interface class IClassNameWidgetModel implements IWidgetModel { } ClassNameWidgetModel defaultClassNameWidgetModelFactory(BuildContext context) { diff --git a/packages/elementary_tools/elementary_cli/pubspec.yaml b/packages/elementary_tools/elementary_cli/pubspec.yaml index 25729f67..c6b744ee 100644 --- a/packages/elementary_tools/elementary_cli/pubspec.yaml +++ b/packages/elementary_tools/elementary_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: elementary_cli description: CLI utilities for Elementary -version: 1.1.0 +version: 2.0.0 repository: "https://github.com/Elementary-team/flutter-elementary/tree/main/packages/elementary_tools/elementary_cli" issue_tracker: "https://github.com/Elementary-team/flutter-elementary/issues" homepage: "https://github.com/Elementary-team/flutter-elementary" @@ -10,7 +10,7 @@ executables: elementary_tools: environment: - sdk: '>=2.17.0 <3.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: args: ^2.3.0 @@ -21,4 +21,4 @@ dependencies: dev_dependencies: dart_code_metrics: ^5.6.0 lints: ^2.0.1 - mjk_lint_rules: ^1.0.1 + mjk_lint_rules: ^2.0.0