fix: slide to open note side menu

This commit is contained in:
Radek Czemerys
2020-11-25 00:07:40 +01:00
parent 527cfd9343
commit fc288fb41c
2 changed files with 24 additions and 7 deletions

View File

@@ -82,7 +82,7 @@ export const AppStackComponent = (
.addStateChangeObserver(event => {
if (event === AppStateType.EditorClosed) {
noteDrawerRef.current?.closeDrawer();
if (!isInTabletMode) {
if (!isInTabletMode && props.navigation.canGoBack()) {
props.navigation.popToTop();
}
}
@@ -147,6 +147,9 @@ export const AppStackComponent = (
drawerWidth={getDefaultDrawerWidth(dimensions)}
drawerPosition={'left'}
drawerType="slide"
drawerLockMode={
hasEditor && !isInTabletMode ? 'locked-closed' : 'unlocked'
}
onDrawerStateChanged={handleDrawerStateChange}
renderNavigationView={() =>
!isLocked && <MainSideMenu drawerRef={drawerRef.current} />
@@ -160,7 +163,7 @@ export const AppStackComponent = (
onDrawerClose={() => setNoteDrawerOpen(false)}
drawerPosition={'right'}
drawerType="slide"
drawerLockMode="locked-closed"
drawerLockMode={hasEditor ? 'unlocked' : 'locked-closed'}
renderNavigationView={() =>
hasEditor && (
<NoteSideMenu

View File

@@ -164,10 +164,14 @@ export const Compose = React.memo(
useEffect(() => {
let mounted = true;
if (mounted && editor && editor.isTemplateNote) {
if (Platform.OS === 'ios') {
editorViewRef.current?.focus();
}
if (
mounted &&
editor &&
editor.isTemplateNote &&
editor.note?.prefersPlainEditor &&
Platform.OS === 'ios'
) {
editorViewRef.current?.focus();
}
return () => {
mounted = false;
@@ -181,6 +185,12 @@ export const Compose = React.memo(
};
}, [application, note?.uuid]);
useEffect(() => {
return () => {
application?.getAppState().closeActiveEditor();
};
}, [application]);
useFocusEffect(
useCallback(() => {
return dissmissKeybard;
@@ -532,7 +542,11 @@ export const Compose = React.memo(
<StyledTextView
testID="noteContentField"
ref={editorViewRef}
autoFocus={Boolean(editor && editor.isTemplateNote)}
autoFocus={Boolean(
editor &&
editor.isTemplateNote &&
editor.note?.prefersPlainEditor
)}
value={note?.text}
selectionColor={lighten(theme.stylekitInfoColor, 0.35)}
handlesColor={theme.stylekitInfoColor}