Updating button VDS component for 3.0 rebranding
This commit is contained in:
parent
5b3b3246ec
commit
02476e766d
@ -128,6 +128,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
self.borderColor = borderColor
|
||||
}
|
||||
}
|
||||
titleEdgeInsets = getContentEdgeInsets()
|
||||
}
|
||||
|
||||
private func getInnerPadding() -> CGFloat {
|
||||
@ -138,6 +139,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
PillButton.getHeight(for: buttonSize, size: size)
|
||||
}
|
||||
|
||||
private func getContentEdgeInsets() -> UIEdgeInsets {
|
||||
var verticalPadding = 0.0
|
||||
var horizontalPadding = 0.0
|
||||
switch buttonSize {
|
||||
case .standard:
|
||||
verticalPadding = Padding.Three
|
||||
horizontalPadding = Padding.Five
|
||||
break
|
||||
case .small:
|
||||
verticalPadding = Padding.Two
|
||||
horizontalPadding = Padding.Four
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding)
|
||||
}
|
||||
|
||||
public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat {
|
||||
|
||||
switch buttonSize {
|
||||
@ -146,7 +165,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
return MFSizeObject(standardSize: tinyHeight,
|
||||
standardiPadPortraitSize: 34,
|
||||
iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight
|
||||
|
||||
case .small:
|
||||
let smallHeight = Styler.Button.Size.small.getHeight()
|
||||
return MFSizeObject(standardSize: smallHeight,
|
||||
standardiPadPortraitSize: 34,
|
||||
iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? smallHeight
|
||||
default:
|
||||
let standardHeight = Styler.Button.Size.standard.getHeight()
|
||||
return MFSizeObject(standardSize: standardHeight,
|
||||
@ -162,8 +185,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
return MFSizeObject(standardSize: 49,
|
||||
standardiPadPortraitSize: 90,
|
||||
iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49
|
||||
|
||||
default: return 151
|
||||
case .small:
|
||||
return MFSizeObject(standardSize: 1,
|
||||
standardiPadPortraitSize: 2,
|
||||
iPadProLandscapeSize: 3)?.getValueBased(onSize: size) ?? 1
|
||||
case .standard:
|
||||
return MFSizeObject(standardSize: 76,
|
||||
standardiPadPortraitSize: 90,
|
||||
iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 76
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,9 +201,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
let size = super.intrinsicContentSize
|
||||
let width = size.width + (2 * getInnerPadding())
|
||||
return CGSize(width: max(width, getMinimumWidth()), height: getHeight())
|
||||
} else if buttonSize == .small {
|
||||
let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0)
|
||||
return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight())
|
||||
} else {
|
||||
let width = Padding.Component.gutterForApplicationWidth + (2.0 * Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth()))
|
||||
return CGSize(width: min(292, width), height: getHeight())
|
||||
let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0)
|
||||
return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight())
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,9 +250,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
switch buttonSize {
|
||||
case .tiny:
|
||||
titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight()))
|
||||
|
||||
default:
|
||||
titleLabel?.font = MFFonts.mfFont75Bd(13 * (intrinsicContentSize.height / Styler.Button.Size.standard.getHeight()))
|
||||
case .small:
|
||||
titleLabel?.font = Styler.Font.BoldBodySmall.getFont()
|
||||
case .standard:
|
||||
titleLabel?.font = Styler.Font.BoldBodyLarge.getFont()
|
||||
}
|
||||
|
||||
layer.cornerRadius = getInnerPadding()
|
||||
|
||||
@ -178,16 +178,18 @@ open class Styler {
|
||||
case primary
|
||||
case secondary
|
||||
}
|
||||
|
||||
///MVA 3.0 - Button sizes are standard(default size), small, Tiny. Tiny button has been depricated as of Rebranding 3.0.
|
||||
public enum Size: String, Codable {
|
||||
case standard
|
||||
case small
|
||||
case tiny
|
||||
|
||||
func getHeight() -> CGFloat {
|
||||
switch self {
|
||||
case .standard:
|
||||
return 42
|
||||
|
||||
return 44
|
||||
case .small:
|
||||
return 32
|
||||
case .tiny:
|
||||
return 20
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user