-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2b93a6
commit 3044e02
Showing
12 changed files
with
104 additions
and
22 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./KeyboardAwareScrollView"; |
File renamed without changes.
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
48 changes: 48 additions & 0 deletions
48
FabricExample/src/screens/Examples/AwareScrollViewStickyFooter/index.tsx
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,48 @@ | ||
import React, { useCallback, useMemo, useState } from 'react'; | ||
import { LayoutChangeEvent, View, Text, Button } from 'react-native'; | ||
import { useResizeMode, KeyboardStickyView } from 'react-native-keyboard-controller'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
|
||
import KeyboardAwareScrollView from '../../../components/AwareScrollView'; | ||
import TextInput from '../../../components/TextInput'; | ||
import { styles } from './styles'; | ||
|
||
export default function AwareScrollViewStickyFooter() { | ||
useResizeMode(); | ||
|
||
const { bottom } = useSafeAreaInsets(); | ||
const [footerHeight, setFooterHeight] = useState(0); | ||
|
||
const handleLayout = useCallback((evt: LayoutChangeEvent) => { | ||
setFooterHeight(evt.nativeEvent.layout.height); | ||
}, []); | ||
const offset = useMemo(() => ({closed: 0, opened: bottom }), [bottom]); | ||
|
||
return ( | ||
<View style={[styles.pageContainer, { paddingBottom: bottom }]}> | ||
<KeyboardAwareScrollView | ||
style={styles.container} | ||
contentContainerStyle={styles.content} | ||
bottomOffset={footerHeight + 50} | ||
keyboardShouldPersistTaps="handled" | ||
> | ||
{new Array(10).fill(0).map((_, i) => ( | ||
<TextInput | ||
key={i} | ||
placeholder={`TextInput#${i}`} | ||
keyboardType={i % 2 === 0 ? 'numeric' : 'default'} | ||
/> | ||
))} | ||
</KeyboardAwareScrollView> | ||
<KeyboardStickyView offset={offset}> | ||
<View onLayout={handleLayout} style={styles.footer}> | ||
<Text style={styles.footerText}>A mocked sticky footer</Text> | ||
<Button title="Click me" /> | ||
</View> | ||
</KeyboardStickyView> | ||
{/*<KeyboardStickyView offset={{closed: -50, opened: bottom - 25}}> | ||
<View style={{position: 'absolute', bottom: 0, right: 30, justifyContent: "flex-end", width: 60, height: 60, borderRadius: 30, backgroundColor: "#002099"}} /> | ||
</KeyboardStickyView>*/} | ||
</View> | ||
); | ||
} |
26 changes: 26 additions & 0 deletions
26
FabricExample/src/screens/Examples/AwareScrollViewStickyFooter/styles.ts
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,26 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
export const styles = StyleSheet.create({ | ||
container: { | ||
flexGrow: 1, | ||
paddingHorizontal: 16, | ||
}, | ||
content: { | ||
paddingTop: 50, | ||
}, | ||
pageContainer: { | ||
flex: 1, | ||
}, | ||
footer: { | ||
backgroundColor: 'green', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: 20, | ||
width: '100%', | ||
gap: 10, | ||
}, | ||
footerText: { | ||
color: 'white', | ||
fontWeight: 'bold', | ||
}, | ||
}); |
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