Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
70 changes: 70 additions & 0 deletions ios/Classes/ProImageEditorPlugin.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}
23 changes: 23 additions & 0 deletions ios/pro_image_editor.podspec
Original file line number Diff line number Diff line change
@@ -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
70 changes: 70 additions & 0 deletions macos/Classes/ProImageEditorPlugin.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}
22 changes: 22 additions & 0 deletions macos/pro_image_editor.podspec
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
Loading