mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Fixes #9376: Sidebar is not dismissed when creating a note
This commit is contained in:
parent
24ed5bda63
commit
fec8c6131c
@ -1,10 +1,12 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
import { useState, useCallback, useMemo } from 'react';
|
import { useState, useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
const Icon = require('react-native-vector-icons/Ionicons').default;
|
|
||||||
import { FAB, Portal } from 'react-native-paper';
|
import { FAB, Portal } from 'react-native-paper';
|
||||||
import { _ } from '@joplin/lib/locale';
|
import { _ } from '@joplin/lib/locale';
|
||||||
|
import { Dispatch } from 'redux';
|
||||||
|
const Icon = require('react-native-vector-icons/Ionicons').default;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-undef -- Don't know why it says React is undefined when it's defined above
|
||||||
|
type FABGroupProps = React.ComponentProps<typeof FAB.Group>;
|
||||||
|
|
||||||
type OnButtonPress = ()=> void;
|
type OnButtonPress = ()=> void;
|
||||||
interface ButtonSpec {
|
interface ButtonSpec {
|
||||||
@ -19,6 +21,7 @@ interface ActionButtonProps {
|
|||||||
|
|
||||||
// If not given, an "add" button will be used.
|
// If not given, an "add" button will be used.
|
||||||
mainButton?: ButtonSpec;
|
mainButton?: ButtonSpec;
|
||||||
|
dispatch: Dispatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOnPress = () => {};
|
const defaultOnPress = () => {};
|
||||||
@ -36,10 +39,12 @@ const useIcon = (iconName: string) => {
|
|||||||
|
|
||||||
const ActionButton = (props: ActionButtonProps) => {
|
const ActionButton = (props: ActionButtonProps) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const onMenuToggled = useCallback(
|
const onMenuToggled: FABGroupProps['onStateChange'] = useCallback(state => {
|
||||||
(state: { open: boolean }) => setOpen(state.open)
|
props.dispatch({
|
||||||
, [setOpen]);
|
type: 'SIDE_MENU_CLOSE',
|
||||||
|
});
|
||||||
|
setOpen(state.open);
|
||||||
|
}, [setOpen, props.dispatch]);
|
||||||
|
|
||||||
const actions = useMemo(() => (props.buttons ?? []).map(button => {
|
const actions = useMemo(() => (props.buttons ?? []).map(button => {
|
||||||
return {
|
return {
|
||||||
|
@ -40,9 +40,7 @@ interface ActionButtonProps {
|
|||||||
onPress: Callback;
|
onPress: Callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ActionButton = (
|
const ActionButton = (props: ActionButtonProps) => {
|
||||||
props: ActionButtonProps,
|
|
||||||
) => {
|
|
||||||
return (
|
return (
|
||||||
<CustomButton
|
<CustomButton
|
||||||
themeId={props.themeId}
|
themeId={props.themeId}
|
||||||
|
@ -1422,7 +1422,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
|
|
||||||
if (this.state.mode === 'edit') return null;
|
if (this.state.mode === 'edit') return null;
|
||||||
|
|
||||||
return <ActionButton mainButton={editButton} />;
|
return <ActionButton mainButton={editButton} dispatch={this.props.dispatch} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save button is not really needed anymore with the improved save logic
|
// Save button is not really needed anymore with the improved save logic
|
||||||
|
@ -265,7 +265,7 @@ class NotesScreenComponent extends BaseScreenComponent<any> {
|
|||||||
color: '#9b59b6',
|
color: '#9b59b6',
|
||||||
icon: 'document',
|
icon: 'document',
|
||||||
});
|
});
|
||||||
return <ActionButton buttons={buttons}/>;
|
return <ActionButton buttons={buttons} dispatch={this.props.dispatch}/>;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user