Skip to content

Commit

Permalink
feat: example with KeyboardAwareScrollView that covers entire screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Jan 3, 2025
1 parent a106fb3 commit 687503b
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/src/constants/screenNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum ScreenNames {
REANIMATED_CHAT_FLAT_LIST = "REANIMATED_CHAT_FLAT_LIST",
EVENTS = "EVENTS",
AWARE_SCROLL_VIEW = "AWARE_SCROLL_VIEW",
AWARE_SCROLL_VIEW_ENTIRE_SCREEN = "AWARE_SCROLL_VIEW_ENTIRE_SCREEN",
AWARE_SCROLL_VIEW_STICKY_FOOTER = "AWARE_SCROLL_VIEW_STICKY_FOOTER",
STATUS_BAR = "STATUS_BAR",
LOTTIE = "LOTTIE",
Expand Down
10 changes: 10 additions & 0 deletions example/src/navigation/ExamplesStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";

import { ScreenNames } from "../../constants/screenNames";
import AwareScrollView from "../../screens/Examples/AwareScrollView";
import AwareScrollViewEntireScreen from "../../screens/Examples/AwareScrollViewEntireScreen";
import AwareScrollViewStickyFooter from "../../screens/Examples/AwareScrollViewStickyFooter";
import CloseScreen from "../../screens/Examples/Close";
import EnabledDisabled from "../../screens/Examples/EnabledDisabled";
Expand Down Expand Up @@ -30,6 +31,7 @@ export type ExamplesStackParamList = {
[ScreenNames.REANIMATED_CHAT_FLAT_LIST]: undefined;
[ScreenNames.EVENTS]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW_ENTIRE_SCREEN]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW_STICKY_FOOTER]: undefined;
[ScreenNames.STATUS_BAR]: undefined;
[ScreenNames.LOTTIE]: undefined;
Expand Down Expand Up @@ -66,6 +68,9 @@ const options = {
[ScreenNames.AWARE_SCROLL_VIEW]: {
title: "Aware scroll view",
},
[ScreenNames.AWARE_SCROLL_VIEW_ENTIRE_SCREEN]: {
title: "Aware scroll view with long text",
},
[ScreenNames.AWARE_SCROLL_VIEW_STICKY_FOOTER]: {
title: "Aware scroll view sticky footer",
},
Expand Down Expand Up @@ -144,6 +149,11 @@ const ExamplesStack = () => (
name={ScreenNames.AWARE_SCROLL_VIEW}
options={options[ScreenNames.AWARE_SCROLL_VIEW]}
/>
<Stack.Screen
component={AwareScrollViewEntireScreen}
name={ScreenNames.AWARE_SCROLL_VIEW_ENTIRE_SCREEN}
options={options[ScreenNames.AWARE_SCROLL_VIEW_ENTIRE_SCREEN]}
/>
<Stack.Screen
component={AwareScrollViewStickyFooter}
name={ScreenNames.AWARE_SCROLL_VIEW_STICKY_FOOTER}
Expand Down
44 changes: 44 additions & 0 deletions example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useState } from "react";
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";

import TextInput from "../../../components/TextInput";

import { styles } from "./styles";

const BIG_TEXT = `Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Clintock)

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (undoubtable)

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Finibus)

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Bonorum)

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Malorum)

Check failure on line 9 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (amet)
s
s
s
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Check failure on line 16 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Clintock)

Check failure on line 16 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (undoubtable)

Check failure on line 16 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Finibus)

Check failure on line 16 in example/src/screens/Examples/AwareScrollViewEntireScreen/index.tsx

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Bonorum)
s
s
s
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.`;

export default function AwareScrollView() {
const [_, setText] = useState("");

return (
<>
<KeyboardAwareScrollView
bottomOffset={50}
contentContainerStyle={styles.content}
style={styles.container}
testID="aware_scroll_view_container"
>
<TextInput
defaultValue={BIG_TEXT}
style={styles.input}
onChangeText={setText}
/>
</KeyboardAwareScrollView>
</>
);
}
17 changes: 17 additions & 0 deletions example/src/screens/Examples/AwareScrollViewEntireScreen/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { StyleSheet } from "react-native";

export const styles = StyleSheet.create({
container: {
paddingHorizontal: 16,
},
content: {
paddingTop: 50,
},
input: {
width: "100%",
borderWidth: 2,
borderColor: "black",
borderRadius: 8,
paddingHorizontal: 12,
},
});
6 changes: 6 additions & 0 deletions example/src/screens/Examples/Main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export const examples: Example[] = [
info: ScreenNames.AWARE_SCROLL_VIEW,
icons: "🤓",
},
{
title: "Aware scroll view with long text",
testID: "aware_scroll_view_entire_screen",
info: ScreenNames.AWARE_SCROLL_VIEW_ENTIRE_SCREEN,
icons: "🤓🏔️",
},
{
title: "Aware scroll view sticky footer",
testID: "aware_scroll_view_sticky_footer",
Expand Down

0 comments on commit 687503b

Please sign in to comment.