styler additon. label width value

This commit is contained in:
Kevin G Christiano 2021-02-23 14:56:23 -05:00
parent b943bed2d8
commit 8a861077dd
2 changed files with 26 additions and 2 deletions

View File

@ -594,7 +594,6 @@ public typealias ActionBlock = () -> ()
attributedText = attributedString
}
@objc public func updateView(_ size: CGFloat) {
scaleSize = size as NSNumber
@ -624,6 +623,9 @@ public typealias ActionBlock = () -> ()
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) {
font = font.updateSize(sizeObject.getValueBased(onSize: size))
}
// Provide the label additional size information to help calculate its intrinsic content.
preferredMaxLayoutWidth = Styler.maxAvailableLayoutWidth(size: size)
}
@objc public func setFont(_ font: UIFont, scale: Bool) {

View File

@ -209,7 +209,29 @@ open class Styler {
}
open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat {
return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size
sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size
}
open class func defaultHorizontalPadding(for size: CGFloat) -> CGFloat {
sizeObject(withScalingStandardSize: CGFloat(Padding.Component.horizontalPaddingForApplicationWidth)).getValueBased(onSize: size)
}
open class func defaultVerticalPadding(for size: CGFloat) -> CGFloat {
sizeObject(withScalingStandardSize: CGFloat(Padding.Component.verticalPaddingForApplicationWidth)).getValueBased(onSize: size)
}
open class func sizeObject(withScalingStandardSize standardSize: CGFloat) -> MFSizeObject {
let object = MFSizeObject()
object.standardSize = standardSize
object.scaleStandardSize = true
return object
}
/// Provide additional size information to help calculate its intrinsic height.
/// - Returns: The available spacing that can be used for intrinsic content width.
open class func maxAvailableLayoutWidth(size: CGFloat) -> CGFloat {
// The 2 is the product of both sides of padding.
size - (defaultHorizontalPadding(for: size) * 2)
}
//--------------------------------------------------