Skip to content

Commit

Permalink
feat: example with KeyboardAwareScrollView that covers entire screen (
Browse files Browse the repository at this point in the history
#751)

## 📜 Description

Added example where input takes full height of the screen. Such scenario
is quite common for messaging app (GMail for example).

## 💡 Motivation and Context

Will help to reproduce
#578
#512
#613

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- added long `TextInput` to `AwareScrollView` example.

## 🤔 How Has This Been Tested?

Tested manually on:
- iPhone 15 Pro;
- Medium Phone API 35;

## 📸 Screenshots (if appropriate):

<img width="274" alt="image"
src="https://github.com/user-attachments/assets/d8bc6126-0435-4965-81e1-80edaf13f14f"
/>

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Jan 3, 2025
1 parent a106fb3 commit 3410d6d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions FabricExample/src/screens/Examples/AwareScrollView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ import type { StackScreenProps } from "@react-navigation/stack";
type Props = StackScreenProps<ExamplesStackParamList>;
const snapToOffsets = [125, 225, 325, 425, 525, 625];

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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.
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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.
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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.`;

export default function AwareScrollView({ navigation }: Props) {
const bottomSheetModalRef = useRef<BottomSheet>(null);
const [_, setText] = useState("");
Expand Down Expand Up @@ -81,6 +98,12 @@ export default function AwareScrollView({ navigation }: Props) {
onChangeText={setText}
/>
))}
<TextInput
defaultValue={BIG_TEXT}
placeholder="TextInput#10"
style={styles.input}
onChangeText={setText}
/>
</KeyboardAwareScrollView>
<BottomSheet ref={bottomSheetModalRef} index={-1} snapPoints={["40%"]}>
<Button
Expand Down
7 changes: 7 additions & 0 deletions FabricExample/src/screens/Examples/AwareScrollView/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ export const styles = StyleSheet.create({
flex: 1,
backgroundColor: "black",
},
input: {
width: "100%",
borderWidth: 2,
borderColor: "black",
borderRadius: 8,
paddingHorizontal: 12,
},
});
23 changes: 23 additions & 0 deletions example/src/screens/Examples/AwareScrollView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ import type { StackScreenProps } from "@react-navigation/stack";
type Props = StackScreenProps<ExamplesStackParamList>;
const snapToOffsets = [125, 225, 325, 425, 525, 625];

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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.
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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.
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, 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 certain source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 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..", comes from a line in section 1.10.32.`;

export default function AwareScrollView({ navigation }: Props) {
const bottomSheetModalRef = useRef<BottomSheet>(null);
const [_, setText] = useState("");
Expand Down Expand Up @@ -81,6 +98,12 @@ export default function AwareScrollView({ navigation }: Props) {
onChangeText={setText}
/>
))}
<TextInput
defaultValue={BIG_TEXT}
placeholder="TextInput#10"
style={styles.input}
onChangeText={setText}
/>
</KeyboardAwareScrollView>
<BottomSheet ref={bottomSheetModalRef} index={-1} snapPoints={["40%"]}>
<Button
Expand Down
7 changes: 7 additions & 0 deletions example/src/screens/Examples/AwareScrollView/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ export const styles = StyleSheet.create({
flex: 1,
backgroundColor: "black",
},
input: {
width: "100%",
borderWidth: 2,
borderColor: "black",
borderRadius: 8,
paddingHorizontal: 12,
},
});

0 comments on commit 3410d6d

Please sign in to comment.