Skip to content
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

ADD CUSTOM HANDLERS FOR TEXT INPUT #851

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions examples/client/Locomotion/src/Components/TextInput/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import {
Input,
} from './styled';

const styles = StyleSheet.create({
customHandle: {
position: 'absolute',
bottom: 0,
width: 20,
height: 30,
borderRadius: 18, // For rounded top corners
backgroundColor: 'cyan', // Default color
transform: [{ translateY: 20 }],
borderBottomLeftRadius: 12, // Larger radius for the bottom to create a drop effect
borderBottomRightRadius: 12,
},
});
const TextInput = (props) => {
const [isFocused, setIsFocused] = useState(false);
const [selection, setSelection] = useState({ start: 0, end: 0 });
return (
<Input
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
isFocused={isFocused}
ref={props.inputRef}
{...props}
testID={props.testID || null}
/>
<>
<Input
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
isFocused={isFocused}
ref={props.inputRef}
{...props}
testID={props.testID || null}
selection={selection}
onSelectionChange={({ nativeEvent }) => setSelection(nativeEvent.selection)}
/>
<View style={[styles.customHandle, { left: selection.start * 8 }]} />
<View style={[styles.customHandle, { left: selection.end * 8 }]} />
</>
);
};

Expand Down
Loading