Skip to content

Commit

Permalink
iOS: Resolves laurent22#11711: Adjust spacing below the Markdown toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed Jan 31, 2025
1 parent fe6c949 commit 18aa758
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/app-mobile/components/ToggleSpaceButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ import Setting from '@joplin/lib/models/Setting';
import { themeStyle } from '@joplin/lib/theme';

import * as React from 'react';
import { ReactNode, useCallback, useState, useEffect } from 'react';
import { ReactNode, useCallback, useState, useEffect, useMemo } from 'react';
import { Platform, View, ViewStyle } from 'react-native';
import IconButton from './IconButton';
import useKeyboardVisible from '../utils/hooks/useKeyboardVisible';

interface Props {
children: ReactNode;
themeId: number;
style?: ViewStyle;
}

const ToggleSpaceButton = (props: Props) => {
const [additionalSpace, setAdditionalSpace] = useState(0);
const [decreaseSpaceBtnVisible, setDecreaseSpaceBtnVisible] = useState(true);

// Some devices need space added, others need space removed.
const additionalPositiveSpace = 14;
const additionalNegativeSpace = -14;
const additionalPositiveSpace = 30;
const additionalNegativeSpace = -8;

// Switch from adding +14px to -14px.
// Switch from adding +30px to -8px.
const onDecreaseSpace = useCallback(() => {
setAdditionalSpace(additionalNegativeSpace);
setDecreaseSpaceBtnVisible(false);
Expand Down Expand Up @@ -79,10 +78,11 @@ const ToggleSpaceButton = (props: Props) => {
const { keyboardVisible } = useKeyboardVisible();
const spaceApplicable = keyboardVisible && Platform.OS === 'ios';

const style: ViewStyle = {
const style: ViewStyle = useMemo(() => ({
marginBottom: spaceApplicable ? additionalSpace : 0,
...props.style,
};
// Additional space (if visible) should match the main toolbar background:
backgroundColor: theme.backgroundColor3,
}), [spaceApplicable, theme, additionalSpace]);

return (
<View style={style}>
Expand Down

0 comments on commit 18aa758

Please sign in to comment.