Skip to content

Commit

Permalink
example: port changes to Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Dec 10, 2024
1 parent 7c4d311 commit 753acf7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion FabricExample/src/screens/Examples/Close/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
import { useRef, useState } from "react";
import { Button, StyleSheet, TextInput, View } from "react-native";
import { KeyboardController } from "react-native-keyboard-controller";

function CloseScreen() {
const ref = useRef<TextInput>(null);
const [keepFocus, setKeepFocus] = useState(false);

return (
<View>
<Button
testID="keep_focus_button"
title={keepFocus ? "Keep focus" : "Don't keep focus"}
onPress={() => setKeepFocus(!keepFocus)}
/>
<Button
testID="set_focus_to_current"
title="KeyboardController.setFocusTo('current')"
onPress={() => KeyboardController.setFocusTo("current")}
/>
<Button
testID="focus_from_ref"
title="Focus from ref"
onPress={() => ref.current?.focus()}
/>
<Button
testID="blur_from_ref"
title="Blur from ref"
onPress={() => ref.current?.blur()}
/>
<Button
testID="close_keyboard_button"
title="Close keyboard"
onPress={KeyboardController.dismiss}
onPress={() => KeyboardController.dismiss({ keepFocus })}
/>
<TextInput
ref={ref}
placeholder="Touch to open the keyboard..."
placeholderTextColor="#7C7C7C"
style={styles.input}
testID="input"
onBlur={() => console.log("blur")}
onFocus={() => console.log("focus")}
/>
Expand Down

0 comments on commit 753acf7

Please sign in to comment.