({
pad,
scale,
multiline,
label,
height,
offset,
dense,
fontSize,
isAndroid,
styles,
}: AdjProps)
| 162 | }; |
| 163 | |
| 164 | export const adjustPaddingFlat = ({ |
| 165 | pad, |
| 166 | scale, |
| 167 | multiline, |
| 168 | label, |
| 169 | height, |
| 170 | offset, |
| 171 | dense, |
| 172 | fontSize, |
| 173 | isAndroid, |
| 174 | styles, |
| 175 | }: AdjProps): Padding => { |
| 176 | let result = pad; |
| 177 | let topResult = result; |
| 178 | let bottomResult = result; |
| 179 | const { paddingTop, paddingBottom } = styles; |
| 180 | const refFontSize = scale * fontSize; |
| 181 | |
| 182 | if (!multiline) { |
| 183 | // do not modify padding if input is not multiline |
| 184 | if (label) { |
| 185 | // return const style for flat input with label |
| 186 | return { paddingTop, paddingBottom }; |
| 187 | } |
| 188 | // return pad for flat input without label |
| 189 | return { paddingTop: result, paddingBottom: result }; |
| 190 | } |
| 191 | |
| 192 | if (label) { |
| 193 | // add paddings passed from styles |
| 194 | topResult = paddingTop; |
| 195 | bottomResult = paddingBottom; |
| 196 | |
| 197 | // adjust top padding for iOS |
| 198 | if (!isAndroid) { |
| 199 | if (dense) { |
| 200 | topResult += |
| 201 | scale < 1 |
| 202 | ? Math.min(result, refFontSize * scale) - result / 2 |
| 203 | : Math.min(result, refFontSize * scale) - result / 2; |
| 204 | } |
| 205 | if (!dense) { |
| 206 | topResult += |
| 207 | scale < 1 |
| 208 | ? Math.min(offset / 2, refFontSize * scale) |
| 209 | : Math.min(result, refFontSize * scale) - offset / 2; |
| 210 | } |
| 211 | } |
| 212 | topResult = Math.floor(topResult); |
| 213 | } else { |
| 214 | if (height) { |
| 215 | // center text when height is passed |
| 216 | return { |
| 217 | paddingTop: Math.max(0, (height - fontSize) / 2), |
| 218 | paddingBottom: Math.max(0, (height - fontSize) / 2), |
| 219 | }; |
| 220 | } |
| 221 | // adjust paddings for iOS if no label |
no outgoing calls
no test coverage detected
searching dependent graphs…