Skip to content

Commit d5850e8

Browse files
Cawlummclaude
andcommitted
fix(mobile): vertically align the duration value with 'min' on iOS
The value/placeholder rendered a touch low next to 'min' on iOS. Share one lineHeight (20) across the value input and both 'min' labels so items-center lines up their text boxes, and drop Android glyph padding via includeFontPadding:false. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ccq3rvfb9ArzS2DidghJm5
1 parent b57273e commit d5850e8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

mobile/src/components/workouts/DurationField.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { useTheme } from '../../theme/useTheme'
88
// Value + onChange are whole MINUTES (same as the form's formData.duration), so the
99
// payload upstream is unchanged.
1010
const STEP = 5
11+
// One shared line box for the value (16pt bold) and the "min" label (14pt) so
12+
// vertical centering lines them up on the same optical line.
13+
const LINE = 20
1114

1215
export function DurationField({ value, onChange, inputAccessoryViewID }: {
1316
value: number
@@ -34,7 +37,7 @@ export function DurationField({ value, onChange, inputAccessoryViewID }: {
3437
value is flanked by equal widths and sits dead-center in the segment — no
3538
matter the digit count — while "min" still reads to its right (no overlap). */}
3639
<View className="flex-1 flex-row items-center justify-center">
37-
<Text className="mr-1 font-sans text-sm opacity-0" aria-hidden>min</Text>
40+
<Text className="mr-1 font-sans text-sm opacity-0" style={{ lineHeight: LINE }} aria-hidden>min</Text>
3841
<TextInput
3942
value={value ? String(value) : ''}
4043
onChangeText={(t) => onChange(Number(t.replace(/[^0-9]/g, '')) || 0)}
@@ -46,9 +49,12 @@ export function DurationField({ value, onChange, inputAccessoryViewID }: {
4649
placeholderTextColor={colors.txMuted}
4750
accessibilityLabel="Duration in minutes"
4851
className="py-0 text-center font-sans-bold text-base text-tx-primary"
49-
style={{ fontVariant: ['tabular-nums'], minWidth: 16, maxWidth: 44 }}
52+
// Share one lineHeight across the value + "min" so items-center lines up
53+
// their text boxes exactly (iOS renders placeholder/value low otherwise).
54+
// includeFontPadding:false drops Android's extra glyph padding.
55+
style={{ fontVariant: ['tabular-nums'], minWidth: 16, maxWidth: 44, lineHeight: LINE, includeFontPadding: false }}
5056
/>
51-
<Text className="ml-1 font-sans text-sm text-tx-muted">min</Text>
57+
<Text className="ml-1 font-sans text-sm text-tx-muted" style={{ lineHeight: LINE }}>min</Text>
5258
</View>
5359

5460
<Pressable

0 commit comments

Comments
 (0)