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
|
self.borderColor = borderColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
titleEdgeInsets = getContentEdgeInsets()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getInnerPadding() -> CGFloat {
|
private func getInnerPadding() -> CGFloat {
|
||||||
@ -138,6 +139,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
PillButton.getHeight(for: buttonSize, size: size)
|
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 {
|
public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat {
|
||||||
|
|
||||||
switch buttonSize {
|
switch buttonSize {
|
||||||
@ -146,7 +165,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
return MFSizeObject(standardSize: tinyHeight,
|
return MFSizeObject(standardSize: tinyHeight,
|
||||||
standardiPadPortraitSize: 34,
|
standardiPadPortraitSize: 34,
|
||||||
iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight
|
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:
|
default:
|
||||||
let standardHeight = Styler.Button.Size.standard.getHeight()
|
let standardHeight = Styler.Button.Size.standard.getHeight()
|
||||||
return MFSizeObject(standardSize: standardHeight,
|
return MFSizeObject(standardSize: standardHeight,
|
||||||
@ -162,8 +185,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
return MFSizeObject(standardSize: 49,
|
return MFSizeObject(standardSize: 49,
|
||||||
standardiPadPortraitSize: 90,
|
standardiPadPortraitSize: 90,
|
||||||
iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49
|
iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49
|
||||||
|
case .small:
|
||||||
default: return 151
|
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 size = super.intrinsicContentSize
|
||||||
let width = size.width + (2 * getInnerPadding())
|
let width = size.width + (2 * getInnerPadding())
|
||||||
return CGSize(width: max(width, getMinimumWidth()), height: getHeight())
|
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 {
|
} else {
|
||||||
let width = Padding.Component.gutterForApplicationWidth + (2.0 * Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth()))
|
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: min(292, width), height: getHeight())
|
return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +250,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
switch buttonSize {
|
switch buttonSize {
|
||||||
case .tiny:
|
case .tiny:
|
||||||
titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight()))
|
titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight()))
|
||||||
|
case .small:
|
||||||
default:
|
titleLabel?.font = Styler.Font.BoldBodySmall.getFont()
|
||||||
titleLabel?.font = MFFonts.mfFont75Bd(13 * (intrinsicContentSize.height / Styler.Button.Size.standard.getHeight()))
|
case .standard:
|
||||||
|
titleLabel?.font = Styler.Font.BoldBodyLarge.getFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.cornerRadius = getInnerPadding()
|
layer.cornerRadius = getInnerPadding()
|
||||||
|
|||||||
@ -178,16 +178,18 @@ open class Styler {
|
|||||||
case primary
|
case primary
|
||||||
case secondary
|
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 {
|
public enum Size: String, Codable {
|
||||||
case standard
|
case standard
|
||||||
|
case small
|
||||||
case tiny
|
case tiny
|
||||||
|
|
||||||
func getHeight() -> CGFloat {
|
func getHeight() -> CGFloat {
|
||||||
switch self {
|
switch self {
|
||||||
case .standard:
|
case .standard:
|
||||||
return 42
|
return 44
|
||||||
|
case .small:
|
||||||
|
return 32
|
||||||
case .tiny:
|
case .tiny:
|
||||||
return 20
|
return 20
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user