From 28341d6776e1f5c18c64b8e96d44b02d4a6d3d88 Mon Sep 17 00:00:00 2001 From: lanhuajian Date: Fri, 8 Sep 2023 15:52:38 +0800 Subject: [PATCH 01/11] [feature] ast_gen/dsl_gen support TypeArgumentList --- dart2dsl/lib/fairdsl/fair_ast_gen.dart | 8 +++++++ dart2dsl/lib/fairdsl/fair_ast_node.dart | 22 +++++++++++++++++++ dart2dsl/lib/fairdsl/fair_check_node_map.dart | 3 ++- dart2dsl/lib/fairdsl/fair_dsl_gen.dart | 12 ++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/dart2dsl/lib/fairdsl/fair_ast_gen.dart b/dart2dsl/lib/fairdsl/fair_ast_gen.dart index f41a9f4c..f40d786f 100644 --- a/dart2dsl/lib/fairdsl/fair_ast_gen.dart +++ b/dart2dsl/lib/fairdsl/fair_ast_gen.dart @@ -385,6 +385,11 @@ class CustomAstVisitor extends SimpleAstVisitor { return _buildArgumentList(_visitNodeList(node.arguments)); } + @override + Map visitTypeArgumentList(TypeArgumentList node) { + return _buildTypeArgumentList(_visitNodeList(node.arguments)); + } + @override Map? visitLabel(Label node) { return _visitNode(node.label); @@ -543,6 +548,9 @@ class CustomAstVisitor extends SimpleAstVisitor { 'body': body, }; + Map _buildTypeArgumentList(List typeArgumentList) => + {'type': 'TypeArgumentList', 'typeArgumentList': typeArgumentList}; + Map _buildArgumentList(List argumentList) => {'type': 'ArgumentList', 'argumentList': argumentList}; Map _buildStringLiteral(String value) => {'type': 'StringLiteral', 'value': value}; diff --git a/dart2dsl/lib/fairdsl/fair_ast_node.dart b/dart2dsl/lib/fairdsl/fair_ast_node.dart index 74269278..3e47c30c 100644 --- a/dart2dsl/lib/fairdsl/fair_ast_node.dart +++ b/dart2dsl/lib/fairdsl/fair_ast_node.dart @@ -432,8 +432,10 @@ class MethodInvocation extends AstNode { Expression? callee; List? argumentList; SelectAstClass? selectAstClass; + List? typeArgumentList; MethodInvocation(this.callee, this.argumentList, this.selectAstClass, + this.typeArgumentList, {Map? ast}) : super(ast: ast); @@ -444,6 +446,7 @@ class MethodInvocation extends AstNode { Expression.fromAst(ast['callee']), _parseArgumentList(ast['argumentList']), SelectAstClass.fromAst(ast['selectAstClass']), + _parseTypeArgumentList(ast['typeArguments']), ast: ast); } return null; @@ -1097,6 +1100,7 @@ class Expression extends AstNode { bool? isVariableDeclaration; bool? isVariableExpression; bool? isFuncParam; + bool? isTypeName; @override Map? toAst() => _ast; @@ -1137,6 +1141,7 @@ class Expression extends AstNode { this.isVariableDeclaration = false, this.isVariableExpression = false, this.isFuncParam =false, + this.isTypeName = false, Map? ast, }) : super(ast: ast); @@ -1237,6 +1242,8 @@ class Expression extends AstNode { isInterpolationExpression: true, ast: ast); } else if (astType == astNodeNameValue(AstNodeName.VariableExpression)) { return Expression(VariableExpression.fromAst(ast), isVariableExpression: true, ast: ast); + } else if (astType == astNodeNameValue(AstNodeName.TypeName)) { + return Expression(TypeName.fromAst(ast), isTypeName: true, ast: ast); } return null; } @@ -1311,6 +1318,8 @@ class Expression extends AstNode { _expression as InterpolationExpression; VariableExpression get asVariableExpression => _expression as VariableExpression; + + TypeName get asTypeNameExpression => _expression as TypeName; } class SelectAstClass { @@ -1350,6 +1359,19 @@ List _parseArgumentList(Map? ast) { return arguments; } +///解析TypeArgumentList 字段 +List _parseTypeArgumentList(Map? ast) { + var arguments = []; + if (ast != null) { + var astTypeArgumentList = ast['typeArgumentList'] as List?; + return astTypeArgumentList + ?.map((arg) => Expression.fromAst(arg)) + .toList() ?? + arguments; + } + return arguments; +} + //num _parseNumericValue(Map ast) { // num n = 0; // if (ast['type'] == astNodeNameValue(AstNodeName.NumericLiteral)) { diff --git a/dart2dsl/lib/fairdsl/fair_check_node_map.dart b/dart2dsl/lib/fairdsl/fair_check_node_map.dart index 5c1aa1a7..834db7e8 100644 --- a/dart2dsl/lib/fairdsl/fair_check_node_map.dart +++ b/dart2dsl/lib/fairdsl/fair_check_node_map.dart @@ -57,5 +57,6 @@ final checkNode = { 'ImplementsClauseImpl': 'visitImplementsClause', 'WithClauseImpl': 'visitWithClause', 'PropertyAccessImpl': 'visitPropertyAccess', - 'PrefixExpressionImpl': 'visitPrefixExpression' + 'PrefixExpressionImpl': 'visitPrefixExpression', + 'TypeArgumentListImpl':'visitTypeArgumentList' }; diff --git a/dart2dsl/lib/fairdsl/fair_dsl_gen.dart b/dart2dsl/lib/fairdsl/fair_dsl_gen.dart index ce91dac6..e4eae548 100644 --- a/dart2dsl/lib/fairdsl/fair_dsl_gen.dart +++ b/dart2dsl/lib/fairdsl/fair_dsl_gen.dart @@ -219,6 +219,7 @@ dynamic _buildWidgetDsl( var dslMap = {}; var paMap = []; var naMap = {}; + var taMap =[]; var methodInvocationExpression = widgetExpression?.asMethodInvocation; //普通类 @@ -309,6 +310,13 @@ dynamic _buildWidgetDsl( } } + //3.ta + if (methodInvocationExpression.typeArgumentList?.isNotEmpty ?? false) { + taMap.addAll(methodInvocationExpression.typeArgumentList + ?.map((ta) => ta?.asTypeNameExpression.name) ?? + []); + } + if (paMap.isNotEmpty) { dslMap.putIfAbsent('pa', () => paMap); } @@ -317,6 +325,10 @@ dynamic _buildWidgetDsl( dslMap.putIfAbsent('na', () => naMap); } + if(taMap.isNotEmpty){ + dslMap.putIfAbsent('typeArgumentList', () => taMap); + } + return dslMap; } From 5b4fc545c97506b55690fa5c5738c0684d923dce Mon Sep 17 00:00:00 2001 From: lanhuajian Date: Wed, 25 Oct 2023 17:44:41 +0800 Subject: [PATCH 02/11] [feature] Function parameters carry TypeArgumentList --- fair/lib/src/render/builder.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fair/lib/src/render/builder.dart b/fair/lib/src/render/builder.dart index ec3b7042..53251465 100644 --- a/fair/lib/src/render/builder.dart +++ b/fair/lib/src/render/builder.dart @@ -47,6 +47,7 @@ class DynamicWidgetBuilder extends DynamicBuilder { : super('className', proxyMirror, page, bound, bundle: bundle); @override + @mustCallSuper dynamic convert(BuildContext context, Map map, Map? methodMap, {Domain? domain}) { var name = map[tag]; @@ -185,13 +186,23 @@ class DynamicWidgetBuilder extends DynamicBuilder { }) { var na = named(name, map['na'], methodMap, ctx, domain); var pa = positioned(map['pa'], methodMap, ctx, domain); + var ta = map['typeArgumentList']; // var arguments = map['arguments']; final bind = widget && (na.binding == true || pa.binding == true); try { fun = FairModule.cast(ctx, fun); if (forceApply || !bind) { - return Function.apply( - fun, [Property.extract(list: pa.data, map: na.data)], null); + if (ta != null) { + var properties = {}; + properties['pa'] = pa.data; + properties.addAll(na.data); + properties['ta'] = ta; + return Function.apply( + fun, [Property.extract(data: properties)], null); + } else { + return Function.apply( + fun, [Property.extract(list: pa.data, map: na.data)], null); + } } return FairComponent(name, func: fun, na: na.data, pa: pa.data); } catch (e, stack) { From f7487f9ec2bc192a21496b4f739aaa7685a7c498 Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Wed, 25 Oct 2023 19:44:40 +0800 Subject: [PATCH 03/11] [feature] fair_provider initial development completed --- fair/assets/fair_core/fair_core.js | 37 + fair_provider/.gitignore | 44 ++ fair_provider/.metadata | 33 + fair_provider/README.md | 16 + fair_provider/analysis_options.yaml | 29 + .../assets/plugin/fair_provider_plugin.js | 91 +++ fair_provider/example/.gitignore | 44 ++ fair_provider/example/.metadata | 33 + fair_provider/example/README.md | 16 + fair_provider/example/analysis_options.yaml | 29 + fair_provider/example/android/.gitignore | 13 + .../example/android/app/build.gradle | 71 ++ .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 34 + .../fair_provider/example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 8 + fair_provider/example/android/build.gradle | 31 + .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + fair_provider/example/android/settings.gradle | 11 + .../fair/lib_ui_counter_page_provider.fair.js | 19 + .../lib_ui_counter_page_provider.fair.json | 206 +++++ ...lib_ui_counter_page_provider.fair.metadata | 7 + fair_provider/example/ios/.gitignore | 34 + .../ios/Flutter/AppFrameworkInfo.plist | 26 + .../example/ios/Flutter/Debug.xcconfig | 2 + .../example/ios/Flutter/Release.xcconfig | 2 + fair_provider/example/ios/Podfile | 41 + fair_provider/example/ios/Podfile.lock | 28 + .../ios/Runner.xcodeproj/project.pbxproj | 553 +++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../xcshareddata/xcschemes/Runner.xcscheme | 87 +++ .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../example/ios/Runner/AppDelegate.swift | 13 + .../AppIcon.appiconset/Contents.json | 122 +++ .../Icon-App-1024x1024@1x.png | Bin 0 -> 10932 bytes .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 0 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 0 -> 406 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 0 -> 450 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 0 -> 282 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 0 -> 462 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 0 -> 704 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 0 -> 406 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 0 -> 586 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 0 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 0 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 0 -> 1674 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 0 -> 762 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 0 -> 1226 bytes .../Icon-App-83.5x83.5@2x.png | Bin 0 -> 1418 bytes .../LaunchImage.imageset/Contents.json | 23 + .../LaunchImage.imageset/LaunchImage.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/LaunchImage@2x.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/LaunchImage@3x.png | Bin 0 -> 68 bytes .../LaunchImage.imageset/README.md | 5 + .../Runner/Base.lproj/LaunchScreen.storyboard | 37 + .../ios/Runner/Base.lproj/Main.storyboard | 26 + fair_provider/example/ios/Runner/Info.plist | 51 ++ .../ios/Runner/Runner-Bridging-Header.h | 1 + .../example/lib/entity/counter_model.dart | 14 + .../example/lib/entity/login_model.dart | 8 + fair_provider/example/lib/main.dart | 131 ++++ .../example/lib/ui/counter_page_provider.dart | 114 +++ fair_provider/example/pubspec.lock | 725 ++++++++++++++++++ fair_provider/example/pubspec.yaml | 39 + fair_provider/example/test/widget_test.dart | 30 + fair_provider/lib/fair_provider.dart | 4 + fair_provider/lib/src/fair_app_module.dart | 46 ++ fair_provider/lib/src/fair_provider_core.dart | 468 +++++++++++ .../lib/src/fair_provider_plugin.dart | 44 ++ .../src/provider_dynamic_widget_builder.dart | 145 ++++ fair_provider/lib/src/utils/time_record.dart | 21 + fair_provider/pubspec.lock | 717 +++++++++++++++++ fair_provider/pubspec.yaml | 40 + 87 files changed, 4500 insertions(+) create mode 100644 fair_provider/.gitignore create mode 100644 fair_provider/.metadata create mode 100644 fair_provider/README.md create mode 100644 fair_provider/analysis_options.yaml create mode 100644 fair_provider/assets/plugin/fair_provider_plugin.js create mode 100644 fair_provider/example/.gitignore create mode 100644 fair_provider/example/.metadata create mode 100644 fair_provider/example/README.md create mode 100644 fair_provider/example/analysis_options.yaml create mode 100644 fair_provider/example/android/.gitignore create mode 100644 fair_provider/example/android/app/build.gradle create mode 100644 fair_provider/example/android/app/src/debug/AndroidManifest.xml create mode 100644 fair_provider/example/android/app/src/main/AndroidManifest.xml create mode 100644 fair_provider/example/android/app/src/main/kotlin/com/wuba/fair/fair_provider/example/MainActivity.kt create mode 100644 fair_provider/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 fair_provider/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 fair_provider/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 fair_provider/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 fair_provider/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 fair_provider/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 fair_provider/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 fair_provider/example/android/app/src/main/res/values-night/styles.xml create mode 100644 fair_provider/example/android/app/src/main/res/values/styles.xml create mode 100644 fair_provider/example/android/app/src/profile/AndroidManifest.xml create mode 100644 fair_provider/example/android/build.gradle create mode 100644 fair_provider/example/android/gradle.properties create mode 100644 fair_provider/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 fair_provider/example/android/settings.gradle create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata create mode 100644 fair_provider/example/ios/.gitignore create mode 100644 fair_provider/example/ios/Flutter/AppFrameworkInfo.plist create mode 100644 fair_provider/example/ios/Flutter/Debug.xcconfig create mode 100644 fair_provider/example/ios/Flutter/Release.xcconfig create mode 100644 fair_provider/example/ios/Podfile create mode 100644 fair_provider/example/ios/Podfile.lock create mode 100644 fair_provider/example/ios/Runner.xcodeproj/project.pbxproj create mode 100644 fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 fair_provider/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 fair_provider/example/ios/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 fair_provider/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 fair_provider/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 fair_provider/example/ios/Runner/AppDelegate.swift create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png create mode 100644 fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md create mode 100644 fair_provider/example/ios/Runner/Base.lproj/LaunchScreen.storyboard create mode 100644 fair_provider/example/ios/Runner/Base.lproj/Main.storyboard create mode 100644 fair_provider/example/ios/Runner/Info.plist create mode 100644 fair_provider/example/ios/Runner/Runner-Bridging-Header.h create mode 100644 fair_provider/example/lib/entity/counter_model.dart create mode 100644 fair_provider/example/lib/entity/login_model.dart create mode 100644 fair_provider/example/lib/main.dart create mode 100644 fair_provider/example/lib/ui/counter_page_provider.dart create mode 100644 fair_provider/example/pubspec.lock create mode 100644 fair_provider/example/pubspec.yaml create mode 100644 fair_provider/example/test/widget_test.dart create mode 100644 fair_provider/lib/fair_provider.dart create mode 100644 fair_provider/lib/src/fair_app_module.dart create mode 100644 fair_provider/lib/src/fair_provider_core.dart create mode 100644 fair_provider/lib/src/fair_provider_plugin.dart create mode 100644 fair_provider/lib/src/provider_dynamic_widget_builder.dart create mode 100644 fair_provider/lib/src/utils/time_record.dart create mode 100644 fair_provider/pubspec.lock create mode 100644 fair_provider/pubspec.yaml diff --git a/fair/assets/fair_core/fair_core.js b/fair/assets/fair_core/fair_core.js index d8538f3a..1ac1ee44 100644 --- a/fair/assets/fair_core/fair_core.js +++ b/fair/assets/fair_core/fair_core.js @@ -58,6 +58,18 @@ function _invokeMethod(par) { if (isNull(func)) { methodResult = ''; } else { + if (Array.isArray(args)) { + for (let key in args) { + if (args.hasOwnProperty(key)) { + const value = args[key]; + if (typeof value === 'object') { + invokeMethodArgsInterceptorManager.handle(value) + } + } + } + } else { + console.log('_invokeMethod intercept failed, args is not array'); + } methodResult = func.apply(mClass, args); } let result = { @@ -183,4 +195,29 @@ const invokeFlutterCommonChannel = (invokeData, callback) => { }); }; +class InvokeMethodArgsInterceptorManager { + constructor() { + this.interceptors = []; + } + + // 注册拦截器 + use(interceptor) { + if (typeof interceptor === 'function') { + this.interceptors.push(interceptor); + } + } + + // 处理对象 + handle(object) { + for (const interceptor of this.interceptors) { + // 如果有拦截器返回 true,则停止处理并返回结果 + if (interceptor(object) === true) { + return object; + } + } + return object; + } +} +// 创建一个拦截器管理器实例 +const invokeMethodArgsInterceptorManager = new InvokeMethodArgsInterceptorManager(); \ No newline at end of file diff --git a/fair_provider/.gitignore b/fair_provider/.gitignore new file mode 100644 index 00000000..24476c5d --- /dev/null +++ b/fair_provider/.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/fair_provider/.metadata b/fair_provider/.metadata new file mode 100644 index 00000000..397befcd --- /dev/null +++ b/fair_provider/.metadata @@ -0,0 +1,33 @@ +# 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: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + - platform: android + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + - platform: ios + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + + # 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/fair_provider/README.md b/fair_provider/README.md new file mode 100644 index 00000000..517d64bb --- /dev/null +++ b/fair_provider/README.md @@ -0,0 +1,16 @@ +# fair_provider + +An extension library for Fair on the Provider framework. + +## 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/fair_provider/analysis_options.yaml b/fair_provider/analysis_options.yaml new file mode 100644 index 00000000..61b6c4de --- /dev/null +++ b/fair_provider/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/fair_provider/assets/plugin/fair_provider_plugin.js b/fair_provider/assets/plugin/fair_provider_plugin.js new file mode 100644 index 00000000..3f84671a --- /dev/null +++ b/fair_provider/assets/plugin/fair_provider_plugin.js @@ -0,0 +1,91 @@ +let FairChangeNotifierPool = {}; + +let FairProviderPlugin = class FairProviderPlugin { + + static create(key, initialJson) { + if (!FairChangeNotifierPool[key]) { + let fairChangeNotifier + try { + fairChangeNotifier = JSON.parse(initialJson); + } catch (e) { + fairChangeNotifier = {} + } + console.log("miseryy 创建model key = " + key) + FairChangeNotifierPool[key] = fairChangeNotifier; + fairChangeNotifier.fairRuntimeTypeKey = key; + fairChangeNotifier.notify = function () { + let paramsMap = {}; + paramsMap['fairRuntimeTypeKey'] = this.fairRuntimeTypeKey + paramsMap['jsonMap'] = JSON.stringify(this) + let requestParameter = {}; + requestParameter['className'] = "FairProvider#notifyListeners"; + requestParameter['funcName'] = 'invokePlugin'; + requestParameter['args'] = paramsMap; + requestParameter['pageName'] = '#FairKey#'; + let map = JSON.stringify(requestParameter); + invokeFlutterCommonChannel(map, (resultStr) => { + }) + } + fairChangeNotifier.print = function () { + console.log("misery " + this.fairRuntimeTypeKey + "👇🏻") + console.log(this) + } + } + } + + static find(className) { + //如果FairChangeNotifierPool中有key为className的value,则直接返回value + //没有则创建FairChangeNotifier并以className为key存入FairChangeNotifierPool + if (!FairChangeNotifierPool[className]) { + FairChangeNotifierPool[className] = new FairChangeNotifier(className); + } + return FairChangeNotifierPool[className]; + } + + static evaluation(className, evaluation) { + if (!FairChangeNotifierPool[className]) { + FairChangeNotifierPool[className] = new FairChangeNotifier(className) + } + let fairChangeNotifier = FairChangeNotifierPool[className] + let temp + eval("temp = fairChangeNotifier." + evaluation) + return temp + } + + static release() { + //TODO + } + +} + +GLOBAL["FairProviderPlugin"] = FairProviderPlugin; + +invokeMethodArgsInterceptorManager.use((object) => { + if (object.hasOwnProperty("id") && object["id"] === "FairContext") { + object.read = function (name) { + //从treeModelKeyRecords数组中找到startwith(name)的元素 + return FairChangeNotifierPool[findFirstMatchedElement(this.treeModelKeyRecords, name)]; + } + return true; + } +}) + +function findFirstMatchedElement(treeModelKeyRecords, name) { + let latestMatchedElement = null; + + for (let i = 0; i < treeModelKeyRecords.length; i++) { + const element = treeModelKeyRecords[i]; + + // 使用正则表达式提取元素中的名称部分 + const match = element.match(/(.+)_(\d+)/); + + if (match && match[1] === name) { + latestMatchedElement = element; + break; // 找到匹配项后,结束循环 + } + } + + return latestMatchedElement; +} + + diff --git a/fair_provider/example/.gitignore b/fair_provider/example/.gitignore new file mode 100644 index 00000000..24476c5d --- /dev/null +++ b/fair_provider/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/fair_provider/example/.metadata b/fair_provider/example/.metadata new file mode 100644 index 00000000..397befcd --- /dev/null +++ b/fair_provider/example/.metadata @@ -0,0 +1,33 @@ +# 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: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + - platform: android + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + - platform: ios + create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + + # 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/fair_provider/example/README.md b/fair_provider/example/README.md new file mode 100644 index 00000000..2b3fce4c --- /dev/null +++ b/fair_provider/example/README.md @@ -0,0 +1,16 @@ +# 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/fair_provider/example/analysis_options.yaml b/fair_provider/example/analysis_options.yaml new file mode 100644 index 00000000..61b6c4de --- /dev/null +++ b/fair_provider/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/fair_provider/example/android/.gitignore b/fair_provider/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/fair_provider/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/fair_provider/example/android/app/build.gradle b/fair_provider/example/android/app/build.gradle new file mode 100644 index 00000000..d6fa3163 --- /dev/null +++ b/fair_provider/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 { + 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 { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.wuba.fair.fair_provider.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/fair_provider/example/android/app/src/debug/AndroidManifest.xml b/fair_provider/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..c1f315f8 --- /dev/null +++ b/fair_provider/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/fair_provider/example/android/app/src/main/AndroidManifest.xml b/fair_provider/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..da8302cc --- /dev/null +++ b/fair_provider/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/fair_provider/example/android/app/src/main/kotlin/com/wuba/fair/fair_provider/example/MainActivity.kt b/fair_provider/example/android/app/src/main/kotlin/com/wuba/fair/fair_provider/example/MainActivity.kt new file mode 100644 index 00000000..fa754924 --- /dev/null +++ b/fair_provider/example/android/app/src/main/kotlin/com/wuba/fair/fair_provider/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.wuba.fair.fair_provider.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/fair_provider/example/android/app/src/main/res/drawable-v21/launch_background.xml b/fair_provider/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/fair_provider/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/fair_provider/example/android/app/src/main/res/drawable/launch_background.xml b/fair_provider/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/fair_provider/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/fair_provider/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/fair_provider/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/fair_provider/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/fair_provider/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/fair_provider/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/fair_provider/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/fair_provider/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/fair_provider/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/fair_provider/example/android/app/src/main/res/values-night/styles.xml b/fair_provider/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/fair_provider/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/fair_provider/example/android/app/src/main/res/values/styles.xml b/fair_provider/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/fair_provider/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/fair_provider/example/android/app/src/profile/AndroidManifest.xml b/fair_provider/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..c1f315f8 --- /dev/null +++ b/fair_provider/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/fair_provider/example/android/build.gradle b/fair_provider/example/android/build.gradle new file mode 100644 index 00000000..58a8c74b --- /dev/null +++ b/fair_provider/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.2.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') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/fair_provider/example/android/gradle.properties b/fair_provider/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/fair_provider/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/fair_provider/example/android/gradle/wrapper/gradle-wrapper.properties b/fair_provider/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3c472b99 --- /dev/null +++ b/fair_provider/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/fair_provider/example/android/settings.gradle b/fair_provider/example/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/fair_provider/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/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js new file mode 100644 index 00000000..2f3a565b --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js @@ -0,0 +1,19 @@ +GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;return runCallback(function(__mod__){with(__mod__.imports){function _CounterPageProviderState(){const inner=_CounterPageProviderState.__inner__;if(this==__global__){return new _CounterPageProviderState({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_CounterPageProviderState.prototype.ctor.apply(this,args);return this;}}_CounterPageProviderState.__inner__=function inner(){this.title="我是写在js侧的title";this.counterModelJson=`{ + "count":22, + "testName":"zzzzzz", + "someModel":{ + "a":"ffffff" + } +} + `;this.loginModelJson=` { + "account":"qwerty12345", + "password":"zxcv54321" +} + `;this.counterModelJson2=`{ + "count":333, + "testName":"testName的初始值", + "someModel":{ + "a":"someModel中a的初始值" + } +} + `;};_CounterPageProviderState.prototype={onLoad:function onLoad(){const __thiz__=this;with(__thiz__){}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},_incrementCounter:function _incrementCounter(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let counterModel=context.read("CounterModel");counterModel.count++;counterModel.testName="及哦飞机佛IE我房间";counterModel.someModel.a="hahahaha";counterModel.notify();}}},};_CounterPageProviderState.prototype.ctor=function(){};;return _CounterPageProviderState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json new file mode 100644 index 00000000..41f7932f --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json @@ -0,0 +1,206 @@ +{ + "className": "FairChangeNotifierProvider", + "na": { + "initialJson": "^(counterModelJson)", + "child": { + "className": "FairChangeNotifierProvider", + "na": { + "initialJson": "^(loginModelJson)", + "child": { + "className": "FairChangeNotifierProvider", + "na": { + "initialJson": "^(counterModelJson2)", + "child": { + "className": "Scaffold", + "na": { + "appBar": { + "className": "AppBar", + "na": { + "title": { + "className": "Text", + "pa": [ + "^(title)" + ] + } + } + }, + "body": { + "className": "Center", + "na": { + "child": { + "className": "Column", + "na": { + "mainAxisAlignment": "#(MainAxisAlignment.center)", + "children": [ + { + "className": "Text", + "pa": [ + "You have pushed the button this many times:" + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "FairSugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "FairSugarProvider.anyToString", + "pa": [ + { + "className": "FairSugarProvider.valueReader", + "pa": [ + "^(value)", + "count" + ] + } + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "CounterModel" + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "FairSugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "FairSugarProvider.stringValueReader", + "pa": [ + "^(value)", + "testName" + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "CounterModel" + ] + }, + { + "className": "FairSelector", + "na": { + "builder": { + "className": "FairSugarProvider.selectorBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + "^(value)" + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + }, + "selector": { + "className": "FairSugarProvider.selector", + "pa": [ + { + "className": "FairSugarProvider.evaluationToString", + "pa": [ + "^(value)", + "someModel.a" + ], + "functionParameters": { + "pa": [ + "context", + "value" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "CounterModel", + "String" + ] + } + ] + } + } + } + }, + "floatingActionButton": { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "FairSugarProvider.widgetBuilder", + "pa": [ + { + "className": "FloatingActionButton", + "na": { + "onPressed": "@(_incrementCounter(^(context)))", + "tooltip": "Increment", + "child": { + "className": "Icon", + "pa": [ + "#(Icons.add)" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + } + } + } + }, + "typeArgumentList": [ + "CounterModel" + ] + } + }, + "typeArgumentList": [ + "LoginModel" + ] + } + }, + "typeArgumentList": [ + "CounterModel" + ], + "methodMap": {}, + "digest": "40c478199087adf8f05936a7f7bc34bd" +} \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata new file mode 100644 index 00000000..a0216d16 --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata @@ -0,0 +1,7 @@ +# Generated by Fair on 2023-10-25 19:35:14.838560. + +source: example|lib/ui/counter_page_provider.dart +md5: fb818b363103f7c487d2f2aeb0162b60 +json: example|build/fair/lib_ui_counter_page_provider.fair.json +bin: example|build/fair/lib_ui_counter_page_provider.fair.bin +date: 2023-10-25 19:35:14.839444 diff --git a/fair_provider/example/ios/.gitignore b/fair_provider/example/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Flutter/AppFrameworkInfo.plist b/fair_provider/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..9625e105 --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Flutter/Debug.xcconfig b/fair_provider/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..ec97fc6f --- /dev/null +++ b/fair_provider/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/fair_provider/example/ios/Flutter/Release.xcconfig b/fair_provider/example/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..c4855bfe --- /dev/null +++ b/fair_provider/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/fair_provider/example/ios/Podfile b/fair_provider/example/ios/Podfile new file mode 100644 index 00000000..88359b22 --- /dev/null +++ b/fair_provider/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/fair_provider/example/ios/Podfile.lock b/fair_provider/example/ios/Podfile.lock new file mode 100644 index 00000000..2e4fcf64 --- /dev/null +++ b/fair_provider/example/ios/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - fair (0.0.1): + - Flutter + - Flutter (1.0.0) + - url_launcher_ios (0.0.1): + - Flutter + +DEPENDENCIES: + - fair (from `.symlinks/plugins/fair/ios`) + - Flutter (from `Flutter`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) + +EXTERNAL SOURCES: + fair: + :path: ".symlinks/plugins/fair/ios" + Flutter: + :path: Flutter + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" + +SPEC CHECKSUMS: + fair: a2ad8650ee4df9e6bcc51426213b3a3561dbacb8 + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86 + +PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 + +COCOAPODS: 1.12.0 diff --git a/fair_provider/example/ios/Runner.xcodeproj/project.pbxproj b/fair_provider/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..55cef8c7 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,553 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + 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 */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 94BA310586B5A9CF87F7AB4B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCF153AF3994561FE278B895 /* Pods_Runner.framework */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 5E4BF71D2BE8D74A80DB18CB /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 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 = ""; }; + B7C30DF2A1F0D0F3E92DF2FC /* 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 = ""; }; + BCF153AF3994561FE278B895 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D7802506E2F397A32E610450 /* 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 = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 94BA310586B5A9CF87F7AB4B /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 93140F6867E9C2D1F2FF6B74 /* Frameworks */ = { + isa = PBXGroup; + children = ( + BCF153AF3994561FE278B895 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + CA7905C5263AA99719E6F822 /* Pods */, + 93140F6867E9C2D1F2FF6B74 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + CA7905C5263AA99719E6F822 /* Pods */ = { + isa = PBXGroup; + children = ( + D7802506E2F397A32E610450 /* Pods-Runner.debug.xcconfig */, + 5E4BF71D2BE8D74A80DB18CB /* Pods-Runner.release.xcconfig */, + B7C30DF2A1F0D0F3E92DF2FC /* Pods-Runner.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + C79AF6FC94FD3E4CDF17A40A /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + D991A3FF2161D64F6EC88A29 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + 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"; + }; + C79AF6FC94FD3E4CDF17A40A /* [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; + }; + D991A3FF2161D64F6EC88A29 /* [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 */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 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)"; + ENABLE_BITCODE = NO; + EXCLUDED_ARCHS = arm64; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.wuba.fair.fairprovider.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 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)"; + ENABLE_BITCODE = NO; + EXCLUDED_ARCHS = arm64; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.wuba.fair.fairprovider.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + EXCLUDED_ARCHS = arm64; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.wuba.fair.fairprovider.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 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/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/fair_provider/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/fair_provider/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..c87d15a3 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fair_provider/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/fair_provider/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..21a3cc14 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/fair_provider/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/fair_provider/example/ios/Runner/AppDelegate.swift b/fair_provider/example/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..70693e4a --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..dc9ada4725e9b0ddb1deab583e5b5102493aa332 GIT binary patch literal 10932 zcmeHN2~<R zh`|8`A_PQ1nSu(UMFx?8j8PC!!VDphaL#`F42fd#7Vlc`zIE4n%Y~eiz4y1j|NDpi z?<@|pSJ-HM`qifhf@m%MamgwK83`XpBA<+azdF#2QsT{X@z0A9Bq>~TVErigKH1~P zRX-!h-f0NJ4Mh++{D}J+K>~~rq}d%o%+4dogzXp7RxX4C>Km5XEI|PAFDmo;DFm6G zzjVoB`@qW98Yl0Kvc-9w09^PrsobmG*Eju^=3f?0o-t$U)TL1B3;sZ^!++3&bGZ!o-*6w?;oOhf z=A+Qb$scV5!RbG+&2S}BQ6YH!FKb0``VVX~T$dzzeSZ$&9=X$3)_7Z{SspSYJ!lGE z7yig_41zpQ)%5dr4ff0rh$@ky3-JLRk&DK)NEIHecf9c*?Z1bUB4%pZjQ7hD!A0r-@NF(^WKdr(LXj|=UE7?gBYGgGQV zidf2`ZT@pzXf7}!NH4q(0IMcxsUGDih(0{kRSez&z?CFA0RVXsVFw3^u=^KMtt95q z43q$b*6#uQDLoiCAF_{RFc{!H^moH_cmll#Fc^KXi{9GDl{>%+3qyfOE5;Zq|6#Hb zp^#1G+z^AXfRKaa9HK;%b3Ux~U@q?xg<2DXP%6k!3E)PA<#4$ui8eDy5|9hA5&{?v z(-;*1%(1~-NTQ`Is1_MGdQ{+i*ccd96ab$R$T3=% zw_KuNF@vI!A>>Y_2pl9L{9h1-C6H8<)J4gKI6{WzGBi<@u3P6hNsXG=bRq5c+z;Gc3VUCe;LIIFDmQAGy+=mRyF++u=drBWV8-^>0yE9N&*05XHZpPlE zxu@?8(ZNy7rm?|<+UNe0Vs6&o?l`Pt>P&WaL~M&#Eh%`rg@Mbb)J&@DA-wheQ>hRV z<(XhigZAT z>=M;URcdCaiO3d^?H<^EiEMDV+7HsTiOhoaMX%P65E<(5xMPJKxf!0u>U~uVqnPN7T!X!o@_gs3Ct1 zlZ_$5QXP4{Aj645wG_SNT&6m|O6~Tsl$q?nK*)(`{J4b=(yb^nOATtF1_aS978$x3 zx>Q@s4i3~IT*+l{@dx~Hst21fR*+5}S1@cf>&8*uLw-0^zK(+OpW?cS-YG1QBZ5q! zgTAgivzoF#`cSz&HL>Ti!!v#?36I1*l^mkrx7Y|K6L#n!-~5=d3;K<;Zqi|gpNUn_ z_^GaQDEQ*jfzh;`j&KXb66fWEk1K7vxQIMQ_#Wu_%3 z4Oeb7FJ`8I>Px;^S?)}2+4D_83gHEq>8qSQY0PVP?o)zAv3K~;R$fnwTmI-=ZLK`= zTm+0h*e+Yfr(IlH3i7gUclNH^!MU>id$Jw>O?2i0Cila#v|twub21@e{S2v}8Z13( zNDrTXZVgris|qYm<0NU(tAPouG!QF4ZNpZPkX~{tVf8xY690JqY1NVdiTtW+NqyRP zZ&;T0ikb8V{wxmFhlLTQ&?OP7 z;(z*<+?J2~z*6asSe7h`$8~Se(@t(#%?BGLVs$p``;CyvcT?7Y!{tIPva$LxCQ&4W z6v#F*);|RXvI%qnoOY&i4S*EL&h%hP3O zLsrFZhv&Hu5tF$Lx!8(hs&?!Kx5&L(fdu}UI5d*wn~A`nPUhG&Rv z2#ixiJdhSF-K2tpVL=)5UkXRuPAFrEW}7mW=uAmtVQ&pGE-&az6@#-(Te^n*lrH^m@X-ftVcwO_#7{WI)5v(?>uC9GG{lcGXYJ~Q8q zbMFl7;t+kV;|;KkBW2!P_o%Czhw&Q(nXlxK9ak&6r5t_KH8#1Mr-*0}2h8R9XNkr zto5-b7P_auqTJb(TJlmJ9xreA=6d=d)CVbYP-r4$hDn5|TIhB>SReMfh&OVLkMk-T zYf%$taLF0OqYF?V{+6Xkn>iX@TuqQ?&cN6UjC9YF&%q{Ut3zv{U2)~$>-3;Dp)*(? zg*$mu8^i=-e#acaj*T$pNowo{xiGEk$%DusaQiS!KjJH96XZ-hXv+jk%ard#fu=@Q z$AM)YWvE^{%tDfK%nD49=PI|wYu}lYVbB#a7wtN^Nml@CE@{Gv7+jo{_V?I*jkdLD zJE|jfdrmVbkfS>rN*+`#l%ZUi5_bMS<>=MBDNlpiSb_tAF|Zy`K7kcp@|d?yaTmB^ zo?(vg;B$vxS|SszusORgDg-*Uitzdi{dUV+glA~R8V(?`3GZIl^egW{a919!j#>f` znL1o_^-b`}xnU0+~KIFLQ)$Q6#ym%)(GYC`^XM*{g zv3AM5$+TtDRs%`2TyR^$(hqE7Y1b&`Jd6dS6B#hDVbJlUXcG3y*439D8MrK!2D~6gn>UD4Imctb z+IvAt0iaW73Iq$K?4}H`7wq6YkTMm`tcktXgK0lKPmh=>h+l}Y+pDtvHnG>uqBA)l zAH6BV4F}v$(o$8Gfo*PB>IuaY1*^*`OTx4|hM8jZ?B6HY;F6p4{`OcZZ(us-RVwDx zUzJrCQlp@mz1ZFiSZ*$yX3c_#h9J;yBE$2g%xjmGF4ca z&yL`nGVs!Zxsh^j6i%$a*I3ZD2SoNT`{D%mU=LKaEwbN(_J5%i-6Va?@*>=3(dQy` zOv%$_9lcy9+(t>qohkuU4r_P=R^6ME+wFu&LA9tw9RA?azGhjrVJKy&8=*qZT5Dr8g--d+S8zAyJ$1HlW3Olryt`yE zFIph~Z6oF&o64rw{>lgZISC6p^CBer9C5G6yq%?8tC+)7*d+ib^?fU!JRFxynRLEZ zj;?PwtS}Ao#9whV@KEmwQgM0TVP{hs>dg(1*DiMUOKHdQGIqa0`yZnHk9mtbPfoLx zo;^V6pKUJ!5#n`w2D&381#5#_t}AlTGEgDz$^;u;-vxDN?^#5!zN9ngytY@oTv!nc zp1Xn8uR$1Z;7vY`-<*?DfPHB;x|GUi_fI9@I9SVRv1)qETbNU_8{5U|(>Du84qP#7 z*l9Y$SgA&wGbj>R1YeT9vYjZuC@|{rajTL0f%N@>3$DFU=`lSPl=Iv;EjuGjBa$Gw zHD-;%YOE@<-!7-Mn`0WuO3oWuL6tB2cpPw~Nvuj|KM@))ixuDK`9;jGMe2d)7gHin zS<>k@!x;!TJEc#HdL#RF(`|4W+H88d4V%zlh(7#{q2d0OQX9*FW^`^_<3r$kabWAB z$9BONo5}*(%kx zOXi-yM_cmB3>inPpI~)duvZykJ@^^aWzQ=eQ&STUa}2uT@lV&WoRzkUoE`rR0)`=l zFT%f|LA9fCw>`enm$p7W^E@U7RNBtsh{_-7vVz3DtB*y#*~(L9+x9*wn8VjWw|Q~q zKFsj1Yl>;}%MG3=PY`$g$_mnyhuV&~O~u~)968$0b2!Jkd;2MtAP#ZDYw9hmK_+M$ zb3pxyYC&|CuAbtiG8HZjj?MZJBFbt`ryf+c1dXFuC z0*ZQhBzNBd*}s6K_G}(|Z_9NDV162#y%WSNe|FTDDhx)K!c(mMJh@h87@8(^YdK$&d*^WQe8Z53 z(|@MRJ$Lk-&ii74MPIs80WsOFZ(NX23oR-?As+*aq6b?~62@fSVmM-_*cb1RzZ)`5$agEiL`-E9s7{GM2?(KNPgK1(+c*|-FKoy}X(D_b#etO|YR z(BGZ)0Ntfv-7R4GHoXp?l5g#*={S1{u-QzxCGng*oWr~@X-5f~RA14b8~B+pLKvr4 zfgL|7I>jlak9>D4=(i(cqYf7#318!OSR=^`xxvI!bBlS??`xxWeg?+|>MxaIdH1U~#1tHu zB{QMR?EGRmQ_l4p6YXJ{o(hh-7Tdm>TAX380TZZZyVkqHNzjUn*_|cb?T? zt;d2s-?B#Mc>T-gvBmQZx(y_cfkXZO~{N zT6rP7SD6g~n9QJ)8F*8uHxTLCAZ{l1Y&?6v)BOJZ)=R-pY=Y=&1}jE7fQ>USS}xP#exo57uND0i*rEk@$;nLvRB@u~s^dwRf?G?_enN@$t* zbL%JO=rV(3Ju8#GqUpeE3l_Wu1lN9Y{D4uaUe`g>zlj$1ER$6S6@{m1!~V|bYkhZA z%CvrDRTkHuajMU8;&RZ&itnC~iYLW4DVkP<$}>#&(`UO>!n)Po;Mt(SY8Yb`AS9lt znbX^i?Oe9r_o=?})IHKHoQGKXsps_SE{hwrg?6dMI|^+$CeC&z@*LuF+P`7LfZ*yr+KN8B4{Nzv<`A(wyR@!|gw{zB6Ha ziwPAYh)oJ(nlqSknu(8g9N&1hu0$vFK$W#mp%>X~AU1ay+EKWcFdif{% z#4!4aoVVJ;ULmkQf!ke2}3hqxLK>eq|-d7Ly7-J9zMpT`?dxo6HdfJA|t)?qPEVBDv z{y_b?4^|YA4%WW0VZd8C(ZgQzRI5(I^)=Ub`Y#MHc@nv0w-DaJAqsbEHDWG8Ia6ju zo-iyr*sq((gEwCC&^TYBWt4_@|81?=B-?#P6NMff(*^re zYqvDuO`K@`mjm_Jd;mW_tP`3$cS?R$jR1ZN09$YO%_iBqh5ftzSpMQQtxKFU=FYmP zeY^jph+g<4>YO;U^O>-NFLn~-RqlHvnZl2yd2A{Yc1G@Ga$d+Q&(f^tnPf+Z7serIU};17+2DU_f4Z z@GaPFut27d?!YiD+QP@)T=77cR9~MK@bd~pY%X(h%L={{OIb8IQmf-!xmZkm8A0Ga zQSWONI17_ru5wpHg3jI@i9D+_Y|pCqVuHJNdHUauTD=R$JcD2K_liQisqG$(sm=k9;L* z!L?*4B~ql7uioSX$zWJ?;q-SWXRFhz2Jt4%fOHA=Bwf|RzhwqdXGr78y$J)LR7&3T zE1WWz*>GPWKZ0%|@%6=fyx)5rzUpI;bCj>3RKzNG_1w$fIFCZ&UR0(7S?g}`&Pg$M zf`SLsz8wK82Vyj7;RyKmY{a8G{2BHG%w!^T|Njr!h9TO2LaP^_f22Q1=l$QiU84ao zHe_#{S6;qrC6w~7{y(hs-?-j?lbOfgH^E=XcSgnwW*eEz{_Z<_xN#0001NP)t-s|Ns9~ z#rXRE|M&d=0au&!`~QyF`q}dRnBDt}*!qXo`c{v z{Djr|@Adh0(D_%#_&mM$D6{kE_x{oE{l@J5@%H*?%=t~i_`ufYOPkAEn!pfkr2$fs z652Tz0001XNklqeeKN4RM4i{jKqmiC$?+xN>3Apn^ z0QfuZLym_5b<*QdmkHjHlj811{If)dl(Z2K0A+ekGtrFJb?g|wt#k#pV-#A~bK=OT ts8>{%cPtyC${m|1#B1A6#u!Q;umknL1chzTM$P~L002ovPDHLkV1lTfnu!1a literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..797d452e458972bab9d994556c8305db4c827017 GIT binary patch literal 406 zcmV;H0crk;P))>cdjpWt&rLJgVp-t?DREyuq1A%0Z4)6_WsQ7{nzjN zo!X zGXV)2i3kcZIL~_j>uIKPK_zib+3T+Nt3Mb&Br)s)UIaA}@p{wDda>7=Q|mGRp7pqY zkJ!7E{MNz$9nOwoVqpFb)}$IP24Wn2JJ=Cw(!`OXJBr45rP>>AQr$6c7slJWvbpNW z@KTwna6d?PP>hvXCcp=4F;=GR@R4E7{4VU^0p4F>v^#A|>07*qoM6N<$f*5nx ACIA2c literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..6ed2d933e1120817fe9182483a228007b18ab6ae GIT binary patch literal 450 zcmV;z0X_bSP)iGWQ_5NJQ_~rNh*z)}eT%KUb z`7gNk0#AwF^#0T0?hIa^`~Ck;!}#m+_uT050aTR(J!bU#|IzRL%^UsMS#KsYnTF*!YeDOytlP4VhV?b} z%rz_<=#CPc)tU1MZTq~*2=8~iZ!lSa<{9b@2Jl;?IEV8)=fG217*|@)CCYgFze-x? zIFODUIA>nWKpE+bn~n7;-89sa>#DR>TSlqWk*!2hSN6D~Qb#VqbP~4Fk&m`@1$JGr zXPIdeRE&b2Thd#{MtDK$px*d3-Wx``>!oimf%|A-&-q*6KAH)e$3|6JV%HX{Hig)k suLT-RhftRq8b9;(V=235Wa|I=027H2wCDra;{X5v07*qoM6N<$f;9x^2LJ#7 literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..4cd7b0099ca80c806f8fe495613e8d6c69460d76 GIT binary patch literal 282 zcmV+#0p(^bcu7P-R4C8Q z&e;xxFbF_Vrezo%_kH*OKhshZ6BFpG-Y1e10`QXJKbND7AMQ&cMj60B5TNObaZxYybcN07*qoM6N<$g3m;S%K!iX literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..fe730945a01f64a61e2235dbe3f45b08f7729182 GIT binary patch literal 462 zcmV;<0WtoGP)-}iV`2<;=$?g5M=KQbZ{F&YRNy7Nn@%_*5{gvDM0aKI4?ESmw z{NnZg)A0R`+4?NF_RZexyVB&^^ZvN!{I28tr{Vje;QNTz`dG&Jz0~Ek&f2;*Z7>B|cg}xYpxEFY+0YrKLF;^Q+-HreN0P{&i zK~zY`?b7ECf-n?@;d<&orQ*Q7KoR%4|C>{W^h6@&01>0SKS`dn{Q}GT%Qj_{PLZ_& zs`MFI#j-(>?bvdZ!8^xTwlY{qA)T4QLbY@j(!YJ7aXJervHy6HaG_2SB`6CC{He}f zHVw(fJWApwPq!6VY7r1w-Fs)@ox~N+q|w~e;JI~C4Vf^@d>Wvj=fl`^u9x9wd9 zR%3*Q+)t%S!MU_`id^@&Y{y7-r98lZX0?YrHlfmwb?#}^1b{8g&KzmkE(L>Z&)179 zp<)v6Y}pRl100G2FL_t(o!|l{-Q-VMg#&MKg7c{O0 z2wJImOS3Gy*Z2Qifdv~JYOp;v+U)a|nLoc7hNH;I$;lzDt$}rkaFw1mYK5_0Q(Sut zvbEloxON7$+HSOgC9Z8ltuC&0OSF!-mXv5caV>#bc3@hBPX@I$58-z}(ZZE!t-aOG zpjNkbau@>yEzH(5Yj4kZiMH32XI!4~gVXNnjAvRx;Sdg^`>2DpUEwoMhTs_st8pKG z(%SHyHdU&v%f36~uERh!bd`!T2dw;z6PrOTQ7Vt*#9F2uHlUVnb#ev_o^fh}Dzmq} zWtlk35}k=?xj28uO|5>>$yXadTUE@@IPpgH`gJ~Ro4>jd1IF|(+IX>8M4Ps{PNvmI zNj4D+XgN83gPt_Gm}`Ybv{;+&yu-C(Grdiahmo~BjG-l&mWM+{e5M1sm&=xduwgM9 z`8OEh`=F3r`^E{n_;%9weN{cf2%7=VzC@cYj+lg>+3|D|_1C@{hcU(DyQG_BvBWe? zvTv``=%b1zrol#=R`JB)>cdjpWt&rLJgVp-t?DREyuq1A%0Z4)6_WsQ7{nzjN zo!X zGXV)2i3kcZIL~_j>uIKPK_zib+3T+Nt3Mb&Br)s)UIaA}@p{wDda>7=Q|mGRp7pqY zkJ!7E{MNz$9nOwoVqpFb)}$IP24Wn2JJ=Cw(!`OXJBr45rP>>AQr$6c7slJWvbpNW z@KTwna6d?PP>hvXCcp=4F;=GR@R4E7{4VU^0p4F>v^#A|>07*qoM6N<$f*5nx ACIA2c literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..502f463a9bc882b461c96aadf492d1729e49e725 GIT binary patch literal 586 zcmV-Q0=4~#P)+}#`wDE{8-2Mebf5<{{PqV{TgVcv*r8?UZ3{-|G?_}T*&y;@cqf{ z{Q*~+qr%%p!1pS*_Uicl#q9lc(D`!D`LN62sNwq{oYw(Wmhk)k<@f$!$@ng~_5)Ru z0Z)trIA5^j{DIW^c+vT2%lW+2<(RtE2wR;4O@)Tm`Xr*?A(qYoM}7i5Yxw>D(&6ou zxz!_Xr~yNF+waPe00049Nkl*;a!v6h%{rlvIH#gW3s8p;bFr=l}mRqpW2h zw=OA%hdyL~z+UHOzl0eKhEr$YYOL-c-%Y<)=j?(bzDweB7{b+%_ypvm_cG{SvM=DK zhv{K@m>#Bw>2W$eUI#iU)Wdgs8Y3U+A$Gd&{+j)d)BmGKx+43U_!tik_YlN)>$7G! zhkE!s;%oku3;IwG3U^2kw?z+HM)jB{@zFhK8P#KMSytSthr+4!c(5c%+^UBn`0X*2 zy3(k600_CSZj?O$Qu%&$;|TGUJrptR(HzyIx>5E(2r{eA(<6t3e3I0B)7d6s7?Z5J zZ!rtKvA{MiEBm&KFtoifx>5P^Z=vl)95XJn()aS5%ad(s?4-=Tkis9IGu{`Fy8r+H07*qoM6N<$f20Z)wqMt%V?S?~D#06};F zA3KcL`Wb+>5ObvgQIG&ig8(;V04hz?@cqy3{mSh8o!|U|)cI!1_+!fWH@o*8vh^CU z^ws0;(c$gI+2~q^tO#GDHf@=;DncUw00J^eL_t(&-tE|HQ`%4vfZ;WsBqu-$0nu1R zq^Vj;p$clf^?twn|KHO+IGt^q#a3X?w9dXC@*yxhv&l}F322(8Y1&=P&I}~G@#h6; z1CV9ecD9ZEe87{{NtI*)_aJ<`kJa z?5=RBtFF50s;jQLFil-`)m2wrb=6h(&brpj%nG_U&ut~$?8Rokzxi8zJoWr#2dto5 zOX_URcc<1`Iky+jc;A%Vzx}1QU{2$|cKPom2Vf1{8m`vja4{F>HS?^Nc^rp}xo+Nh zxd}eOm`fm3@MQC1< zIk&aCjb~Yh%5+Yq0`)D;q{#-Uqlv*o+Oor zE!I71Z@ASH3grl8&P^L0WpavHoP|UX4e?!igT`4?AZk$hu*@%6WJ;zDOGlw7kj@ zY5!B-0ft0f?Lgb>C;$Ke07*qoM6N<$f~t1N9smFU literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0ec303439225b78712f49115768196d8d76f6790 GIT binary patch literal 862 zcmV-k1EKthP)20Z)wqMt%V?S?~D#06};F zA3KcL`Wb+>5ObvgQIG&ig8(;V04hz?@cqy3{mSh8o!|U|)cI!1_+!fWH@o*8vh^CU z^ws0;(c$gI+2~q^tO#GDHf@=;DncUw00J^eL_t(&-tE|HQ`%4vfZ;WsBqu-$0nu1R zq^Vj;p$clf^?twn|KHO+IGt^q#a3X?w9dXC@*yxhv&l}F322(8Y1&=P&I}~G@#h6; z1CV9ecD9ZEe87{{NtI*)_aJ<`kJa z?5=RBtFF50s;jQLFil-`)m2wrb=6h(&brpj%nG_U&ut~$?8Rokzxi8zJoWr#2dto5 zOX_URcc<1`Iky+jc;A%Vzx}1QU{2$|cKPom2Vf1{8m`vja4{F>HS?^Nc^rp}xo+Nh zxd}eOm`fm3@MQC1< zIk&aCjb~Yh%5+Yq0`)D;q{#-Uqlv*o+Oor zE!I71Z@ASH3grl8&P^L0WpavHoP|UX4e?!igT`4?AZk$hu*@%6WJ;zDOGlw7kj@ zY5!B-0ft0f?Lgb>C;$Ke07*qoM6N<$f~t1N9smFU literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..e9f5fea27c705180eb716271f41b582e76dcbd90 GIT binary patch literal 1674 zcmV;526g#~P){YQnis^a@{&-nmRmq)<&%Mztj67_#M}W?l>kYSliK<%xAp;0j{!}J0!o7b zE>q9${Lb$D&h7k=+4=!ek^n+`0zq>LL1O?lVyea53S5x`Nqqo2YyeuIrQrJj9XjOp z{;T5qbj3}&1vg1VK~#9!?b~^C5-}JC@Pyrv-6dSEqJqT}#j9#dJ@GzT@B8}x zU&J@bBI>f6w6en+CeI)3^kC*U?}X%OD8$Fd$H&LV$H&LV$H&LV#|K5~mLYf|VqzOc zkc7qL~0sOYuM{tG`rYEDV{DWY`Z8&)kW*hc2VkBuY+^Yx&92j&StN}Wp=LD zxoGxXw6f&8sB^u})h@b@z0RBeD`K7RMR9deyL(ZJu#39Z>rT)^>v}Khq8U-IbIvT> z?4pV9qGj=2)TNH3d)=De<+^w;>S7m_eFKTvzeaBeir45xY!^m!FmxnljbSS_3o=g( z->^wC9%qkR{kbGnW8MfFew_o9h3(r55Is`L$8KI@d+*%{=Nx+FXJ98L0PjFIu;rGnnfY zn1R5Qnp<{Jq0M1vX=X&F8gtLmcWv$1*M@4ZfF^9``()#hGTeKeP`1!iED ztNE(TN}M5}3Bbc*d=FIv`DNv&@|C6yYj{sSqUj5oo$#*0$7pu|Dd2TLI>t5%I zIa4Dvr(iayb+5x=j*Vum9&irk)xV1`t509lnPO0%skL8_1c#Xbamh(2@f?4yUI zhhuT5<#8RJhGz4%b$`PJwKPAudsm|at?u;*hGgnA zU1;9gnxVBC)wA(BsB`AW54N{|qmikJR*%x0c`{LGsSfa|NK61pYH(r-UQ4_JXd!Rsz)=k zL{GMc5{h138)fF5CzHEDM>+FqY)$pdN3}Ml+riTgJOLN0F*Vh?{9ESR{SVVg>*>=# zix;VJHPtvFFCRY$Ks*F;VX~%*r9F)W`PmPE9F!(&s#x07n2<}?S{(ygpXgX-&B&OM zONY&BRQ(#%0%jeQs?oJ4P!p*R98>qCy5p8w>_gpuh39NcOlp)(wOoz0sY-Qz55eB~ z7OC-fKBaD1sE3$l-6QgBJO!n?QOTza`!S_YK z_v-lm^7{VO^8Q@M_^8F)09Ki6%=s?2_5eupee(w1FB%aqSweusQ-T+CH0Xt{` zFjMvW{@C&TB)k25()nh~_yJ9coBRL(0oO@HK~z}7?bm5j;y@69;bvlHb2tf!$ReA~x{22wTq550 z?f?Hnw(;m3ip30;QzdV~7pi!wyMYhDtXW#cO7T>|f=bdFhu+F!zMZ2UFj;GUKX7tI z;hv3{q~!*pMj75WP_c}>6)IWvg5_yyg<9Op()eD1hWC19M@?_9_MHec{Z8n3FaF{8 z;u`Mw0ly(uE>*CgQYv{be6ab2LWhlaH1^iLIM{olnag$78^Fd}%dR7;JECQ+hmk|o z!u2&!3MqPfP5ChDSkFSH8F2WVOEf0(E_M(JL17G}Y+fg0_IuW%WQ zG(mG&u?|->YSdk0;8rc{yw2@2Z&GA}z{Wb91Ooz9VhA{b2DYE7RmG zjL}?eq#iX%3#k;JWMx_{^2nNax`xPhByFiDX+a7uTGU|otOvIAUy|dEKkXOm-`aWS z27pUzD{a)Ct<6p{{3)+lq@i`t@%>-wT4r?*S}k)58e09WZYP0{{R3FC5Sl00039P)t-s|Ns9~ z#rP?<_5oL$Q^olD{r_0T`27C={r>*`|Nj71npVa5OTzc(_WfbW_({R{p56NV{r*M2 z_xt?)2V0#0NsfV0u>{42ctGP(8vQj-Btk1n|O0ZD=YLwd&R{Ko41Gr9H= zY@z@@bOAMB5Ltl$E>bJJ{>JP30ZxkmI%?eW{k`b?Wy<&gOo;dS`~CR$Vwb@XWtR|N zi~t=w02?-0&j0TD{>bb6sNwsK*!p?V`RMQUl(*DVjk-9Cx+-z1KXab|Ka2oXhX5f% z`$|e!000AhNklrxs)5QTeTVRiEmz~MKK1WAjCw(c-JK6eox;2O)?`? zTG`AHia671e^vgmp!llKp|=5sVHk#C7=~epA~VAf-~%aPC=%Qw01h8mnSZ|p?hz91 z7p83F3%LVu9;S$tSI$C^%^yud1dfTM_6p2|+5Ejp$bd`GDvbR|xit>i!ZD&F>@CJrPmu*UjD&?DfZs=$@e3FQA(vNiU+$A*%a} z?`XcG2jDxJ_ZQ#Md`H{4Lpf6QBDp81_KWZ6Tk#yCy1)32zO#3<7>b`eT7UyYH1eGz z;O(rH$=QR*L%%ZcBpc=eGua?N55nD^K(8<#gl2+pN_j~b2MHs4#mcLmv%DkspS-3< zpI1F=^9siI0s-;IN_IrA;5xm~3?3!StX}pUv0vkxMaqm+zxrg7X7(I&*N~&dEd0kD z-FRV|g=|QuUsuh>-xCI}vD2imzYIOIdcCVV=$Bz@*u0+Bs<|L^)32nN*=wu3n%Ynw z@1|eLG>!8ruU1pFXUfb`j>(=Gy~?Rn4QJ-c3%3T|(Frd!bI`9u&zAnyFYTqlG#&J7 zAkD(jpw|oZLNiA>;>hgp1KX7-wxC~31II47gc zHcehD6Uxlf%+M^^uN5Wc*G%^;>D5qT{>=uxUhX%WJu^Z*(_Wq9y}npFO{Hhb>s6<9 zNi0pHXWFaVZnb)1+RS&F)xOv6&aeILcI)`k#0YE+?e)5&#r7J#c`3Z7x!LpTc01dx zrdC3{Z;joZ^KN&))zB_i)I9fWedoN>Zl-6_Iz+^G&*ak2jpF07*qoM6N<$f;w%0(f|Me literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0467bf12aa4d28f374bb26596605a46dcbb3e7c8 GIT binary patch literal 1418 zcmV;51$Fv~P)q zKfU)WzW*n(@|xWGCA9ScMt*e9`2kdxPQ&&>|-UCa7_51w+ zLUsW@ZzZSW0y$)Hp~e9%PvP|a03ks1`~K?q{u;6NC8*{AOqIUq{CL&;p56Lf$oQGq z^={4hPQv)y=I|4n+?>7Fim=dxt1 z2H+Dm+1+fh+IF>G0SjJMkQQre1x4|G*Z==(Ot&kCnUrL4I(rf(ucITwmuHf^hXiJT zkdTm&kdTm&kdTm&kdP`esgWG0BcWCVkVZ&2dUwN`cgM8QJb`Z7Z~e<&Yj2(}>Tmf` zm1{eLgw!b{bXkjWbF%dTkTZEJWyWOb##Lfw4EK2}<0d6%>AGS{po>WCOy&f$Tay_> z?NBlkpo@s-O;0V%Y_Xa-G#_O08q5LR*~F%&)}{}r&L%Sbs8AS4t7Y0NEx*{soY=0MZExqA5XHQkqi#4gW3 zqODM^iyZl;dvf)-bOXtOru(s)Uc7~BFx{w-FK;2{`VA?(g&@3z&bfLFyctOH!cVsF z7IL=fo-qBndRUm;kAdXR4e6>k-z|21AaN%ubeVrHl*<|s&Ax@W-t?LR(P-24A5=>a z*R9#QvjzF8n%@1Nw@?CG@6(%>+-0ASK~jEmCV|&a*7-GKT72W<(TbSjf)&Eme6nGE z>Gkj4Sq&2e+-G%|+NM8OOm5zVl9{Z8Dd8A5z3y8mZ=4Bv4%>as_{9cN#bm~;h>62( zdqY93Zy}v&c4n($Vv!UybR8ocs7#zbfX1IY-*w~)p}XyZ-SFC~4w>BvMVr`dFbelV{lLL0bx7@*ZZdebr3`sP;? zVImji)kG)(6Juv0lz@q`F!k1FE;CQ(D0iG$wchPbKZQELlsZ#~rt8#90Y_Xh&3U-< z{s<&cCV_1`^TD^ia9!*mQDq& zn2{r`j};V|uV%_wsP!zB?m%;FeaRe+X47K0e+KE!8C{gAWF8)lCd1u1%~|M!XNRvw zvtqy3iz0WSpWdhn6$hP8PaRBmp)q`#PCA`Vd#Tc$@f1tAcM>f_I@bC)hkI9|o(Iqv zo}Piadq!j76}004RBio<`)70k^`K1NK)q>w?p^C6J2ZC!+UppiK6&y3Kmbv&O!oYF z34$0Z;QO!JOY#!`qyGH<3Pd}Pt@q*A0V=3SVtWKRR8d8Z&@)3qLPA19LPA19LPEUC YUoZo%k(ykuW&i*H07*qoM6N<$f+CH{y8r+H literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J Q1PU{Fy85}Sb4q9e0B4a5jsO4v literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J Q1PU{Fy85}Sb4q9e0B4a5jsO4v literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J Q1PU{Fy85}Sb4q9e0B4a5jsO4v literal 0 HcmV?d00001 diff --git a/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/fair_provider/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/fair_provider/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/fair_provider/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/fair_provider/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/fair_provider/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fair_provider/example/ios/Runner/Base.lproj/Main.storyboard b/fair_provider/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/fair_provider/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fair_provider/example/ios/Runner/Info.plist b/fair_provider/example/ios/Runner/Info.plist new file mode 100644 index 00000000..7f553465 --- /dev/null +++ b/fair_provider/example/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + 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/fair_provider/example/ios/Runner/Runner-Bridging-Header.h b/fair_provider/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/fair_provider/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/fair_provider/example/lib/entity/counter_model.dart b/fair_provider/example/lib/entity/counter_model.dart new file mode 100644 index 00000000..d3fe5460 --- /dev/null +++ b/fair_provider/example/lib/entity/counter_model.dart @@ -0,0 +1,14 @@ +import 'package:fair_provider/fair_provider.dart'; + +class CounterModel extends FairChangeNotifier { + + var count = 0; + var testName = "dsds"; + SomeModel? someModel; + +} + +class SomeModel{ + var a = "a"; + +} \ No newline at end of file diff --git a/fair_provider/example/lib/entity/login_model.dart b/fair_provider/example/lib/entity/login_model.dart new file mode 100644 index 00000000..ce68490f --- /dev/null +++ b/fair_provider/example/lib/entity/login_model.dart @@ -0,0 +1,8 @@ +import 'package:fair_provider/fair_provider.dart'; + +class LoginModel extends FairChangeNotifier { + + String? account; + String? password; + +} \ No newline at end of file diff --git a/fair_provider/example/lib/main.dart b/fair_provider/example/lib/main.dart new file mode 100644 index 00000000..3a03dcac --- /dev/null +++ b/fair_provider/example/lib/main.dart @@ -0,0 +1,131 @@ +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; +import 'package:flutter/material.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + + FairApp.runApplication( + FairApp( + generated: FairAppModule(), + child: const MyApp(), + dynamicWidgetBuilder: (proxyMirror, page, bound, {bundle}) => + ProviderDynamicWidgetBuilder(proxyMirror, page, bound, + bundle: bundle), + ), + plugins: {'FairProvider': FairProvider()}, + jsPlugins: {'fair_provider': 'packages/fair_provider/assets/plugin/fair_provider_plugin.js'} + ); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: + // MyHomePage(title: "dasdasdsa",), + Scaffold( + appBar: AppBar( + title: const Text('Flutter Lab'), + ), + body: Builder( + builder: (context) => ListView( + children: [ + addItem("CounterProvider Fair", () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FairWidget( + name: "CounterProvider", + path: + "assets/fair/lib_ui_counter_page_provider.fair.json", + ), + )); + }), + ], + ), + ))); + } +} + +Widget addItem(String itemName, dynamic onPress) { + return GestureDetector( + onTap: onPress, + child: Container( + alignment: Alignment.centerLeft, + height: 70, + decoration: BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + color: Colors.grey.withOpacity(0.5), width: 0.5))), + padding: const EdgeInsets.only(left: 20.0), + child: Text( + itemName, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + textAlign: TextAlign.left, + ))); +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + test(), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); + } + + Widget test() { + return Container(); + } +} diff --git a/fair_provider/example/lib/ui/counter_page_provider.dart b/fair_provider/example/lib/ui/counter_page_provider.dart new file mode 100644 index 00000000..09d32bbb --- /dev/null +++ b/fair_provider/example/lib/ui/counter_page_provider.dart @@ -0,0 +1,114 @@ +import 'package:example/entity/counter_model.dart'; +import 'package:example/entity/login_model.dart'; +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; +import 'package:flutter/material.dart'; + +@FairPatch() +class CounterPageProvider extends StatefulWidget { + const CounterPageProvider({super.key}); + + @override + State createState() => _CounterPageProviderState(); +} + +class _CounterPageProviderState extends State { + var title = "我是写在js侧的title"; + + var counterModelJson = ''' +{ + "count":22, + "testName":"zzzzzz", + "someModel":{ + "a":"ffffff" + } +} + '''; + + var loginModelJson = ''' + { + "account":"qwerty12345", + "password":"zxcv54321" +} + '''; + + var counterModelJson2 = ''' +{ + "count":333, + "testName":"testName的初始值", + "someModel":{ + "a":"someModel中a的初始值" + } +} + '''; + + void onLoad() {} + + void onUnload() {} + + void _incrementCounter(FairContext context) { + var counterModel = context.read("CounterModel"); + counterModel.count++; + counterModel.testName = "及哦飞机佛IE我房间"; + counterModel.someModel?.a = "hahahaha"; + counterModel.notify(); + } + + @override + Widget build(BuildContext context) { + return FairChangeNotifierProvider( + initialJson: counterModelJson, + child: FairChangeNotifierProvider( + initialJson: loginModelJson, + child: FairChangeNotifierProvider( + initialJson: counterModelJson2, + child: Scaffold( + appBar: AppBar( + title: Text( + title, + ), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + FairConsumer( + builder: FairSugarProvider.consumerBuilder((context, value, + child) => + Text(FairSugarProvider.anyToString( + FairSugarProvider.valueReader(value, 'count')))), + ), + FairConsumer( + builder: FairSugarProvider.consumerBuilder( + (context, value, child) => Text( + FairSugarProvider.stringValueReader( + value, 'testName'))), + ), + FairSelector( + builder: FairSugarProvider.selectorBuilder( + (context, value, child) => Text(value)), + selector: FairSugarProvider.selector((context, value) => + FairSugarProvider.evaluationToString( + value, 'someModel.a'))), + ], + ), + ), + floatingActionButton: FairContextBuilder( + builder: FairSugarProvider.widgetBuilder( + (context) => FloatingActionButton( + onPressed: () { + _incrementCounter(context); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + )), + ), + ), + ), + ), + ); + } +} diff --git a/fair_provider/example/pubspec.lock b/fair_provider/example/pubspec.lock new file mode 100644 index 00000000..8a6f031c --- /dev/null +++ b/fair_provider/example/pubspec.lock @@ -0,0 +1,725 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + url: "https://pub.dev" + source: hosted + version: "61.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + url: "https://pub.dev" + source: hosted + version: "5.13.0" + archive: + dependency: transitive + description: + name: archive + sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03" + url: "https://pub.dev" + source: hosted + version: "3.4.6" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "757153e5d9cd88253cb13f28c2fb55a537dc31fefd98137549895b5beb7c6169" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "0713a05b0386bd97f9e63e78108805a4feca5898a4b821d6610857f10c91e975" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + url: "https://pub.dev" + source: hosted + version: "2.3.3" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "0671ad4162ed510b70d0eb4ad6354c249f8429cab4ae7a4cec86bbc2886eb76e" + url: "https://pub.dev" + source: hosted + version: "7.2.7+1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: a8de5955205b4d1dbbbc267daddf2178bd737e4bab8987c04a500478c9651e74 + url: "https://pub.dev" + source: hosted + version: "8.6.3" + characters: + dependency: transitive + description: + name: characters + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" + source: hosted + version: "1.2.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "1be9be30396d7e4c0db42c35ea6ccd7cc6a1e19916b5dc64d6ac216b5544d677" + url: "https://pub.dev" + source: hosted + version: "4.7.0" + collection: + dependency: "direct overridden" + description: + name: collection + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + fair: + dependency: "direct main" + description: + path: "../../fair" + relative: true + source: path + version: "3.3.0" + fair_annotation: + dependency: transitive + description: + name: fair_annotation + sha256: "921581dd3979e64a8e246ac4af728aaa1edb65867370f44f8276b0bed20e3cc3" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + fair_compiler: + dependency: "direct dev" + description: + path: "../../compiler" + relative: true + source: path + version: "1.8.0" + fair_dart2dsl: + dependency: "direct overridden" + description: + path: "../../dart2dsl" + relative: true + source: path + version: "1.4.0" + fair_dart2js: + dependency: transitive + description: + name: fair_dart2js + sha256: f9b14f1fc887866238fb0c446667611bcd8896f889cd18950ce4b3cd7a3cfad2 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + fair_provider: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "1.0.0+1" + fair_version: + dependency: "direct overridden" + description: + path: "../../flutter_version/flutter_3_7_0" + relative: true + source: path + version: "3.7.0" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flat_buffers: + dependency: transitive + description: + name: flat_buffers + sha256: "23e2ced0d8e8ecdffbd9f267f49a668c74438393b9acaeac1c724123e3764263" + url: "https://pub.dev" + source: hosted + version: "2.0.5" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + url: "https://pub.dev" + source: hosted + version: "0.17.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + lints: + dependency: transitive + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" + source: hosted + version: "0.12.13" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + meta: + dependency: transitive + description: + name: meta + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" + source: hosted + version: "1.8.2" + pedantic: + dependency: transitive + description: + name: pedantic + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + platform: + dependency: transitive + description: + name: platform + sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + url: "https://pub.dev" + source: hosted + version: "3.7.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + provider: + dependency: transitive + description: + name: provider + sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + url: "https://pub.dev" + source: hosted + version: "6.0.5" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "373f96cf5a8744bc9816c1ff41cf5391bbdbe3d7a96fe98c622b6738a8a7bd33" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" + source: hosted + version: "0.4.16" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 + url: "https://pub.dev" + source: hosted + version: "6.1.11" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: ba140138558fcc3eead51a1c42e92a9fb074a1b1149ed3c73e66035b2ccd94f2 + url: "https://pub.dev" + source: hosted + version: "2.0.19" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=2.19.6 <3.0.0" + flutter: ">=3.7.0" diff --git a/fair_provider/example/pubspec.yaml b/fair_provider/example/pubspec.yaml new file mode 100644 index 00000000..7a510fe0 --- /dev/null +++ b/fair_provider/example/pubspec.yaml @@ -0,0 +1,39 @@ +name: example +description: A new Flutter project. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev +version: 1.0.0+1 + +environment: + sdk: '>=2.19.6 <3.0.0' + +dependencies: + flutter: + sdk: flutter + cupertino_icons: ^1.0.2 + fair_provider: + path: ../../fair_provider + + fair: + path: ../../../fair/fair + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + build_runner: ^2.1.2 + fair_compiler: ^1.8.0 + +dependency_overrides: + collection: 1.17.0 + fair_version: + path: ../../../fair/flutter_version/flutter_3_7_0 + fair_compiler: + path: ../../../fair/compiler + fair_dart2dsl: + path: ../../../fair/dart2dsl + +flutter: + uses-material-design: true + assets: + - assets/ + - assets/fair/ diff --git a/fair_provider/example/test/widget_test.dart b/fair_provider/example/test/widget_test.dart new file mode 100644 index 00000000..092d222f --- /dev/null +++ b/fair_provider/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/fair_provider/lib/fair_provider.dart b/fair_provider/lib/fair_provider.dart new file mode 100644 index 00000000..170c4220 --- /dev/null +++ b/fair_provider/lib/fair_provider.dart @@ -0,0 +1,4 @@ +export 'src/fair_app_module.dart'; +export 'src/fair_provider_core.dart'; +export 'src/fair_provider_plugin.dart'; +export 'src/provider_dynamic_widget_builder.dart'; \ No newline at end of file diff --git a/fair_provider/lib/src/fair_app_module.dart b/fair_provider/lib/src/fair_app_module.dart new file mode 100644 index 00000000..86ccc036 --- /dev/null +++ b/fair_provider/lib/src/fair_app_module.dart @@ -0,0 +1,46 @@ +import 'package:fair/fair.dart'; +import 'package:flutter/material.dart'; + +import 'fair_provider_core.dart'; + +class FairAppModule extends GeneratedModule { + @override + Map components() { + return { + 'InputBorder.none': InputBorder.none, + 'FairChangeNotifierProvider': (props) => FairChangeNotifierProvider( + key: props['key'], + child: props['child'], + initialJson: props['initialJson'], + )..setTypeArgumentList(props['ta']), + 'FairConsumer': (props) => FairConsumer( + key: props['key'], + builder: props['builder'], + child: props['child'], + )..setTypeArgumentList(props['ta']), + 'FairSelector': (props) => FairSelector( + key: props['key'], + builder: props['builder'], + selector: props['selector'], + child: props['child'], + )..setTypeArgumentList(props['ta']), + 'FairSugarProvider.valueReader': (props) => + FairSugarProvider.valueReader(props['pa'][0], props['pa'][1]), + 'FairSugarProvider.stringValueReader': (props) => + FairSugarProvider.stringValueReader(props['pa'][0], props['pa'][1]), + 'FairSugarProvider.evaluationToString': (props) => + FairSugarProvider.evaluationToString(props['pa'][0], props['pa'][1]), + 'FairSugarProvider.anyToString': (props) => + FairSugarProvider.anyToString(props['pa'][0]), + 'FairContextBuilder': (props) => FairContextBuilder( + key: props['key'], + builder: props['builder'], + ), + }; + } + + @override + Map mapping() { + return {}; + } +} diff --git a/fair_provider/lib/src/fair_provider_core.dart b/fair_provider/lib/src/fair_provider_core.dart new file mode 100644 index 00000000..9448dce0 --- /dev/null +++ b/fair_provider/lib/src/fair_provider_core.dart @@ -0,0 +1,468 @@ +import 'dart:convert'; + +import 'package:fair/fair.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:provider/single_child_widget.dart'; +import 'package:collection/collection.dart'; + +import 'utils/time_record.dart'; + +final Map _fairModelPool = {}; + +class FairProviderPlugin { + static T find(String className) { + return _fairModelPool[className] as T; + } + + static printObject(dynamic obj) {} +} + +class FairChangeNotifier extends ChangeNotifier { + FairChangeNotifier(); + + String? fairRuntimeTypeKey; + final Runtime _runtime = Runtime(); + + dynamic operator [](String key) { + final record = TimeRecord("FairChangeNotifier取值")..start(); + final jsResult = _runtime + .invokeMethodSync("FairProviderPlugin", "find", [fairRuntimeTypeKey]); + record.done(); + final jsResultObj = jsonDecode(jsResult); + final jsModel = jsResultObj["result"]["result"]; + return jsModel[key]; + } + + dynamic evaluation(String expression) { + final record = TimeRecord("FairChangeNotifier执行表达式")..start(); + final jsResult = _runtime.invokeMethodSync( + "FairProviderPlugin", "evaluation", [fairRuntimeTypeKey, expression]); + record.done(); + final jsResultObj = jsonDecode(jsResult); + final jsModel = jsResultObj["result"]["result"]; + return jsModel; + } + + void notify() { + notifyListeners(); + } + + void print() { + //impl in js plugin + } +} + +class FairContext { + String id = "FairContext"; + List treeModelKeyRecords = []; + + FairContext(this.treeModelKeyRecords); + + Map toJson() { + Map map = {}; + map["id"] = id; + map["treeModelKeyRecords"] = treeModelKeyRecords; + return map; + } + + T read(String className) { + return _fairModelPool[className] as T; + } +} + +typedef FairContextWidgetBuilder = Widget Function(FairContext context); +typedef FairContextWidgetBuilder2 = Widget Function(String context); + +class FairContextBuilder extends StatelessWidget { + /// Creates a widget that delegates its build to a callback. + /// + /// The [builder] argument must not be null. + const FairContextBuilder({ + super.key, + required this.builder, + }) : assert(builder != null); + + /// Called to obtain the child widget. + /// + /// This function is called whenever this widget is included in its parent's + /// build and the old widget (if any) that it synchronizes with has a distinct + /// object identity. Typically the parent's build method will construct + /// a new tree of widgets and so a new Builder child will not be [identical] + /// to the corresponding old one. + final FairContextWidgetBuilder builder; + + @override + Widget build(BuildContext context) { + //构建FairContext将整颗树的信息录入 + final fairContext = FairContext( + (context as FairContextBuilderElement).getTreeModelKeyRecords()); + return builder(fairContext); + } + + @override + StatelessElement createElement() { + return FairContextBuilderElement(this); + } +} + +class FairContextBuilderElement extends StatelessElement { + FairContextBuilderElement(FairContextBuilder widget) : super(widget); + + FairContextBuilder get widget => super.widget as FairContextBuilder; + + List getTreeModelKeyRecords() { + List treeModelKeyRecords = []; + visitAncestorElements((parent) { + if (parent.runtimeType.toString() == + '_InheritedProviderScopeElement') { + final grandParent = _findGrandParent(parent); + if (grandParent != null && + grandParent is FairChangeNotifierProviderElement) { + treeModelKeyRecords.add(grandParent.widget.modelKey); + } + } + return true; + }); + return treeModelKeyRecords; + } + + Element? _findGrandParent(Element child) { + int count = 0; + Element? grandParent; + child.visitAncestorElements((parent) { + if (++count == 2) { + grandParent = parent; + return false; + } + return true; + }); + return grandParent; + } +} + +typedef FairConsumerBuilder = Widget Function( + BuildContext context, + dynamic value, + Widget? child, + ); + +typedef FairSelectorSelector = dynamic Function( + BuildContext context, + dynamic value, + ); + +class FairSugarProvider { + FairSugarProvider._(); + + /// Provider消费者Builder,用于Consumer + static FairConsumerBuilder consumerBuilder(FairConsumerBuilder builder) => + builder; + + /// Provider消费者Builder,用于Selector + static FairConsumerBuilder selectorBuilder(FairConsumerBuilder builder) => + builder; + + /// 用于Selector中指定监听字段的selector + static FairSelectorSelector selector(FairSelectorSelector selector) => + selector; + + ///用于从 + static dynamic valueReader( + FairChangeNotifier model, + String key, + ) => + model[key] ?? 'null'; + + static String stringValueReader( + FairChangeNotifier model, + String key, + ) => + (model[key] ?? 'null').toString(); + + static dynamic anyToString(dynamic value) { + return value.toString(); + } + + static String evaluationToString( + FairChangeNotifier model, + String expression, + ) => + (model.evaluation(expression) ?? 'null').toString(); + + static FairContextWidgetBuilder widgetBuilder( + FairContextWidgetBuilder builder) => + builder; + + static FairContextWidgetBuilder2 widgetBuilder2( + FairContextWidgetBuilder2 builder) => + builder; +} + +class FairChangeNotifierProvider + extends StatefulWidget +{ + FairChangeNotifierProvider({Key? key, required this.child, this.initialJson}) + : super(key: key); + + Widget child; + + String? initialJson; + + late String modelKey; + + final Runtime _runtime = Runtime(); + + String? fairRuntimeTypeKey; + + List? typeArgumentList; + + void setTypeArgumentList(List typeArgumentList) { + this.typeArgumentList = typeArgumentList; + fairRuntimeTypeKey = typeArgumentList[0]; + } + + @override + State createState() => + FairChangeNotifierProviderState(); + + @override + StatefulElement createElement() { + return FairChangeNotifierProviderElement(this); + } +} + +class FairChangeNotifierProviderElement extends StatefulElement { + FairChangeNotifierProviderElement(this.widget) : super(widget); + FairChangeNotifierProvider widget; +} + +class FairChangeNotifierProviderState + extends State { + static int _counter = 0; + + late FairChangeNotifier fairModel; + + @override + void initState() { + super.initState(); + _createModelInJs(); + } + + /// 通知js侧创建model,然后counter++ + void _createModelInJs() { + final record = TimeRecord("FairChangeNotifierProvider创建jsModel")..start(); + widget.modelKey = "${widget.fairRuntimeTypeKey}_${_counter++}"; + final jsResult = widget._runtime.invokeMethodSync( + "FairProviderPlugin", "create", [widget.modelKey, widget.initialJson]); + record.done(); + final jsResultObj = jsonDecode(jsResult); + final jsModel = jsResultObj["result"]["result"]; + fairModel = _fairModelPool[widget.modelKey] = FairChangeNotifier() + ..fairRuntimeTypeKey = widget.modelKey; + } + + @override + void dispose() { + super.dispose(); + _fairModelPool.remove(widget.modelKey); + } + + @override + Widget build(BuildContext context) { + return ChangeNotifierProvider( + create: (context) => fairModel, + lazy: false, + child: widget.child, + ); + } +} + +class FairConsumer + extends SingleChildStatelessWidget // with GenericsReceiver +{ + FairConsumer({Key? key, required this.builder, Widget? child}) + : super(key: key, child: child); + + String? fairRuntimeTypeKey; + + late String modelKey; + + FairChangeNotifier get fairModel { + return _fairModelPool[modelKey] as FairChangeNotifier; + } + + List? typeArgumentList; + + void setTypeArgumentList(List typeArgumentList) { + this.typeArgumentList = typeArgumentList; + fairRuntimeTypeKey = typeArgumentList[0]; + } + + final Widget Function( + BuildContext context, + FairChangeNotifier value, + Widget? child, + ) builder; + + @override + Widget buildWithChild(BuildContext context, Widget? child) { + //绑定观察者 updateDependents + (context as FairConsumerElement).bindDependents(); + return builder( + context, + fairModel, + child, + ); + } + + @override + SingleChildStatelessElement createElement() { + return FairConsumerElement(this); + } +} + +class FairConsumerElement extends SingleChildStatelessElement { + FairConsumerElement(FairConsumer widget) : super(widget); + + FairConsumer get widget => super.widget as FairConsumer; + + void bindDependents() { + visitAncestorElements((parent) { + if (parent.runtimeType.toString() == + '_InheritedProviderScopeElement') { + final grandParent = _findGrandParent(parent); + if (grandParent != null && + grandParent is FairChangeNotifierProviderElement && + grandParent.widget.fairRuntimeTypeKey == + widget.fairRuntimeTypeKey) { + widget.modelKey = grandParent.widget.modelKey; + dependOnInheritedElement(parent as InheritedElement); + return false; + } + } + return true; + }); + } + + Element? _findGrandParent(Element child) { + int count = 0; + Element? grandParent; + child.visitAncestorElements((parent) { + if (++count == 2) { + grandParent = parent; + return false; + } + return true; + }); + return grandParent; + } +} + +class FairSelector + extends SingleChildStatefulWidget { + FairSelector({ + Key? key, + required this.builder, + required this.selector, + ShouldRebuild? shouldRebuild, + Widget? child, + }) : _shouldRebuild = shouldRebuild, + super(key: key, child: child); + + String? fairRuntimeTypeKey; + + late String modelKey; + + FairChangeNotifier get fairModel { + return _fairModelPool[modelKey] as FairChangeNotifier; + } + + List? typeArgumentList; + + void setTypeArgumentList(List typeArgumentList) { + this.typeArgumentList = typeArgumentList; + fairRuntimeTypeKey = typeArgumentList[0]; + } + + final ValueWidgetBuilder builder; + + final FairSelectorSelector selector; + + final ShouldRebuild? _shouldRebuild; + + @override + _FairSelectorState createState() => _FairSelectorState(); + + @override + SingleChildStatefulElement createElement() { + return FairSelectorElement(this); + } +} + +class _FairSelectorState + extends SingleChildState> { + T? value; + Widget? cache; + Widget? oldWidget; + + @override + Widget buildWithChild(BuildContext context, Widget? child) { + (context as FairSelectorElement).bindDependents(); + final selected = widget.selector(context, widget.fairModel); + + final shouldInvalidateCache = oldWidget != widget || + (widget._shouldRebuild != null && + widget._shouldRebuild!(value as T, selected)) || + (widget._shouldRebuild == null && + !const DeepCollectionEquality().equals(value, selected)); + if (shouldInvalidateCache) { + value = selected; + oldWidget = widget; + cache = widget.builder( + context, + selected, + child, + ); + } + return cache!; + } +} + +class FairSelectorElement extends SingleChildStatefulElement { + FairSelectorElement(FairSelector widget) : super(widget); + + FairSelector get widget => super.widget as FairSelector; + + void bindDependents() { + visitAncestorElements((parent) { + if (parent.runtimeType.toString() == + '_InheritedProviderScopeElement') { + final grandParent = _findGrandParent(parent); + //如果grandParent是FairChangeNotifierProviderElement + if (grandParent != null && + grandParent is FairChangeNotifierProviderElement && + grandParent.widget.fairRuntimeTypeKey == + widget.fairRuntimeTypeKey) { + widget.modelKey = grandParent.widget.modelKey; + dependOnInheritedElement(parent as InheritedElement); + return false; + } + } + return true; + }); + } + + Element? _findGrandParent(Element child) { + int count = 0; + Element? grandParent; + child.visitAncestorElements((parent) { + if (++count == 2) { + grandParent = parent; + return false; + } + return true; + }); + return grandParent; + } +} diff --git a/fair_provider/lib/src/fair_provider_plugin.dart b/fair_provider/lib/src/fair_provider_plugin.dart new file mode 100644 index 00000000..e003836a --- /dev/null +++ b/fair_provider/lib/src/fair_provider_plugin.dart @@ -0,0 +1,44 @@ +import 'dart:convert'; + +import 'package:fair/fair.dart'; + +import 'fair_provider_core.dart'; + +class FairProvider extends IFairPlugin { + static final FairProvider _fairProvider = FairProvider._internal(); + + FairProvider._internal(); + + factory FairProvider() { + return _fairProvider; + } + + static void notifyListeners({ + required String fairRuntimeTypeKey, + }) { + FairProviderPlugin.find(fairRuntimeTypeKey).notify(); + } + + static void _notifyListeners(dynamic map) async { + if (map == null) { + return; + } + var req; + if (map is Map) { + req = map; + } else { + req = jsonDecode(map); + } + var args = req['args']; + var jsonMap = jsonDecode(args['jsonMap']); + var fairRuntimeTypeKey = jsonMap['fairRuntimeTypeKey']; + notifyListeners(fairRuntimeTypeKey: fairRuntimeTypeKey); + } + + @override + Map getRegisterMethods() { + var functions = {}; + functions.putIfAbsent('notifyListeners', () => _notifyListeners); + return functions; + } +} diff --git a/fair_provider/lib/src/provider_dynamic_widget_builder.dart b/fair_provider/lib/src/provider_dynamic_widget_builder.dart new file mode 100644 index 00000000..a9be0e16 --- /dev/null +++ b/fair_provider/lib/src/provider_dynamic_widget_builder.dart @@ -0,0 +1,145 @@ +import 'package:fair/src/render/builder.dart'; +import 'package:fair/src/render/proxy.dart'; +import 'package:fair/src/render/domain.dart'; +import 'package:fair/src/internal/bind_data.dart'; +import 'package:fair/src/type.dart'; +import 'package:flutter/material.dart'; + +import 'fair_provider_core.dart'; + +class ProviderDynamicWidgetBuilder extends DynamicWidgetBuilder { + ProviderDynamicWidgetBuilder( + ProxyMirror? proxyMirror, String? page, BindingData? bound, + {String? bundle}) + : super(proxyMirror, page, bound, bundle: bundle); + + @override + dynamic convert(BuildContext context, Map map, Map? methodMap, + {Domain? domain}) { + var name = map[tag]; + if (name == 'FairSugarProvider.consumerBuilder' || + name == 'FairSugarProvider.selectorBuilder') { + return _buildFairSugarConsumerBuilder( + context, + map, + methodMap, + domain: domain, + ); + } else if (name == 'FairSugarProvider.selector') { + return _buildFairSugarSelector( + context, + map, + methodMap, + domain: domain, + ); + } else if (name == 'FairSugarProvider.widgetBuilder') { + return _buildFairSugarWidgetBuilder( + context, + map, + methodMap, + domain: domain, + ); + } else if (name == 'FairSugarProvider.widgetBuilder2') { + return _buildFairSugarWidgetBuilder2( + context, + map, + methodMap, + domain: domain, + ); + } + return super.convert( + context, + map, + methodMap, + domain: domain, + ); + } + + dynamic _buildFairSugarConsumerBuilder( + BuildContext context, Map map, Map? methodMap, + {Domain? domain}) { + dynamic source = pa0(map); + assert(source is Map); + List functionParameters = FunctionDomain.pa(source); + FairConsumerBuilder builder = (builderContext, value, child) { + return convert( + context, + source, + methodMap, + domain: FunctionDomain( + { + functionParameters[0]: builderContext, + functionParameters[1]: value, + functionParameters[2]: child, + }, + parent: domain, + ), + ); + }; + return builder; + } + + dynamic _buildFairSugarSelector(BuildContext context, Map map, Map? methodMap, + {Domain? domain}) { + dynamic source = pa0(map); + assert(source is Map); + List functionParameters = FunctionDomain.pa(source); + FairSelectorSelector selector = (builderContext, value) { + return convert( + context, + source, + methodMap, + domain: FunctionDomain( + { + functionParameters[0]: builderContext, + functionParameters[1]: value, + }, + parent: domain, + ), + ); + }; + return selector; + } + + dynamic _buildFairSugarWidgetBuilder(BuildContext context, Map map, Map? methodMap, + {Domain? domain}) { + dynamic source = pa0(map); + assert(source is Map); + List functionParameters = FunctionDomain.pa(source); + FairContextWidgetBuilder builder = (builderContext) { + return convert( + context, + source, + methodMap, + domain: FunctionDomain( + { + functionParameters[0]: builderContext, + }, + parent: domain, + ), + ); + }; + return builder; + } + + dynamic _buildFairSugarWidgetBuilder2(BuildContext context, Map map, Map? methodMap, + {Domain? domain}) { + dynamic source = pa0(map); + assert(source is Map); + List functionParameters = FunctionDomain.pa(source); + FairContextWidgetBuilder2 builder = (builderContext) { + return convert( + context, + source, + methodMap, + domain: FunctionDomain( + { + functionParameters[0]: builderContext, + }, + parent: domain, + ), + ); + }; + return builder; + } +} diff --git a/fair_provider/lib/src/utils/time_record.dart b/fair_provider/lib/src/utils/time_record.dart new file mode 100644 index 00000000..060ee5ff --- /dev/null +++ b/fair_provider/lib/src/utils/time_record.dart @@ -0,0 +1,21 @@ +class TimeRecord { + + TimeRecord(this.tag); + + String? tag; + + late DateTime _startTime; + late DateTime _endTime; + + void start() { + _startTime = DateTime.now(); + } + + void done() { + _endTime = DateTime.now(); + final duration = _endTime.difference(_startTime); + final milliseconds = duration.inMilliseconds; + print('耗时统计 Time elapsed: $milliseconds milliseconds'); + } + +} \ No newline at end of file diff --git a/fair_provider/pubspec.lock b/fair_provider/pubspec.lock new file mode 100644 index 00000000..889b5f76 --- /dev/null +++ b/fair_provider/pubspec.lock @@ -0,0 +1,717 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + url: "https://pub.dev" + source: hosted + version: "61.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + url: "https://pub.dev" + source: hosted + version: "5.13.0" + archive: + dependency: transitive + description: + name: archive + sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03" + url: "https://pub.dev" + source: hosted + version: "3.4.6" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "757153e5d9cd88253cb13f28c2fb55a537dc31fefd98137549895b5beb7c6169" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "0713a05b0386bd97f9e63e78108805a4feca5898a4b821d6610857f10c91e975" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + url: "https://pub.dev" + source: hosted + version: "2.3.3" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "0671ad4162ed510b70d0eb4ad6354c249f8429cab4ae7a4cec86bbc2886eb76e" + url: "https://pub.dev" + source: hosted + version: "7.2.7+1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: a8de5955205b4d1dbbbc267daddf2178bd737e4bab8987c04a500478c9651e74 + url: "https://pub.dev" + source: hosted + version: "8.6.3" + characters: + dependency: transitive + description: + name: characters + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" + source: hosted + version: "1.2.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "1be9be30396d7e4c0db42c35ea6ccd7cc6a1e19916b5dc64d6ac216b5544d677" + url: "https://pub.dev" + source: hosted + version: "4.7.0" + collection: + dependency: "direct overridden" + description: + name: collection + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + fair: + dependency: "direct main" + description: + path: "../../fair/fair" + relative: true + source: path + version: "3.3.0" + fair_annotation: + dependency: transitive + description: + name: fair_annotation + sha256: "921581dd3979e64a8e246ac4af728aaa1edb65867370f44f8276b0bed20e3cc3" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + fair_compiler: + dependency: "direct dev" + description: + path: "../../fair/compiler" + relative: true + source: path + version: "1.8.0" + fair_dart2dsl: + dependency: "direct overridden" + description: + path: "../../fair/dart2dsl" + relative: true + source: path + version: "1.4.0" + fair_dart2js: + dependency: "direct overridden" + description: + path: "../../fair/dart2js" + relative: true + source: path + version: "1.4.0" + fair_version: + dependency: "direct overridden" + description: + path: "../../fair/flutter_version/flutter_3_7_0" + relative: true + source: path + version: "3.7.0" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flat_buffers: + dependency: transitive + description: + name: flat_buffers + sha256: "23e2ced0d8e8ecdffbd9f267f49a668c74438393b9acaeac1c724123e3764263" + url: "https://pub.dev" + source: hosted + version: "2.0.5" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + url: "https://pub.dev" + source: hosted + version: "0.17.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + lints: + dependency: transitive + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" + source: hosted + version: "0.12.13" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + meta: + dependency: transitive + description: + name: meta + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" + source: hosted + version: "1.8.2" + pedantic: + dependency: transitive + description: + name: pedantic + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + platform: + dependency: transitive + description: + name: platform + sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + url: "https://pub.dev" + source: hosted + version: "3.7.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + provider: + dependency: "direct main" + description: + name: provider + sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + url: "https://pub.dev" + source: hosted + version: "6.0.5" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "373f96cf5a8744bc9816c1ff41cf5391bbdbe3d7a96fe98c622b6738a8a7bd33" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" + source: hosted + version: "0.4.16" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 + url: "https://pub.dev" + source: hosted + version: "6.1.11" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: ba140138558fcc3eead51a1c42e92a9fb074a1b1149ed3c73e66035b2ccd94f2 + url: "https://pub.dev" + source: hosted + version: "2.0.19" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=2.19.6 <3.0.0" + flutter: ">=3.7.0" diff --git a/fair_provider/pubspec.yaml b/fair_provider/pubspec.yaml new file mode 100644 index 00000000..dee023a7 --- /dev/null +++ b/fair_provider/pubspec.yaml @@ -0,0 +1,40 @@ +name: fair_provider +description: An extension library for Fair on the Provider framework. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev +version: 1.0.0+1 + +environment: + sdk: '>=2.19.6 <3.0.0' + +dependencies: + flutter: + sdk: flutter + cupertino_icons: ^1.0.2 + # fair: 3.3.0 + fair: + path: ../../fair/fair + provider: ^6.0.5 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + build_runner: ^2.1.2 + fair_compiler: ^1.8.0 + +dependency_overrides: + collection: 1.17.0 + fair_version: + path: ../../fair/flutter_version/flutter_3_7_0 + fair_dart2dsl: + path: ../../fair/dart2dsl + fair_dart2js: + path: ../../fair/dart2js + fair_compiler: + path: ../../fair/compiler + +flutter: + uses-material-design: true + assets: + - assets/ + - assets/plugin/ \ No newline at end of file From fe47850277e0fed21b30cc1a2b6b22f6ea2a8a5b Mon Sep 17 00:00:00 2001 From: lanhuajian Date: Mon, 6 Nov 2023 14:48:16 +0800 Subject: [PATCH 04/11] [feature] Abstract fast access interface --- fair/lib/fair.dart | 5 ++ fair/lib/src/adapter.dart | 22 ++++++++ fair/lib/src/app.dart | 71 ++++++++++++++++++++----- fair/lib/src/internal/global_state.dart | 17 ++++++ fair/lib/src/public_type.dart | 2 + fair/lib/src/render/decode.dart | 11 +++- 6 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 fair/lib/src/adapter.dart diff --git a/fair/lib/fair.dart b/fair/lib/fair.dart index 2f71a467..c0a740a8 100644 --- a/fair/lib/fair.dart +++ b/fair/lib/fair.dart @@ -15,6 +15,11 @@ export 'src/experiment/sugar.dart'; export 'src/module/fair_module.dart'; export 'src/public_type.dart'; export 'src/widget.dart'; +export 'src/adapter.dart'; +export 'src/internal/bind_data.dart'; +export 'src/render/builder.dart'; +export 'src/render/domain.dart'; +export 'src/render/proxy.dart'; export 'src/runtime/plugin/fair_plugin.dart'; export 'src/runtime/plugin/plugin_dispatcher.dart'; export 'src/runtime/plugin/fair_common_plugin.dart'; diff --git a/fair/lib/src/adapter.dart b/fair/lib/src/adapter.dart new file mode 100644 index 00000000..96b2717f --- /dev/null +++ b/fair/lib/src/adapter.dart @@ -0,0 +1,22 @@ +import 'package:fair/fair.dart'; + +//adapt third-party library +abstract class IFairLibraryAdapter{ + //provide the generated module + GeneratedModule? provideGeneratedModule(); + + //provide fair plugins + Map? provideFairPlugins(); + + //provide js plugins + Map? provideJSPlugins(); + + //provide dynamic widget builder + DynamicWidgetBuilderFunction? provideDynamicWidgetBuilder(); + + //provide fair delegate + Map? provideFairDelegate(); + + //provide fair module + Map? provideFairModule(); +} diff --git a/fair/lib/src/app.dart b/fair/lib/src/app.dart index 50e787f2..2638af8c 100644 --- a/fair/lib/src/app.dart +++ b/fair/lib/src/app.dart @@ -7,16 +7,12 @@ import 'dart:io'; import 'package:fair/fair.dart'; -import 'package:fair/src/internal/bind_data.dart'; -import 'package:fair/src/render/builder.dart'; -import 'package:fair/src/render/proxy.dart'; +import 'package:fair/src/internal/global_state.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'internal/flexbuffer/fair_js_decoder_http_decoder.dart'; import 'state.dart'; -import 'type.dart'; /// Application which can update the widget tree through bundle file. /// @@ -64,8 +60,7 @@ class FairApp extends InheritedWidget with AppState { final bool debugShowFairBanner; /// Define a custom DynamicWidgetBuilder to solve special case - final DynamicWidgetBuilder Function(ProxyMirror? proxyMirror, String? page, BindingData? bound, - {String? bundle})? dynamicWidgetBuilder; + List? dynamicWidgetBuilder; static final WidgetBuilder _defaultHolder = (BuildContext context) { return Container( @@ -119,12 +114,17 @@ class FairApp extends InheritedWidget with AppState { properties.add(DiagnosticsProperty>('bundle', bundleAlias)); } - static void runApplication(Widget app, { - Map? plugins, - Map? jsPlugins, - String? package, - List? baseJsSources, + static void runApplication( + Widget app, { + Map? plugins, + Map? jsPlugins, + String? package, + List? baseJsSources, + List? adapters, }) { + //init 3rd-library adapter + initFairLibraryAdapter(app, plugins: plugins, jsPlugins: jsPlugins, adapters: adapters); + // WidgetsFlutterBinding.ensureInitialized(); FairPluginDispatcher.registerPlugins(plugins); @@ -139,4 +139,51 @@ class FairApp extends InheritedWidget with AppState { Runtime().loadCoreJs(package: package, jsPlugins: jsPlugins, baseJsSources: baseJsSources).then((value) => runApp(app)); } } + + ///[app] FairApp + ///[plugins] Fair plugin code with Dart + ///[jsPlugins] Fair plugin code with JavaScript + ///[adapters] 3rd-party libraries which adapted Fair + static void initFairLibraryAdapter( + Widget app, { + Map? plugins, + Map? jsPlugins, + List? adapters, + }) { + + if (adapters != null && adapters.isNotEmpty) { + adapters.forEach((element) { + + if (element.provideFairPlugins()?.isNotEmpty == true) { + plugins?.addAll(element.provideFairPlugins()!); + } + + if (element.provideJSPlugins()?.isNotEmpty == true) { + jsPlugins?.addAll(element.provideJSPlugins()!); + } + + if (app is FairApp) { + if (element.provideFairModule() != null) { + app.modules.addAll(element.provideFairModule()); + } + + if (element.provideGeneratedModule() != null && app.proxy is ProxyMirror) { + (app.proxy as ProxyMirror).addGeneratedBinding(element.provideGeneratedModule()!); + } + + if (element.provideFairDelegate() != null) { + GlobalState.instance().addExtBuilder(element.provideFairDelegate()); + } + + if (element.provideDynamicWidgetBuilder() != null) { + if (app.dynamicWidgetBuilder == null) { + app.dynamicWidgetBuilder = [element.provideDynamicWidgetBuilder()]; + } else { + app.dynamicWidgetBuilder!.add(element.provideDynamicWidgetBuilder()); + } + } + } + }); + } + } } diff --git a/fair/lib/src/internal/global_state.dart b/fair/lib/src/internal/global_state.dart index 63d57a74..09eaa167 100644 --- a/fair/lib/src/internal/global_state.dart +++ b/fair/lib/src/internal/global_state.dart @@ -39,6 +39,23 @@ class GlobalState { _builder = builder; } + void addExtBuilder(Map? extBuilder) { + if (extBuilder != null) { + try { + if (_builder != null) { + _builder?.addAll(extBuilder); + } else { + //when _builder is uninitialized + _builder = extBuilder; + } + } catch (e) { + //caught when thrown “_builder is an unmodifiable map” + extBuilder.addAll(_builder!); + _builder = extBuilder; + } + } + } + static String id(String? prefix) { return '$prefix#${GlobalState._counter++}'; } diff --git a/fair/lib/src/public_type.dart b/fair/lib/src/public_type.dart index 7fb10b55..7a97cd76 100644 --- a/fair/lib/src/public_type.dart +++ b/fair/lib/src/public_type.dart @@ -20,6 +20,8 @@ typedef FairDelegateBuilder = FairDelegate Function( typedef FairModuleBuilder = FairModule Function(); typedef PropertyValue = T Function(); +typedef DynamicWidgetBuilderFunction = DynamicWidgetBuilder Function(ProxyMirror? proxyMirror, String? page, BindingData? bound, {String? bundle}); + /// Interface of bundle loader abstract class BundleLoader { /// Load resource data into json object; The path can be either assets key or diff --git a/fair/lib/src/render/decode.dart b/fair/lib/src/render/decode.dart index ba9f6446..959b928a 100644 --- a/fair/lib/src/render/decode.dart +++ b/fair/lib/src/render/decode.dart @@ -76,8 +76,17 @@ class Decoder { bound ??= BindingData(app?.modules); bound.data = data; } + + var dynamicBuilder; var proxy = app?.proxy; - Widget w =( app?.dynamicWidgetBuilder?.call(proxy as ProxyMirror?, page, bound, bundle: url) ?? DynamicWidgetBuilder(proxy as ProxyMirror?, page, bound, bundle: url)).convert(context, map, methodMap) ?? + final dynamicBuilders = app?.dynamicWidgetBuilder?.map((e) => e?.call(proxy as ProxyMirror?, page, bound, bundle: url)); + if (dynamicBuilders == null || dynamicBuilders.isEmpty) { + dynamicBuilder = DynamicWidgetBuilder(proxy as ProxyMirror?, page, bound, bundle: url); + } else { + dynamicBuilder = + dynamicBuilders.map((e) => e?.convert(context, map, methodMap)).toList().firstWhere((element) => element != null, orElse: () => null); + } + Widget w =(dynamicBuilder ?? DynamicWidgetBuilder(proxy as ProxyMirror?, page, bound, bundle: url)).convert(context, map, methodMap) ?? WarningWidget(parentContext:context,name: page, url: url, error: 'tag name not supported yet'); return w; } From 947c4da11b3be091d123577f1cf35bf156de9528 Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Mon, 6 Nov 2023 16:33:01 +0800 Subject: [PATCH 05/11] [feature]Optimize reader syntax sugar and Improve basic usage examples. --- fair/assets/fair_core/fair_core.js | 10 + .../assets/plugin/fair_provider_plugin.js | 2 +- .../assets/fair/lib_ui_counter_page.fair.js | 4 + .../assets/fair/lib_ui_counter_page.fair.json | 106 +++ .../fair/lib_ui_counter_page.fair.metadata | 7 + .../fair/lib_ui_counter_page_provider.fair.js | 19 - .../lib_ui_counter_page_provider.fair.json | 206 ----- ...lib_ui_counter_page_provider.fair.metadata | 7 - .../assets/fair/lib_ui_example_page.fair.js | 11 + .../assets/fair/lib_ui_example_page.fair.json | 867 ++++++++++++++++++ .../fair/lib_ui_example_page.fair.metadata | 7 + .../assets/fair/lib_ui_example_page2.fair.js | 1 + .../fair/lib_ui_example_page2.fair.json | 97 ++ .../fair/lib_ui_example_page2.fair.metadata | 7 + .../example/lib/entity/counter_model.dart | 11 +- .../example/lib/entity/example_model.dart | 14 + .../example/lib/entity/login_model.dart | 8 - .../example/lib/entity/top_model.dart | 6 + fair_provider/example/lib/main.dart | 60 +- .../example/lib/ui/counter_page.dart | 69 ++ .../example/lib/ui/counter_page_provider.dart | 114 --- .../example/lib/ui/example_page.dart | 376 ++++++++ .../example/lib/ui/example_page2.dart | 61 ++ fair_provider/example/pubspec.lock | 2 +- fair_provider/example/pubspec.yaml | 1 + fair_provider/lib/fair_provider.dart | 2 +- fair_provider/lib/src/fair_app_module.dart | 46 - fair_provider/lib/src/fair_provider_core.dart | 168 +++- .../lib/src/fair_provider_module.dart | 90 ++ .../src/provider_dynamic_widget_builder.dart | 10 +- fair_provider/lib/src/utils/time_record.dart | 10 +- fair_provider/pubspec.lock | 12 +- fair_provider/pubspec.yaml | 3 +- 33 files changed, 1954 insertions(+), 460 deletions(-) create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page.fair.js create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page.fair.json create mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata delete mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js delete mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json delete mode 100644 fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page.fair.js create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page.fair.json create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page2.fair.js create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page2.fair.json create mode 100644 fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata create mode 100644 fair_provider/example/lib/entity/example_model.dart delete mode 100644 fair_provider/example/lib/entity/login_model.dart create mode 100644 fair_provider/example/lib/entity/top_model.dart create mode 100644 fair_provider/example/lib/ui/counter_page.dart delete mode 100644 fair_provider/example/lib/ui/counter_page_provider.dart create mode 100644 fair_provider/example/lib/ui/example_page.dart create mode 100644 fair_provider/example/lib/ui/example_page2.dart delete mode 100644 fair_provider/lib/src/fair_app_module.dart create mode 100644 fair_provider/lib/src/fair_provider_module.dart diff --git a/fair/assets/fair_core/fair_core.js b/fair/assets/fair_core/fair_core.js index 1ac1ee44..ed4d3202 100644 --- a/fair/assets/fair_core/fair_core.js +++ b/fair/assets/fair_core/fair_core.js @@ -64,6 +64,16 @@ function _invokeMethod(par) { const value = args[key]; if (typeof value === 'object') { invokeMethodArgsInterceptorManager.handle(value) + //入参被压缩为数组时,确保数组内所有元素经拦截器处理 + const innerArgs = value; + for (let innerKey in innerArgs) { + if (innerArgs.hasOwnProperty(innerKey)) { + const innerValue = innerArgs[innerKey]; + if (typeof innerValue === 'object') { + invokeMethodArgsInterceptorManager.handle(innerValue) + } + } + } } } } diff --git a/fair_provider/assets/plugin/fair_provider_plugin.js b/fair_provider/assets/plugin/fair_provider_plugin.js index 3f84671a..bfe51ea4 100644 --- a/fair_provider/assets/plugin/fair_provider_plugin.js +++ b/fair_provider/assets/plugin/fair_provider_plugin.js @@ -10,7 +10,7 @@ let FairProviderPlugin = class FairProviderPlugin { } catch (e) { fairChangeNotifier = {} } - console.log("miseryy 创建model key = " + key) + console.log(fairChangeNotifier) FairChangeNotifierPool[key] = fairChangeNotifier; fairChangeNotifier.fairRuntimeTypeKey = key; fairChangeNotifier.notify = function () { diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.js b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.js new file mode 100644 index 00000000..52efba09 --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.js @@ -0,0 +1,4 @@ +GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;return runCallback(function(__mod__){with(__mod__.imports){function _CounterPageState(){const inner=_CounterPageState.__inner__;if(this==__global__){return new _CounterPageState({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_CounterPageState.prototype.ctor.apply(this,args);return this;}}_CounterPageState.__inner__=function inner(){this.counterModelJson=`{ + "count":22 +} + `;};_CounterPageState.prototype={onLoad:function onLoad(){const __thiz__=this;with(__thiz__){}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},_incrementCounter:function _incrementCounter(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let counterModel=context.read("CounterModel");counterModel.count++;counterModel.notify();}}},};_CounterPageState.prototype.ctor=function(){};;return _CounterPageState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json new file mode 100644 index 00000000..727f5217 --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json @@ -0,0 +1,106 @@ +{ + "className": "FairChangeNotifierProvider", + "na": { + "initialJson": "^(counterModelJson)", + "child": { + "className": "Scaffold", + "na": { + "appBar": { + "className": "AppBar", + "na": { + "title": { + "className": "Text", + "pa": [ + "计数器示例" + ] + } + } + }, + "body": { + "className": "Center", + "na": { + "child": { + "className": "Column", + "na": { + "mainAxisAlignment": "#(MainAxisAlignment.center)", + "children": [ + { + "className": "Text", + "pa": [ + "You have pushed the button this many times:" + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.readAsString", + "pa": [ + "^(value)", + "count" + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "CounterModel" + ] + } + ] + } + } + } + }, + "floatingActionButton": { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "FloatingActionButton", + "na": { + "onPressed": "@(_incrementCounter(^(context)))", + "tooltip": "Increment", + "child": { + "className": "Icon", + "pa": [ + "#(Icons.add)" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + } + } + } + }, + "typeArgumentList": [ + "CounterModel" + ], + "methodMap": {}, + "digest": "61dcca0ca25598d884689e6aa5679d0f" +} \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata new file mode 100644 index 00000000..99cacf8c --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata @@ -0,0 +1,7 @@ +# Generated by Fair on 2023-11-06 16:28:36.272460. + +source: example|lib/ui/counter_page.dart +md5: 90013183bf2a75597cb7644ab4e97676 +json: example|build/fair/lib_ui_counter_page.fair.json +bin: example|build/fair/lib_ui_counter_page.fair.bin +date: 2023-11-06 16:28:36.272763 diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js deleted file mode 100644 index 2f3a565b..00000000 --- a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.js +++ /dev/null @@ -1,19 +0,0 @@ -GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;return runCallback(function(__mod__){with(__mod__.imports){function _CounterPageProviderState(){const inner=_CounterPageProviderState.__inner__;if(this==__global__){return new _CounterPageProviderState({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_CounterPageProviderState.prototype.ctor.apply(this,args);return this;}}_CounterPageProviderState.__inner__=function inner(){this.title="我是写在js侧的title";this.counterModelJson=`{ - "count":22, - "testName":"zzzzzz", - "someModel":{ - "a":"ffffff" - } -} - `;this.loginModelJson=` { - "account":"qwerty12345", - "password":"zxcv54321" -} - `;this.counterModelJson2=`{ - "count":333, - "testName":"testName的初始值", - "someModel":{ - "a":"someModel中a的初始值" - } -} - `;};_CounterPageProviderState.prototype={onLoad:function onLoad(){const __thiz__=this;with(__thiz__){}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},_incrementCounter:function _incrementCounter(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let counterModel=context.read("CounterModel");counterModel.count++;counterModel.testName="及哦飞机佛IE我房间";counterModel.someModel.a="hahahaha";counterModel.notify();}}},};_CounterPageProviderState.prototype.ctor=function(){};;return _CounterPageProviderState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json deleted file mode 100644 index 41f7932f..00000000 --- a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "className": "FairChangeNotifierProvider", - "na": { - "initialJson": "^(counterModelJson)", - "child": { - "className": "FairChangeNotifierProvider", - "na": { - "initialJson": "^(loginModelJson)", - "child": { - "className": "FairChangeNotifierProvider", - "na": { - "initialJson": "^(counterModelJson2)", - "child": { - "className": "Scaffold", - "na": { - "appBar": { - "className": "AppBar", - "na": { - "title": { - "className": "Text", - "pa": [ - "^(title)" - ] - } - } - }, - "body": { - "className": "Center", - "na": { - "child": { - "className": "Column", - "na": { - "mainAxisAlignment": "#(MainAxisAlignment.center)", - "children": [ - { - "className": "Text", - "pa": [ - "You have pushed the button this many times:" - ] - }, - { - "className": "FairConsumer", - "na": { - "builder": { - "className": "FairSugarProvider.consumerBuilder", - "pa": [ - { - "className": "Text", - "pa": [ - { - "className": "FairSugarProvider.anyToString", - "pa": [ - { - "className": "FairSugarProvider.valueReader", - "pa": [ - "^(value)", - "count" - ] - } - ] - } - ], - "functionParameters": { - "pa": [ - "context", - "value", - "child" - ] - } - } - ] - } - }, - "typeArgumentList": [ - "CounterModel" - ] - }, - { - "className": "FairConsumer", - "na": { - "builder": { - "className": "FairSugarProvider.consumerBuilder", - "pa": [ - { - "className": "Text", - "pa": [ - { - "className": "FairSugarProvider.stringValueReader", - "pa": [ - "^(value)", - "testName" - ] - } - ], - "functionParameters": { - "pa": [ - "context", - "value", - "child" - ] - } - } - ] - } - }, - "typeArgumentList": [ - "CounterModel" - ] - }, - { - "className": "FairSelector", - "na": { - "builder": { - "className": "FairSugarProvider.selectorBuilder", - "pa": [ - { - "className": "Text", - "pa": [ - "^(value)" - ], - "functionParameters": { - "pa": [ - "context", - "value", - "child" - ] - } - } - ] - }, - "selector": { - "className": "FairSugarProvider.selector", - "pa": [ - { - "className": "FairSugarProvider.evaluationToString", - "pa": [ - "^(value)", - "someModel.a" - ], - "functionParameters": { - "pa": [ - "context", - "value" - ] - } - } - ] - } - }, - "typeArgumentList": [ - "CounterModel", - "String" - ] - } - ] - } - } - } - }, - "floatingActionButton": { - "className": "FairContextBuilder", - "na": { - "builder": { - "className": "FairSugarProvider.widgetBuilder", - "pa": [ - { - "className": "FloatingActionButton", - "na": { - "onPressed": "@(_incrementCounter(^(context)))", - "tooltip": "Increment", - "child": { - "className": "Icon", - "pa": [ - "#(Icons.add)" - ] - } - }, - "functionParameters": { - "pa": [ - "context" - ] - } - } - ] - } - } - } - } - } - }, - "typeArgumentList": [ - "CounterModel" - ] - } - }, - "typeArgumentList": [ - "LoginModel" - ] - } - }, - "typeArgumentList": [ - "CounterModel" - ], - "methodMap": {}, - "digest": "40c478199087adf8f05936a7f7bc34bd" -} \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata b/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata deleted file mode 100644 index a0216d16..00000000 --- a/fair_provider/example/assets/fair/lib_ui_counter_page_provider.fair.metadata +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by Fair on 2023-10-25 19:35:14.838560. - -source: example|lib/ui/counter_page_provider.dart -md5: fb818b363103f7c487d2f2aeb0162b60 -json: example|build/fair/lib_ui_counter_page_provider.fair.json -bin: example|build/fair/lib_ui_counter_page_provider.fair.bin -date: 2023-10-25 19:35:14.839444 diff --git a/fair_provider/example/assets/fair/lib_ui_example_page.fair.js b/fair_provider/example/assets/fair/lib_ui_example_page.fair.js new file mode 100644 index 00000000..fb31eeed --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page.fair.js @@ -0,0 +1,11 @@ +GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;return runCallback(function(__mod__){with(__mod__.imports){function _ExamplePageState(){const inner=_ExamplePageState.__inner__;if(this==__global__){return new _ExamplePageState({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_ExamplePageState.prototype.ctor.apply(this,args);return this;}}_ExamplePageState.__inner__=function inner(){this.exampleModelJson=`{ + "stringField":"字符串字段", + "intField":22, + "doubleField":3.3, + "boolField":true, + "listField":[1,2,3,4], + "innerModel":{ + "innerBoolField":false + } +} + `;this.stringList=['白日依山尽','黄河入海流','欲穷千里目','更上一层楼'];this.stringIndex=0;this.nestedList=[['1','2','3','4'],['5','6','7','8'],['9','10','11','12'],['13','14','15','16']];this.listIndex=0;};_ExamplePageState.prototype={onLoad:function onLoad(){const __thiz__=this;with(__thiz__){}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},_updateAll:function _updateAll(context,context2){const __thiz__=this;const __arg_ctx__={context,context2,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");if(stringIndex>3){stringIndex=0;}exampleModel.stringField=stringList.__op_idx__(stringIndex++);exampleModel.intField++;if(exampleModel.doubleField==33.3){exampleModel.doubleField=66.6;}else{exampleModel.doubleField=33.3;}exampleModel.boolField=!exampleModel.boolField;if(listIndex>3){listIndex=0;}exampleModel.listField=nestedList.__op_idx__(listIndex++);if(exampleModel.innerModel.innerBoolField==true){exampleModel.innerModel.innerBoolField=false;}else{exampleModel.innerModel.innerBoolField=true;}exampleModel.notify();}}},_onSliderChange:function _onSliderChange(input){const __thiz__=this;const __arg_ctx__={input,};with(__thiz__){with(__arg_ctx__){let progress=input.__op_idx__(0);let fairContext=input.__op_idx__(1);let exampleModel=fairContext.read("ExampleModel");exampleModel.doubleField=progress;exampleModel.notify();}}},_toggleBoolChange:function _toggleBoolChange(input){const __thiz__=this;const __arg_ctx__={input,};with(__thiz__){with(__arg_ctx__){let flag=input.__op_idx__(0);let fairContext=input.__op_idx__(1);let exampleModel=fairContext.read("ExampleModel");exampleModel.boolField=flag;exampleModel.notify();}}},_updateStringField:function _updateStringField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){if(stringIndex>3){stringIndex=0;}let exampleModel=context.read("ExampleModel");exampleModel.stringField=stringList.__op_idx__(stringIndex++);exampleModel.notify();}}},_updateIntField:function _updateIntField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");exampleModel.intField++;exampleModel.notify();}}},_updateDoubleField:function _updateDoubleField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");if(exampleModel.doubleField==33.3){exampleModel.doubleField=66.6;}else{exampleModel.doubleField=33.3;}exampleModel.notify();}}},_updateBoolField:function _updateBoolField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");exampleModel.boolField=!exampleModel.boolField;exampleModel.notify();}}},_updateListField:function _updateListField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");if(listIndex>3){listIndex=0;}exampleModel.listField=nestedList.__op_idx__(listIndex++);exampleModel.notify();}}},_updateInnerField:function _updateInnerField(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let exampleModel=context.read("ExampleModel");if(exampleModel.innerModel.innerBoolField==true){exampleModel.innerModel.innerBoolField=false;}else{exampleModel.innerModel.innerBoolField=true;}exampleModel.notify();}}},};_ExamplePageState.prototype.ctor=function(){};;return _ExamplePageState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_example_page.fair.json b/fair_provider/example/assets/fair/lib_ui_example_page.fair.json new file mode 100644 index 00000000..14d979ee --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page.fair.json @@ -0,0 +1,867 @@ +{ + "className": "FairChangeNotifierProvider", + "na": { + "initialJson": "^(exampleModelJson)", + "child": { + "className": "Scaffold", + "na": { + "appBar": { + "className": "AppBar", + "na": { + "title": { + "className": "Text", + "pa": [ + "基本使用示例" + ] + } + } + }, + "body": { + "className": "Padding", + "na": { + "padding": { + "className": "EdgeInsets.only", + "na": { + "left": 16.0 + } + }, + "child": { + "className": "ListView", + "na": { + "scrollDirection": "#(Axis.vertical)", + "children": [ + { + "className": "Text", + "pa": [ + "初始化json信息👇🏻" + ] + }, + { + "className": "Text", + "pa": [ + "^(exampleModelJson)" + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.green)" + } + } + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取stringField: " + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.readString", + "pa": [ + "^(value)", + "stringField" + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取intField: " + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.anyToString", + "pa": [ + { + "className": "SugarProvider.readInt", + "pa": [ + "^(value)", + "intField" + ] + } + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取doubleField: " + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.anyToString", + "pa": [ + { + "className": "SugarProvider.readDouble", + "pa": [ + "^(value)", + "doubleField" + ] + } + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取boolField: " + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.anyToString", + "pa": [ + { + "className": "SugarProvider.readBool", + "pa": [ + "^(value)", + "boolField" + ] + } + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取listField: " + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.anyToString", + "pa": [ + { + "className": "SugarProvider.readList", + "pa": [ + "^(value)", + "listField" + ] + } + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取数组下标为1字段:" + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.readAsStringInList", + "pa": [ + "^(value)", + "listField", + 1 + ] + } + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + }, + { + "className": "Row", + "na": { + "children": [ + { + "className": "Text", + "pa": [ + "读取innerModel.innerBoolField: " + ] + }, + { + "className": "FairSelector", + "na": { + "builder": { + "className": "SugarProvider.selectorBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + "^(value)" + ], + "na": { + "style": { + "className": "TextStyle", + "na": { + "color": "#(Colors.red)" + } + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + }, + "selector": { + "className": "SugarProvider.selector", + "pa": [ + { + "className": "SugarProvider.evaluationAsString", + "pa": [ + "^(value)", + "innerModel.innerBoolField" + ], + "functionParameters": { + "pa": [ + "context", + "value" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel", + "String" + ] + } + ] + } + }, + { + "className": "Wrap", + "na": { + "spacing": 8, + "runSpacing": 8, + "children": [ + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateStringField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变stringField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + }, + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateIntField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变intField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + }, + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateDoubleField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变doubleField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + }, + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateBoolField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变boolField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + }, + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateListField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变listField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + }, + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "ElevatedButton", + "na": { + "onPressed": "@(_updateInnerField(^(context)))", + "child": { + "className": "Text", + "pa": [ + "改变innerModel.innerBoolField" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + } + ] + } + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.concatenates", + "pa": [ + "是否选中:", + { + "className": "SugarProvider.readAsString", + "pa": [ + "^(value)", + "boolField" + ] + } + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + }, + { + "className": "Align", + "na": { + "alignment": "#(Alignment.centerLeft)", + "child": { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "Switch", + "na": { + "value": { + "className": "SugarProvider.readBool", + "pa": [ + "^(value)", + "boolField" + ] + }, + "onChanged": { + "className": "SugarProvider.onValueChangeWithFairContext", + "na": { + "function": "@(_toggleBoolChange)", + "fairContext": "^(fairContext)" + } + } + }, + "functionParameters": { + "pa": [ + "fairContext" + ] + } + } + ] + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + } + }, + { + "className": "Align", + "na": { + "alignment": "#(Alignment.centerLeft)", + "child": { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.concatenates", + "pa": [ + "进度:", + { + "className": "SugarProvider.readAsString", + "pa": [ + "^(value)", + "doubleField" + ] + } + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + } + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "Slider", + "na": { + "max": 100, + "value": { + "className": "SugarProvider.readDouble", + "pa": [ + "^(value)", + "doubleField" + ] + }, + "onChanged": { + "className": "SugarProvider.onValueChangeWithFairContext", + "na": { + "function": "@(_onSliderChange)", + "fairContext": "^(fairContext)" + } + } + }, + "functionParameters": { + "pa": [ + "fairContext" + ] + } + } + ] + } + }, + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "ExampleModel" + ] + } + ] + } + } + } + }, + "floatingActionButton": { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "FloatingActionButton", + "na": { + "onPressed": "@(_updateAll(^(context),^(context)))", + "tooltip": "Increment", + "child": { + "className": "Icon", + "pa": [ + "#(Icons.add)" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + } + } + } + }, + "typeArgumentList": [ + "ExampleModel" + ], + "methodMap": {}, + "digest": "e892fd0f6f5e2dd8e7bf13ebf6525b34" +} \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata b/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata new file mode 100644 index 00000000..c3adbf76 --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata @@ -0,0 +1,7 @@ +# Generated by Fair on 2023-11-06 16:28:36.335620. + +source: example|lib/ui/example_page.dart +md5: df9a174788a4cad9b1e55169ba5e5dcf +json: example|build/fair/lib_ui_example_page.fair.json +bin: example|build/fair/lib_ui_example_page.fair.bin +date: 2023-11-06 16:28:36.336063 diff --git a/fair_provider/example/assets/fair/lib_ui_example_page2.fair.js b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.js new file mode 100644 index 00000000..240afade --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.js @@ -0,0 +1 @@ +GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;return runCallback(function(__mod__){with(__mod__.imports){function _ExamplePage2State(){const inner=_ExamplePage2State.__inner__;if(this==__global__){return new _ExamplePage2State({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_ExamplePage2State.prototype.ctor.apply(this,args);return this;}}_ExamplePage2State.__inner__=function inner(){};_ExamplePage2State.prototype={onLoad:function onLoad(){const __thiz__=this;with(__thiz__){}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},_incrementCounter:function _incrementCounter(context){const __thiz__=this;const __arg_ctx__={context,};with(__thiz__){with(__arg_ctx__){let topModel=context.read("TopModel");topModel.intField++;topModel.notify();}}},};_ExamplePage2State.prototype.ctor=function(){};;return _ExamplePage2State();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_example_page2.fair.json b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.json new file mode 100644 index 00000000..dd0969fb --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.json @@ -0,0 +1,97 @@ +{ + "className": "Scaffold", + "na": { + "appBar": { + "className": "AppBar", + "na": { + "title": { + "className": "Text", + "pa": [ + "跨组件共享状态" + ] + } + } + }, + "body": { + "className": "Center", + "na": { + "child": { + "className": "Column", + "na": { + "mainAxisAlignment": "#(MainAxisAlignment.center)", + "children": [ + { + "className": "Text", + "pa": [ + "监听TopModel中的intFiled:" + ] + }, + { + "className": "FairConsumer", + "na": { + "builder": { + "className": "SugarProvider.consumerBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.readAsString", + "pa": [ + "^(value)", + "intField" + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "TopModel" + ] + } + ] + } + } + } + }, + "floatingActionButton": { + "className": "FairContextBuilder", + "na": { + "builder": { + "className": "SugarProvider.widgetBuilder", + "pa": [ + { + "className": "FloatingActionButton", + "na": { + "onPressed": "@(_incrementCounter(^(context)))", + "tooltip": "Increment", + "child": { + "className": "Icon", + "pa": [ + "#(Icons.add)" + ] + } + }, + "functionParameters": { + "pa": [ + "context" + ] + } + } + ] + } + } + } + }, + "methodMap": {}, + "digest": "2411e8da388fc4af26fa00d0278de484" +} \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata new file mode 100644 index 00000000..c8c87d89 --- /dev/null +++ b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata @@ -0,0 +1,7 @@ +# Generated by Fair on 2023-11-06 16:28:36.313857. + +source: example|lib/ui/example_page2.dart +md5: 7e0452e2e8e8d84789b198debd6035da +json: example|build/fair/lib_ui_example_page2.fair.json +bin: example|build/fair/lib_ui_example_page2.fair.bin +date: 2023-11-06 16:28:36.314082 diff --git a/fair_provider/example/lib/entity/counter_model.dart b/fair_provider/example/lib/entity/counter_model.dart index d3fe5460..ac46367c 100644 --- a/fair_provider/example/lib/entity/counter_model.dart +++ b/fair_provider/example/lib/entity/counter_model.dart @@ -1,14 +1,5 @@ import 'package:fair_provider/fair_provider.dart'; class CounterModel extends FairChangeNotifier { - - var count = 0; - var testName = "dsds"; - SomeModel? someModel; - + int count = 0; } - -class SomeModel{ - var a = "a"; - -} \ No newline at end of file diff --git a/fair_provider/example/lib/entity/example_model.dart b/fair_provider/example/lib/entity/example_model.dart new file mode 100644 index 00000000..409c115c --- /dev/null +++ b/fair_provider/example/lib/entity/example_model.dart @@ -0,0 +1,14 @@ +import 'package:fair_provider/fair_provider.dart'; + +class ExampleModel extends FairChangeNotifier { + String? stringField; + int intField = 1; + double? doubleField; + bool boolField = false; + List? listField; + ExampleInnerModel? innerModel; +} + +class ExampleInnerModel { + bool? innerBoolField; +} diff --git a/fair_provider/example/lib/entity/login_model.dart b/fair_provider/example/lib/entity/login_model.dart deleted file mode 100644 index ce68490f..00000000 --- a/fair_provider/example/lib/entity/login_model.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:fair_provider/fair_provider.dart'; - -class LoginModel extends FairChangeNotifier { - - String? account; - String? password; - -} \ No newline at end of file diff --git a/fair_provider/example/lib/entity/top_model.dart b/fair_provider/example/lib/entity/top_model.dart new file mode 100644 index 00000000..740e373c --- /dev/null +++ b/fair_provider/example/lib/entity/top_model.dart @@ -0,0 +1,6 @@ +import 'package:fair_provider/fair_provider.dart'; + +class TopModel extends FairChangeNotifier { + int intField = 1; + double doubleFiled = 0.0; +} \ No newline at end of file diff --git a/fair_provider/example/lib/main.dart b/fair_provider/example/lib/main.dart index 3a03dcac..b660267d 100644 --- a/fair_provider/example/lib/main.dart +++ b/fair_provider/example/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:example/entity/top_model.dart'; import 'package:fair/fair.dart'; import 'package:fair_provider/fair_provider.dart'; import 'package:flutter/material.dart'; @@ -6,16 +7,27 @@ void main() { WidgetsFlutterBinding.ensureInitialized(); FairApp.runApplication( - FairApp( - generated: FairAppModule(), - child: const MyApp(), - dynamicWidgetBuilder: (proxyMirror, page, bound, {bundle}) => - ProviderDynamicWidgetBuilder(proxyMirror, page, bound, - bundle: bundle), - ), - plugins: {'FairProvider': FairProvider()}, - jsPlugins: {'fair_provider': 'packages/fair_provider/assets/plugin/fair_provider_plugin.js'} - ); + FairApp( + generated: FairProviderModule(), + child: FairChangeNotifierProvider( + initialJson: ''' +{ + "intField":99 +} + ''', + child: const MyApp(), + ), + dynamicWidgetBuilder: (proxyMirror, page, bound, {bundle}) => + ProviderDynamicWidgetBuilder(proxyMirror, page, bound, + bundle: bundle), + ), + plugins: { + 'FairProvider': FairProvider() + }, + jsPlugins: { + 'fair_provider': + 'packages/fair_provider/assets/plugin/fair_provider_plugin.js' + }); } class MyApp extends StatelessWidget { @@ -37,14 +49,36 @@ class MyApp extends StatelessWidget { body: Builder( builder: (context) => ListView( children: [ - addItem("CounterProvider Fair", () { + addItem("计数器示例", () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FairWidget( + name: "lib_ui_counter_page", + path: + "assets/fair/lib_ui_counter_page.fair.json", + ), + )); + }), + addItem("基本使用示例", () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FairWidget( + name: "lib_ui_example_page", + path: + "assets/fair/lib_ui_example_page.fair.json", + ), + )); + }), + addItem("跨页面共享状态", () { Navigator.push( context, MaterialPageRoute( builder: (context) => FairWidget( - name: "CounterProvider", + name: "lib_ui_example_page2", path: - "assets/fair/lib_ui_counter_page_provider.fair.json", + "assets/fair/lib_ui_example_page2.fair.json", ), )); }), diff --git a/fair_provider/example/lib/ui/counter_page.dart b/fair_provider/example/lib/ui/counter_page.dart new file mode 100644 index 00000000..b2855cd6 --- /dev/null +++ b/fair_provider/example/lib/ui/counter_page.dart @@ -0,0 +1,69 @@ +import 'package:example/entity/counter_model.dart'; +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; +import 'package:flutter/material.dart'; + +@FairPatch() +class CounterPage extends StatefulWidget { + const CounterPage({super.key}); + + @override + State createState() => _CounterPageState(); +} + +class _CounterPageState extends State { + var counterModelJson = ''' +{ + "count":22 +} + '''; + + void onLoad() {} + + void onUnload() {} + + void _incrementCounter(FairContext context) { + var counterModel = context.read("CounterModel"); + counterModel.count++; + counterModel.notify(); + } + + @override + Widget build(BuildContext context) { + return FairChangeNotifierProvider( + initialJson: counterModelJson, + child: Scaffold( + appBar: AppBar( + title: const Text( + "计数器示例", + ), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => + Text(SugarProvider.readAsString(value, 'count'))), + ), + ], + ), + ), + floatingActionButton: FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => FloatingActionButton( + onPressed: () { + _incrementCounter(context); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + )), + ), + ), + ); + } +} diff --git a/fair_provider/example/lib/ui/counter_page_provider.dart b/fair_provider/example/lib/ui/counter_page_provider.dart deleted file mode 100644 index 09d32bbb..00000000 --- a/fair_provider/example/lib/ui/counter_page_provider.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'package:example/entity/counter_model.dart'; -import 'package:example/entity/login_model.dart'; -import 'package:fair/fair.dart'; -import 'package:fair_provider/fair_provider.dart'; -import 'package:flutter/material.dart'; - -@FairPatch() -class CounterPageProvider extends StatefulWidget { - const CounterPageProvider({super.key}); - - @override - State createState() => _CounterPageProviderState(); -} - -class _CounterPageProviderState extends State { - var title = "我是写在js侧的title"; - - var counterModelJson = ''' -{ - "count":22, - "testName":"zzzzzz", - "someModel":{ - "a":"ffffff" - } -} - '''; - - var loginModelJson = ''' - { - "account":"qwerty12345", - "password":"zxcv54321" -} - '''; - - var counterModelJson2 = ''' -{ - "count":333, - "testName":"testName的初始值", - "someModel":{ - "a":"someModel中a的初始值" - } -} - '''; - - void onLoad() {} - - void onUnload() {} - - void _incrementCounter(FairContext context) { - var counterModel = context.read("CounterModel"); - counterModel.count++; - counterModel.testName = "及哦飞机佛IE我房间"; - counterModel.someModel?.a = "hahahaha"; - counterModel.notify(); - } - - @override - Widget build(BuildContext context) { - return FairChangeNotifierProvider( - initialJson: counterModelJson, - child: FairChangeNotifierProvider( - initialJson: loginModelJson, - child: FairChangeNotifierProvider( - initialJson: counterModelJson2, - child: Scaffold( - appBar: AppBar( - title: Text( - title, - ), - ), - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - FairConsumer( - builder: FairSugarProvider.consumerBuilder((context, value, - child) => - Text(FairSugarProvider.anyToString( - FairSugarProvider.valueReader(value, 'count')))), - ), - FairConsumer( - builder: FairSugarProvider.consumerBuilder( - (context, value, child) => Text( - FairSugarProvider.stringValueReader( - value, 'testName'))), - ), - FairSelector( - builder: FairSugarProvider.selectorBuilder( - (context, value, child) => Text(value)), - selector: FairSugarProvider.selector((context, value) => - FairSugarProvider.evaluationToString( - value, 'someModel.a'))), - ], - ), - ), - floatingActionButton: FairContextBuilder( - builder: FairSugarProvider.widgetBuilder( - (context) => FloatingActionButton( - onPressed: () { - _incrementCounter(context); - }, - tooltip: 'Increment', - child: const Icon(Icons.add), - )), - ), - ), - ), - ), - ); - } -} diff --git a/fair_provider/example/lib/ui/example_page.dart b/fair_provider/example/lib/ui/example_page.dart new file mode 100644 index 00000000..0dabe8dd --- /dev/null +++ b/fair_provider/example/lib/ui/example_page.dart @@ -0,0 +1,376 @@ +import 'dart:math'; + +import 'package:example/entity/example_model.dart'; +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; +import 'package:flutter/material.dart'; + +@FairPatch() +class ExamplePage extends StatefulWidget { + const ExamplePage({super.key}); + + @override + State createState() => _ExamplePageState(); +} + +class _ExamplePageState extends State { + var exampleModelJson = ''' +{ + "stringField":"字符串字段", + "intField":22, + "doubleField":3.3, + "boolField":true, + "listField":[1,2,3,4], + "innerModel":{ + "innerBoolField":false + } +} + '''; + + var stringList = ['白日依山尽', '黄河入海流', '欲穷千里目', '更上一层楼']; + var stringIndex = 0; + + var nestedList = [ + ['1', '2', '3', '4'], + ['5', '6', '7', '8'], + ['9', '10', '11', '12'], + ['13', '14', '15', '16'] + ]; + var listIndex = 0; + + void onLoad() {} + + void onUnload() {} + + ///更新全部 + void _updateAll(FairContext context, FairContext context2) { + var exampleModel = context.read("ExampleModel"); + if (stringIndex > 3) { + stringIndex = 0; + } + exampleModel.stringField = stringList[stringIndex++]; + exampleModel.intField++; + if (exampleModel.doubleField == 33.3) { + exampleModel.doubleField = 66.6; + } else { + exampleModel.doubleField = 33.3; + } + exampleModel.boolField = !exampleModel.boolField; + if (listIndex > 3) { + listIndex = 0; + } + exampleModel.listField = nestedList[listIndex++]; + if (exampleModel.innerModel?.innerBoolField == true) { + exampleModel.innerModel?.innerBoolField = false; + } else { + exampleModel.innerModel?.innerBoolField = true; + } + exampleModel.notify(); + } + + ///进度条变化 + void _onSliderChange(List input) { + var progress = input[0]; + FairContext fairContext = input[1]; + var exampleModel = fairContext.read("ExampleModel"); + exampleModel.doubleField = progress; + exampleModel.notify(); + } + + ///切换选中状态变化 + void _toggleBoolChange(List input) { + var flag = input[0]; + FairContext fairContext = input[1]; + var exampleModel = fairContext.read("ExampleModel"); + exampleModel.boolField = flag; + exampleModel.notify(); + } + + ///更新字符串字段 + void _updateStringField(FairContext context) { + if (stringIndex > 3) { + stringIndex = 0; + } + var exampleModel = context.read("ExampleModel"); + exampleModel.stringField = stringList[stringIndex++]; + exampleModel.notify(); + } + + ///更新整型字段 + void _updateIntField(FairContext context) { + var exampleModel = context.read("ExampleModel"); + exampleModel.intField++; + exampleModel.notify(); + } + + ///更新浮点型字段 + void _updateDoubleField(FairContext context) { + var exampleModel = context.read("ExampleModel"); + if (exampleModel.doubleField == 33.3) { + exampleModel.doubleField = 66.6; + } else { + exampleModel.doubleField = 33.3; + } + exampleModel.notify(); + } + + ///更新布尔值字段 + void _updateBoolField(FairContext context) { + var exampleModel = context.read("ExampleModel"); + exampleModel.boolField = !exampleModel.boolField; + exampleModel.notify(); + } + + ///更新数组字段 + void _updateListField(FairContext context) { + var exampleModel = context.read("ExampleModel"); + if (listIndex > 3) { + listIndex = 0; + } + exampleModel.listField = nestedList[listIndex++]; + exampleModel.notify(); + } + + ///更新嵌套字段 + void _updateInnerField(FairContext context) { + var exampleModel = context.read("ExampleModel"); + if (exampleModel.innerModel?.innerBoolField == true) { + exampleModel.innerModel?.innerBoolField = false; + } else { + exampleModel.innerModel?.innerBoolField = true; + } + exampleModel.notify(); + } + + @override + Widget build(BuildContext context) { + return FairChangeNotifierProvider( + initialJson: exampleModelJson, + child: Scaffold( + appBar: AppBar( + title: const Text( + "基本使用示例", + ), + ), + body: Padding( + padding: const EdgeInsets.only(left: 16.0), // 设置左侧内边距 + child: ListView( + scrollDirection: Axis.vertical, // 设置滑动方向为垂直或水平 + children: [ + const Text( + '初始化json信息👇🏻', + ), + Text( + exampleModelJson, + style: const TextStyle(color: Colors.green), + ), + Row(children: [ + const Text('读取stringField: '), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.readString(value, 'stringField'), + style: const TextStyle(color: Colors.red), + )), + ), + ]), + Row( + children: [ + const Text('读取intField: '), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.anyToString( + SugarProvider.readInt(value, 'intField')), + style: const TextStyle(color: Colors.red), + )), + ), + ], + ), + Row( + children: [ + const Text('读取doubleField: '), + FairConsumer( + builder: SugarProvider.consumerBuilder((context, value, + child) => + Text( + SugarProvider.anyToString( + SugarProvider.readDouble(value, 'doubleField')), + style: const TextStyle(color: Colors.red), + )), + ), + ], + ), + Row( + children: [ + const Text('读取boolField: '), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.anyToString( + SugarProvider.readBool(value, 'boolField')), + style: const TextStyle(color: Colors.red), + )), + ), + ], + ), + Row( + children: [ + const Text('读取listField: '), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.anyToString( + SugarProvider.readList(value, 'listField')), + style: const TextStyle(color: Colors.red), + )), + ), + ], + ), + Row( + children: [ + const Text('读取数组下标为1字段:'), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.readAsStringInList( + value, 'listField', 1), + style: const TextStyle(color: Colors.red), + )), + ), + ], + ), + Row( + children: [ + const Text('读取innerModel.innerBoolField: '), + FairSelector( + builder: SugarProvider.selectorBuilder( + (context, value, child) => Text( + value, + style: const TextStyle(color: Colors.red), + )), + selector: SugarProvider.selector((context, value) => + SugarProvider.evaluationAsString( + value, 'innerModel.innerBoolField'))), + ], + ), + Wrap(spacing: 8, runSpacing: 8, children: [ + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateStringField(context); + }, + child: const Text('改变stringField'), + ))), + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateIntField(context); + }, + child: const Text('改变intField'), + ))), + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateDoubleField(context); + }, + child: const Text('改变doubleField'), + ))), + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateBoolField(context); + }, + child: const Text('改变boolField'), + ))), + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateListField(context); + }, + child: const Text('改变listField'), + ))), + FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => ElevatedButton( + onPressed: () { + _updateInnerField(context); + }, + child: const Text('改变innerModel.innerBoolField'), + ))), + ]), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.concatenates( + '是否选中:', + SugarProvider.readAsString(value, 'boolField'), + ), + )), + ), + Align( + alignment: Alignment.centerLeft, + child: FairConsumer( + builder: SugarProvider.consumerBuilder((context, value, + child) => + FairContextBuilder( + builder: SugarProvider.widgetBuilder((fairContext) => + Switch( + value: + SugarProvider.readBool(value, "boolField"), + onChanged: + SugarProvider.onValueChangeWithFairContext( + function: _toggleBoolChange, + fairContext: fairContext))), + )), + ), + ), + Align( + alignment: Alignment.centerLeft, + child: FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text( + SugarProvider.concatenates( + '进度:', + SugarProvider.readAsString(value, 'doubleField'), + ), + )), + ), + ), + FairConsumer( + builder: SugarProvider.consumerBuilder((context, value, + child) => + FairContextBuilder( + builder: SugarProvider.widgetBuilder((fairContext) => + Slider( + max: 100, + value: SugarProvider.readDouble( + value, "doubleField"), + onChanged: + SugarProvider.onValueChangeWithFairContext( + function: _onSliderChange, + fairContext: fairContext))), + )), + ), + ], + ), + ), + floatingActionButton: FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => FloatingActionButton( + onPressed: () { + _updateAll(context, context); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + )), + ), + ), + ); + } +} diff --git a/fair_provider/example/lib/ui/example_page2.dart b/fair_provider/example/lib/ui/example_page2.dart new file mode 100644 index 00000000..931618a0 --- /dev/null +++ b/fair_provider/example/lib/ui/example_page2.dart @@ -0,0 +1,61 @@ +import 'package:example/entity/counter_model.dart'; +import 'package:example/entity/top_model.dart'; +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; +import 'package:flutter/material.dart'; + +@FairPatch() +class ExamplePage2 extends StatefulWidget { + const ExamplePage2({super.key}); + + @override + State createState() => _ExamplePage2State(); +} + +class _ExamplePage2State extends State { + void onLoad() {} + + void onUnload() {} + + void _incrementCounter(FairContext context) { + var topModel = context.read("TopModel"); + topModel.intField++; + topModel.notify(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text( + "跨组件共享状态", + ), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + '监听TopModel中的intFiled:', + ), + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => + Text(SugarProvider.readAsString(value, 'intField'))), + ), + ], + ), + ), + floatingActionButton: FairContextBuilder( + builder: + SugarProvider.widgetBuilder((context) => FloatingActionButton( + onPressed: () { + _incrementCounter(context); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + )), + ), + ); + } +} diff --git a/fair_provider/example/pubspec.lock b/fair_provider/example/pubspec.lock index 8a6f031c..0337fef1 100644 --- a/fair_provider/example/pubspec.lock +++ b/fair_provider/example/pubspec.lock @@ -500,7 +500,7 @@ packages: source: hosted version: "4.2.4" provider: - dependency: transitive + dependency: "direct main" description: name: provider sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f diff --git a/fair_provider/example/pubspec.yaml b/fair_provider/example/pubspec.yaml index 7a510fe0..dd9282e6 100644 --- a/fair_provider/example/pubspec.yaml +++ b/fair_provider/example/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 + provider: ^6.0.5 fair_provider: path: ../../fair_provider diff --git a/fair_provider/lib/fair_provider.dart b/fair_provider/lib/fair_provider.dart index 170c4220..e4b5fcbc 100644 --- a/fair_provider/lib/fair_provider.dart +++ b/fair_provider/lib/fair_provider.dart @@ -1,4 +1,4 @@ -export 'src/fair_app_module.dart'; +export 'src/fair_provider_module.dart'; export 'src/fair_provider_core.dart'; export 'src/fair_provider_plugin.dart'; export 'src/provider_dynamic_widget_builder.dart'; \ No newline at end of file diff --git a/fair_provider/lib/src/fair_app_module.dart b/fair_provider/lib/src/fair_app_module.dart deleted file mode 100644 index 86ccc036..00000000 --- a/fair_provider/lib/src/fair_app_module.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:fair/fair.dart'; -import 'package:flutter/material.dart'; - -import 'fair_provider_core.dart'; - -class FairAppModule extends GeneratedModule { - @override - Map components() { - return { - 'InputBorder.none': InputBorder.none, - 'FairChangeNotifierProvider': (props) => FairChangeNotifierProvider( - key: props['key'], - child: props['child'], - initialJson: props['initialJson'], - )..setTypeArgumentList(props['ta']), - 'FairConsumer': (props) => FairConsumer( - key: props['key'], - builder: props['builder'], - child: props['child'], - )..setTypeArgumentList(props['ta']), - 'FairSelector': (props) => FairSelector( - key: props['key'], - builder: props['builder'], - selector: props['selector'], - child: props['child'], - )..setTypeArgumentList(props['ta']), - 'FairSugarProvider.valueReader': (props) => - FairSugarProvider.valueReader(props['pa'][0], props['pa'][1]), - 'FairSugarProvider.stringValueReader': (props) => - FairSugarProvider.stringValueReader(props['pa'][0], props['pa'][1]), - 'FairSugarProvider.evaluationToString': (props) => - FairSugarProvider.evaluationToString(props['pa'][0], props['pa'][1]), - 'FairSugarProvider.anyToString': (props) => - FairSugarProvider.anyToString(props['pa'][0]), - 'FairContextBuilder': (props) => FairContextBuilder( - key: props['key'], - builder: props['builder'], - ), - }; - } - - @override - Map mapping() { - return {}; - } -} diff --git a/fair_provider/lib/src/fair_provider_core.dart b/fair_provider/lib/src/fair_provider_core.dart index 9448dce0..56618e3f 100644 --- a/fair_provider/lib/src/fair_provider_core.dart +++ b/fair_provider/lib/src/fair_provider_core.dart @@ -8,6 +8,8 @@ import 'package:collection/collection.dart'; import 'utils/time_record.dart'; +var providerLogOn = false; + final Map _fairModelPool = {}; class FairProviderPlugin { @@ -78,10 +80,9 @@ class FairContextBuilder extends StatelessWidget { /// Creates a widget that delegates its build to a callback. /// /// The [builder] argument must not be null. - const FairContextBuilder({ - super.key, + const FairContextBuilder({Key? key, required this.builder, - }) : assert(builder != null); + }) : super(key: key); /// Called to obtain the child widget. /// @@ -152,8 +153,10 @@ typedef FairSelectorSelector = dynamic Function( dynamic value, ); -class FairSugarProvider { - FairSugarProvider._(); +typedef OnValueChanged = void Function(dynamic value); + +class SugarProvider { + SugarProvider._(); /// Provider消费者Builder,用于Consumer static FairConsumerBuilder consumerBuilder(FairConsumerBuilder builder) => @@ -167,18 +170,96 @@ class FairSugarProvider { static FairSelectorSelector selector(FairSelectorSelector selector) => selector; - ///用于从 - static dynamic valueReader( - FairChangeNotifier model, - String key, - ) => - model[key] ?? 'null'; + static String readString( + FairChangeNotifier model, + String key, + ) { + return model[key] ?? 'null'; + } - static String stringValueReader( - FairChangeNotifier model, - String key, - ) => - (model[key] ?? 'null').toString(); + static String readAsString( + FairChangeNotifier model, + String key, + ) { + return model[key].toString() ?? 'null'; + } + + static int readInt( + FairChangeNotifier model, + String key, + ) { + return model[key] ?? 0; + } + + static double readDouble( + FairChangeNotifier model, + String key, + ) { + return model[key].toDouble() ?? 0.0; + } + + static bool readBool( + FairChangeNotifier model, + String key, + ) { + return model[key] ?? false; + } + + static dynamic readDynamic( + FairChangeNotifier model, + String key, + ) { + return model[key] ?? null; + } + + static List readList( + FairChangeNotifier model, + String key, + ) { + return model[key] ?? null; + } + + static String readStringInList( + FairChangeNotifier model, + String key, + int index) { + return model[key][index] ?? "null"; + } + + static String readAsStringInList( + FairChangeNotifier model, + String key, + int index) { + return model[key][index].toString() ?? "null"; + } + + static int readIntInList( + FairChangeNotifier model, + String key, + int index) { + return model[key] ?? 0; + } + + static double readDoubleInList( + FairChangeNotifier model, + String key, + int index) { + return model[key] ?? 0.0; + } + + static bool readBoolInList( + FairChangeNotifier model, + String key, + int index) { + return model[key] ?? false; + } + + static dynamic readDynamicInList( + FairChangeNotifier model, + String key, + int index) { + return model[key] ?? null; + } static dynamic anyToString(dynamic value) { return value.toString(); @@ -188,7 +269,43 @@ class FairSugarProvider { FairChangeNotifier model, String expression, ) => - (model.evaluation(expression) ?? 'null').toString(); + model.evaluation(expression) ?? 'null'; + + static String evaluationAsString( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression).toString() ?? 'null'; + + static int evaluationToInt( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression) ?? 0; + + static double evaluationToDouble( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression) ?? 0.0; + + static bool evaluationToBool( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression) ?? false; + + static List evaluationToList( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression) ?? null; + + static dynamic evaluationToDynamic( + FairChangeNotifier model, + String expression, + ) => + model.evaluation(expression) ?? null; static FairContextWidgetBuilder widgetBuilder( FairContextWidgetBuilder builder) => @@ -197,6 +314,21 @@ class FairSugarProvider { static FairContextWidgetBuilder2 widgetBuilder2( FairContextWidgetBuilder2 builder) => builder; + + /// Creates a new string by concatenating this string with [other]. + /// + /// Example: + /// ```dart + /// const string = 'dart' + 'lang'; // 'dartlang' + /// ``` + static String concatenates(String input, String other) => input + other; + + static OnValueChanged onValueChangeWithFairContext( + {required Function function,required FairContext fairContext}) { + return (value) { + function.call([value, fairContext]); + }; + } } class FairChangeNotifierProvider @@ -213,7 +345,7 @@ class FairChangeNotifierProvider final Runtime _runtime = Runtime(); - String? fairRuntimeTypeKey; + String? fairRuntimeTypeKey = T.toString(); List? typeArgumentList; diff --git a/fair_provider/lib/src/fair_provider_module.dart b/fair_provider/lib/src/fair_provider_module.dart new file mode 100644 index 00000000..c5b61439 --- /dev/null +++ b/fair_provider/lib/src/fair_provider_module.dart @@ -0,0 +1,90 @@ +import 'package:fair/fair.dart'; +import 'package:flutter/material.dart'; + +import 'fair_provider_core.dart'; + +class FairProviderModule extends GeneratedModule { + @override + Map components() { + return { + 'FairChangeNotifierProvider': (props) => + FairChangeNotifierProvider( + key: props['key'], + child: props['child'], + initialJson: props['initialJson'], + ) + ..setTypeArgumentList(props['ta']), + 'FairConsumer': (props) => + FairConsumer( + key: props['key'], + builder: props['builder'], + child: props['child'], + ) + ..setTypeArgumentList(props['ta']), + 'FairSelector': (props) => + FairSelector( + key: props['key'], + builder: props['builder'], + selector: props['selector'], + child: props['child'], + ) + ..setTypeArgumentList(props['ta']), + 'SugarProvider.readString': (props) => + SugarProvider.readString(props['pa'][0], props['pa'][1]), + 'SugarProvider.readAsString': (props) => + SugarProvider.readAsString(props['pa'][0], props['pa'][1]), + 'SugarProvider.readInt': (props) => + SugarProvider.readInt(props['pa'][0], props['pa'][1]), + 'SugarProvider.readDouble': (props) => + SugarProvider.readDouble(props['pa'][0], props['pa'][1]), + 'SugarProvider.readBool': (props) => + SugarProvider.readBool(props['pa'][0], props['pa'][1]), + 'SugarProvider.readDynamic': (props) => + SugarProvider.readDynamic(props['pa'][0], props['pa'][1]), + 'SugarProvider.readList': (props) => + SugarProvider.readList(props['pa'][0], props['pa'][1]), + 'SugarProvider.readStringInList': (props) => + SugarProvider.readStringInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.readAsStringInList': (props) => + SugarProvider.readAsStringInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.readIntInList': (props) => + SugarProvider.readIntInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.readDoubleInList': (props) => + SugarProvider.readDoubleInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.readBoolInList': (props) => + SugarProvider.readBoolInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.readDynamicInList': (props) => + SugarProvider.readDynamicInList(props['pa'][0], props['pa'][1], props['pa'][2]), + 'SugarProvider.evaluationToString': (props) => + SugarProvider.evaluationToString(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationAsString': (props) => + SugarProvider.evaluationAsString(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationToInt': (props) => + SugarProvider.evaluationToInt(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationToDouble': (props) => + SugarProvider.evaluationToDouble(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationToBool': (props) => + SugarProvider.evaluationToBool(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationToList': (props) => + SugarProvider.evaluationToList(props['pa'][0], props['pa'][1]), + 'SugarProvider.evaluationToDynamic': (props) => + SugarProvider.evaluationToDynamic(props['pa'][0], props['pa'][1]), + 'SugarProvider.anyToString': (props) => + SugarProvider.anyToString(props['pa'][0]), + 'SugarProvider.concatenates': (props) => + SugarProvider.concatenates(props['pa'][0], props['pa'][1]), + 'FairContextBuilder': (props) => + FairContextBuilder( + key: props['key'], + builder: props['builder'], + ), + 'SugarProvider.onValueChangeWithFairContext': (props) => + SugarProvider.onValueChangeWithFairContext(function: props['function'], fairContext: props['fairContext']), + }; + } + + @override + Map mapping() { + return {}; + } +} diff --git a/fair_provider/lib/src/provider_dynamic_widget_builder.dart b/fair_provider/lib/src/provider_dynamic_widget_builder.dart index a9be0e16..91a58fb6 100644 --- a/fair_provider/lib/src/provider_dynamic_widget_builder.dart +++ b/fair_provider/lib/src/provider_dynamic_widget_builder.dart @@ -17,29 +17,29 @@ class ProviderDynamicWidgetBuilder extends DynamicWidgetBuilder { dynamic convert(BuildContext context, Map map, Map? methodMap, {Domain? domain}) { var name = map[tag]; - if (name == 'FairSugarProvider.consumerBuilder' || - name == 'FairSugarProvider.selectorBuilder') { + if (name == 'SugarProvider.consumerBuilder' || + name == 'SugarProvider.selectorBuilder') { return _buildFairSugarConsumerBuilder( context, map, methodMap, domain: domain, ); - } else if (name == 'FairSugarProvider.selector') { + } else if (name == 'SugarProvider.selector') { return _buildFairSugarSelector( context, map, methodMap, domain: domain, ); - } else if (name == 'FairSugarProvider.widgetBuilder') { + } else if (name == 'SugarProvider.widgetBuilder') { return _buildFairSugarWidgetBuilder( context, map, methodMap, domain: domain, ); - } else if (name == 'FairSugarProvider.widgetBuilder2') { + } else if (name == 'SugarProvider.widgetBuilder2') { return _buildFairSugarWidgetBuilder2( context, map, diff --git a/fair_provider/lib/src/utils/time_record.dart b/fair_provider/lib/src/utils/time_record.dart index 060ee5ff..86c90cf7 100644 --- a/fair_provider/lib/src/utils/time_record.dart +++ b/fair_provider/lib/src/utils/time_record.dart @@ -1,5 +1,6 @@ -class TimeRecord { +import 'package:fair_provider/fair_provider.dart'; +class TimeRecord { TimeRecord(this.tag); String? tag; @@ -15,7 +16,8 @@ class TimeRecord { _endTime = DateTime.now(); final duration = _endTime.difference(_startTime); final milliseconds = duration.inMilliseconds; - print('耗时统计 Time elapsed: $milliseconds milliseconds'); + if (providerLogOn) { + print('耗时统计 Time elapsed: $milliseconds milliseconds'); + } } - -} \ No newline at end of file +} diff --git a/fair_provider/pubspec.lock b/fair_provider/pubspec.lock index 889b5f76..eb5006a5 100644 --- a/fair_provider/pubspec.lock +++ b/fair_provider/pubspec.lock @@ -188,7 +188,7 @@ packages: fair: dependency: "direct main" description: - path: "../../fair/fair" + path: "../fair" relative: true source: path version: "3.3.0" @@ -203,28 +203,28 @@ packages: fair_compiler: dependency: "direct dev" description: - path: "../../fair/compiler" + path: "../compiler" relative: true source: path version: "1.8.0" fair_dart2dsl: dependency: "direct overridden" description: - path: "../../fair/dart2dsl" + path: "../dart2dsl" relative: true source: path version: "1.4.0" fair_dart2js: dependency: "direct overridden" description: - path: "../../fair/dart2js" + path: "../dart2js" relative: true source: path version: "1.4.0" fair_version: dependency: "direct overridden" description: - path: "../../fair/flutter_version/flutter_3_7_0" + path: "../flutter_version/flutter_3_7_0" relative: true source: path version: "3.7.0" @@ -713,5 +713,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=2.19.6 <3.0.0" + dart: ">=2.19.0 <3.0.0" flutter: ">=3.7.0" diff --git a/fair_provider/pubspec.yaml b/fair_provider/pubspec.yaml index dee023a7..38a9b688 100644 --- a/fair_provider/pubspec.yaml +++ b/fair_provider/pubspec.yaml @@ -4,7 +4,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: ">=2.12.0 <4.0.0" + flutter: ">=1.16.0" dependencies: flutter: From 1e6d0329ab19c874ca8858e1ce356fb2a3a804f1 Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Mon, 6 Nov 2023 17:46:02 +0800 Subject: [PATCH 06/11] [feature]adapt provider and fix bug in Abstract fast access interface feature --- fair/lib/src/app.dart | 6 +++ fair/lib/src/render/decode.dart | 4 +- fair_provider/example/lib/main.dart | 23 ++++------- fair_provider/lib/fair_provider.dart | 3 +- .../lib/src/fair_provider_adapter.dart | 38 +++++++++++++++++++ 5 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 fair_provider/lib/src/fair_provider_adapter.dart diff --git a/fair/lib/src/app.dart b/fair/lib/src/app.dart index 2638af8c..e72f5cf6 100644 --- a/fair/lib/src/app.dart +++ b/fair/lib/src/app.dart @@ -122,6 +122,12 @@ class FairApp extends InheritedWidget with AppState { List? baseJsSources, List? adapters, }) { + if (plugins == null) { + plugins = {}; + } + if (jsPlugins == null) { + jsPlugins = {}; + } //init 3rd-library adapter initFairLibraryAdapter(app, plugins: plugins, jsPlugins: jsPlugins, adapters: adapters); diff --git a/fair/lib/src/render/decode.dart b/fair/lib/src/render/decode.dart index 959b928a..1f93e3dc 100644 --- a/fair/lib/src/render/decode.dart +++ b/fair/lib/src/render/decode.dart @@ -84,10 +84,10 @@ class Decoder { dynamicBuilder = DynamicWidgetBuilder(proxy as ProxyMirror?, page, bound, bundle: url); } else { dynamicBuilder = - dynamicBuilders.map((e) => e?.convert(context, map, methodMap)).toList().firstWhere((element) => element != null, orElse: () => null); + dynamicBuilders.firstWhere((element) => element?.convert(context, map, methodMap) != null, orElse: () => null); } Widget w =(dynamicBuilder ?? DynamicWidgetBuilder(proxy as ProxyMirror?, page, bound, bundle: url)).convert(context, map, methodMap) ?? - WarningWidget(parentContext:context,name: page, url: url, error: 'tag name not supported yet'); + WarningWidget(parentContext:context,name: page, url: url, error: 'tag name not supported yet'); return w; } } diff --git a/fair_provider/example/lib/main.dart b/fair_provider/example/lib/main.dart index b660267d..1964cb0e 100644 --- a/fair_provider/example/lib/main.dart +++ b/fair_provider/example/lib/main.dart @@ -7,27 +7,18 @@ void main() { WidgetsFlutterBinding.ensureInitialized(); FairApp.runApplication( - FairApp( - generated: FairProviderModule(), - child: FairChangeNotifierProvider( - initialJson: ''' + FairApp( + child: FairChangeNotifierProvider( + initialJson: ''' { "intField":99 } ''', - child: const MyApp(), - ), - dynamicWidgetBuilder: (proxyMirror, page, bound, {bundle}) => - ProviderDynamicWidgetBuilder(proxyMirror, page, bound, - bundle: bundle), + child: const MyApp(), ), - plugins: { - 'FairProvider': FairProvider() - }, - jsPlugins: { - 'fair_provider': - 'packages/fair_provider/assets/plugin/fair_provider_plugin.js' - }); + ), + adapters: [FairProviderAdapter()], + ); } class MyApp extends StatelessWidget { diff --git a/fair_provider/lib/fair_provider.dart b/fair_provider/lib/fair_provider.dart index e4b5fcbc..822c1115 100644 --- a/fair_provider/lib/fair_provider.dart +++ b/fair_provider/lib/fair_provider.dart @@ -1,4 +1,5 @@ export 'src/fair_provider_module.dart'; export 'src/fair_provider_core.dart'; export 'src/fair_provider_plugin.dart'; -export 'src/provider_dynamic_widget_builder.dart'; \ No newline at end of file +export 'src/provider_dynamic_widget_builder.dart'; +export 'src/fair_provider_adapter.dart'; \ No newline at end of file diff --git a/fair_provider/lib/src/fair_provider_adapter.dart b/fair_provider/lib/src/fair_provider_adapter.dart new file mode 100644 index 00000000..1901037b --- /dev/null +++ b/fair_provider/lib/src/fair_provider_adapter.dart @@ -0,0 +1,38 @@ +import 'package:fair/fair.dart'; +import 'package:fair_provider/fair_provider.dart'; + +class FairProviderAdapter implements IFairLibraryAdapter { + @override + GeneratedModule provideGeneratedModule() { + return FairProviderModule(); + } + + @override + Map provideFairModule() { + return {}; + } + + @override + Map provideFairDelegate() { + return {}; + } + + @override + DynamicWidgetBuilderFunction provideDynamicWidgetBuilder() { + return (proxyMirror, page, bound, {bundle}) => + ProviderDynamicWidgetBuilder(proxyMirror, page, bound, bundle: bundle); + } + + @override + Map provideJSPlugins() { + return { + 'fair_provider': + 'packages/fair_provider/assets/plugin/fair_provider_plugin.js' + }; + } + + @override + Map provideFairPlugins() { + return {'FairProvider': FairProvider()}; + } +} From 67c45d335a5627ca17496caa997b544aa6a69761 Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Mon, 6 Nov 2023 21:43:19 +0800 Subject: [PATCH 07/11] [feature] improve readme --- fair_provider/README.md | 136 ++++++++++++++++-- fair_provider/lib/src/fair_provider_core.dart | 5 - 2 files changed, 126 insertions(+), 15 deletions(-) diff --git a/fair_provider/README.md b/fair_provider/README.md index 517d64bb..6c978039 100644 --- a/fair_provider/README.md +++ b/fair_provider/README.md @@ -1,16 +1,132 @@ -# fair_provider +`fair-provider` 是为了丰富 `fair` 的状态管理能力,以 `provider` 原理进行封装的sdk。使用其可以以类似 `provider` 的用法在 `fair` 页面中进行状态管理。 -An extension library for Fair on the Provider framework. +目前对 `provider` 中部分组件进行了适配支持,可以满足基本场景的使用,核心组件对应关系如下: +- ChangeNotifierProvider => [FairChangeNotifierProvider]() +- Consumer => [FairConsumer]() +- Selector => [FairSelector]() +- ChangeNotifier => [FairChangeNotifier]() -## Getting Started +## 快速接入 +pub添加依赖 +```yaml +dependencies: + fair_provider: ^0.0.1 +``` -This project is a starting point for a Flutter application. +初始化FairApp时传入FairProviderAdapter +```dart +///入口函数 +void main() { + WidgetsFlutterBinding.ensureInitialized(); -A few resources to get you started if this is your first Flutter project: + FairApp.runApplication( + FairApp( + child: const MyApp(), + ), + adapters: [FairProviderAdapter()], + ); +} +``` -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) +## 基本使用 +以计数器举例 +首先声明状态管理类,继承 `FairChangeNotifier` +```dart +class CounterModel extends FairChangeNotifier { + int count = 0; +} +``` +创建Provider,将初始化数据以json的形式传入 +```dart + var initialJson = ''' +{ + "count":22 +} + '''; -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. + @override + Widget build(BuildContext context) { + return FairChangeNotifierProvider( + initialJson: initialJson, + child: ... + ); + } +``` +使用 `FairConsumer`/`FairSelector` 配合语法糖来观察状态变更 +```dart + FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => + Text(SugarProvider.readAsString(value, 'count'))), + ) +``` +编写事件处理函数,更新状态 +注意read函数的泛型即是状态管理类的类型,参数需要手动输入该类的字符串 +```dart + void _incrementCounter(FairContext context) { + var counterModel = context.read("CounterModel"); + counterModel.count++; + counterModel.notify(); + } +``` +由于fair中的逻辑函数会经 `dart2js` 编译器转换为js,所以是不支持 `BuildContext` 上下文的,这里需要使用经过特殊处理的 `FairContext`,`FairContext` 的构造需要 `FairContextBuilder` 配合语法糖 `SugarProvider.widgetBuilder` 来获取 +```dart +FairContextBuilder( + builder: SugarProvider.widgetBuilder((context) => FloatingActionButton( + onPressed: () { + _incrementCounter(context); + }, + tooltip: 'Increment', + child: const Icon(Icons.add), + )), +), +``` + +## 进阶使用 +由于 `fair` 的布局动态化特性,在构建布局时不支持随意编写取值代码,这里需要借助 [SugarProvider]() 中的一系列语法糖来完成 + +这里以example中的基本示例代码举例 +```dart +class ExampleModel extends FairChangeNotifier { + String? stringField; + int intField = 1; + double? doubleField; + bool boolField = false; + List? listField; + ExampleInnerModel? innerModel; +} + +class ExampleInnerModel { + bool? innerBoolField; +} +``` +语法糖提供了基本类型和数组的取值api,具体使用细节可以参考example中的 [基本使用示例]() +```dart +///一个读取字符串的例子 +FairConsumer( + builder: SugarProvider.consumerBuilder( + (context, value, child) => Text(SugarProvider.readString(value, 'stringField'))), +), +``` +- **readString** 使用key从model中读取String类型的值 +- **readAsString** 使用key从model中读取并强转为String类型的值 +- **readInt** 使用key从model中读取Int类型的值 +- **readDouble** 使用key从model中读取Double类型的值 +- **readBool** 使用key从model中读取布尔型的值 +- **readList** 使用key从model中读取数组类型的值 +- **readDynamic** 使用key从model中读取任意类型的值 + +还支持表达式取值,使用规则如 `a.b.c` +```dart +FairSelector( + builder: SugarProvider.selectorBuilder((context, value, child) => Text(value)), + selector: SugarProvider.selector((context, value) =>SugarProvider.evaluationAsString(value, 'innerModel.innerBoolField')) +) +``` +- **evaluationToString** 使用表达式从model中读取String类型的值 +- **evaluationAsString** 使用表达式从model中读取并强转为String类型的值 +- **evaluationToInt** 使用表达式从model中读取Int类型的值 +- **evaluationToDouble** 使用表达式从model中读取Double类型的值 +- **evaluationToBool** 使用表达式从model中读取布尔型的值 +- **evaluationToList** 使用表达式从model中读取数组类型的值 +- **evaluationToDynamic** 使用表达式从model中读取任意类型的值 diff --git a/fair_provider/lib/src/fair_provider_core.dart b/fair_provider/lib/src/fair_provider_core.dart index 56618e3f..6c127473 100644 --- a/fair_provider/lib/src/fair_provider_core.dart +++ b/fair_provider/lib/src/fair_provider_core.dart @@ -74,7 +74,6 @@ class FairContext { } typedef FairContextWidgetBuilder = Widget Function(FairContext context); -typedef FairContextWidgetBuilder2 = Widget Function(String context); class FairContextBuilder extends StatelessWidget { /// Creates a widget that delegates its build to a callback. @@ -311,10 +310,6 @@ class SugarProvider { FairContextWidgetBuilder builder) => builder; - static FairContextWidgetBuilder2 widgetBuilder2( - FairContextWidgetBuilder2 builder) => - builder; - /// Creates a new string by concatenating this string with [other]. /// /// Example: From 6a0132d3b24b0340a9e3c3c569146abd64d3b66a Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Tue, 7 Nov 2023 10:59:49 +0800 Subject: [PATCH 08/11] [feature] improve readme --- fair_provider/README.md | 12 ++++- .../assets/fair/lib_ui_counter_page.fair.json | 52 ++++++++++++++++++- .../fair/lib_ui_counter_page.fair.metadata | 6 +-- .../fair/lib_ui_example_page.fair.metadata | 4 +- .../fair/lib_ui_example_page2.fair.metadata | 4 +- .../example/lib/ui/counter_page.dart | 7 +++ .../src/provider_dynamic_widget_builder.dart | 27 ---------- 7 files changed, 75 insertions(+), 37 deletions(-) diff --git a/fair_provider/README.md b/fair_provider/README.md index 6c978039..6ed27614 100644 --- a/fair_provider/README.md +++ b/fair_provider/README.md @@ -52,7 +52,7 @@ class CounterModel extends FairChangeNotifier { ); } ``` -使用 `FairConsumer`/`FairSelector` 配合语法糖来观察状态变更 +使用 `FairConsumer`/`FairSelector` 配合语法糖来观察状态变更,注意由于 `fair` DSL布局的特性,匿名函数是不支持的(后续计划支持优化),所以其中的builder函数还需要语法糖来包装下。最后从自定义的 `FairChangeNotifier` 状态管理对象中取值同样也需要借助语法糖来完成,目前已经提供了大量的取值语法糖,可以满足大多数场景的使用,详细说明可参考进阶使用部分。 ```dart FairConsumer( builder: SugarProvider.consumerBuilder( @@ -60,6 +60,14 @@ class CounterModel extends FairChangeNotifier { Text(SugarProvider.readAsString(value, 'count'))), ) ``` +```dart + FairSelector( + builder: SugarProvider.selectorBuilder( + (context, value, child) => + Text(SugarProvider.anyToString(value))), + selector: SugarProvider.selector((context, value) => + SugarProvider.readInt(value, 'count'))), +``` 编写事件处理函数,更新状态 注意read函数的泛型即是状态管理类的类型,参数需要手动输入该类的字符串 ```dart @@ -116,7 +124,7 @@ FairConsumer( - **readList** 使用key从model中读取数组类型的值 - **readDynamic** 使用key从model中读取任意类型的值 -还支持表达式取值,使用规则如 `a.b.c` +还支持表达式取值,使用规则如 `a.b.c`,基本原理则是将表达式发送到 `js` 侧使用 `eval` 函数进行取值,具体使用如下,也可参考 [基本使用示例]() ```dart FairSelector( builder: SugarProvider.selectorBuilder((context, value, child) => Text(value)), diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json index 727f5217..a069de0d 100644 --- a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json +++ b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.json @@ -61,6 +61,56 @@ "typeArgumentList": [ "CounterModel" ] + }, + { + "className": "FairSelector", + "na": { + "builder": { + "className": "SugarProvider.selectorBuilder", + "pa": [ + { + "className": "Text", + "pa": [ + { + "className": "SugarProvider.anyToString", + "pa": [ + "^(value)" + ] + } + ], + "functionParameters": { + "pa": [ + "context", + "value", + "child" + ] + } + } + ] + }, + "selector": { + "className": "SugarProvider.selector", + "pa": [ + { + "className": "SugarProvider.readInt", + "pa": [ + "^(value)", + "count" + ], + "functionParameters": { + "pa": [ + "context", + "value" + ] + } + } + ] + } + }, + "typeArgumentList": [ + "CounterModel", + "int" + ] } ] } @@ -102,5 +152,5 @@ "CounterModel" ], "methodMap": {}, - "digest": "61dcca0ca25598d884689e6aa5679d0f" + "digest": "2a50f76be88274617782a4aaf287fae5" } \ No newline at end of file diff --git a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata index 99cacf8c..04d5a236 100644 --- a/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata +++ b/fair_provider/example/assets/fair/lib_ui_counter_page.fair.metadata @@ -1,7 +1,7 @@ -# Generated by Fair on 2023-11-06 16:28:36.272460. +# Generated by Fair on 2023-11-07 10:58:27.291068. source: example|lib/ui/counter_page.dart -md5: 90013183bf2a75597cb7644ab4e97676 +md5: d2e3f3306a431e152fa405978c7ff341 json: example|build/fair/lib_ui_counter_page.fair.json bin: example|build/fair/lib_ui_counter_page.fair.bin -date: 2023-11-06 16:28:36.272763 +date: 2023-11-07 10:58:27.291284 diff --git a/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata b/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata index c3adbf76..7f354866 100644 --- a/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata +++ b/fair_provider/example/assets/fair/lib_ui_example_page.fair.metadata @@ -1,7 +1,7 @@ -# Generated by Fair on 2023-11-06 16:28:36.335620. +# Generated by Fair on 2023-11-07 10:58:27.258829. source: example|lib/ui/example_page.dart md5: df9a174788a4cad9b1e55169ba5e5dcf json: example|build/fair/lib_ui_example_page.fair.json bin: example|build/fair/lib_ui_example_page.fair.bin -date: 2023-11-06 16:28:36.336063 +date: 2023-11-07 10:58:27.259251 diff --git a/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata index c8c87d89..2bd5af1b 100644 --- a/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata +++ b/fair_provider/example/assets/fair/lib_ui_example_page2.fair.metadata @@ -1,7 +1,7 @@ -# Generated by Fair on 2023-11-06 16:28:36.313857. +# Generated by Fair on 2023-11-07 10:58:27.306859. source: example|lib/ui/example_page2.dart md5: 7e0452e2e8e8d84789b198debd6035da json: example|build/fair/lib_ui_example_page2.fair.json bin: example|build/fair/lib_ui_example_page2.fair.bin -date: 2023-11-06 16:28:36.314082 +date: 2023-11-07 10:58:27.307047 diff --git a/fair_provider/example/lib/ui/counter_page.dart b/fair_provider/example/lib/ui/counter_page.dart index b2855cd6..036bd9de 100644 --- a/fair_provider/example/lib/ui/counter_page.dart +++ b/fair_provider/example/lib/ui/counter_page.dart @@ -50,6 +50,13 @@ class _CounterPageState extends State { (context, value, child) => Text(SugarProvider.readAsString(value, 'count'))), ), + FairSelector( + builder: + SugarProvider.selectorBuilder((context, value, child) { + return Text(SugarProvider.anyToString(value)); + }), + selector: SugarProvider.selector((context, value) => + SugarProvider.readInt(value, 'count'))), ], ), ), diff --git a/fair_provider/lib/src/provider_dynamic_widget_builder.dart b/fair_provider/lib/src/provider_dynamic_widget_builder.dart index 91a58fb6..825d7d12 100644 --- a/fair_provider/lib/src/provider_dynamic_widget_builder.dart +++ b/fair_provider/lib/src/provider_dynamic_widget_builder.dart @@ -39,13 +39,6 @@ class ProviderDynamicWidgetBuilder extends DynamicWidgetBuilder { methodMap, domain: domain, ); - } else if (name == 'SugarProvider.widgetBuilder2') { - return _buildFairSugarWidgetBuilder2( - context, - map, - methodMap, - domain: domain, - ); } return super.convert( context, @@ -122,24 +115,4 @@ class ProviderDynamicWidgetBuilder extends DynamicWidgetBuilder { return builder; } - dynamic _buildFairSugarWidgetBuilder2(BuildContext context, Map map, Map? methodMap, - {Domain? domain}) { - dynamic source = pa0(map); - assert(source is Map); - List functionParameters = FunctionDomain.pa(source); - FairContextWidgetBuilder2 builder = (builderContext) { - return convert( - context, - source, - methodMap, - domain: FunctionDomain( - { - functionParameters[0]: builderContext, - }, - parent: domain, - ), - ); - }; - return builder; - } } From bb20ea10442ba76a9ac3cfa227d44f06908a4ffa Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Tue, 7 Nov 2023 15:11:07 +0800 Subject: [PATCH 09/11] [feature] improve readme --- fair_provider/README.md | 6 ++++-- fair_provider/example/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fair_provider/README.md b/fair_provider/README.md index 6ed27614..70e016cd 100644 --- a/fair_provider/README.md +++ b/fair_provider/README.md @@ -77,7 +77,7 @@ class CounterModel extends FairChangeNotifier { counterModel.notify(); } ``` -由于fair中的逻辑函数会经 `dart2js` 编译器转换为js,所以是不支持 `BuildContext` 上下文的,这里需要使用经过特殊处理的 `FairContext`,`FairContext` 的构造需要 `FairContextBuilder` 配合语法糖 `SugarProvider.widgetBuilder` 来获取 +这里需要使用经过特殊处理的 `FairContext`,`FairContext` 的构造需要 `FairContextBuilder` 配合语法糖 `SugarProvider.widgetBuilder` 来获取 ```dart FairContextBuilder( builder: SugarProvider.widgetBuilder((context) => FloatingActionButton( @@ -124,7 +124,7 @@ FairConsumer( - **readList** 使用key从model中读取数组类型的值 - **readDynamic** 使用key从model中读取任意类型的值 -还支持表达式取值,使用规则如 `a.b.c`,基本原理则是将表达式发送到 `js` 侧使用 `eval` 函数进行取值,具体使用如下,也可参考 [基本使用示例]() +还支持表达式取值,使用规则如 `a.b.c`,以上面的ExampleModel为例,如果想读取成员 `innerModel` 中的 `innerBoolField` 字段,使用表达式取值可以这么写 ```dart FairSelector( builder: SugarProvider.selectorBuilder((context, value, child) => Text(value)), @@ -138,3 +138,5 @@ FairSelector( - **evaluationToBool** 使用表达式从model中读取布尔型的值 - **evaluationToList** 使用表达式从model中读取数组类型的值 - **evaluationToDynamic** 使用表达式从model中读取任意类型的值 + +## 更多示例请见 [example]() \ No newline at end of file diff --git a/fair_provider/example/pubspec.yaml b/fair_provider/example/pubspec.yaml index dd9282e6..aab22396 100644 --- a/fair_provider/example/pubspec.yaml +++ b/fair_provider/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: ">=2.12.0 <4.0.0" dependencies: flutter: From d8cba552043a7e1b336cbe49a0d599a286b0a19c Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Thu, 9 Nov 2023 19:43:34 +0800 Subject: [PATCH 10/11] [feature] improve readme --- fair_provider/README.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/fair_provider/README.md b/fair_provider/README.md index 70e016cd..fec0a758 100644 --- a/fair_provider/README.md +++ b/fair_provider/README.md @@ -28,9 +28,11 @@ void main() { } ``` -## 基本使用 +## 简单使用 以计数器举例 + 首先声明状态管理类,继承 `FairChangeNotifier` + ```dart class CounterModel extends FairChangeNotifier { int count = 0; @@ -90,10 +92,12 @@ FairContextBuilder( ), ``` -## 进阶使用 -由于 `fair` 的布局动态化特性,在构建布局时不支持随意编写取值代码,这里需要借助 [SugarProvider]() 中的一系列语法糖来完成 +## 使用说明 + +### 1. FairChangeNotifier的使用限制 + +注意 `FairChangeNotifier` 的定义有一些限制,这里以 [example]() 中的ExampleModel举例 -这里以example中的基本示例代码举例 ```dart class ExampleModel extends FairChangeNotifier { String? stringField; @@ -108,6 +112,22 @@ class ExampleInnerModel { bool? innerBoolField; } ``` + +1. 支持的类型为基本类型和数组、字典 + - int + - double + - String + - bool + - List + - Map +2. 目前只支持基本类型或者简单的嵌套对象(内部也是基本类型),不支持自定义函数(Function) +3. 当需要通知状态更新时需要手动调用`notify`/`notifyListeners` +4. 暂时不支持定义在`bean`结尾的包中 + +### 2. 在布局中取值需使用语法糖 + +由于 `fair` 的布局动态化特性,在构建布局时不支持随意编写取值代码,这里需要借助 [SugarProvider]() 中的一系列语法糖来完成 + 语法糖提供了基本类型和数组的取值api,具体使用细节可以参考example中的 [基本使用示例]() ```dart ///一个读取字符串的例子 From 94b18c2904ca90a55de8f324b13f09fbd4447e0d Mon Sep 17 00:00:00 2001 From: yangjiayi Date: Fri, 10 Nov 2023 14:34:21 +0800 Subject: [PATCH 11/11] [feature] improve readme --- fair_provider/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fair_provider/README.md b/fair_provider/README.md index fec0a758..2d119977 100644 --- a/fair_provider/README.md +++ b/fair_provider/README.md @@ -113,13 +113,12 @@ class ExampleInnerModel { } ``` -1. 支持的类型为基本类型和数组、字典 +1. 支持的类型为基本类型和数组 - int - double - String - bool - List - - Map 2. 目前只支持基本类型或者简单的嵌套对象(内部也是基本类型),不支持自定义函数(Function) 3. 当需要通知状态更新时需要手动调用`notify`/`notifyListeners` 4. 暂时不支持定义在`bean`结尾的包中