2024-06-04 10:57:52 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
import { PluginSettings } from '@joplin/lib/services/plugins/PluginService';
|
|
|
|
import configScreenStyles from '../../configScreenStyles';
|
|
|
|
import Setting from '@joplin/lib/models/Setting';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { Store } from 'redux';
|
|
|
|
import { PaperProvider } from 'react-native-paper';
|
|
|
|
import PluginStates from '../PluginStates';
|
|
|
|
import { AppState } from '../../../../../utils/types';
|
|
|
|
import { useCallback, useState } from 'react';
|
2024-06-15 11:00:21 +02:00
|
|
|
import { MenuProvider } from 'react-native-popup-menu';
|
2024-06-04 10:57:52 +02:00
|
|
|
|
|
|
|
interface WrapperProps {
|
|
|
|
initialPluginSettings: PluginSettings;
|
|
|
|
store: Store<AppState>;
|
|
|
|
}
|
|
|
|
const shouldShowBasedOnSettingSearchQuery = ()=>true;
|
|
|
|
|
|
|
|
const PluginStatesWrapper = (props: WrapperProps) => {
|
|
|
|
const styles = configScreenStyles(Setting.THEME_LIGHT);
|
|
|
|
|
|
|
|
const [pluginSettings, setPluginSettings] = useState(() => {
|
|
|
|
return props.initialPluginSettings ?? {};
|
|
|
|
});
|
|
|
|
|
|
|
|
const updatePluginStates = useCallback((newStates: PluginSettings) => {
|
|
|
|
setPluginSettings(newStates);
|
|
|
|
Setting.setValue('plugins.states', newStates);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Provider store={props.store}>
|
2024-06-15 11:00:21 +02:00
|
|
|
<MenuProvider>
|
|
|
|
<PaperProvider>
|
|
|
|
<PluginStates
|
|
|
|
styles={styles}
|
|
|
|
themeId={Setting.THEME_LIGHT}
|
|
|
|
updatePluginStates={updatePluginStates}
|
|
|
|
pluginSettings={pluginSettings}
|
|
|
|
shouldShowBasedOnSearchQuery={shouldShowBasedOnSettingSearchQuery}
|
|
|
|
/>
|
|
|
|
</PaperProvider>
|
|
|
|
</MenuProvider>
|
2024-06-04 10:57:52 +02:00
|
|
|
</Provider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PluginStatesWrapper;
|