({
pad,
multiline,
label,
scale,
height,
fontSize,
lineHeight,
dense,
offset,
isAndroid,
}: AdjProps)
| 117 | }; |
| 118 | |
| 119 | export const adjustPaddingOut = ({ |
| 120 | pad, |
| 121 | multiline, |
| 122 | label, |
| 123 | scale, |
| 124 | height, |
| 125 | fontSize, |
| 126 | lineHeight, |
| 127 | dense, |
| 128 | offset, |
| 129 | isAndroid, |
| 130 | }: AdjProps): Padding => { |
| 131 | const fontHeight = lineHeight ?? fontSize; |
| 132 | const refFontHeight = scale * fontSize; |
| 133 | let result = pad; |
| 134 | |
| 135 | if (!isAndroid && height && !multiline) { |
| 136 | return { |
| 137 | paddingTop: Math.max(0, (height - fontHeight) / 2), |
| 138 | paddingBottom: Math.max(0, (height - fontHeight) / 2), |
| 139 | }; |
| 140 | } |
| 141 | if (!isAndroid && multiline) { |
| 142 | if (dense) { |
| 143 | if (label) { |
| 144 | result += scale < 1 ? Math.min(offset, (refFontHeight / 2) * scale) : 0; |
| 145 | } else { |
| 146 | result += 0; |
| 147 | } |
| 148 | } |
| 149 | if (!dense) { |
| 150 | if (label) { |
| 151 | result += |
| 152 | scale < 1 |
| 153 | ? Math.min(offset, refFontHeight * scale) |
| 154 | : Math.min(offset / 2, refFontHeight * scale); |
| 155 | } else { |
| 156 | result += scale < 1 ? Math.min(offset / 2, refFontHeight * scale) : 0; |
| 157 | } |
| 158 | } |
| 159 | result = Math.floor(result); |
| 160 | } |
| 161 | return { paddingTop: result, paddingBottom: result }; |
| 162 | }; |
| 163 | |
| 164 | export const adjustPaddingFlat = ({ |
| 165 | pad, |
no outgoing calls
no test coverage detected
searching dependent graphs…