mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Moved dictionary extension to separate file
commit_hash:b84d9d9539d3c41f922b158e1274cb6257d80a35
This commit is contained in:
@@ -13866,6 +13866,7 @@
|
||||
"client/ios/DivKitExtensions/ExtensionHandlers/PinchToZoomExtensionHandler.swift":"divkit/public/client/ios/DivKitExtensions/ExtensionHandlers/PinchToZoomExtensionHandler.swift",
|
||||
"client/ios/DivKitExtensions/ExtensionHandlers/TextExtensionHandler.swift":"divkit/public/client/ios/DivKitExtensions/ExtensionHandlers/TextExtensionHandler.swift",
|
||||
"client/ios/DivKitExtensions/ExtensionHandlers/VideoDurationExtensionHandler.swift":"divkit/public/client/ios/DivKitExtensions/ExtensionHandlers/VideoDurationExtensionHandler.swift",
|
||||
"client/ios/DivKitExtensions/Serialization+Extensions.swift":"divkit/public/client/ios/DivKitExtensions/Serialization+Extensions.swift",
|
||||
"client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewExtension.swift":"divkit/public/client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewExtension.swift",
|
||||
"client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewStyle.swift":"divkit/public/client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewStyle.swift",
|
||||
"client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewView.swift":"divkit/public/client/ios/DivKitExtensions/Shimmers/Shimmer/ShimmerImagePreviewView.swift",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import DivKit
|
||||
import Foundation
|
||||
|
||||
extension Dictionary where Key == String {
|
||||
func getOptionalBool(
|
||||
_ key: Key,
|
||||
expressionResolver: ExpressionResolver
|
||||
) throws -> Bool? {
|
||||
let result: Bool?
|
||||
if let value = self[key] as? Bool {
|
||||
result = value
|
||||
} else if let expression: String = try getOptionalField(key) {
|
||||
result = expressionResolver.resolve(expression) as? Bool
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getOptionalFloat(
|
||||
_ key: Key,
|
||||
expressionResolver: ExpressionResolver
|
||||
) throws -> CGFloat? {
|
||||
let result: Double?
|
||||
if let value = self[key] as? Double {
|
||||
result = value
|
||||
} else if let value = self[key] as? Int {
|
||||
result = Double(value)
|
||||
} else if let expression: String = try getOptionalField(key) {
|
||||
result = expressionResolver.resolveNumeric(expression)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return result.map { CGFloat($0) }
|
||||
}
|
||||
}
|
||||
@@ -41,38 +41,6 @@ extension DivBase {
|
||||
}
|
||||
|
||||
extension Dictionary where Key == String {
|
||||
func getOptionalBool(
|
||||
_ key: Key,
|
||||
expressionResolver: ExpressionResolver
|
||||
) throws -> Bool? {
|
||||
let result: Bool?
|
||||
if let value = self[key] as? Bool {
|
||||
result = value
|
||||
} else if let expression: String = try getOptionalField(key) {
|
||||
result = expressionResolver.resolve(expression) as? Bool
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getOptionalFloat(
|
||||
_ key: Key,
|
||||
expressionResolver: ExpressionResolver
|
||||
) throws -> CGFloat? {
|
||||
let result: Double?
|
||||
if let value = self[key] as? Double {
|
||||
result = value
|
||||
} else if let value = self[key] as? Int {
|
||||
result = Double(value)
|
||||
} else if let expression: String = try getOptionalField(key) {
|
||||
result = expressionResolver.resolveNumeric(expression)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return result.map { CGFloat($0) }
|
||||
}
|
||||
|
||||
func getOptionalColorArray(
|
||||
_ key: Key,
|
||||
expressionResolver: ExpressionResolver
|
||||
|
||||
@@ -278,6 +278,20 @@ final class TooltipWindowManager {
|
||||
modalWindow.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
extension UIAccessibility {
|
||||
fileprivate static func postDelayed(
|
||||
notification: UIAccessibility.Notification,
|
||||
argument: Any?
|
||||
) {
|
||||
after(0.2) {
|
||||
UIAccessibility.post(
|
||||
notification: notification,
|
||||
argument: argument
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
public protocol TooltipManager: AnyObject, TooltipActionPerformer, RenderingDelegate {}
|
||||
|
||||
@@ -293,17 +307,3 @@ extension TooltipManager {
|
||||
public func mapView(_: BlockView, to _: BlockViewID) {}
|
||||
public func reset() {}
|
||||
}
|
||||
|
||||
extension UIAccessibility {
|
||||
fileprivate static func postDelayed(
|
||||
notification: UIAccessibility.Notification,
|
||||
argument: Any?
|
||||
) {
|
||||
after(0.2) {
|
||||
UIAccessibility.post(
|
||||
notification: notification,
|
||||
argument: argument
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user