46 lines
1.1 KiB
Swift
46 lines
1.1 KiB
Swift
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import yoga;
|
|
postfix operator %
|
|
|
|
extension Int {
|
|
public static postfix func %(value: Int) -> YGValue {
|
|
return YGValue(value: Float(value), unit: .percent)
|
|
}
|
|
}
|
|
|
|
extension Float {
|
|
public static postfix func %(value: Float) -> YGValue {
|
|
return YGValue(value: value, unit: .percent)
|
|
}
|
|
}
|
|
|
|
extension CGFloat {
|
|
public static postfix func %(value: CGFloat) -> YGValue {
|
|
return YGValue(value: Float(value), unit: .percent)
|
|
}
|
|
}
|
|
|
|
extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
|
|
public init(integerLiteral value: Int) {
|
|
self = YGValue(value: Float(value), unit: .point)
|
|
}
|
|
|
|
public init(floatLiteral value: Float) {
|
|
self = YGValue(value: value, unit: .point)
|
|
}
|
|
|
|
public init(_ value: Float) {
|
|
self = YGValue(value: value, unit: .point)
|
|
}
|
|
|
|
public init(_ value: CGFloat) {
|
|
self = YGValue(value: Float(value), unit: .point)
|
|
}
|
|
}
|