Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
fix: slide to open note side menu
Browse files Browse the repository at this point in the history
  • Loading branch information
radko93 committed Nov 24, 2020
1 parent 527cfd9 commit fc288fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/AppStack.tsx
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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} />
Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions src/screens/Compose/Compose.tsx
Expand Up @@ -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;
Expand All @@ -181,6 +185,12 @@ export const Compose = React.memo(
};
}, [application, note?.uuid]);

useEffect(() => {
return () => {
application?.getAppState().closeActiveEditor();
};
}, [application]);

useFocusEffect(
useCallback(() => {
return dissmissKeybard;
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit fc288fb

Please sign in to comment.