-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add ability to use custom flatlist implementation #173
Open
arpitv96171
wants to merge
6
commits into
10play:main
Choose a base branch
from
arpitv96171:use-custom-flatlist
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+818
−29
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cbf926b
fix: add ability to use custom flatlist implementation
arpitv96171 dc181bd
fix: spelling fix
arpitv96171 72d3e45
fix: reset semver
arpitv96171 ffcb6e5
Merge branch 'main' into use-custom-flatlist
arpitv96171 c38884a
fix: enable android scroll and make ios toolbar visible
arpitv96171 1625a3e
Merge branch 'main' into use-custom-flatlist
arpitv96171 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import BottomSheet, { | ||
BottomSheetScrollView, | ||
BottomSheetView, | ||
} from '@gorhom/bottom-sheet'; | ||
import { Portal } from '@gorhom/portal'; | ||
import type { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
SafeAreaView, | ||
Platform, | ||
StyleSheet, | ||
Button, | ||
Keyboard, | ||
type KeyboardEvent, | ||
TouchableOpacity, | ||
Text, | ||
KeyboardAvoidingView, | ||
} from 'react-native'; | ||
import { RichText, Toolbar, useEditorBridge } from '@10play/tentap-editor'; | ||
|
||
const useKeyboard = () => { | ||
const [keyboardHeight, setKeyboardHeight] = useState(0); | ||
|
||
useEffect(() => { | ||
function onKeyboardDidShow(e: KeyboardEvent) { | ||
// Remove type here if not using TypeScript | ||
setKeyboardHeight(e.endCoordinates.height); | ||
} | ||
|
||
function onKeyboardDidHide() { | ||
setKeyboardHeight(0); | ||
} | ||
|
||
const showSubscription = Keyboard.addListener( | ||
'keyboardDidShow', | ||
onKeyboardDidShow | ||
); | ||
const hideSubscription = Keyboard.addListener( | ||
'keyboardDidHide', | ||
onKeyboardDidHide | ||
); | ||
return () => { | ||
showSubscription.remove(); | ||
hideSubscription.remove(); | ||
}; | ||
}, []); | ||
|
||
return keyboardHeight; | ||
}; | ||
|
||
export const WithBottomSheet = ({}: NativeStackScreenProps<any, any, any>) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am still unable to scroll on Android - seems like the scroll is getting handled by the drawer Screen.Recording.2024-08-04.at.14.31.44.mov |
||
const bottomSheetRef = React.useRef<BottomSheet>(null); | ||
const keyboardHeight = useKeyboard(); | ||
const editor = useEditorBridge({ | ||
// autofocus: true, | ||
avoidIosKeyboard: true, | ||
initialContent, | ||
}); | ||
const openBottomSheet = () => { | ||
bottomSheetRef.current?.snapToIndex(0); | ||
}; | ||
|
||
const closeBottomSheet = () => { | ||
bottomSheetRef.current?.close(); | ||
}; | ||
|
||
return ( | ||
<SafeAreaView style={exampleStyles.fullScreen}> | ||
<Button title="Open Bottom Sheet" onPress={openBottomSheet} /> | ||
<Portal> | ||
<BottomSheet | ||
snapPoints={['90%']} | ||
ref={bottomSheetRef} | ||
keyboardBehavior="extend" | ||
android_keyboardInputMode="adjustResize" | ||
keyboardBlurBehavior="restore" | ||
bottomInset={0.2} | ||
> | ||
<BottomSheetScrollView | ||
keyboardDismissMode="interactive" | ||
keyboardShouldPersistTaps="handled" | ||
> | ||
<BottomSheetView> | ||
<TouchableOpacity | ||
onPress={closeBottomSheet} | ||
style={exampleStyles.closeButton} | ||
> | ||
<Text style={exampleStyles.closeButtonText}> | ||
Close BottomSheet | ||
</Text> | ||
</TouchableOpacity> | ||
</BottomSheetView> | ||
<BottomSheetView style={exampleStyles.editorContainer}> | ||
<RichText editor={editor} hideKeyboardAccessoryView={false} /> | ||
</BottomSheetView> | ||
</BottomSheetScrollView> | ||
<Portal> | ||
<KeyboardAvoidingView | ||
style={{ | ||
position: 'absolute', | ||
bottom: Keyboard.isVisible() | ||
? Platform.OS === 'android' | ||
? 0 | ||
: keyboardHeight | ||
: -100, | ||
width: '100%', | ||
}} | ||
> | ||
<Toolbar editor={editor} /> | ||
</KeyboardAvoidingView> | ||
</Portal> | ||
</BottomSheet> | ||
</Portal> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const exampleStyles = StyleSheet.create({ | ||
closeButton: { | ||
marginTop: 16, | ||
marginHorizontal: 16, | ||
paddingHorizontal: 16, | ||
paddingVertical: 8, | ||
borderWidth: 2, | ||
borderRadius: 8, | ||
}, | ||
closeButtonText: { | ||
textAlign: 'center', | ||
}, | ||
editorContainer: { | ||
height: 100, | ||
marginHorizontal: 16, | ||
paddingHorizontal: 16, | ||
marginTop: 10, | ||
borderWidth: 1, | ||
}, | ||
fullScreen: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); | ||
|
||
const initialContent = `<p>This is a basic example!</p>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to import this from
@10play/tentap-editor