This commit is contained in:
agra
2026-01-16 14:11:34 +02:00
commit 2b39c6e17f
155 changed files with 5966 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
import UIKit
import HardwareC
// Known corner radius values for iOS devices (used on simulator)
private let deviceCornerRadii: [String: Double] = [
// 39.0 - iPhone X, Xs, Xs Max, 11 Pro, 11 Pro Max
"iPhone10,3": 39.0, "iPhone10,6": 39.0, // iPhone X
"iPhone11,2": 39.0, // iPhone Xs
"iPhone11,4": 39.0, "iPhone11,6": 39.0, // iPhone Xs Max
"iPhone12,3": 39.0, // iPhone 11 Pro
"iPhone12,5": 39.0, // iPhone 11 Pro Max
// 41.5 - iPhone Xr, 11
"iPhone11,8": 41.5, // iPhone Xr
"iPhone12,1": 41.5, // iPhone 11
// 44.0 - iPhone 12 mini, 13 mini
"iPhone13,1": 44.0, // iPhone 12 mini
"iPhone14,4": 44.0, // iPhone 13 mini
// 47.33 - iPhone 12, 12 Pro, 13, 13 Pro, 14, 16e
"iPhone13,2": 47.33, // iPhone 12
"iPhone13,3": 47.33, // iPhone 12 Pro
"iPhone14,5": 47.33, // iPhone 13
"iPhone14,2": 47.33, // iPhone 13 Pro
"iPhone14,7": 47.33, // iPhone 14
"iPhone17,5": 47.33, // iPhone 16e
// 53.33 - iPhone 12 Pro Max, 13 Pro Max, 14 Plus
"iPhone13,4": 53.33, // iPhone 12 Pro Max
"iPhone14,3": 53.33, // iPhone 13 Pro Max
"iPhone14,8": 53.33, // iPhone 14 Plus
// 55.0 - iPhone 14 Pro, 14 Pro Max, 15, 15 Plus, 15 Pro, 15 Pro Max, 16, 16 Plus
"iPhone15,2": 55.0, // iPhone 14 Pro
"iPhone15,3": 55.0, // iPhone 14 Pro Max
"iPhone15,4": 55.0, // iPhone 15
"iPhone15,5": 55.0, // iPhone 15 Plus
"iPhone16,1": 55.0, // iPhone 15 Pro
"iPhone16,2": 55.0, // iPhone 15 Pro Max
"iPhone17,1": 55.0, // iPhone 16
"iPhone17,2": 55.0, // iPhone 16 Plus
// 62.0 - iPhone 16 Pro, 16 Pro Max, 17, 17 Pro, 17 Pro Max, Air
"iPhone17,3": 62.0, // iPhone 16 Pro
"iPhone17,4": 62.0, // iPhone 16 Pro Max
"iPhone18,1": 62.0, // iPhone 17
"iPhone18,2": 62.0, // iPhone 17 Pro
"iPhone18,3": 62.0, // iPhone 17 Pro Max
"iPhone18,4": 62.0, // iPhone Air
// 18.0 - iPad Air / iPad Pro 11-inch / 12.9-inch
"iPad8,1": 18.0, "iPad8,2": 18.0, "iPad8,3": 18.0, "iPad8,4": 18.0, // iPad Pro 11-inch 1st gen
"iPad8,5": 18.0, "iPad8,6": 18.0, "iPad8,7": 18.0, "iPad8,8": 18.0, // iPad Pro 12.9-inch 3rd gen
"iPad8,9": 18.0, "iPad8,10": 18.0, // iPad Pro 11-inch 2nd gen
"iPad8,11": 18.0, "iPad8,12": 18.0, // iPad Pro 12.9-inch 4th gen
"iPad13,4": 18.0, "iPad13,5": 18.0, "iPad13,6": 18.0, "iPad13,7": 18.0, // iPad Pro 11-inch 3rd gen
"iPad13,8": 18.0, "iPad13,9": 18.0, "iPad13,10": 18.0, "iPad13,11": 18.0, // iPad Pro 12.9-inch 5th gen
"iPad13,16": 18.0, "iPad13,17": 18.0, // iPad Air 5th gen
"iPad14,3": 18.0, "iPad14,4": 18.0, // iPad Pro 11-inch 4th gen
"iPad14,5": 18.0, "iPad14,6": 18.0, // iPad Pro 12.9-inch 6th gen
]
private func getDeviceIdentifier() -> String {
#if targetEnvironment(simulator)
// On simulator, use the SIMULATOR_MODEL_IDENTIFIER environment variable
// uname() returns host architecture (e.g., "arm64") instead of device model
return ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] ?? ""
#else
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
return identifier
#endif
}
@_cdecl("get_screen_border_radius")
public func getScreenBorderRadius() -> DoubleOption {
var result = DoubleOption()
// Use device identifier lookup for both simulator and real devices
// There is no public API for displayCornerRadius on UIScreen
let identifier = getDeviceIdentifier()
if let radius = deviceCornerRadii[identifier] {
result.value = radius
result.hasValue = 1
} else {
result.value = 0
result.hasValue = 0
}
return result
}

View File

@@ -0,0 +1,4 @@
module HardwareC {
header "../../src/hardware.h"
export *
}

33
ios/hardware.podspec Normal file
View File

@@ -0,0 +1,33 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint hardware.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'hardware'
s.version = '0.0.1'
s.summary = 'A new Flutter FFI plugin project.'
s.description = <<-DESC
A new Flutter FFI plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
# This will ensure the source files in Classes/ are included in the native
# builds of apps using this FFI plugin. Podspec does not support relative
# paths, so Classes contains a forwarder C file that relatively imports
# `../src/*` so that the C sources can be shared among all target platforms.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*.swift'
s.preserve_paths = 'Classes/module.modulemap'
s.dependency 'Flutter'
s.platform = :ios, '13.0'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/Classes'
}
s.swift_version = '5.0'
end