我正在使用来自 React-Native-Gesture-Handler 的 Swipeable 来合并滑动以在我的页面上删除。当我按删除时,联系人会被删除,但可滑动保持打开状态。
我希望它在按下后关闭,但我似乎不知道该怎么做。
这是我的代码:
const RightActions = (progress, dragX) => {
return (
<TouchableOpacity onPress={()=>{DeleteContact(i)}}>
<View style={[ContactsStyles.rightAction]}>
<Text style={ContactsStyles.actionText}>Delete</Text>
</View>
</TouchableOpacity>
)
}
Run Code Online (Sandbox Code Playgroud)
这是我可以滑动的地方:
<Swipeable renderRightActions={RightActions} >
<View style={ContactsStyles.UserContainer}>
<Text numberOfLines={1} style={[Fonts.Name]}> {obj.firstname} {obj.lastname} </Text>
{/* Message/Call Container */}
<View style={ContactsStyles.ImageCont}>
{/* Message */}
<TouchableOpacity onPress={() => Communications.text(obj.phone, 'Hey ' + obj.firstname + ', im in need of a Ryde. Are you able to pick me up? This is my current location: ' + location)} >
<View …Run Code Online (Sandbox Code Playgroud) 当用户输入电话号码时,我希望该号码以电话号码格式显示,例如 (123) 456-7890
我不知道如何去做,但这是我目前拥有的代码。
使用 UseState:
const [PNumber,setPNumber] = useState();
Run Code Online (Sandbox Code Playgroud)
在我的文本输入中:
<TextInput
style={Fonts.Inp}
keyboardType={'number-pad'}
placeholder="(604) 333-3333"
placeholderTextColor='gray'
maxLength={10}
onChangeText = {(Text)=> setPNumber(Text)}
/>
Run Code Online (Sandbox Code Playgroud)
因此目前,它显示为“1234567890”。我希望它显示为 (123) 456-7890