diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5f8122..4d8373b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 12.0.10 +- **FIX**(iOS, macOS): Restore CocoaPods compatibility for the native Darwin plugin alongside Swift Package Manager support. + ## 12.0.9 - **FIX**(text-editor): Disable system text scale factor in `RoundedBackgroundTextField` to ensure consistent text sizing regardless of user accessibility settings. diff --git a/ios/Classes/ProImageEditorPlugin.swift b/ios/Classes/ProImageEditorPlugin.swift new file mode 100644 index 00000000..a08a7a0a --- /dev/null +++ b/ios/Classes/ProImageEditorPlugin.swift @@ -0,0 +1,70 @@ +import Foundation +import Flutter +import UIKit + +public class ProImageEditorPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let messenger = registrar.messenger() + + let channel = FlutterMethodChannel( + name: "pro_image_editor", + binaryMessenger: messenger + ) + let instance = ProImageEditorPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "getSupportedEmojis": + guard let args = call.arguments as? [String: Any], + let source = args["source"] as? [String] else { + result(FlutterError( + code: "INVALID_ARGUMENTS", + message: "Expected 'source' list of strings", + details: nil + )) + return + } + + let supportedList = source.map { emoji -> Bool in + return isEmojiSupported(emoji) + } + result(supportedList) + + default: + result(FlutterMethodNotImplemented) + } + } + + private func isEmojiSupported(_ emoji: String) -> Bool { + let font = UIFont.systemFont(ofSize: 12) + + let attributedString = NSAttributedString( + string: emoji, + attributes: [.font: font] + ) + + let line = CTLineCreateWithAttributedString(attributedString) + let glyphCount = CTLineGetGlyphCount(line) + + // If emoji is rendered as multiple glyphs or no glyphs, it's not supported + // A properly supported emoji should render as a single glyph + return glyphCount > 0 && !emoji.unicodeScalars.contains { scalar in + let string = String(scalar) + let attrStr = NSAttributedString( + string: string, + attributes: [.font: font] + ) + let singleLine = CTLineCreateWithAttributedString(attrStr) + let runs = CTLineGetGlyphRuns(singleLine) as! [CTRun] + + guard let run = runs.first else { return true } + var glyph: CGGlyph = 0 + CTRunGetGlyphs(run, CFRangeMake(0, 1), &glyph) + + // Glyph 0 typically means the character is not supported + return glyph == 0 + } + } +} diff --git a/ios/pro_image_editor.podspec b/ios/pro_image_editor.podspec new file mode 100644 index 00000000..cdb4918c --- /dev/null +++ b/ios/pro_image_editor.podspec @@ -0,0 +1,23 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint pro_image_editor.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'pro_image_editor' + s.version = '12.0.8' + s.summary = 'A Flutter image editor plugin.' + s.description = <<-DESC +A Flutter image editor: Seamlessly enhance your images with user-friendly editing features. + DESC + s.homepage = 'https://github.com/hm21/pro_image_editor' + s.license = { :file => '../LICENSE' } + s.author = { 'hm21' => 'info@waio.ch' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'Flutter' + s.platform = :ios, '12.0' + + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } + s.swift_version = '5.0' +end diff --git a/macos/Classes/ProImageEditorPlugin.swift b/macos/Classes/ProImageEditorPlugin.swift new file mode 100644 index 00000000..6789f021 --- /dev/null +++ b/macos/Classes/ProImageEditorPlugin.swift @@ -0,0 +1,70 @@ +import Foundation +import FlutterMacOS +import AppKit + +public class ProImageEditorPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let messenger = registrar.messenger + + let channel = FlutterMethodChannel( + name: "pro_image_editor", + binaryMessenger: messenger + ) + let instance = ProImageEditorPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "getSupportedEmojis": + guard let args = call.arguments as? [String: Any], + let source = args["source"] as? [String] else { + result(FlutterError( + code: "INVALID_ARGUMENTS", + message: "Expected 'source' list of strings", + details: nil + )) + return + } + + let supportedList = source.map { emoji -> Bool in + return isEmojiSupported(emoji) + } + result(supportedList) + + default: + result(FlutterMethodNotImplemented) + } + } + + private func isEmojiSupported(_ emoji: String) -> Bool { + let font = NSFont.systemFont(ofSize: 12) + + let attributedString = NSAttributedString( + string: emoji, + attributes: [.font: font] + ) + + let line = CTLineCreateWithAttributedString(attributedString) + let glyphCount = CTLineGetGlyphCount(line) + + // If emoji is rendered as multiple glyphs or no glyphs, it's not supported + // A properly supported emoji should render as a single glyph + return glyphCount > 0 && !emoji.unicodeScalars.contains { scalar in + let string = String(scalar) + let attrStr = NSAttributedString( + string: string, + attributes: [.font: font] + ) + let singleLine = CTLineCreateWithAttributedString(attrStr) + let runs = CTLineGetGlyphRuns(singleLine) as! [CTRun] + + guard let run = runs.first else { return true } + var glyph: CGGlyph = 0 + CTRunGetGlyphs(run, CFRangeMake(0, 1), &glyph) + + // Glyph 0 typically means the character is not supported + return glyph == 0 + } + } +} diff --git a/macos/pro_image_editor.podspec b/macos/pro_image_editor.podspec new file mode 100644 index 00000000..66a4609d --- /dev/null +++ b/macos/pro_image_editor.podspec @@ -0,0 +1,22 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint pro_image_editor.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'pro_image_editor' + s.version = '12.0.8' + s.summary = 'A Flutter image editor plugin.' + s.description = <<-DESC +A Flutter image editor: Seamlessly enhance your images with user-friendly editing features. + DESC + s.homepage = 'https://github.com/hm21/pro_image_editor' + s.license = { :file => '../LICENSE' } + s.author = { 'hm21' => 'info@waio.ch' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'FlutterMacOS' + s.platform = :osx, '10.14' + + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } + s.swift_version = '5.0' +end diff --git a/pubspec.yaml b/pubspec.yaml index 42ede319..6aaa972f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pro_image_editor description: "A Flutter image editor: Seamlessly enhance your images with user-friendly editing features." -version: 12.0.9 +version: 12.0.10 homepage: https://github.com/hm21/pro_image_editor/ repository: https://github.com/hm21/pro_image_editor/ documentation: https://github.com/hm21/pro_image_editor/