From 760557731389f83d6e86513b0c54bd7de6764b5c Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Wed, 26 Jul 2023 18:39:00 +0400 Subject: [PATCH] Added google_fonts package for fonts (gfonts - asset) - Added mirai text theme data in Mirai theme - Added mirai font family parser - Added font resource type enum --- examples/mirai_gallery/.metadata | 25 +- .../assets/json/example_dark_theme.json | 5 +- .../assets/json/example_light_theme.json | 5 +- .../assets/json/text_example.json | 10 +- .../mirai_gallery/ios/Flutter/Debug.xcconfig | 1 + .../ios/Flutter/Release.xcconfig | 1 + examples/mirai_gallery/ios/Podfile | 44 ++ examples/mirai_gallery/ios/Podfile.lock | 23 + .../ios/Runner.xcodeproj/project.pbxproj | 237 ++++++ .../xcshareddata/xcschemes/Runner.xcscheme | 11 + .../contents.xcworkspacedata | 3 + .../ios/RunnerTests/RunnerTests.swift | 12 + .../macos/Flutter/Flutter-Debug.xcconfig | 1 + .../macos/Flutter/Flutter-Release.xcconfig | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 2 + examples/mirai_gallery/macos/Podfile | 43 ++ .../macos/Runner/DebugProfile.entitlements | 2 + .../macos/Runner/Release.entitlements | 2 + examples/mirai_gallery/pubspec.lock | 106 ++- .../mirai/lib/src/framework/mirai_app.dart | 16 +- .../mirai_font_family/mirai_font_family.dart | 26 + .../mirai_font_family.freezed.dart | 172 +++++ .../mirai_font_family.g.dart | 26 + .../mirai_text_style/mirai_text_style.dart | 11 +- .../mirai_text_style.freezed.dart | 54 +- .../mirai_text_style/mirai_text_style.g.dart | 7 +- .../mirai_text_theme/mirai_text_theme.dart | 52 ++ .../mirai_text_theme.freezed.dart | 693 ++++++++++++++++++ .../mirai_text_theme/mirai_text_theme.g.dart | 83 +++ .../src/parsers/mirai_theme/mirai_theme.dart | 18 +- .../mirai_theme/mirai_theme.freezed.dart | 168 ++++- .../parsers/mirai_theme/mirai_theme.g.dart | 20 +- packages/mirai/pubspec.yaml | 1 + 33 files changed, 1775 insertions(+), 106 deletions(-) create mode 100644 examples/mirai_gallery/ios/Podfile create mode 100644 examples/mirai_gallery/ios/Podfile.lock create mode 100644 examples/mirai_gallery/ios/RunnerTests/RunnerTests.swift create mode 100644 examples/mirai_gallery/macos/Podfile create mode 100644 packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.g.dart diff --git a/examples/mirai_gallery/.metadata b/examples/mirai_gallery/.metadata index 8e89d4de..a9c5f49a 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: 9cd3d0d9ff05768afa249e036acc66e8abe93bff 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 + create_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff + base_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff - platform: ios - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - platform: linux - create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - - 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: 9cd3d0d9ff05768afa249e036acc66e8abe93bff + base_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff # User provided section diff --git a/examples/mirai_gallery/assets/json/example_dark_theme.json b/examples/mirai_gallery/assets/json/example_dark_theme.json index 117ae4c5..f919a120 100644 --- a/examples/mirai_gallery/assets/json/example_dark_theme.json +++ b/examples/mirai_gallery/assets/json/example_dark_theme.json @@ -1,7 +1,10 @@ { "brightness": "dark", "disabledColor": "#60FFFFFF", - "fontFamily": "Handjet", + "fontFamily": { + "family": "Macondo Swash Caps", + "resource": "gfont" + }, "colorScheme": { "brightness": "dark", "primary": "#CCBDFA", diff --git a/examples/mirai_gallery/assets/json/example_light_theme.json b/examples/mirai_gallery/assets/json/example_light_theme.json index badb60f5..c0b0ca07 100644 --- a/examples/mirai_gallery/assets/json/example_light_theme.json +++ b/examples/mirai_gallery/assets/json/example_light_theme.json @@ -1,7 +1,10 @@ { "brightness": "light", "disabledColor": "#60FEF7FF", - "fontFamily": "LisuBosa", + "fontFamily": { + "family": "Handjet", + "resource": "asset" + }, "colorScheme": { "brightness": "light", "primary": "#6750a4", diff --git a/examples/mirai_gallery/assets/json/text_example.json b/examples/mirai_gallery/assets/json/text_example.json index 8b5ec7b3..8cb64acd 100644 --- a/examples/mirai_gallery/assets/json/text_example.json +++ b/examples/mirai_gallery/assets/json/text_example.json @@ -30,7 +30,10 @@ "style": { "fontSize": 23, "fontWeight": "w600", - "fontFamily": "Handjet" + "fontFamily": { + "family": "Handjet", + "resource": "asset" + } } }, { @@ -42,7 +45,10 @@ "data": "This is a normal Text.", "style": { "fontSize": 14, - "fontFamily": "LisuBosa" + "fontFamily": { + "family": "Macondo Swash Caps", + "resource": "gfont" + } } }, { 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..56e32e0f --- /dev/null +++ b/examples/mirai_gallery/ios/Podfile.lock @@ -0,0 +1,23 @@ +PODS: + - Flutter (1.0.0) + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS + +DEPENDENCIES: + - Flutter (from `Flutter`) + - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + path_provider_foundation: + :path: ".symlinks/plugins/path_provider_foundation/darwin" + +SPEC CHECKSUMS: + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + +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 e07d42a6..27664b1b 100644 --- a/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/mirai_gallery/ios/Runner.xcodeproj/project.pbxproj @@ -8,6 +8,9 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 2B2CBEB664B3EEBCB3FA39D1 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8166BC27DA893200E5BF5FBC /* Pods_RunnerTests.framework */; }; + 2F6E5230FCC6AE6544E1B8FB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7A4ECE2A7187F181F8372C5 /* Pods_Runner.framework */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; @@ -15,6 +18,16 @@ 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; @@ -31,10 +44,18 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 165586E0E828A0B0F3869163 /* 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 = ""; }; + 260195E4CA92DFABA981B267 /* 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 = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 48D7703A7BFDAA27E2B3F5C6 /* 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 = ""; }; + 672ED98175020332A9C4EB72 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 74BE86D579E84E539FC52890 /* 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 = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 8166BC27DA893200E5BF5FBC /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -42,19 +63,61 @@ 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 = ""; }; + D5DC64FF989424839A501375 /* 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 = ""; }; + F7A4ECE2A7187F181F8372C5 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 37569956BEC7C8EE90B294A0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2B2CBEB664B3EEBCB3FA39D1 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2F6E5230FCC6AE6544E1B8FB /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1E0FB79BF89126E7E85BA15A /* Frameworks */ = { + isa = PBXGroup; + children = ( + F7A4ECE2A7187F181F8372C5 /* Pods_Runner.framework */, + 8166BC27DA893200E5BF5FBC /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 650CBBB0A44DB0C34BFA2DE6 /* Pods */ = { + isa = PBXGroup; + children = ( + 74BE86D579E84E539FC52890 /* Pods-Runner.debug.xcconfig */, + 672ED98175020332A9C4EB72 /* Pods-Runner.release.xcconfig */, + 260195E4CA92DFABA981B267 /* Pods-Runner.profile.xcconfig */, + D5DC64FF989424839A501375 /* Pods-RunnerTests.debug.xcconfig */, + 165586E0E828A0B0F3869163 /* Pods-RunnerTests.release.xcconfig */, + 48D7703A7BFDAA27E2B3F5C6 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +135,9 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + 650CBBB0A44DB0C34BFA2DE6 /* Pods */, + 1E0FB79BF89126E7E85BA15A /* Frameworks */, ); sourceTree = ""; }; @@ -79,6 +145,7 @@ isa = PBXGroup; children = ( 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, ); name = Products; sourceTree = ""; @@ -101,16 +168,37 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + FE82EA37C0AA5A501F8D5A80 /* [CP] Check Pods Manifest.lock */, + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + 37569956BEC7C8EE90B294A0 /* 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 = ( + B0990E9D3E6BE187D53BE196 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 9D2E8FCB0F3ABD8D18606923 /* [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; @@ -200,9 +300,78 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + 9D2E8FCB0F3ABD8D18606923 /* [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; + }; + B0990E9D3E6BE187D53BE196 /* [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; + }; + FE82EA37C0AA5A501F8D5A80 /* [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 */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -214,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; @@ -306,6 +483,56 @@ }; name = Profile; }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D5DC64FF989424839A501375 /* 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 = 165586E0E828A0B0F3869163 /* 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 = 48D7703A7BFDAA27E2B3F5C6 /* 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 = { @@ -461,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/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..e777c67d 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 path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } 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/Runner/DebugProfile.entitlements b/examples/mirai_gallery/macos/Runner/DebugProfile.entitlements index dddb8a30..08c3ab17 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 + com.apple.security.network.client + diff --git a/examples/mirai_gallery/macos/Runner/Release.entitlements b/examples/mirai_gallery/macos/Runner/Release.entitlements index 852fa1a4..ee95ab7e 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 + com.apple.security.network.client + diff --git a/examples/mirai_gallery/pubspec.lock b/examples/mirai_gallery/pubspec.lock index 348fd210..da000e94 100644 --- a/examples/mirai_gallery/pubspec.lock +++ b/examples/mirai_gallery/pubspec.lock @@ -201,6 +201,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.dev" + source: hosted + version: "2.0.2" file: dependency: transitive description: @@ -275,6 +283,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + google_fonts: + dependency: transitive + description: + name: google_fonts + sha256: e20ff62b158b96f392bfc8afe29dee1503c94fbea2cbe8186fd59b756b8ae982 + url: "https://pub.dev" + source: hosted + version: "5.1.0" graphs: dependency: transitive description: @@ -283,6 +299,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" + http: + dependency: transitive + description: + name: http + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + url: "https://pub.dev" + source: hosted + version: "1.1.0" http_multi_server: dependency: transitive description: @@ -418,6 +442,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" + url: "https://pub.dev" + source: hosted + version: "2.0.15" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" + url: "https://pub.dev" + source: hosted + version: "2.0.27" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" + url: "https://pub.dev" + source: hosted + version: "2.2.4" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 + url: "https://pub.dev" + source: hosted + version: "2.1.11" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" + url: "https://pub.dev" + source: hosted + version: "2.0.6" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" + url: "https://pub.dev" + source: hosted + version: "2.1.7" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" pool: dependency: transitive description: @@ -583,6 +671,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + win32: + dependency: transitive + description: + name: win32 + sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0 + url: "https://pub.dev" + source: hosted + version: "5.0.6" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff + url: "https://pub.dev" + source: hosted + version: "1.0.1" yaml: dependency: transitive description: @@ -593,4 +697,4 @@ packages: version: "3.1.1" sdks: dart: ">=3.0.0 <4.0.0" - flutter: ">=1.17.0" + flutter: ">=3.3.0" diff --git a/packages/mirai/lib/src/framework/mirai_app.dart b/packages/mirai/lib/src/framework/mirai_app.dart index 8c008f5c..a7cd8323 100644 --- a/packages/mirai/lib/src/framework/mirai_app.dart +++ b/packages/mirai/lib/src/framework/mirai_app.dart @@ -136,12 +136,12 @@ class MiraiApp extends StatelessWidget { @override Widget build(BuildContext context) { if (routerDelegate != null || routerConfig != null) { - return _materialRouterApp; + return _materialRouterApp(context); } - return _materialApp; + return _materialApp(context); } - Widget get _materialApp { + Widget _materialApp(BuildContext context) { return MaterialApp( navigatorKey: navigatorKey, scaffoldMessengerKey: scaffoldMessengerKey, @@ -162,8 +162,8 @@ class MiraiApp extends StatelessWidget { builder: builder, title: title, onGenerateTitle: onGenerateTitle, - theme: theme?.parse, - darkTheme: darkTheme?.parse, + theme: theme?.parse(context), + darkTheme: darkTheme?.parse(context), highContrastTheme: highContrastTheme, highContrastDarkTheme: highContrastDarkTheme, themeMode: themeMode, @@ -188,7 +188,7 @@ class MiraiApp extends StatelessWidget { ); } - Widget get _materialRouterApp { + Widget _materialRouterApp(BuildContext context) { return MaterialApp.router( scaffoldMessengerKey: scaffoldMessengerKey, routeInformationProvider: routeInformationProvider, @@ -200,8 +200,8 @@ class MiraiApp extends StatelessWidget { title: title, onGenerateTitle: onGenerateTitle, color: color, - theme: theme?.parse, - darkTheme: darkTheme?.parse, + theme: theme?.parse(context), + darkTheme: darkTheme?.parse(context), highContrastTheme: highContrastTheme, highContrastDarkTheme: highContrastDarkTheme, themeMode: themeMode, diff --git a/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.dart b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.dart new file mode 100644 index 00000000..157ed72b --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.dart @@ -0,0 +1,26 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:google_fonts/google_fonts.dart'; + +part 'mirai_font_family.freezed.dart'; +part 'mirai_font_family.g.dart'; + +enum FontFamilyResource { asset, gfont } + +@freezed +class MiraiFontFamily with _$MiraiFontFamily { + const factory MiraiFontFamily({ + required String family, + @Default(FontFamilyResource.asset) FontFamilyResource resource, + }) = _MiraiFontFamily; + + factory MiraiFontFamily.fromJson(Map json) => + _$MiraiFontFamilyFromJson(json); +} + +extension MiraiFontFamilyPrser on MiraiFontFamily { + String? get parse { + return resource == FontFamilyResource.gfont + ? GoogleFonts.getFont(family).fontFamily + : family; + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.freezed.dart b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.freezed.dart new file mode 100644 index 00000000..b592c6d8 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.freezed.dart @@ -0,0 +1,172 @@ +// 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_font_family.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'); + +MiraiFontFamily _$MiraiFontFamilyFromJson(Map json) { + return _MiraiFontFamily.fromJson(json); +} + +/// @nodoc +mixin _$MiraiFontFamily { + String get family => throw _privateConstructorUsedError; + FontFamilyResource get resource => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiFontFamilyCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiFontFamilyCopyWith<$Res> { + factory $MiraiFontFamilyCopyWith( + MiraiFontFamily value, $Res Function(MiraiFontFamily) then) = + _$MiraiFontFamilyCopyWithImpl<$Res, MiraiFontFamily>; + @useResult + $Res call({String family, FontFamilyResource resource}); +} + +/// @nodoc +class _$MiraiFontFamilyCopyWithImpl<$Res, $Val extends MiraiFontFamily> + implements $MiraiFontFamilyCopyWith<$Res> { + _$MiraiFontFamilyCopyWithImpl(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? family = null, + Object? resource = null, + }) { + return _then(_value.copyWith( + family: null == family + ? _value.family + : family // ignore: cast_nullable_to_non_nullable + as String, + resource: null == resource + ? _value.resource + : resource // ignore: cast_nullable_to_non_nullable + as FontFamilyResource, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_MiraiFontFamilyCopyWith<$Res> + implements $MiraiFontFamilyCopyWith<$Res> { + factory _$$_MiraiFontFamilyCopyWith( + _$_MiraiFontFamily value, $Res Function(_$_MiraiFontFamily) then) = + __$$_MiraiFontFamilyCopyWithImpl<$Res>; + @override + @useResult + $Res call({String family, FontFamilyResource resource}); +} + +/// @nodoc +class __$$_MiraiFontFamilyCopyWithImpl<$Res> + extends _$MiraiFontFamilyCopyWithImpl<$Res, _$_MiraiFontFamily> + implements _$$_MiraiFontFamilyCopyWith<$Res> { + __$$_MiraiFontFamilyCopyWithImpl( + _$_MiraiFontFamily _value, $Res Function(_$_MiraiFontFamily) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? family = null, + Object? resource = null, + }) { + return _then(_$_MiraiFontFamily( + family: null == family + ? _value.family + : family // ignore: cast_nullable_to_non_nullable + as String, + resource: null == resource + ? _value.resource + : resource // ignore: cast_nullable_to_non_nullable + as FontFamilyResource, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_MiraiFontFamily implements _MiraiFontFamily { + const _$_MiraiFontFamily( + {required this.family, this.resource = FontFamilyResource.asset}); + + factory _$_MiraiFontFamily.fromJson(Map json) => + _$$_MiraiFontFamilyFromJson(json); + + @override + final String family; + @override + @JsonKey() + final FontFamilyResource resource; + + @override + String toString() { + return 'MiraiFontFamily(family: $family, resource: $resource)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_MiraiFontFamily && + (identical(other.family, family) || other.family == family) && + (identical(other.resource, resource) || + other.resource == resource)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, family, resource); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_MiraiFontFamilyCopyWith<_$_MiraiFontFamily> get copyWith => + __$$_MiraiFontFamilyCopyWithImpl<_$_MiraiFontFamily>(this, _$identity); + + @override + Map toJson() { + return _$$_MiraiFontFamilyToJson( + this, + ); + } +} + +abstract class _MiraiFontFamily implements MiraiFontFamily { + const factory _MiraiFontFamily( + {required final String family, + final FontFamilyResource resource}) = _$_MiraiFontFamily; + + factory _MiraiFontFamily.fromJson(Map json) = + _$_MiraiFontFamily.fromJson; + + @override + String get family; + @override + FontFamilyResource get resource; + @override + @JsonKey(ignore: true) + _$$_MiraiFontFamilyCopyWith<_$_MiraiFontFamily> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.g.dart b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.g.dart new file mode 100644 index 00000000..db1c2c07 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_font_family/mirai_font_family.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_font_family.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_MiraiFontFamily _$$_MiraiFontFamilyFromJson(Map json) => + _$_MiraiFontFamily( + family: json['family'] as String, + resource: + $enumDecodeNullable(_$FontFamilyResourceEnumMap, json['resource']) ?? + FontFamilyResource.asset, + ); + +Map _$$_MiraiFontFamilyToJson(_$_MiraiFontFamily instance) => + { + 'family': instance.family, + 'resource': _$FontFamilyResourceEnumMap[instance.resource]!, + }; + +const _$FontFamilyResourceEnumMap = { + FontFamilyResource.asset: 'asset', + FontFamilyResource.gfont: 'gfont', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart index 449f0120..f5a64546 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/src/parsers/mirai_font_family/mirai_font_family.dart'; import 'package:mirai/src/parsers/mirai_font_weight/mirai_font_weight.dart'; import 'package:mirai/src/utils/color_utils.dart'; @@ -15,8 +16,8 @@ class MiraiTextStyle with _$MiraiTextStyle { double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, - String? fontFamily, - List? fontFamilyFallback, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, @@ -36,8 +37,10 @@ extension MiraiTextStyleParser on MiraiTextStyle { fontSize: fontSize, fontWeight: fontWeight?.value, fontStyle: fontStyle, - fontFamily: fontFamily, - fontFamilyFallback: fontFamilyFallback, + fontFamily: fontFamily?.parse, + fontFamilyFallback: fontFamilyFallback + ?.map((family) => family.parse ?? "Roboto") + .toList(), letterSpacing: letterSpacing, wordSpacing: wordSpacing, textBaseline: textBaseline, diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart index 8aba930b..5af34996 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.freezed.dart @@ -26,8 +26,9 @@ mixin _$MiraiTextStyle { double? get fontSize => throw _privateConstructorUsedError; MiraiFontWeight? get fontWeight => throw _privateConstructorUsedError; FontStyle? get fontStyle => throw _privateConstructorUsedError; - String? get fontFamily => throw _privateConstructorUsedError; - List? get fontFamilyFallback => throw _privateConstructorUsedError; + MiraiFontFamily? get fontFamily => throw _privateConstructorUsedError; + List? get fontFamilyFallback => + throw _privateConstructorUsedError; double? get letterSpacing => throw _privateConstructorUsedError; double? get wordSpacing => throw _privateConstructorUsedError; TextBaseline? get textBaseline => throw _privateConstructorUsedError; @@ -52,12 +53,14 @@ abstract class $MiraiTextStyleCopyWith<$Res> { double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, - String? fontFamily, - List? fontFamilyFallback, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, double? height}); + + $MiraiFontFamilyCopyWith<$Res>? get fontFamily; } /// @nodoc @@ -114,11 +117,11 @@ class _$MiraiTextStyleCopyWithImpl<$Res, $Val extends MiraiTextStyle> fontFamily: freezed == fontFamily ? _value.fontFamily : fontFamily // ignore: cast_nullable_to_non_nullable - as String?, + as MiraiFontFamily?, fontFamilyFallback: freezed == fontFamilyFallback ? _value.fontFamilyFallback : fontFamilyFallback // ignore: cast_nullable_to_non_nullable - as List?, + as List?, letterSpacing: freezed == letterSpacing ? _value.letterSpacing : letterSpacing // ignore: cast_nullable_to_non_nullable @@ -137,6 +140,18 @@ class _$MiraiTextStyleCopyWithImpl<$Res, $Val extends MiraiTextStyle> as double?, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $MiraiFontFamilyCopyWith<$Res>? get fontFamily { + if (_value.fontFamily == null) { + return null; + } + + return $MiraiFontFamilyCopyWith<$Res>(_value.fontFamily!, (value) { + return _then(_value.copyWith(fontFamily: value) as $Val); + }); + } } /// @nodoc @@ -154,12 +169,15 @@ abstract class _$$_MiraiTextStyleCopyWith<$Res> double? fontSize, MiraiFontWeight? fontWeight, FontStyle? fontStyle, - String? fontFamily, - List? fontFamilyFallback, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, double? height}); + + @override + $MiraiFontFamilyCopyWith<$Res>? get fontFamily; } /// @nodoc @@ -214,11 +232,11 @@ class __$$_MiraiTextStyleCopyWithImpl<$Res> fontFamily: freezed == fontFamily ? _value.fontFamily : fontFamily // ignore: cast_nullable_to_non_nullable - as String?, + as MiraiFontFamily?, fontFamilyFallback: freezed == fontFamilyFallback ? _value._fontFamilyFallback : fontFamilyFallback // ignore: cast_nullable_to_non_nullable - as List?, + as List?, letterSpacing: freezed == letterSpacing ? _value.letterSpacing : letterSpacing // ignore: cast_nullable_to_non_nullable @@ -250,7 +268,7 @@ class _$_MiraiTextStyle implements _MiraiTextStyle { this.fontWeight, this.fontStyle, this.fontFamily, - final List? fontFamilyFallback, + final List? fontFamilyFallback, this.letterSpacing, this.wordSpacing, this.textBaseline, @@ -274,10 +292,10 @@ class _$_MiraiTextStyle implements _MiraiTextStyle { @override final FontStyle? fontStyle; @override - final String? fontFamily; - final List? _fontFamilyFallback; + final MiraiFontFamily? fontFamily; + final List? _fontFamilyFallback; @override - List? get fontFamilyFallback { + List? get fontFamilyFallback { final value = _fontFamilyFallback; if (value == null) return null; if (_fontFamilyFallback is EqualUnmodifiableListView) @@ -367,8 +385,8 @@ abstract class _MiraiTextStyle implements MiraiTextStyle { final double? fontSize, final MiraiFontWeight? fontWeight, final FontStyle? fontStyle, - final String? fontFamily, - final List? fontFamilyFallback, + final MiraiFontFamily? fontFamily, + final List? fontFamilyFallback, final double? letterSpacing, final double? wordSpacing, final TextBaseline? textBaseline, @@ -390,9 +408,9 @@ abstract class _MiraiTextStyle implements MiraiTextStyle { @override FontStyle? get fontStyle; @override - String? get fontFamily; + MiraiFontFamily? get fontFamily; @override - List? get fontFamilyFallback; + List? get fontFamilyFallback; @override double? get letterSpacing; @override diff --git a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart index 7a797c3e..02470c47 100644 --- a/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text_style/mirai_text_style.g.dart @@ -15,9 +15,12 @@ _$_MiraiTextStyle _$$_MiraiTextStyleFromJson(Map json) => fontWeight: $enumDecodeNullable(_$MiraiFontWeightEnumMap, json['fontWeight']), fontStyle: $enumDecodeNullable(_$FontStyleEnumMap, json['fontStyle']), - fontFamily: json['fontFamily'] as String?, + fontFamily: json['fontFamily'] == null + ? null + : MiraiFontFamily.fromJson( + json['fontFamily'] as Map), fontFamilyFallback: (json['fontFamilyFallback'] as List?) - ?.map((e) => e as String) + ?.map((e) => MiraiFontFamily.fromJson(e as Map)) .toList(), letterSpacing: (json['letterSpacing'] as num?)?.toDouble(), wordSpacing: (json['wordSpacing'] as num?)?.toDouble(), diff --git a/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.dart b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.dart new file mode 100644 index 00000000..b1b20c74 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart'; + +part 'mirai_text_theme.freezed.dart'; +part 'mirai_text_theme.g.dart'; + +@freezed +class MiraiTextTheme with _$MiraiTextTheme { + const factory MiraiTextTheme({ + MiraiTextStyle? displayLarge, + MiraiTextStyle? displayMedium, + MiraiTextStyle? displaySmall, + MiraiTextStyle? headlineLarge, + MiraiTextStyle? headlineMedium, + MiraiTextStyle? headlineSmall, + MiraiTextStyle? titleLarge, + MiraiTextStyle? titleMedium, + MiraiTextStyle? titleSmall, + MiraiTextStyle? bodyLarge, + MiraiTextStyle? bodyMedium, + MiraiTextStyle? bodySmall, + MiraiTextStyle? labelLarge, + MiraiTextStyle? labelMedium, + MiraiTextStyle? labelSmall, + }) = _MiraiTextTheme; + + factory MiraiTextTheme.fromJson(Map json) => + _$MiraiTextThemeFromJson(json); +} + +extension MiraiTextThemeParser on MiraiTextTheme { + TextTheme? get parse { + return TextTheme( + displayLarge: displayLarge?.parse, + displayMedium: displayMedium?.parse, + displaySmall: displaySmall?.parse, + headlineLarge: headlineLarge?.parse, + headlineMedium: headlineMedium?.parse, + headlineSmall: headlineSmall?.parse, + titleLarge: titleLarge?.parse, + titleMedium: titleMedium?.parse, + titleSmall: titleSmall?.parse, + bodyLarge: bodyLarge?.parse, + bodyMedium: bodyMedium?.parse, + bodySmall: bodySmall?.parse, + labelLarge: labelLarge?.parse, + labelMedium: labelMedium?.parse, + labelSmall: labelSmall?.parse, + ); + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.freezed.dart b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.freezed.dart new file mode 100644 index 00000000..2e4fd91c --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.freezed.dart @@ -0,0 +1,693 @@ +// 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_text_theme.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'); + +MiraiTextTheme _$MiraiTextThemeFromJson(Map json) { + return _MiraiTextTheme.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTextTheme { + MiraiTextStyle? get displayLarge => throw _privateConstructorUsedError; + MiraiTextStyle? get displayMedium => throw _privateConstructorUsedError; + MiraiTextStyle? get displaySmall => throw _privateConstructorUsedError; + MiraiTextStyle? get headlineLarge => throw _privateConstructorUsedError; + MiraiTextStyle? get headlineMedium => throw _privateConstructorUsedError; + MiraiTextStyle? get headlineSmall => throw _privateConstructorUsedError; + MiraiTextStyle? get titleLarge => throw _privateConstructorUsedError; + MiraiTextStyle? get titleMedium => throw _privateConstructorUsedError; + MiraiTextStyle? get titleSmall => throw _privateConstructorUsedError; + MiraiTextStyle? get bodyLarge => throw _privateConstructorUsedError; + MiraiTextStyle? get bodyMedium => throw _privateConstructorUsedError; + MiraiTextStyle? get bodySmall => throw _privateConstructorUsedError; + MiraiTextStyle? get labelLarge => throw _privateConstructorUsedError; + MiraiTextStyle? get labelMedium => throw _privateConstructorUsedError; + MiraiTextStyle? get labelSmall => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTextThemeCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTextThemeCopyWith<$Res> { + factory $MiraiTextThemeCopyWith( + MiraiTextTheme value, $Res Function(MiraiTextTheme) then) = + _$MiraiTextThemeCopyWithImpl<$Res, MiraiTextTheme>; + @useResult + $Res call( + {MiraiTextStyle? displayLarge, + MiraiTextStyle? displayMedium, + MiraiTextStyle? displaySmall, + MiraiTextStyle? headlineLarge, + MiraiTextStyle? headlineMedium, + MiraiTextStyle? headlineSmall, + MiraiTextStyle? titleLarge, + MiraiTextStyle? titleMedium, + MiraiTextStyle? titleSmall, + MiraiTextStyle? bodyLarge, + MiraiTextStyle? bodyMedium, + MiraiTextStyle? bodySmall, + MiraiTextStyle? labelLarge, + MiraiTextStyle? labelMedium, + MiraiTextStyle? labelSmall}); + + $MiraiTextStyleCopyWith<$Res>? get displayLarge; + $MiraiTextStyleCopyWith<$Res>? get displayMedium; + $MiraiTextStyleCopyWith<$Res>? get displaySmall; + $MiraiTextStyleCopyWith<$Res>? get headlineLarge; + $MiraiTextStyleCopyWith<$Res>? get headlineMedium; + $MiraiTextStyleCopyWith<$Res>? get headlineSmall; + $MiraiTextStyleCopyWith<$Res>? get titleLarge; + $MiraiTextStyleCopyWith<$Res>? get titleMedium; + $MiraiTextStyleCopyWith<$Res>? get titleSmall; + $MiraiTextStyleCopyWith<$Res>? get bodyLarge; + $MiraiTextStyleCopyWith<$Res>? get bodyMedium; + $MiraiTextStyleCopyWith<$Res>? get bodySmall; + $MiraiTextStyleCopyWith<$Res>? get labelLarge; + $MiraiTextStyleCopyWith<$Res>? get labelMedium; + $MiraiTextStyleCopyWith<$Res>? get labelSmall; +} + +/// @nodoc +class _$MiraiTextThemeCopyWithImpl<$Res, $Val extends MiraiTextTheme> + implements $MiraiTextThemeCopyWith<$Res> { + _$MiraiTextThemeCopyWithImpl(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? displayLarge = freezed, + Object? displayMedium = freezed, + Object? displaySmall = freezed, + Object? headlineLarge = freezed, + Object? headlineMedium = freezed, + Object? headlineSmall = freezed, + Object? titleLarge = freezed, + Object? titleMedium = freezed, + Object? titleSmall = freezed, + Object? bodyLarge = freezed, + Object? bodyMedium = freezed, + Object? bodySmall = freezed, + Object? labelLarge = freezed, + Object? labelMedium = freezed, + Object? labelSmall = freezed, + }) { + return _then(_value.copyWith( + displayLarge: freezed == displayLarge + ? _value.displayLarge + : displayLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + displayMedium: freezed == displayMedium + ? _value.displayMedium + : displayMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + displaySmall: freezed == displaySmall + ? _value.displaySmall + : displaySmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineLarge: freezed == headlineLarge + ? _value.headlineLarge + : headlineLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineMedium: freezed == headlineMedium + ? _value.headlineMedium + : headlineMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineSmall: freezed == headlineSmall + ? _value.headlineSmall + : headlineSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleLarge: freezed == titleLarge + ? _value.titleLarge + : titleLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleMedium: freezed == titleMedium + ? _value.titleMedium + : titleMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleSmall: freezed == titleSmall + ? _value.titleSmall + : titleSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodyLarge: freezed == bodyLarge + ? _value.bodyLarge + : bodyLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodyMedium: freezed == bodyMedium + ? _value.bodyMedium + : bodyMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodySmall: freezed == bodySmall + ? _value.bodySmall + : bodySmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelLarge: freezed == labelLarge + ? _value.labelLarge + : labelLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelMedium: freezed == labelMedium + ? _value.labelMedium + : labelMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelSmall: freezed == labelSmall + ? _value.labelSmall + : labelSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get displayLarge { + if (_value.displayLarge == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.displayLarge!, (value) { + return _then(_value.copyWith(displayLarge: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get displayMedium { + if (_value.displayMedium == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.displayMedium!, (value) { + return _then(_value.copyWith(displayMedium: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get displaySmall { + if (_value.displaySmall == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.displaySmall!, (value) { + return _then(_value.copyWith(displaySmall: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get headlineLarge { + if (_value.headlineLarge == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.headlineLarge!, (value) { + return _then(_value.copyWith(headlineLarge: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get headlineMedium { + if (_value.headlineMedium == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.headlineMedium!, (value) { + return _then(_value.copyWith(headlineMedium: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get headlineSmall { + if (_value.headlineSmall == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.headlineSmall!, (value) { + return _then(_value.copyWith(headlineSmall: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get titleLarge { + if (_value.titleLarge == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.titleLarge!, (value) { + return _then(_value.copyWith(titleLarge: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get titleMedium { + if (_value.titleMedium == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.titleMedium!, (value) { + return _then(_value.copyWith(titleMedium: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get titleSmall { + if (_value.titleSmall == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.titleSmall!, (value) { + return _then(_value.copyWith(titleSmall: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get bodyLarge { + if (_value.bodyLarge == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.bodyLarge!, (value) { + return _then(_value.copyWith(bodyLarge: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get bodyMedium { + if (_value.bodyMedium == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.bodyMedium!, (value) { + return _then(_value.copyWith(bodyMedium: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get bodySmall { + if (_value.bodySmall == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.bodySmall!, (value) { + return _then(_value.copyWith(bodySmall: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get labelLarge { + if (_value.labelLarge == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.labelLarge!, (value) { + return _then(_value.copyWith(labelLarge: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get labelMedium { + if (_value.labelMedium == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.labelMedium!, (value) { + return _then(_value.copyWith(labelMedium: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextStyleCopyWith<$Res>? get labelSmall { + if (_value.labelSmall == null) { + return null; + } + + return $MiraiTextStyleCopyWith<$Res>(_value.labelSmall!, (value) { + return _then(_value.copyWith(labelSmall: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_MiraiTextThemeCopyWith<$Res> + implements $MiraiTextThemeCopyWith<$Res> { + factory _$$_MiraiTextThemeCopyWith( + _$_MiraiTextTheme value, $Res Function(_$_MiraiTextTheme) then) = + __$$_MiraiTextThemeCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {MiraiTextStyle? displayLarge, + MiraiTextStyle? displayMedium, + MiraiTextStyle? displaySmall, + MiraiTextStyle? headlineLarge, + MiraiTextStyle? headlineMedium, + MiraiTextStyle? headlineSmall, + MiraiTextStyle? titleLarge, + MiraiTextStyle? titleMedium, + MiraiTextStyle? titleSmall, + MiraiTextStyle? bodyLarge, + MiraiTextStyle? bodyMedium, + MiraiTextStyle? bodySmall, + MiraiTextStyle? labelLarge, + MiraiTextStyle? labelMedium, + MiraiTextStyle? labelSmall}); + + @override + $MiraiTextStyleCopyWith<$Res>? get displayLarge; + @override + $MiraiTextStyleCopyWith<$Res>? get displayMedium; + @override + $MiraiTextStyleCopyWith<$Res>? get displaySmall; + @override + $MiraiTextStyleCopyWith<$Res>? get headlineLarge; + @override + $MiraiTextStyleCopyWith<$Res>? get headlineMedium; + @override + $MiraiTextStyleCopyWith<$Res>? get headlineSmall; + @override + $MiraiTextStyleCopyWith<$Res>? get titleLarge; + @override + $MiraiTextStyleCopyWith<$Res>? get titleMedium; + @override + $MiraiTextStyleCopyWith<$Res>? get titleSmall; + @override + $MiraiTextStyleCopyWith<$Res>? get bodyLarge; + @override + $MiraiTextStyleCopyWith<$Res>? get bodyMedium; + @override + $MiraiTextStyleCopyWith<$Res>? get bodySmall; + @override + $MiraiTextStyleCopyWith<$Res>? get labelLarge; + @override + $MiraiTextStyleCopyWith<$Res>? get labelMedium; + @override + $MiraiTextStyleCopyWith<$Res>? get labelSmall; +} + +/// @nodoc +class __$$_MiraiTextThemeCopyWithImpl<$Res> + extends _$MiraiTextThemeCopyWithImpl<$Res, _$_MiraiTextTheme> + implements _$$_MiraiTextThemeCopyWith<$Res> { + __$$_MiraiTextThemeCopyWithImpl( + _$_MiraiTextTheme _value, $Res Function(_$_MiraiTextTheme) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? displayLarge = freezed, + Object? displayMedium = freezed, + Object? displaySmall = freezed, + Object? headlineLarge = freezed, + Object? headlineMedium = freezed, + Object? headlineSmall = freezed, + Object? titleLarge = freezed, + Object? titleMedium = freezed, + Object? titleSmall = freezed, + Object? bodyLarge = freezed, + Object? bodyMedium = freezed, + Object? bodySmall = freezed, + Object? labelLarge = freezed, + Object? labelMedium = freezed, + Object? labelSmall = freezed, + }) { + return _then(_$_MiraiTextTheme( + displayLarge: freezed == displayLarge + ? _value.displayLarge + : displayLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + displayMedium: freezed == displayMedium + ? _value.displayMedium + : displayMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + displaySmall: freezed == displaySmall + ? _value.displaySmall + : displaySmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineLarge: freezed == headlineLarge + ? _value.headlineLarge + : headlineLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineMedium: freezed == headlineMedium + ? _value.headlineMedium + : headlineMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + headlineSmall: freezed == headlineSmall + ? _value.headlineSmall + : headlineSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleLarge: freezed == titleLarge + ? _value.titleLarge + : titleLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleMedium: freezed == titleMedium + ? _value.titleMedium + : titleMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + titleSmall: freezed == titleSmall + ? _value.titleSmall + : titleSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodyLarge: freezed == bodyLarge + ? _value.bodyLarge + : bodyLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodyMedium: freezed == bodyMedium + ? _value.bodyMedium + : bodyMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + bodySmall: freezed == bodySmall + ? _value.bodySmall + : bodySmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelLarge: freezed == labelLarge + ? _value.labelLarge + : labelLarge // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelMedium: freezed == labelMedium + ? _value.labelMedium + : labelMedium // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + labelSmall: freezed == labelSmall + ? _value.labelSmall + : labelSmall // ignore: cast_nullable_to_non_nullable + as MiraiTextStyle?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_MiraiTextTheme implements _MiraiTextTheme { + const _$_MiraiTextTheme( + {this.displayLarge, + this.displayMedium, + this.displaySmall, + this.headlineLarge, + this.headlineMedium, + this.headlineSmall, + this.titleLarge, + this.titleMedium, + this.titleSmall, + this.bodyLarge, + this.bodyMedium, + this.bodySmall, + this.labelLarge, + this.labelMedium, + this.labelSmall}); + + factory _$_MiraiTextTheme.fromJson(Map json) => + _$$_MiraiTextThemeFromJson(json); + + @override + final MiraiTextStyle? displayLarge; + @override + final MiraiTextStyle? displayMedium; + @override + final MiraiTextStyle? displaySmall; + @override + final MiraiTextStyle? headlineLarge; + @override + final MiraiTextStyle? headlineMedium; + @override + final MiraiTextStyle? headlineSmall; + @override + final MiraiTextStyle? titleLarge; + @override + final MiraiTextStyle? titleMedium; + @override + final MiraiTextStyle? titleSmall; + @override + final MiraiTextStyle? bodyLarge; + @override + final MiraiTextStyle? bodyMedium; + @override + final MiraiTextStyle? bodySmall; + @override + final MiraiTextStyle? labelLarge; + @override + final MiraiTextStyle? labelMedium; + @override + final MiraiTextStyle? labelSmall; + + @override + String toString() { + return 'MiraiTextTheme(displayLarge: $displayLarge, displayMedium: $displayMedium, displaySmall: $displaySmall, headlineLarge: $headlineLarge, headlineMedium: $headlineMedium, headlineSmall: $headlineSmall, titleLarge: $titleLarge, titleMedium: $titleMedium, titleSmall: $titleSmall, bodyLarge: $bodyLarge, bodyMedium: $bodyMedium, bodySmall: $bodySmall, labelLarge: $labelLarge, labelMedium: $labelMedium, labelSmall: $labelSmall)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_MiraiTextTheme && + (identical(other.displayLarge, displayLarge) || + other.displayLarge == displayLarge) && + (identical(other.displayMedium, displayMedium) || + other.displayMedium == displayMedium) && + (identical(other.displaySmall, displaySmall) || + other.displaySmall == displaySmall) && + (identical(other.headlineLarge, headlineLarge) || + other.headlineLarge == headlineLarge) && + (identical(other.headlineMedium, headlineMedium) || + other.headlineMedium == headlineMedium) && + (identical(other.headlineSmall, headlineSmall) || + other.headlineSmall == headlineSmall) && + (identical(other.titleLarge, titleLarge) || + other.titleLarge == titleLarge) && + (identical(other.titleMedium, titleMedium) || + other.titleMedium == titleMedium) && + (identical(other.titleSmall, titleSmall) || + other.titleSmall == titleSmall) && + (identical(other.bodyLarge, bodyLarge) || + other.bodyLarge == bodyLarge) && + (identical(other.bodyMedium, bodyMedium) || + other.bodyMedium == bodyMedium) && + (identical(other.bodySmall, bodySmall) || + other.bodySmall == bodySmall) && + (identical(other.labelLarge, labelLarge) || + other.labelLarge == labelLarge) && + (identical(other.labelMedium, labelMedium) || + other.labelMedium == labelMedium) && + (identical(other.labelSmall, labelSmall) || + other.labelSmall == labelSmall)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + displayLarge, + displayMedium, + displaySmall, + headlineLarge, + headlineMedium, + headlineSmall, + titleLarge, + titleMedium, + titleSmall, + bodyLarge, + bodyMedium, + bodySmall, + labelLarge, + labelMedium, + labelSmall); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_MiraiTextThemeCopyWith<_$_MiraiTextTheme> get copyWith => + __$$_MiraiTextThemeCopyWithImpl<_$_MiraiTextTheme>(this, _$identity); + + @override + Map toJson() { + return _$$_MiraiTextThemeToJson( + this, + ); + } +} + +abstract class _MiraiTextTheme implements MiraiTextTheme { + const factory _MiraiTextTheme( + {final MiraiTextStyle? displayLarge, + final MiraiTextStyle? displayMedium, + final MiraiTextStyle? displaySmall, + final MiraiTextStyle? headlineLarge, + final MiraiTextStyle? headlineMedium, + final MiraiTextStyle? headlineSmall, + final MiraiTextStyle? titleLarge, + final MiraiTextStyle? titleMedium, + final MiraiTextStyle? titleSmall, + final MiraiTextStyle? bodyLarge, + final MiraiTextStyle? bodyMedium, + final MiraiTextStyle? bodySmall, + final MiraiTextStyle? labelLarge, + final MiraiTextStyle? labelMedium, + final MiraiTextStyle? labelSmall}) = _$_MiraiTextTheme; + + factory _MiraiTextTheme.fromJson(Map json) = + _$_MiraiTextTheme.fromJson; + + @override + MiraiTextStyle? get displayLarge; + @override + MiraiTextStyle? get displayMedium; + @override + MiraiTextStyle? get displaySmall; + @override + MiraiTextStyle? get headlineLarge; + @override + MiraiTextStyle? get headlineMedium; + @override + MiraiTextStyle? get headlineSmall; + @override + MiraiTextStyle? get titleLarge; + @override + MiraiTextStyle? get titleMedium; + @override + MiraiTextStyle? get titleSmall; + @override + MiraiTextStyle? get bodyLarge; + @override + MiraiTextStyle? get bodyMedium; + @override + MiraiTextStyle? get bodySmall; + @override + MiraiTextStyle? get labelLarge; + @override + MiraiTextStyle? get labelMedium; + @override + MiraiTextStyle? get labelSmall; + @override + @JsonKey(ignore: true) + _$$_MiraiTextThemeCopyWith<_$_MiraiTextTheme> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.g.dart new file mode 100644 index 00000000..73638366 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_theme/mirai_text_theme.g.dart @@ -0,0 +1,83 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_text_theme.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_MiraiTextTheme _$$_MiraiTextThemeFromJson(Map json) => + _$_MiraiTextTheme( + displayLarge: json['displayLarge'] == null + ? null + : MiraiTextStyle.fromJson( + json['displayLarge'] as Map), + displayMedium: json['displayMedium'] == null + ? null + : MiraiTextStyle.fromJson( + json['displayMedium'] as Map), + displaySmall: json['displaySmall'] == null + ? null + : MiraiTextStyle.fromJson( + json['displaySmall'] as Map), + headlineLarge: json['headlineLarge'] == null + ? null + : MiraiTextStyle.fromJson( + json['headlineLarge'] as Map), + headlineMedium: json['headlineMedium'] == null + ? null + : MiraiTextStyle.fromJson( + json['headlineMedium'] as Map), + headlineSmall: json['headlineSmall'] == null + ? null + : MiraiTextStyle.fromJson( + json['headlineSmall'] as Map), + titleLarge: json['titleLarge'] == null + ? null + : MiraiTextStyle.fromJson(json['titleLarge'] as Map), + titleMedium: json['titleMedium'] == null + ? null + : MiraiTextStyle.fromJson( + json['titleMedium'] as Map), + titleSmall: json['titleSmall'] == null + ? null + : MiraiTextStyle.fromJson(json['titleSmall'] as Map), + bodyLarge: json['bodyLarge'] == null + ? null + : MiraiTextStyle.fromJson(json['bodyLarge'] as Map), + bodyMedium: json['bodyMedium'] == null + ? null + : MiraiTextStyle.fromJson(json['bodyMedium'] as Map), + bodySmall: json['bodySmall'] == null + ? null + : MiraiTextStyle.fromJson(json['bodySmall'] as Map), + labelLarge: json['labelLarge'] == null + ? null + : MiraiTextStyle.fromJson(json['labelLarge'] as Map), + labelMedium: json['labelMedium'] == null + ? null + : MiraiTextStyle.fromJson( + json['labelMedium'] as Map), + labelSmall: json['labelSmall'] == null + ? null + : MiraiTextStyle.fromJson(json['labelSmall'] as Map), + ); + +Map _$$_MiraiTextThemeToJson(_$_MiraiTextTheme instance) => + { + 'displayLarge': instance.displayLarge, + 'displayMedium': instance.displayMedium, + 'displaySmall': instance.displaySmall, + 'headlineLarge': instance.headlineLarge, + 'headlineMedium': instance.headlineMedium, + 'headlineSmall': instance.headlineSmall, + 'titleLarge': instance.titleLarge, + 'titleMedium': instance.titleMedium, + 'titleSmall': instance.titleSmall, + 'bodyLarge': instance.bodyLarge, + 'bodyMedium': instance.bodyMedium, + 'bodySmall': instance.bodySmall, + 'labelLarge': instance.labelLarge, + 'labelMedium': instance.labelMedium, + 'labelSmall': instance.labelSmall, + }; diff --git a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.dart b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.dart index 0ba4972b..d9ab6bf7 100644 --- a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.dart +++ b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.dart @@ -4,9 +4,11 @@ import 'package:mirai/mirai.dart'; import 'package:mirai/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.dart'; import 'package:mirai/src/parsers/mirai_bottom_sheet_theme/mirai_bottom_sheet_theme.dart'; import 'package:mirai/src/parsers/mirai_color_scheme/mirai_color_scheme.dart'; +import 'package:mirai/src/parsers/mirai_font_family/mirai_font_family.dart'; import 'package:mirai/src/parsers/mirai_icon_theme_data/mirai_icon_theme_data.dart'; import 'package:mirai/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.dart'; import 'package:mirai/src/parsers/mirai_material_color/mirai_material_color.dart'; +import 'package:mirai/src/parsers/mirai_text_theme/mirai_text_theme.dart'; import 'package:mirai/src/utils/color_utils.dart'; part 'mirai_theme.freezed.dart'; @@ -39,9 +41,11 @@ class MiraiTheme with _$MiraiTheme { String? secondaryHeaderColor, String? shadowColor, String? splashColor, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, + MiraiTextTheme? textTheme, + MiraiTextTheme? primaryTextTheme, String? unselectedWidgetColor, - String? fontFamily, - List? fontFamilyFallback, MiraiAppBarTheme? appBarTheme, MiraiButtonStyle? elevatedButtonTheme, MiraiButtonStyle? outlinedButtonTheme, @@ -65,7 +69,7 @@ class MiraiTheme with _$MiraiTheme { } extension MiraiThemeParser on MiraiTheme { - ThemeData? get parse { + ThemeData? parse(BuildContext context) { return ThemeData( applyElevationOverlayColor: applyElevationOverlayColor, inputDecorationTheme: inputDecorationTheme.parse, @@ -89,9 +93,13 @@ extension MiraiThemeParser on MiraiTheme { secondaryHeaderColor: secondaryHeaderColor.toColor, shadowColor: shadowColor.toColor, splashColor: splashColor.toColor, + fontFamily: fontFamily?.parse, + fontFamilyFallback: fontFamilyFallback + ?.map((family) => family.parse ?? "Roboto") + .toList(), + textTheme: textTheme?.parse, + primaryTextTheme: primaryTextTheme?.parse, unselectedWidgetColor: unselectedWidgetColor.toColor, - fontFamily: fontFamily, - fontFamilyFallback: fontFamilyFallback, primarySwatch: primarySwatch?.parse, appBarTheme: appBarTheme?.parse, elevatedButtonTheme: diff --git a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.freezed.dart b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.freezed.dart index 4e35f8b0..accaef44 100644 --- a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.freezed.dart @@ -45,9 +45,12 @@ mixin _$MiraiTheme { String? get secondaryHeaderColor => throw _privateConstructorUsedError; String? get shadowColor => throw _privateConstructorUsedError; String? get splashColor => throw _privateConstructorUsedError; + MiraiFontFamily? get fontFamily => throw _privateConstructorUsedError; + List? get fontFamilyFallback => + throw _privateConstructorUsedError; + MiraiTextTheme? get textTheme => throw _privateConstructorUsedError; + MiraiTextTheme? get primaryTextTheme => throw _privateConstructorUsedError; String? get unselectedWidgetColor => throw _privateConstructorUsedError; - String? get fontFamily => throw _privateConstructorUsedError; - List? get fontFamilyFallback => throw _privateConstructorUsedError; MiraiAppBarTheme? get appBarTheme => throw _privateConstructorUsedError; MiraiButtonStyle? get elevatedButtonTheme => throw _privateConstructorUsedError; @@ -111,9 +114,11 @@ abstract class $MiraiThemeCopyWith<$Res> { String? secondaryHeaderColor, String? shadowColor, String? splashColor, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, + MiraiTextTheme? textTheme, + MiraiTextTheme? primaryTextTheme, String? unselectedWidgetColor, - String? fontFamily, - List? fontFamilyFallback, MiraiAppBarTheme? appBarTheme, MiraiButtonStyle? elevatedButtonTheme, MiraiButtonStyle? outlinedButtonTheme, @@ -134,6 +139,9 @@ abstract class $MiraiThemeCopyWith<$Res> { $MiraiInputDecorationThemeCopyWith<$Res>? get inputDecorationTheme; $MiraiColorSchemeCopyWith<$Res>? get colorScheme; $MiraiMaterialColorCopyWith<$Res>? get primarySwatch; + $MiraiFontFamilyCopyWith<$Res>? get fontFamily; + $MiraiTextThemeCopyWith<$Res>? get textTheme; + $MiraiTextThemeCopyWith<$Res>? get primaryTextTheme; $MiraiAppBarThemeCopyWith<$Res>? get appBarTheme; $MiraiButtonStyleCopyWith<$Res>? get elevatedButtonTheme; $MiraiButtonStyleCopyWith<$Res>? get outlinedButtonTheme; @@ -190,9 +198,11 @@ class _$MiraiThemeCopyWithImpl<$Res, $Val extends MiraiTheme> Object? secondaryHeaderColor = freezed, Object? shadowColor = freezed, Object? splashColor = freezed, - Object? unselectedWidgetColor = freezed, Object? fontFamily = freezed, Object? fontFamilyFallback = freezed, + Object? textTheme = freezed, + Object? primaryTextTheme = freezed, + Object? unselectedWidgetColor = freezed, Object? appBarTheme = freezed, Object? elevatedButtonTheme = freezed, Object? outlinedButtonTheme = freezed, @@ -307,18 +317,26 @@ class _$MiraiThemeCopyWithImpl<$Res, $Val extends MiraiTheme> ? _value.splashColor : splashColor // ignore: cast_nullable_to_non_nullable as String?, - unselectedWidgetColor: freezed == unselectedWidgetColor - ? _value.unselectedWidgetColor - : unselectedWidgetColor // ignore: cast_nullable_to_non_nullable - as String?, fontFamily: freezed == fontFamily ? _value.fontFamily : fontFamily // ignore: cast_nullable_to_non_nullable - as String?, + as MiraiFontFamily?, fontFamilyFallback: freezed == fontFamilyFallback ? _value.fontFamilyFallback : fontFamilyFallback // ignore: cast_nullable_to_non_nullable - as List?, + as List?, + textTheme: freezed == textTheme + ? _value.textTheme + : textTheme // ignore: cast_nullable_to_non_nullable + as MiraiTextTheme?, + primaryTextTheme: freezed == primaryTextTheme + ? _value.primaryTextTheme + : primaryTextTheme // ignore: cast_nullable_to_non_nullable + as MiraiTextTheme?, + unselectedWidgetColor: freezed == unselectedWidgetColor + ? _value.unselectedWidgetColor + : unselectedWidgetColor // ignore: cast_nullable_to_non_nullable + as String?, appBarTheme: freezed == appBarTheme ? _value.appBarTheme : appBarTheme // ignore: cast_nullable_to_non_nullable @@ -423,6 +441,42 @@ class _$MiraiThemeCopyWithImpl<$Res, $Val extends MiraiTheme> }); } + @override + @pragma('vm:prefer-inline') + $MiraiFontFamilyCopyWith<$Res>? get fontFamily { + if (_value.fontFamily == null) { + return null; + } + + return $MiraiFontFamilyCopyWith<$Res>(_value.fontFamily!, (value) { + return _then(_value.copyWith(fontFamily: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextThemeCopyWith<$Res>? get textTheme { + if (_value.textTheme == null) { + return null; + } + + return $MiraiTextThemeCopyWith<$Res>(_value.textTheme!, (value) { + return _then(_value.copyWith(textTheme: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTextThemeCopyWith<$Res>? get primaryTextTheme { + if (_value.primaryTextTheme == null) { + return null; + } + + return $MiraiTextThemeCopyWith<$Res>(_value.primaryTextTheme!, (value) { + return _then(_value.copyWith(primaryTextTheme: value) as $Val); + }); + } + @override @pragma('vm:prefer-inline') $MiraiAppBarThemeCopyWith<$Res>? get appBarTheme { @@ -658,9 +712,11 @@ abstract class _$$_MiraiThemeCopyWith<$Res> String? secondaryHeaderColor, String? shadowColor, String? splashColor, + MiraiFontFamily? fontFamily, + List? fontFamilyFallback, + MiraiTextTheme? textTheme, + MiraiTextTheme? primaryTextTheme, String? unselectedWidgetColor, - String? fontFamily, - List? fontFamilyFallback, MiraiAppBarTheme? appBarTheme, MiraiButtonStyle? elevatedButtonTheme, MiraiButtonStyle? outlinedButtonTheme, @@ -685,6 +741,12 @@ abstract class _$$_MiraiThemeCopyWith<$Res> @override $MiraiMaterialColorCopyWith<$Res>? get primarySwatch; @override + $MiraiFontFamilyCopyWith<$Res>? get fontFamily; + @override + $MiraiTextThemeCopyWith<$Res>? get textTheme; + @override + $MiraiTextThemeCopyWith<$Res>? get primaryTextTheme; + @override $MiraiAppBarThemeCopyWith<$Res>? get appBarTheme; @override $MiraiButtonStyleCopyWith<$Res>? get elevatedButtonTheme; @@ -754,9 +816,11 @@ class __$$_MiraiThemeCopyWithImpl<$Res> Object? secondaryHeaderColor = freezed, Object? shadowColor = freezed, Object? splashColor = freezed, - Object? unselectedWidgetColor = freezed, Object? fontFamily = freezed, Object? fontFamilyFallback = freezed, + Object? textTheme = freezed, + Object? primaryTextTheme = freezed, + Object? unselectedWidgetColor = freezed, Object? appBarTheme = freezed, Object? elevatedButtonTheme = freezed, Object? outlinedButtonTheme = freezed, @@ -871,18 +935,26 @@ class __$$_MiraiThemeCopyWithImpl<$Res> ? _value.splashColor : splashColor // ignore: cast_nullable_to_non_nullable as String?, - unselectedWidgetColor: freezed == unselectedWidgetColor - ? _value.unselectedWidgetColor - : unselectedWidgetColor // ignore: cast_nullable_to_non_nullable - as String?, fontFamily: freezed == fontFamily ? _value.fontFamily : fontFamily // ignore: cast_nullable_to_non_nullable - as String?, + as MiraiFontFamily?, fontFamilyFallback: freezed == fontFamilyFallback ? _value._fontFamilyFallback : fontFamilyFallback // ignore: cast_nullable_to_non_nullable - as List?, + as List?, + textTheme: freezed == textTheme + ? _value.textTheme + : textTheme // ignore: cast_nullable_to_non_nullable + as MiraiTextTheme?, + primaryTextTheme: freezed == primaryTextTheme + ? _value.primaryTextTheme + : primaryTextTheme // ignore: cast_nullable_to_non_nullable + as MiraiTextTheme?, + unselectedWidgetColor: freezed == unselectedWidgetColor + ? _value.unselectedWidgetColor + : unselectedWidgetColor // ignore: cast_nullable_to_non_nullable + as String?, appBarTheme: freezed == appBarTheme ? _value.appBarTheme : appBarTheme // ignore: cast_nullable_to_non_nullable @@ -979,9 +1051,11 @@ class _$_MiraiTheme implements _MiraiTheme { this.secondaryHeaderColor, this.shadowColor, this.splashColor, - this.unselectedWidgetColor, this.fontFamily, - final List? fontFamilyFallback, + final List? fontFamilyFallback, + this.textTheme, + this.primaryTextTheme, + this.unselectedWidgetColor, this.appBarTheme, this.elevatedButtonTheme, this.outlinedButtonTheme, @@ -1052,12 +1126,10 @@ class _$_MiraiTheme implements _MiraiTheme { @override final String? splashColor; @override - final String? unselectedWidgetColor; - @override - final String? fontFamily; - final List? _fontFamilyFallback; + final MiraiFontFamily? fontFamily; + final List? _fontFamilyFallback; @override - List? get fontFamilyFallback { + List? get fontFamilyFallback { final value = _fontFamilyFallback; if (value == null) return null; if (_fontFamilyFallback is EqualUnmodifiableListView) @@ -1066,6 +1138,12 @@ class _$_MiraiTheme implements _MiraiTheme { return EqualUnmodifiableListView(value); } + @override + final MiraiTextTheme? textTheme; + @override + final MiraiTextTheme? primaryTextTheme; + @override + final String? unselectedWidgetColor; @override final MiraiAppBarTheme? appBarTheme; @override @@ -1101,7 +1179,7 @@ class _$_MiraiTheme implements _MiraiTheme { @override String toString() { - return 'MiraiTheme(applyElevationOverlayColor: $applyElevationOverlayColor, inputDecorationTheme: $inputDecorationTheme, useMaterial3: $useMaterial3, brightness: $brightness, canvasColor: $canvasColor, cardColor: $cardColor, colorScheme: $colorScheme, colorSchemeSeed: $colorSchemeSeed, dialogBackgroundColor: $dialogBackgroundColor, disabledColor: $disabledColor, dividerColor: $dividerColor, focusColor: $focusColor, highlightColor: $highlightColor, hintColor: $hintColor, hoverColor: $hoverColor, indicatorColor: $indicatorColor, primaryColor: $primaryColor, primaryColorDark: $primaryColorDark, primaryColorLight: $primaryColorLight, primarySwatch: $primarySwatch, scaffoldBackgroundColor: $scaffoldBackgroundColor, secondaryHeaderColor: $secondaryHeaderColor, shadowColor: $shadowColor, splashColor: $splashColor, unselectedWidgetColor: $unselectedWidgetColor, fontFamily: $fontFamily, fontFamilyFallback: $fontFamilyFallback, appBarTheme: $appBarTheme, elevatedButtonTheme: $elevatedButtonTheme, outlinedButtonTheme: $outlinedButtonTheme, iconButtonTheme: $iconButtonTheme, iconTheme: $iconTheme, primaryIconTheme: $primaryIconTheme, dialogTheme: $dialogTheme, floatingActionButtonTheme: $floatingActionButtonTheme, textButtonTheme: $textButtonTheme, bottomAppBarTheme: $bottomAppBarTheme, bottomNavigationBarTheme: $bottomNavigationBarTheme, bottomSheetTheme: $bottomSheetTheme, cardTheme: $cardTheme, listTileTheme: $listTileTheme, navigationBarTheme: $navigationBarTheme, tabBarTheme: $tabBarTheme)'; + return 'MiraiTheme(applyElevationOverlayColor: $applyElevationOverlayColor, inputDecorationTheme: $inputDecorationTheme, useMaterial3: $useMaterial3, brightness: $brightness, canvasColor: $canvasColor, cardColor: $cardColor, colorScheme: $colorScheme, colorSchemeSeed: $colorSchemeSeed, dialogBackgroundColor: $dialogBackgroundColor, disabledColor: $disabledColor, dividerColor: $dividerColor, focusColor: $focusColor, highlightColor: $highlightColor, hintColor: $hintColor, hoverColor: $hoverColor, indicatorColor: $indicatorColor, primaryColor: $primaryColor, primaryColorDark: $primaryColorDark, primaryColorLight: $primaryColorLight, primarySwatch: $primarySwatch, scaffoldBackgroundColor: $scaffoldBackgroundColor, secondaryHeaderColor: $secondaryHeaderColor, shadowColor: $shadowColor, splashColor: $splashColor, fontFamily: $fontFamily, fontFamilyFallback: $fontFamilyFallback, textTheme: $textTheme, primaryTextTheme: $primaryTextTheme, unselectedWidgetColor: $unselectedWidgetColor, appBarTheme: $appBarTheme, elevatedButtonTheme: $elevatedButtonTheme, outlinedButtonTheme: $outlinedButtonTheme, iconButtonTheme: $iconButtonTheme, iconTheme: $iconTheme, primaryIconTheme: $primaryIconTheme, dialogTheme: $dialogTheme, floatingActionButtonTheme: $floatingActionButtonTheme, textButtonTheme: $textButtonTheme, bottomAppBarTheme: $bottomAppBarTheme, bottomNavigationBarTheme: $bottomNavigationBarTheme, bottomSheetTheme: $bottomSheetTheme, cardTheme: $cardTheme, listTileTheme: $listTileTheme, navigationBarTheme: $navigationBarTheme, tabBarTheme: $tabBarTheme)'; } @override @@ -1158,22 +1236,24 @@ class _$_MiraiTheme implements _MiraiTheme { other.shadowColor == shadowColor) && (identical(other.splashColor, splashColor) || other.splashColor == splashColor) && - (identical(other.unselectedWidgetColor, unselectedWidgetColor) || - other.unselectedWidgetColor == unselectedWidgetColor) && (identical(other.fontFamily, fontFamily) || other.fontFamily == fontFamily) && const DeepCollectionEquality() .equals(other._fontFamilyFallback, _fontFamilyFallback) && + (identical(other.textTheme, textTheme) || + other.textTheme == textTheme) && + (identical(other.primaryTextTheme, primaryTextTheme) || + other.primaryTextTheme == primaryTextTheme) && + (identical(other.unselectedWidgetColor, unselectedWidgetColor) || + other.unselectedWidgetColor == unselectedWidgetColor) && (identical(other.appBarTheme, appBarTheme) || other.appBarTheme == appBarTheme) && (identical(other.elevatedButtonTheme, elevatedButtonTheme) || other.elevatedButtonTheme == elevatedButtonTheme) && (identical(other.outlinedButtonTheme, outlinedButtonTheme) || other.outlinedButtonTheme == outlinedButtonTheme) && - (identical(other.iconButtonTheme, iconButtonTheme) || - other.iconButtonTheme == iconButtonTheme) && - (identical(other.iconTheme, iconTheme) || - other.iconTheme == iconTheme) && + (identical(other.iconButtonTheme, iconButtonTheme) || other.iconButtonTheme == iconButtonTheme) && + (identical(other.iconTheme, iconTheme) || other.iconTheme == iconTheme) && (identical(other.primaryIconTheme, primaryIconTheme) || other.primaryIconTheme == primaryIconTheme) && (identical(other.dialogTheme, dialogTheme) || other.dialogTheme == dialogTheme) && (identical(other.floatingActionButtonTheme, floatingActionButtonTheme) || other.floatingActionButtonTheme == floatingActionButtonTheme) && @@ -1215,9 +1295,11 @@ class _$_MiraiTheme implements _MiraiTheme { secondaryHeaderColor, shadowColor, splashColor, - unselectedWidgetColor, fontFamily, const DeepCollectionEquality().hash(_fontFamilyFallback), + textTheme, + primaryTextTheme, + unselectedWidgetColor, appBarTheme, elevatedButtonTheme, outlinedButtonTheme, @@ -1276,9 +1358,11 @@ abstract class _MiraiTheme implements MiraiTheme { final String? secondaryHeaderColor, final String? shadowColor, final String? splashColor, + final MiraiFontFamily? fontFamily, + final List? fontFamilyFallback, + final MiraiTextTheme? textTheme, + final MiraiTextTheme? primaryTextTheme, final String? unselectedWidgetColor, - final String? fontFamily, - final List? fontFamilyFallback, final MiraiAppBarTheme? appBarTheme, final MiraiButtonStyle? elevatedButtonTheme, final MiraiButtonStyle? outlinedButtonTheme, @@ -1348,11 +1432,15 @@ abstract class _MiraiTheme implements MiraiTheme { @override String? get splashColor; @override - String? get unselectedWidgetColor; + MiraiFontFamily? get fontFamily; + @override + List? get fontFamilyFallback; @override - String? get fontFamily; + MiraiTextTheme? get textTheme; @override - List? get fontFamilyFallback; + MiraiTextTheme? get primaryTextTheme; + @override + String? get unselectedWidgetColor; @override MiraiAppBarTheme? get appBarTheme; @override diff --git a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.g.dart b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.g.dart index 43106812..e233a154 100644 --- a/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.g.dart @@ -41,11 +41,21 @@ _$_MiraiTheme _$$_MiraiThemeFromJson(Map json) => secondaryHeaderColor: json['secondaryHeaderColor'] as String?, shadowColor: json['shadowColor'] as String?, splashColor: json['splashColor'] as String?, - unselectedWidgetColor: json['unselectedWidgetColor'] as String?, - fontFamily: json['fontFamily'] as String?, + fontFamily: json['fontFamily'] == null + ? null + : MiraiFontFamily.fromJson( + json['fontFamily'] as Map), fontFamilyFallback: (json['fontFamilyFallback'] as List?) - ?.map((e) => e as String) + ?.map((e) => MiraiFontFamily.fromJson(e as Map)) .toList(), + textTheme: json['textTheme'] == null + ? null + : MiraiTextTheme.fromJson(json['textTheme'] as Map), + primaryTextTheme: json['primaryTextTheme'] == null + ? null + : MiraiTextTheme.fromJson( + json['primaryTextTheme'] as Map), + unselectedWidgetColor: json['unselectedWidgetColor'] as String?, appBarTheme: json['appBarTheme'] == null ? null : MiraiAppBarTheme.fromJson( @@ -138,9 +148,11 @@ Map _$$_MiraiThemeToJson(_$_MiraiTheme instance) => 'secondaryHeaderColor': instance.secondaryHeaderColor, 'shadowColor': instance.shadowColor, 'splashColor': instance.splashColor, - 'unselectedWidgetColor': instance.unselectedWidgetColor, 'fontFamily': instance.fontFamily, 'fontFamilyFallback': instance.fontFamilyFallback, + 'textTheme': instance.textTheme, + 'primaryTextTheme': instance.primaryTextTheme, + 'unselectedWidgetColor': instance.unselectedWidgetColor, 'appBarTheme': instance.appBarTheme, 'elevatedButtonTheme': instance.elevatedButtonTheme, 'outlinedButtonTheme': instance.outlinedButtonTheme, diff --git a/packages/mirai/pubspec.yaml b/packages/mirai/pubspec.yaml index 392f7e57..d1f06317 100644 --- a/packages/mirai/pubspec.yaml +++ b/packages/mirai/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: json_annotation: ^4.8.1 logger: ^1.4.0 dio: ^5.2.0+1 + google_fonts: ^5.1.0 dev_dependencies: flutter_test: