diff --git a/examples/mirai_gallery/.metadata b/examples/mirai_gallery/.metadata index 8e89d4de..aa7708c2 100644 --- a/examples/mirai_gallery/.metadata +++ b/examples/mirai_gallery/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: 9944297138845a94256f1cf37beb88ff9a8e811a + revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 channel: stable project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: android - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: ios - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: linux - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 + base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 - platform: macos - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: web - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: windows - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 + base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 # User provided section diff --git a/examples/mirai_gallery/android/app/build.gradle b/examples/mirai_gallery/android/app/build.gradle index 7023f473..4d15d9c2 100644 --- a/examples/mirai_gallery/android/app/build.gradle +++ b/examples/mirai_gallery/android/app/build.gradle @@ -47,7 +47,7 @@ android { applicationId "com.securrency.mirai_gallery" // 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 + minSdkVersion 18 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/examples/mirai_gallery/android/build.gradle b/examples/mirai_gallery/android/build.gradle index 58a8c74b..713d7f6e 100644 --- a/examples/mirai_gallery/android/build.gradle +++ b/examples/mirai_gallery/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 4b1e8d6f..4656ad3b 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -222,6 +222,38 @@ } } }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "storage" + }, + "title": { + "type": "text", + "data": "Mirai Storage", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "This is an example of how mirai-storage works.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "navigationType": "screen", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/storage_example.json" + } + } + }, { "type": "listTile", "leading": { diff --git a/examples/mirai_gallery/assets/json/storage_example.json b/examples/mirai_gallery/assets/json/storage_example.json new file mode 100644 index 00000000..65b47549 --- /dev/null +++ b/examples/mirai_gallery/assets/json/storage_example.json @@ -0,0 +1,121 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Storage" + } + }, + "body": { + "type": "column", + "crossAxisAlignment": "center", + "children": [ + { + "type": "sizedBox", + "height": 24 + }, + { + "type": "row", + "mainAxisAlignment": "center", + "crossAxisAlignment": "center", + "children": [ + { + "type": "outlinedButton", + "child": { + "type": "text", + "data": "write 'name:jack'" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + }, + "onPressed": { + "actionType": "storage", + "storage": { + "type": "write", + "key": "name", + "value": "jack" + } + } + }, + { + "type": "sizedBox", + "width": 12 + } + ] + }, + { + "type": "sizedBox", + "height": 24 + }, + { + "type": "center", + "child": { + "type": "outlinedButton", + "child": { + "type": "text", + "data": "Delete 'name:'" + }, + "style": { + "padding": { + "top": 8, + "left": 12, + "right": 12, + "bottom": 8 + } + }, + "onPressed": { + "actionType": "storage", + "storage": { + "type": "delete", + "key": "name" + } + } + } + }, + { + "type": "sizedBox", + "height": 24 + }, + { + "type": "padding", + "padding": { + "left": 0, + "right": 0 + }, + "child": { + "type": "storageWidget", + "storageKeys": [ + "name" + ], + "body": { + "type": "column", + "children": [ + { + "type": "text", + "data": "writed Value for key:name", + "align": "center", + "style": { + "fontSize": 16 + } + }, + { + "type": "text", + "data": "$name", + "align": "center", + "style": { + "fontSize": 16 + } + } + ] + } + } + } + ] + } +} \ No newline at end of file diff --git a/examples/mirai_gallery/ios/Flutter/Debug.xcconfig b/examples/mirai_gallery/ios/Flutter/Debug.xcconfig index 592ceee8..ec97fc6f 100644 --- a/examples/mirai_gallery/ios/Flutter/Debug.xcconfig +++ b/examples/mirai_gallery/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/examples/mirai_gallery/ios/Flutter/Release.xcconfig b/examples/mirai_gallery/ios/Flutter/Release.xcconfig index 592ceee8..c4855bfe 100644 --- a/examples/mirai_gallery/ios/Flutter/Release.xcconfig +++ b/examples/mirai_gallery/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/examples/mirai_gallery/ios/Podfile b/examples/mirai_gallery/ios/Podfile new file mode 100644 index 00000000..fdcc671e --- /dev/null +++ b/examples/mirai_gallery/ios/Podfile @@ -0,0 +1,44 @@ +# 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__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/examples/mirai_gallery/ios/Podfile.lock b/examples/mirai_gallery/ios/Podfile.lock new file mode 100644 index 00000000..5bc406fa --- /dev/null +++ b/examples/mirai_gallery/ios/Podfile.lock @@ -0,0 +1,22 @@ +PODS: + - Flutter (1.0.0) + - flutter_secure_storage (6.0.0): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + flutter_secure_storage: + :path: ".symlinks/plugins/flutter_secure_storage/ios" + +SPEC CHECKSUMS: + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be + +PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 + +COCOAPODS: 1.11.3 diff --git a/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj b/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj index cd191099..e930aa11 100644 --- a/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj @@ -7,14 +7,27 @@ objects = { /* Begin PBXBuildFile section */ + 0AC200E3D9A6E837BF261111 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CAC72D3F7EC2CB580260DD50 /* Pods_Runner.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 82FFDE8DF67841BB9123A298 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C31BC5F334ADD3A7B12820F /* Pods_RunnerTests.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 PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 9705A1C41CF9048500538489 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; @@ -29,12 +42,19 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 04B430FC3C2F46C6322B6E0F /* 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 = ""; }; + 0C31BC5F334ADD3A7B12820F /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 349F2AE5FC7038DC6B0FBFB8 /* 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 = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 6842C6AB2C9B85D269FDB424 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7F1992C875CD8149698EA033 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.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; }; @@ -42,19 +62,53 @@ 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 = ""; }; + 9FF9EE628CDC6C16A100E921 /* 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 = ""; }; + A6C01CF6846F850EEA069CC0 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + CAC72D3F7EC2CB580260DD50 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 02CC609FF5FAB08698207333 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 82FFDE8DF67841BB9123A298 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 0AC200E3D9A6E837BF261111 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 8E55ED1748E0776D9FFCAD2D /* Pods */ = { + isa = PBXGroup; + children = ( + 9FF9EE628CDC6C16A100E921 /* Pods-Runner.debug.xcconfig */, + 349F2AE5FC7038DC6B0FBFB8 /* Pods-Runner.release.xcconfig */, + 04B430FC3C2F46C6322B6E0F /* Pods-Runner.profile.xcconfig */, + 7F1992C875CD8149698EA033 /* Pods-RunnerTests.debug.xcconfig */, + A6C01CF6846F850EEA069CC0 /* Pods-RunnerTests.release.xcconfig */, + 6842C6AB2C9B85D269FDB424 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +126,9 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + 8E55ED1748E0776D9FFCAD2D /* Pods */, + B7C7632E01398D12554AECC0 /* Frameworks */, ); sourceTree = ""; }; @@ -79,6 +136,7 @@ isa = PBXGroup; children = ( 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, ); name = Products; sourceTree = ""; @@ -98,19 +156,49 @@ path = Runner; sourceTree = ""; }; + B7C7632E01398D12554AECC0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + CAC72D3F7EC2CB580260DD50 /* Pods_Runner.framework */, + 0C31BC5F334ADD3A7B12820F /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 0AB749F5C175B5D414F63C20 /* [CP] Check Pods Manifest.lock */, + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + 02CC609FF5FAB08698207333 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 97C146ED1CF9000F007C117D /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 475869589363272EDFC79B32 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + FC228F8085F4EE919949D3DE /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -130,6 +218,10 @@ LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; LastSwiftMigration = 1100; @@ -150,11 +242,19 @@ projectRoot = ""; targets = ( 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EC1CF9000F007C117D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -169,6 +269,28 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 0AB749F5C175B5D414F63C20 /* [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-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -176,6 +298,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -184,6 +307,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 475869589363272EDFC79B32 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -199,9 +344,34 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + FC228F8085F4EE919949D3DE /* [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 */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -213,6 +383,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 97C146FA1CF9000F007C117D /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -305,6 +483,56 @@ }; name = Profile; }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7F1992C875CD8149698EA033 /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A6C01CF6846F850EEA069CC0 /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 6842C6AB2C9B85D269FDB424 /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -460,6 +688,16 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/examples/mirai_gallery/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/mirai_gallery/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..e42adcb3 100644 --- a/examples/mirai_gallery/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/examples/mirai_gallery/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -37,6 +37,17 @@ + + + + + + diff --git a/examples/mirai_gallery/ios/RunnerTests/RunnerTests.swift b/examples/mirai_gallery/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..86a7c3b1 --- /dev/null +++ b/examples/mirai_gallery/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/examples/mirai_gallery/linux/flutter/generated_plugin_registrant.cc b/examples/mirai_gallery/linux/flutter/generated_plugin_registrant.cc index e71a16d2..d0e7f797 100644 --- a/examples/mirai_gallery/linux/flutter/generated_plugin_registrant.cc +++ b/examples/mirai_gallery/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); + flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); } diff --git a/examples/mirai_gallery/linux/flutter/generated_plugins.cmake b/examples/mirai_gallery/linux/flutter/generated_plugins.cmake index 2e1de87a..b29e9ba0 100644 --- a/examples/mirai_gallery/linux/flutter/generated_plugins.cmake +++ b/examples/mirai_gallery/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + flutter_secure_storage_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/examples/mirai_gallery/macos/Flutter/Flutter-Debug.xcconfig b/examples/mirai_gallery/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b6..4b81f9b2 100644 --- a/examples/mirai_gallery/macos/Flutter/Flutter-Debug.xcconfig +++ b/examples/mirai_gallery/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/mirai_gallery/macos/Flutter/Flutter-Release.xcconfig b/examples/mirai_gallery/macos/Flutter/Flutter-Release.xcconfig index c2efd0b6..5caa9d15 100644 --- a/examples/mirai_gallery/macos/Flutter/Flutter-Release.xcconfig +++ b/examples/mirai_gallery/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/mirai_gallery/macos/Flutter/GeneratedPluginRegistrant.swift b/examples/mirai_gallery/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817a..e84ed5a8 100644 --- a/examples/mirai_gallery/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/examples/mirai_gallery/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import flutter_secure_storage_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) } diff --git a/examples/mirai_gallery/macos/Podfile b/examples/mirai_gallery/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/examples/mirai_gallery/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# 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', 'ephemeral', '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 Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/examples/mirai_gallery/macos/Podfile.lock b/examples/mirai_gallery/macos/Podfile.lock new file mode 100644 index 00000000..b3975a0a --- /dev/null +++ b/examples/mirai_gallery/macos/Podfile.lock @@ -0,0 +1,22 @@ +PODS: + - flutter_secure_storage_macos (6.1.1): + - FlutterMacOS + - FlutterMacOS (1.0.0) + +DEPENDENCIES: + - flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) + +EXTERNAL SOURCES: + flutter_secure_storage_macos: + :path: Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos + FlutterMacOS: + :path: Flutter/ephemeral + +SPEC CHECKSUMS: + flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + +PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 + +COCOAPODS: 1.11.3 diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj index 1d482d16..c4a9cba5 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/project.pbxproj @@ -21,14 +21,24 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1FC5B7A51BEA67DC6D5EC67E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1CF028CB1E7AE80B1640D42 /* Pods_Runner.framework */; }; + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 4F7C1D16C1696235BDC4B1E4 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59A0F998F3B4543CE940CA1F /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 33CC10E52044A3C60003C045 /* Project object */; @@ -52,9 +62,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* mirai_gallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "mirai_gallery.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* mirai_gallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = mirai_gallery.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -66,21 +78,59 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 3B4CA55DA5662996390DD26A /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + 4A5BB40478A2A47218FE6B08 /* 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 = ""; }; + 59A0F998F3B4543CE940CA1F /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 86EB574C77B92AECABABE9AA /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + AE1CF15A80FC85EFAF30AC8B /* 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 = ""; }; + CE7B4EA68469A773314786BE /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + D1CF028CB1E7AE80B1640D42 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D93EAD0FB1FFEFF0AD496FA7 /* 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4F7C1D16C1696235BDC4B1E4 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 33CC10EA2044A3C60003C045 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1FC5B7A51BEA67DC6D5EC67E /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2F053A177A0637B9D077928B /* Pods */ = { + isa = PBXGroup; + children = ( + AE1CF15A80FC85EFAF30AC8B /* Pods-Runner.debug.xcconfig */, + 4A5BB40478A2A47218FE6B08 /* Pods-Runner.release.xcconfig */, + D93EAD0FB1FFEFF0AD496FA7 /* Pods-Runner.profile.xcconfig */, + 3B4CA55DA5662996390DD26A /* Pods-RunnerTests.debug.xcconfig */, + CE7B4EA68469A773314786BE /* Pods-RunnerTests.release.xcconfig */, + 86EB574C77B92AECABABE9AA /* Pods-RunnerTests.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; 33BA886A226E78AF003329D5 /* Configs */ = { isa = PBXGroup; children = ( @@ -97,8 +147,10 @@ children = ( 33FAB671232836740065AC1E /* Runner */, 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + 2F053A177A0637B9D077928B /* Pods */, ); sourceTree = ""; }; @@ -106,6 +158,7 @@ isa = PBXGroup; children = ( 33CC10ED2044A3C60003C045 /* mirai_gallery.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, ); name = Products; sourceTree = ""; @@ -148,6 +201,8 @@ D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + D1CF028CB1E7AE80B1640D42 /* Pods_Runner.framework */, + 59A0F998F3B4543CE940CA1F /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -155,15 +210,36 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 5E53DA8FF9D2C438B8F0C040 /* [CP] Check Pods Manifest.lock */, + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 33CC10EC2044A3C60003C045 /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 3697D2453B11CCBD9293B91F /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + 1F8FEDC50CCFDB2BC9BA4AB6 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -185,6 +261,10 @@ LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; 33CC10EC2044A3C60003C045 = { CreatedOnToolsVersion = 9.2; LastSwiftMigration = 1100; @@ -215,12 +295,20 @@ projectRoot = ""; targets = ( 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, 33CC111A2044C6BA0003C045 /* Flutter Assemble */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 33CC10EB2044A3C60003C045 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -233,6 +321,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1F8FEDC50CCFDB2BC9BA4AB6 /* [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; + }; 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -271,9 +376,61 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 3697D2453B11CCBD9293B91F /* [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; + }; + 5E53DA8FF9D2C438B8F0C040 /* [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-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 33CC10E92044A3C60003C045 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -287,6 +444,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; @@ -307,6 +469,51 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3B4CA55DA5662996390DD26A /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mirai_gallery.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mirai_gallery"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CE7B4EA68469A773314786BE /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mirai_gallery.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mirai_gallery"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 86EB574C77B92AECABABE9AA /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.securrency.miraiGallery.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mirai_gallery.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mirai_gallery"; + }; + name = Profile; + }; 338D0CE9231458BD00FA5F75 /* Profile */ = { isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; @@ -360,8 +567,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = D9Q5W3R5X6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -486,8 +695,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = D9Q5W3R5X6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -506,8 +717,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = D9Q5W3R5X6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -537,6 +750,16 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a91620c2..8cb497cd 100644 --- a/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/examples/mirai_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -37,6 +37,17 @@ + + + + + + diff --git a/examples/mirai_gallery/macos/Runner/DebugProfile.entitlements b/examples/mirai_gallery/macos/Runner/DebugProfile.entitlements index dddb8a30..b231432b 100644 --- a/examples/mirai_gallery/macos/Runner/DebugProfile.entitlements +++ b/examples/mirai_gallery/macos/Runner/DebugProfile.entitlements @@ -8,5 +8,7 @@ com.apple.security.network.server + keychain-access-groups + diff --git a/examples/mirai_gallery/macos/Runner/MainFlutterWindow.swift b/examples/mirai_gallery/macos/Runner/MainFlutterWindow.swift index 2722837e..3cc05eb2 100644 --- a/examples/mirai_gallery/macos/Runner/MainFlutterWindow.swift +++ b/examples/mirai_gallery/macos/Runner/MainFlutterWindow.swift @@ -3,7 +3,7 @@ import FlutterMacOS class MainFlutterWindow: NSWindow { override func awakeFromNib() { - let flutterViewController = FlutterViewController.init() + let flutterViewController = FlutterViewController() let windowFrame = self.frame self.contentViewController = flutterViewController self.setFrame(windowFrame, display: true) diff --git a/examples/mirai_gallery/macos/Runner/Release.entitlements b/examples/mirai_gallery/macos/Runner/Release.entitlements index 852fa1a4..0833c1b4 100644 --- a/examples/mirai_gallery/macos/Runner/Release.entitlements +++ b/examples/mirai_gallery/macos/Runner/Release.entitlements @@ -4,5 +4,7 @@ com.apple.security.app-sandbox + keychain-access-groups + diff --git a/examples/mirai_gallery/macos/RunnerTests/RunnerTests.swift b/examples/mirai_gallery/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..5418c9f5 --- /dev/null +++ b/examples/mirai_gallery/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/examples/mirai_gallery/pubspec.lock b/examples/mirai_gallery/pubspec.lock index 640a8e0a..aa72fcf3 100644 --- a/examples/mirai_gallery/pubspec.lock +++ b/examples/mirai_gallery/pubspec.lock @@ -238,11 +238,64 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + flutter_secure_storage: + dependency: transitive + description: + name: flutter_secure_storage + sha256: "98352186ee7ad3639ccc77ad7924b773ff6883076ab952437d20f18a61f0a7c5" + url: "https://pub.dev" + source: hosted + version: "8.0.0" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: "0912ae29a572230ad52d8a4697e5518d7f0f429052fd51df7e5a7952c7efe2a3" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "083add01847fc1c80a07a08e1ed6927e9acd9618a35e330239d4422cd2a58c50" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: b3773190e385a3c8a382007893d678ae95462b3c2279e987b55d140d3b0cb81b + url: "https://pub.dev" + source: hosted + version: "1.0.1" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: "42938e70d4b872e856e678c423cc0e9065d7d294f45bc41fc1981a4eb4beaffe" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: fc2910ec9b28d60598216c29ea763b3a96c401f0ce1d13cdf69ccb0e5c93c3ee + url: "https://pub.dev" + source: hosted + version: "2.0.0" 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" freezed: dependency: "direct dev" description: @@ -418,6 +471,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" + source: hosted + version: "2.1.4" pool: dependency: transitive description: @@ -593,4 +654,4 @@ packages: version: "3.1.1" sdks: dart: ">=3.0.0 <4.0.0" - flutter: ">=1.17.0" + flutter: ">=2.0.0" diff --git a/examples/mirai_gallery/windows/flutter/generated_plugin_registrant.cc b/examples/mirai_gallery/windows/flutter/generated_plugin_registrant.cc index 8b6d4680..0c507538 100644 --- a/examples/mirai_gallery/windows/flutter/generated_plugin_registrant.cc +++ b/examples/mirai_gallery/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FlutterSecureStorageWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); } diff --git a/examples/mirai_gallery/windows/flutter/generated_plugins.cmake b/examples/mirai_gallery/windows/flutter/generated_plugins.cmake index b93c4c30..4fc759c4 100644 --- a/examples/mirai_gallery/windows/flutter/generated_plugins.cmake +++ b/examples/mirai_gallery/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + flutter_secure_storage_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/packages/mirai/lib/src/action/mirai_action.dart b/packages/mirai/lib/src/action/mirai_action.dart index 650d89e5..fb81807b 100644 --- a/packages/mirai/lib/src/action/mirai_action.dart +++ b/packages/mirai/lib/src/action/mirai_action.dart @@ -1,11 +1,12 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:mirai/src/navigation/mirai_navigator.dart'; import 'package:mirai/src/network/mirai_request.dart'; +import 'package:mirai/src/storage/mirai_storage.dart'; part 'mirai_action.freezed.dart'; part 'mirai_action.g.dart'; -enum ActionType { navigate, request, none } +enum ActionType { navigate, request, storage, none } @freezed class MiraiAction with _$MiraiAction { @@ -16,6 +17,7 @@ class MiraiAction with _$MiraiAction { String? assetPath, NavigationType? navigationType, NavigationStyle? navigationStyle, + MiraiStorage? storage, }) = _MiraiAction; factory MiraiAction.fromJson(Map json) => diff --git a/packages/mirai/lib/src/action/mirai_action.freezed.dart b/packages/mirai/lib/src/action/mirai_action.freezed.dart index e657f5ed..0060236c 100644 --- a/packages/mirai/lib/src/action/mirai_action.freezed.dart +++ b/packages/mirai/lib/src/action/mirai_action.freezed.dart @@ -26,6 +26,7 @@ mixin _$MiraiAction { String? get assetPath => throw _privateConstructorUsedError; NavigationType? get navigationType => throw _privateConstructorUsedError; NavigationStyle? get navigationStyle => throw _privateConstructorUsedError; + MiraiStorage? get storage => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -45,9 +46,11 @@ abstract class $MiraiActionCopyWith<$Res> { Map? widgetJson, String? assetPath, NavigationType? navigationType, - NavigationStyle? navigationStyle}); + NavigationStyle? navigationStyle, + MiraiStorage? storage}); $MiraiRequestCopyWith<$Res>? get request; + $MiraiStorageCopyWith<$Res>? get storage; } /// @nodoc @@ -69,6 +72,7 @@ class _$MiraiActionCopyWithImpl<$Res, $Val extends MiraiAction> Object? assetPath = freezed, Object? navigationType = freezed, Object? navigationStyle = freezed, + Object? storage = freezed, }) { return _then(_value.copyWith( actionType: null == actionType @@ -95,6 +99,10 @@ class _$MiraiActionCopyWithImpl<$Res, $Val extends MiraiAction> ? _value.navigationStyle : navigationStyle // ignore: cast_nullable_to_non_nullable as NavigationStyle?, + storage: freezed == storage + ? _value.storage + : storage // ignore: cast_nullable_to_non_nullable + as MiraiStorage?, ) as $Val); } @@ -109,6 +117,18 @@ class _$MiraiActionCopyWithImpl<$Res, $Val extends MiraiAction> return _then(_value.copyWith(request: value) as $Val); }); } + + @override + @pragma('vm:prefer-inline') + $MiraiStorageCopyWith<$Res>? get storage { + if (_value.storage == null) { + return null; + } + + return $MiraiStorageCopyWith<$Res>(_value.storage!, (value) { + return _then(_value.copyWith(storage: value) as $Val); + }); + } } /// @nodoc @@ -125,10 +145,13 @@ abstract class _$$_MiraiActionCopyWith<$Res> Map? widgetJson, String? assetPath, NavigationType? navigationType, - NavigationStyle? navigationStyle}); + NavigationStyle? navigationStyle, + MiraiStorage? storage}); @override $MiraiRequestCopyWith<$Res>? get request; + @override + $MiraiStorageCopyWith<$Res>? get storage; } /// @nodoc @@ -148,6 +171,7 @@ class __$$_MiraiActionCopyWithImpl<$Res> Object? assetPath = freezed, Object? navigationType = freezed, Object? navigationStyle = freezed, + Object? storage = freezed, }) { return _then(_$_MiraiAction( actionType: null == actionType @@ -174,6 +198,10 @@ class __$$_MiraiActionCopyWithImpl<$Res> ? _value.navigationStyle : navigationStyle // ignore: cast_nullable_to_non_nullable as NavigationStyle?, + storage: freezed == storage + ? _value.storage + : storage // ignore: cast_nullable_to_non_nullable + as MiraiStorage?, )); } } @@ -187,7 +215,8 @@ class _$_MiraiAction implements _MiraiAction { final Map? widgetJson, this.assetPath, this.navigationType, - this.navigationStyle}) + this.navigationStyle, + this.storage}) : _widgetJson = widgetJson; factory _$_MiraiAction.fromJson(Map json) => @@ -214,10 +243,12 @@ class _$_MiraiAction implements _MiraiAction { final NavigationType? navigationType; @override final NavigationStyle? navigationStyle; + @override + final MiraiStorage? storage; @override String toString() { - return 'MiraiAction(actionType: $actionType, request: $request, widgetJson: $widgetJson, assetPath: $assetPath, navigationType: $navigationType, navigationStyle: $navigationStyle)'; + return 'MiraiAction(actionType: $actionType, request: $request, widgetJson: $widgetJson, assetPath: $assetPath, navigationType: $navigationType, navigationStyle: $navigationStyle, storage: $storage)'; } @override @@ -235,7 +266,8 @@ class _$_MiraiAction implements _MiraiAction { (identical(other.navigationType, navigationType) || other.navigationType == navigationType) && (identical(other.navigationStyle, navigationStyle) || - other.navigationStyle == navigationStyle)); + other.navigationStyle == navigationStyle) && + (identical(other.storage, storage) || other.storage == storage)); } @JsonKey(ignore: true) @@ -247,7 +279,8 @@ class _$_MiraiAction implements _MiraiAction { const DeepCollectionEquality().hash(_widgetJson), assetPath, navigationType, - navigationStyle); + navigationStyle, + storage); @JsonKey(ignore: true) @override @@ -270,7 +303,8 @@ abstract class _MiraiAction implements MiraiAction { final Map? widgetJson, final String? assetPath, final NavigationType? navigationType, - final NavigationStyle? navigationStyle}) = _$_MiraiAction; + final NavigationStyle? navigationStyle, + final MiraiStorage? storage}) = _$_MiraiAction; factory _MiraiAction.fromJson(Map json) = _$_MiraiAction.fromJson; @@ -288,6 +322,8 @@ abstract class _MiraiAction implements MiraiAction { @override NavigationStyle? get navigationStyle; @override + MiraiStorage? get storage; + @override @JsonKey(ignore: true) _$$_MiraiActionCopyWith<_$_MiraiAction> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/mirai/lib/src/action/mirai_action.g.dart b/packages/mirai/lib/src/action/mirai_action.g.dart index 56171bdb..d683de73 100644 --- a/packages/mirai/lib/src/action/mirai_action.g.dart +++ b/packages/mirai/lib/src/action/mirai_action.g.dart @@ -20,6 +20,9 @@ _$_MiraiAction _$$_MiraiActionFromJson(Map json) => $enumDecodeNullable(_$NavigationTypeEnumMap, json['navigationType']), navigationStyle: $enumDecodeNullable( _$NavigationStyleEnumMap, json['navigationStyle']), + storage: json['storage'] == null + ? null + : MiraiStorage.fromJson(json['storage'] as Map), ); Map _$$_MiraiActionToJson(_$_MiraiAction instance) => @@ -30,11 +33,13 @@ Map _$$_MiraiActionToJson(_$_MiraiAction instance) => 'assetPath': instance.assetPath, 'navigationType': _$NavigationTypeEnumMap[instance.navigationType], 'navigationStyle': _$NavigationStyleEnumMap[instance.navigationStyle], + 'storage': instance.storage, }; const _$ActionTypeEnumMap = { ActionType.navigate: 'navigate', ActionType.request: 'request', + ActionType.storage: 'storage', ActionType.none: 'none', }; diff --git a/packages/mirai/lib/src/action/mirai_action_parser.dart b/packages/mirai/lib/src/action/mirai_action_parser.dart index e2b5cf43..78b3c09c 100644 --- a/packages/mirai/lib/src/action/mirai_action_parser.dart +++ b/packages/mirai/lib/src/action/mirai_action_parser.dart @@ -3,6 +3,8 @@ import 'package:mirai/src/action/mirai_action.dart'; import 'package:mirai/src/framework/framework.dart'; import 'package:mirai/src/navigation/mirai_navigator.dart'; import 'package:mirai/src/network/mirai_network.dart'; +import 'package:mirai/src/storage/mirai_storage.dart'; +import 'package:mirai/src/storage/storage_manager.dart'; extension MiraiActionParser on MiraiAction? { Future? onCall(BuildContext context) async { @@ -10,6 +12,7 @@ extension MiraiActionParser on MiraiAction? { if (this?.navigationStyle == NavigationStyle.pop) { MiraiNavigator.navigateBack(context); } + switch (this?.actionType ?? ActionType.none) { case ActionType.navigate: Widget? widget; @@ -50,6 +53,17 @@ extension MiraiActionParser on MiraiAction? { case ActionType.request: return MiraiNetwork.request(this!.request!); + + case ActionType.storage: + switch (this?.storage?.type ?? MiraiStorageType.write) { + case MiraiStorageType.write: + return StorageManager.write( + this?.storage?.key ?? "", this?.storage?.value ?? ""); + + case MiraiStorageType.delete: + return StorageManager.delete(this?.storage?.key ?? ""); + } + case ActionType.none: break; } diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index faf024ba..3689616e 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -3,14 +3,17 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:mirai/src/framework/mirai_parser.dart'; import 'package:mirai/src/framework/mirai_registry.dart'; import 'package:mirai/src/network/mirai_network.dart'; import 'package:mirai/src/network/mirai_request.dart'; import 'package:mirai/src/parsers/mirai_center/mirai_center_parser.dart'; import 'package:mirai/src/parsers/mirai_fractionally_sized_box/mirai_fractionally_sized_box_parser.dart'; +import 'package:mirai/src/parsers/mirai_storage_widget/mirai_storage_widget.dart'; import 'package:mirai/src/parsers/mirai_tab/mirai_tab_parser.dart'; import 'package:mirai/src/parsers/parsers.dart'; +import 'package:mirai/src/storage/storage_manager.dart'; import 'package:mirai/src/utils/log.dart'; typedef ErrorWidgetBuilder = Widget Function( @@ -53,6 +56,7 @@ class Mirai { const MiraiScrollViewParser(), const MiraiAlertDialogParser(), const MiraiTabParser(), + const MiraiStorageWidgetParser(), ]; static Future initialize({ @@ -62,6 +66,7 @@ class Mirai { _parsers.addAll(parsers); MiraiRegistry.instance.registerAll(_parsers); MiraiNetwork.initialize(dio ?? Dio()); + StorageManager.initialize(const FlutterSecureStorage()); } static Widget? fromJson(Map? json, BuildContext context) { diff --git a/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.dart b/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.dart index 89badf68..0241ea24 100644 --- a/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.dart +++ b/packages/mirai/lib/src/parsers/mirai_alert_dialog/mirai_alert_dialog.dart @@ -31,11 +31,9 @@ class MiraiAlertDialog with _$MiraiAlertDialog { double? elevation, String? semanticLabel, @Default(MiraiEdgeInsets(left: 40, right: 40, top: 24, bottom: 24)) - MiraiEdgeInsets insetPadding, - @Default(Clip.none) - Clip clipBehavior, - @Default(false) - bool scrollable, + MiraiEdgeInsets insetPadding, + @Default(Clip.none) Clip clipBehavior, + @Default(false) bool scrollable, }) = _MiraiAlertDialog; factory MiraiAlertDialog.fromJson(Map json) => diff --git a/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.dart b/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.dart index 765f1419..7308e723 100644 --- a/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.dart +++ b/packages/mirai/lib/src/parsers/mirai_floating_action_button/mirai_floating_action_button.dart @@ -14,9 +14,8 @@ class MiraiFloatingActionButton with _$MiraiFloatingActionButton { MiraiAction? onPressed, MiraiTextStyle? textStyle, @Default(FloatingActionButtonType.small) - FloatingActionButtonType buttonType, - @Default(false) - bool autofocus, + FloatingActionButtonType buttonType, + @Default(false) bool autofocus, Map? icon, String? backgroundColor, String? foregroundColor, diff --git a/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.dart b/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.dart index d1003c0d..24ac9196 100644 --- a/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.dart +++ b/packages/mirai/lib/src/parsers/mirai_list_view/mirai_list_view.dart @@ -12,33 +12,24 @@ part 'mirai_list_view.g.dart'; @freezed class MiraiListView with _$MiraiListView { const factory MiraiListView({ - @Default(Axis.vertical) - Axis scrollDirection, - @Default(false) - bool reverse, + @Default(Axis.vertical) Axis scrollDirection, + @Default(false) bool reverse, bool? primary, MiraiScrollPhysics? physics, - @Default(false) - bool shrinkWrap, + @Default(false) bool shrinkWrap, MiraiEdgeInsets? padding, - @Default(true) - bool addAutomaticKeepAlives, - @Default(true) - bool addRepaintBoundaries, - @Default(true) - bool addSemanticIndexes, + @Default(true) bool addAutomaticKeepAlives, + @Default(true) bool addRepaintBoundaries, + @Default(true) bool addSemanticIndexes, double? cacheExtent, - @Default([]) - List> children, + @Default([]) List> children, Map? separator, int? semanticChildCount, - @Default(DragStartBehavior.start) - DragStartBehavior dragStartBehavior, + @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, @Default(ScrollViewKeyboardDismissBehavior.manual) - ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, String? restorationId, - @Default(Clip.hardEdge) - Clip clipBehavior, + @Default(Clip.hardEdge) Clip clipBehavior, }) = _MiraiListView; factory MiraiListView.fromJson(Map json) => diff --git a/packages/mirai/lib/src/parsers/mirai_scroll_view/mirai_scroll_view.dart b/packages/mirai/lib/src/parsers/mirai_scroll_view/mirai_scroll_view.dart index f4ab5a71..ca60a19f 100644 --- a/packages/mirai/lib/src/parsers/mirai_scroll_view/mirai_scroll_view.dart +++ b/packages/mirai/lib/src/parsers/mirai_scroll_view/mirai_scroll_view.dart @@ -12,21 +12,17 @@ part 'mirai_scroll_view.g.dart'; @freezed class MiraiScrollView with _$MiraiScrollView { const factory MiraiScrollView({ - @Default(Axis.vertical) - Axis scrollDirection, - @Default(false) - bool reverse, + @Default(Axis.vertical) Axis scrollDirection, + @Default(false) bool reverse, MiraiEdgeInsets? padding, bool? primary, MiraiScrollPhysics? physics, Map? child, - @Default(DragStartBehavior.start) - DragStartBehavior dragStartBehavior, - @Default(Clip.hardEdge) - Clip clipBehavior, + @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, + @Default(Clip.hardEdge) Clip clipBehavior, String? restorationId, @Default(ScrollViewKeyboardDismissBehavior.manual) - ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, }) = _MiraiScrollView; factory MiraiScrollView.fromJson(Map json) => diff --git a/packages/mirai/lib/src/parsers/mirai_stack/mirai_stack.dart b/packages/mirai/lib/src/parsers/mirai_stack/mirai_stack.dart index 4ab62c2d..2a495fa0 100644 --- a/packages/mirai/lib/src/parsers/mirai_stack/mirai_stack.dart +++ b/packages/mirai/lib/src/parsers/mirai_stack/mirai_stack.dart @@ -11,14 +11,11 @@ part 'mirai_stack.g.dart'; class MiraiStack with _$MiraiStack { const factory MiraiStack({ @Default(MiraiAlignmentDirectional.topStart) - MiraiAlignmentDirectional alignment, - @Default(Clip.hardEdge) - Clip clipBehavior, - @Default(StackFit.loose) - StackFit fit, + MiraiAlignmentDirectional alignment, + @Default(Clip.hardEdge) Clip clipBehavior, + @Default(StackFit.loose) StackFit fit, TextDirection? textDirection, - @Default([]) - List> children, + @Default([]) List> children, }) = _MiraiStack; factory MiraiStack.fromJson(Map json) => diff --git a/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.dart b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.dart new file mode 100644 index 00000000..403f4bf1 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.dart @@ -0,0 +1,17 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'package:mirai/src/parsers/mirai_storage_widget/mirai_storage_widget_parser.dart'; + +part 'mirai_storage_widget.freezed.dart'; +part 'mirai_storage_widget.g.dart'; + +@freezed +class MiraiStorageWidget with _$MiraiStorageWidget { + const factory MiraiStorageWidget({ + required Map body, + @Default([]) List storageKeys, + }) = _MiraiStorageWidget; + + factory MiraiStorageWidget.fromJson(Map json) => + _$MiraiStorageWidgetFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.freezed.dart b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.freezed.dart new file mode 100644 index 00000000..b0d7247a --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.freezed.dart @@ -0,0 +1,190 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_storage_widget.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +MiraiStorageWidget _$MiraiStorageWidgetFromJson(Map json) { + return _MiraiStorageWidget.fromJson(json); +} + +/// @nodoc +mixin _$MiraiStorageWidget { + Map get body => throw _privateConstructorUsedError; + List get storageKeys => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiStorageWidgetCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiStorageWidgetCopyWith<$Res> { + factory $MiraiStorageWidgetCopyWith( + MiraiStorageWidget value, $Res Function(MiraiStorageWidget) then) = + _$MiraiStorageWidgetCopyWithImpl<$Res, MiraiStorageWidget>; + @useResult + $Res call({Map body, List storageKeys}); +} + +/// @nodoc +class _$MiraiStorageWidgetCopyWithImpl<$Res, $Val extends MiraiStorageWidget> + implements $MiraiStorageWidgetCopyWith<$Res> { + _$MiraiStorageWidgetCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? body = null, + Object? storageKeys = null, + }) { + return _then(_value.copyWith( + body: null == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as Map, + storageKeys: null == storageKeys + ? _value.storageKeys + : storageKeys // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_MiraiStorageWidgetCopyWith<$Res> + implements $MiraiStorageWidgetCopyWith<$Res> { + factory _$$_MiraiStorageWidgetCopyWith(_$_MiraiStorageWidget value, + $Res Function(_$_MiraiStorageWidget) then) = + __$$_MiraiStorageWidgetCopyWithImpl<$Res>; + @override + @useResult + $Res call({Map body, List storageKeys}); +} + +/// @nodoc +class __$$_MiraiStorageWidgetCopyWithImpl<$Res> + extends _$MiraiStorageWidgetCopyWithImpl<$Res, _$_MiraiStorageWidget> + implements _$$_MiraiStorageWidgetCopyWith<$Res> { + __$$_MiraiStorageWidgetCopyWithImpl( + _$_MiraiStorageWidget _value, $Res Function(_$_MiraiStorageWidget) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? body = null, + Object? storageKeys = null, + }) { + return _then(_$_MiraiStorageWidget( + body: null == body + ? _value._body + : body // ignore: cast_nullable_to_non_nullable + as Map, + storageKeys: null == storageKeys + ? _value._storageKeys + : storageKeys // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_MiraiStorageWidget implements _MiraiStorageWidget { + const _$_MiraiStorageWidget( + {required final Map body, + final List storageKeys = const []}) + : _body = body, + _storageKeys = storageKeys; + + factory _$_MiraiStorageWidget.fromJson(Map json) => + _$$_MiraiStorageWidgetFromJson(json); + + final Map _body; + @override + Map get body { + if (_body is EqualUnmodifiableMapView) return _body; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_body); + } + + final List _storageKeys; + @override + @JsonKey() + List get storageKeys { + if (_storageKeys is EqualUnmodifiableListView) return _storageKeys; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_storageKeys); + } + + @override + String toString() { + return 'MiraiStorageWidget(body: $body, storageKeys: $storageKeys)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_MiraiStorageWidget && + const DeepCollectionEquality().equals(other._body, _body) && + const DeepCollectionEquality() + .equals(other._storageKeys, _storageKeys)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_body), + const DeepCollectionEquality().hash(_storageKeys)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_MiraiStorageWidgetCopyWith<_$_MiraiStorageWidget> get copyWith => + __$$_MiraiStorageWidgetCopyWithImpl<_$_MiraiStorageWidget>( + this, _$identity); + + @override + Map toJson() { + return _$$_MiraiStorageWidgetToJson( + this, + ); + } +} + +abstract class _MiraiStorageWidget implements MiraiStorageWidget { + const factory _MiraiStorageWidget( + {required final Map body, + final List storageKeys}) = _$_MiraiStorageWidget; + + factory _MiraiStorageWidget.fromJson(Map json) = + _$_MiraiStorageWidget.fromJson; + + @override + Map get body; + @override + List get storageKeys; + @override + @JsonKey(ignore: true) + _$$_MiraiStorageWidgetCopyWith<_$_MiraiStorageWidget> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.g.dart b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.g.dart new file mode 100644 index 00000000..4e3a7a82 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_storage_widget.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_MiraiStorageWidget _$$_MiraiStorageWidgetFromJson( + Map json) => + _$_MiraiStorageWidget( + body: json['body'] as Map, + storageKeys: (json['storageKeys'] as List?) + ?.map((e) => e as String) + .toList() ?? + const [], + ); + +Map _$$_MiraiStorageWidgetToJson( + _$_MiraiStorageWidget instance) => + { + 'body': instance.body, + 'storageKeys': instance.storageKeys, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget_parser.dart b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget_parser.dart new file mode 100644 index 00000000..17f6e74e --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_storage_widget/mirai_storage_widget_parser.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/src/framework/framework.dart'; +import 'package:mirai/src/parsers/mirai_storage_widget/mirai_storage_widget.dart'; +import 'package:mirai/src/storage/storage_manager.dart'; +import 'package:mirai/src/utils/log.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiStorageWidgetParser extends MiraiParser { + const MiraiStorageWidgetParser(); + + @override + MiraiStorageWidget getModel(Map json) => + MiraiStorageWidget.fromJson(json); + + @override + String get type => WidgetType.storageWidget.name; + + @override + Widget parse(BuildContext context, MiraiStorageWidget model) { + return FutureBuilder>( + future: _loadDataFromStorage(model.storageKeys), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + snapshot.data.forEach((key, value) { + _updateBodyJson(model.body, key, value); + }); + + return Mirai.fromJson(model.body, context) ?? const SizedBox(); + } + + return const Center( + child: CircularProgressIndicator(), + ); + }, + ); + } + + Future> _loadDataFromStorage(List keys) async { + final Map data = {}; + + for (String key in keys) { + final value = await StorageManager.read(key) ?? ""; + data[key] = value; + } + + return data; + } + + _updateBodyJson(Map data, String key, dynamic value) { + for (MapEntry mapEntry in data.entries) { + if (_sameKeySymbol(key, "${mapEntry.value}")) { + try { + data.update( + mapEntry.key, + (existingValue) => "$value", + ); + } catch (e) { + Log.e(e); + } + + break; + } + + if (mapEntry.value is Map) { + _updateBodyJson(mapEntry.value, key, value); + } + + if (mapEntry.value is List) { + for (Map listItem in mapEntry.value) { + _updateBodyJson(listItem, key, value); + } + } + } + } + + bool _sameKeySymbol(String value1, String value2) { + if (value1 == value2) { + return true; + } else if (value1.contains("\$") || value2.contains("\$")) { + if (value1.replaceAll(RegExp(r'[^\w\s]+'), '') == + value2.replaceAll(RegExp(r'[^\w\s]+'), '')) { + return true; + } + } + + return false; + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.dart b/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.dart index 2eca1bc7..23cfcd75 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_form_field/mirai_text_form_field.dart @@ -20,51 +20,38 @@ class MiraiTextFormField with _$MiraiTextFormField { String? initialValue, MiraiTextInputType? keyboardType, TextInputAction? textInputAction, - @Default(TextCapitalization.none) - TextCapitalization textCapitalization, + @Default(TextCapitalization.none) TextCapitalization textCapitalization, MiraiTextStyle? style, - @Default(TextAlign.start) - TextAlign textAlign, + @Default(TextAlign.start) TextAlign textAlign, MiraiTextAlignVertical? textAlignVertical, TextDirection? textDirection, - @Default(false) - bool readOnly, + @Default(false) bool readOnly, bool? showCursor, - @Default(false) - bool autofocus, - @Default('•') - String obscuringCharacter, + @Default(false) bool autofocus, + @Default('•') String obscuringCharacter, int? maxLines, int? minLines, int? maxLength, - @Default(false) - bool obscureText, - @Default(true) - bool autocorrect, + @Default(false) bool obscureText, + @Default(true) bool autocorrect, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, MaxLengthEnforcement? maxLengthEnforcement, - @Default(false) - bool expands, + @Default(false) bool expands, Brightness? keyboardAppearance, @Default(MiraiEdgeInsets(bottom: 20, top: 20, left: 20, right: 20)) - MiraiEdgeInsets scrollPadding, + MiraiEdgeInsets scrollPadding, String? restorationId, - @Default(true) - bool enableIMEPersonalizedLearning, - @Default(true) - bool enableSuggestions, + @Default(true) bool enableIMEPersonalizedLearning, + @Default(true) bool enableSuggestions, bool? enabled, - @Default(2) - double cursorWidth, + @Default(2) double cursorWidth, double? cursorHeight, String? cursorColor, String? hintText, AutovalidateMode? autovalidateMode, - @Default([]) - List inputFormatters, - @Default([]) - List validatorRules, + @Default([]) List inputFormatters, + @Default([]) List validatorRules, }) = _MiraiTextFormField; factory MiraiTextFormField.fromJson(Map json) => diff --git a/packages/mirai/lib/src/storage/mirai_storage.dart b/packages/mirai/lib/src/storage/mirai_storage.dart new file mode 100644 index 00000000..7c5cd3a3 --- /dev/null +++ b/packages/mirai/lib/src/storage/mirai_storage.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'mirai_storage.freezed.dart'; +part 'mirai_storage.g.dart'; + +enum MiraiStorageType { write, delete } + +@freezed +class MiraiStorage with _$MiraiStorage { + factory MiraiStorage({ + @Default(MiraiStorageType.write) MiraiStorageType type, + required String key, + String? value, + }) = _MiraiStorage; + + factory MiraiStorage.fromJson(Map json) => + _$MiraiStorageFromJson(json); +} diff --git a/packages/mirai/lib/src/storage/mirai_storage.freezed.dart b/packages/mirai/lib/src/storage/mirai_storage.freezed.dart new file mode 100644 index 00000000..2ee4e507 --- /dev/null +++ b/packages/mirai/lib/src/storage/mirai_storage.freezed.dart @@ -0,0 +1,188 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_storage.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +MiraiStorage _$MiraiStorageFromJson(Map json) { + return _MiraiStorage.fromJson(json); +} + +/// @nodoc +mixin _$MiraiStorage { + MiraiStorageType get type => throw _privateConstructorUsedError; + String get key => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiStorageCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiStorageCopyWith<$Res> { + factory $MiraiStorageCopyWith( + MiraiStorage value, $Res Function(MiraiStorage) then) = + _$MiraiStorageCopyWithImpl<$Res, MiraiStorage>; + @useResult + $Res call({MiraiStorageType type, String key, String? value}); +} + +/// @nodoc +class _$MiraiStorageCopyWithImpl<$Res, $Val extends MiraiStorage> + implements $MiraiStorageCopyWith<$Res> { + _$MiraiStorageCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? key = null, + Object? value = freezed, + }) { + return _then(_value.copyWith( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as MiraiStorageType, + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_MiraiStorageCopyWith<$Res> + implements $MiraiStorageCopyWith<$Res> { + factory _$$_MiraiStorageCopyWith( + _$_MiraiStorage value, $Res Function(_$_MiraiStorage) then) = + __$$_MiraiStorageCopyWithImpl<$Res>; + @override + @useResult + $Res call({MiraiStorageType type, String key, String? value}); +} + +/// @nodoc +class __$$_MiraiStorageCopyWithImpl<$Res> + extends _$MiraiStorageCopyWithImpl<$Res, _$_MiraiStorage> + implements _$$_MiraiStorageCopyWith<$Res> { + __$$_MiraiStorageCopyWithImpl( + _$_MiraiStorage _value, $Res Function(_$_MiraiStorage) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? key = null, + Object? value = freezed, + }) { + return _then(_$_MiraiStorage( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as MiraiStorageType, + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_MiraiStorage implements _MiraiStorage { + _$_MiraiStorage( + {this.type = MiraiStorageType.write, required this.key, this.value}); + + factory _$_MiraiStorage.fromJson(Map json) => + _$$_MiraiStorageFromJson(json); + + @override + @JsonKey() + final MiraiStorageType type; + @override + final String key; + @override + final String? value; + + @override + String toString() { + return 'MiraiStorage(type: $type, key: $key, value: $value)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_MiraiStorage && + (identical(other.type, type) || other.type == type) && + (identical(other.key, key) || other.key == key) && + (identical(other.value, value) || other.value == value)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, type, key, value); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_MiraiStorageCopyWith<_$_MiraiStorage> get copyWith => + __$$_MiraiStorageCopyWithImpl<_$_MiraiStorage>(this, _$identity); + + @override + Map toJson() { + return _$$_MiraiStorageToJson( + this, + ); + } +} + +abstract class _MiraiStorage implements MiraiStorage { + factory _MiraiStorage( + {final MiraiStorageType type, + required final String key, + final String? value}) = _$_MiraiStorage; + + factory _MiraiStorage.fromJson(Map json) = + _$_MiraiStorage.fromJson; + + @override + MiraiStorageType get type; + @override + String get key; + @override + String? get value; + @override + @JsonKey(ignore: true) + _$$_MiraiStorageCopyWith<_$_MiraiStorage> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/storage/mirai_storage.g.dart b/packages/mirai/lib/src/storage/mirai_storage.g.dart new file mode 100644 index 00000000..f37822bd --- /dev/null +++ b/packages/mirai/lib/src/storage/mirai_storage.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_storage.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_MiraiStorage _$$_MiraiStorageFromJson(Map json) => + _$_MiraiStorage( + type: $enumDecodeNullable(_$MiraiStorageTypeEnumMap, json['type']) ?? + MiraiStorageType.write, + key: json['key'] as String, + value: json['value'] as String?, + ); + +Map _$$_MiraiStorageToJson(_$_MiraiStorage instance) => + { + 'type': _$MiraiStorageTypeEnumMap[instance.type]!, + 'key': instance.key, + 'value': instance.value, + }; + +const _$MiraiStorageTypeEnumMap = { + MiraiStorageType.write: 'write', + MiraiStorageType.delete: 'delete', +}; diff --git a/packages/mirai/lib/src/storage/storage_manager.dart b/packages/mirai/lib/src/storage/storage_manager.dart new file mode 100644 index 00000000..4c2e6242 --- /dev/null +++ b/packages/mirai/lib/src/storage/storage_manager.dart @@ -0,0 +1,17 @@ +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; + +class StorageManager { + const StorageManager._(); + + static late FlutterSecureStorage _flutterSecureStorage; + static void initialize(FlutterSecureStorage flutterSecureStorage) => + _flutterSecureStorage = flutterSecureStorage; + + static Future deleteAll() => _flutterSecureStorage.deleteAll(); + static Future delete(String key) => + _flutterSecureStorage.delete(key: key); + static Future read(String key) => + _flutterSecureStorage.read(key: key); + static Future write(String key, String value) => + _flutterSecureStorage.write(key: key, value: value); +} diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 62643a24..829d7844 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -30,4 +30,5 @@ enum WidgetType { defaultTabController, scrollView, tab, + storageWidget, } diff --git a/packages/mirai/pubspec.yaml b/packages/mirai/pubspec.yaml index 88c0874f..4c556731 100644 --- a/packages/mirai/pubspec.yaml +++ b/packages/mirai/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: json_annotation: ^4.8.0 logger: ^1.3.0 dio: ^5.1.1 + flutter_secure_storage: ^8.0.0 dev_dependencies: flutter_test: