-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🧬 upd. CardAddress. + error message
- Loading branch information
1 parent
0afae2c
commit f59bc6c
Showing
3 changed files
with
75 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,64 @@ | ||
import { StyleProp, StyleSheet, View, ViewStyle } from "react-native"; | ||
import { observer } from "mobx-react-lite"; | ||
import { Card, Icon2 } from "components/atoms"; | ||
import { useTheme } from "hooks"; | ||
import { TextInput, TouchableOpacity } from "react-native-gesture-handler"; | ||
import { COLOR, InputHandler } from "utils"; | ||
import { useMemo } from "react"; | ||
import { trimAddress } from "utils/string"; | ||
import { StyleProp, StyleSheet, View, ViewStyle } from "react-native" | ||
import { observer } from "mobx-react-lite" | ||
import { Icon2, Input } from "components/atoms" | ||
import { useTheme } from "hooks" | ||
import { TouchableOpacity } from "react-native-gesture-handler" | ||
import { COLOR, InputHandler } from "utils" | ||
import { useMemo } from "react" | ||
import { trimAddress } from "utils/string" | ||
|
||
type Props = { | ||
input: InputHandler; | ||
onPressQR(): void; | ||
style?: StyleProp<ViewStyle>; | ||
}; | ||
input: InputHandler | ||
onPressQR(): void | ||
style?: StyleProp<ViewStyle> | ||
isError?: boolean | ||
} | ||
|
||
export default observer<Props>(function CardWallet({ | ||
onPressQR, | ||
input, | ||
style, | ||
}: Props) { | ||
const theme = useTheme(); | ||
const value = useMemo(() => { | ||
const text = input.value; | ||
if (input.isFocused || text.length < 25) return text; | ||
return trimAddress(text); | ||
}, [input.isFocused, input.value]); | ||
export default observer<Props>(function CardWallet({ onPressQR, input, style, isError }: Props) { | ||
const theme = useTheme() | ||
|
||
return ( | ||
<Card style={[styles.container, style]}> | ||
<TextInput | ||
style={[theme.text.primary, styles.input]} | ||
placeholder="Public Address" | ||
onChangeText={input.set} | ||
onFocus={input.focusON} | ||
onBlur={input.focusOFF} | ||
placeholderTextColor={theme.input.placeholder} | ||
value={value} | ||
/> | ||
<View style={styles.buttonContainer}> | ||
<TouchableOpacity onPress={onPressQR} style={styles.touchable}> | ||
<Icon2 name="scan" stroke={COLOR.RoyalBlue} size={18} /> | ||
</TouchableOpacity> | ||
</View> | ||
</Card> | ||
); | ||
}); | ||
const value = useMemo(() => { | ||
const text = input.value | ||
if (input.isFocused || text.length < 25) return text | ||
return trimAddress(text) | ||
}, [input.isFocused, input.value]) | ||
|
||
return ( | ||
<Input | ||
bottomsheet | ||
style={[theme.text.primary, styles.container, style]} | ||
inputStyle={styles.input} | ||
placeholder="Public Address" | ||
onChangeText={input.set} | ||
onFocus={input.focusON} | ||
onBlur={input.focusOFF} | ||
placeholderTextColor={theme.input.placeholder} | ||
value={value} | ||
errorMessage={isError && "Invalid address"} | ||
errorStyle={styles.error} | ||
Right={ | ||
<View style={styles.buttonContainer}> | ||
<TouchableOpacity onPress={onPressQR} style={styles.touchable}> | ||
<Icon2 name="scan" stroke={COLOR.RoyalBlue} size={18} /> | ||
</TouchableOpacity> | ||
</View> | ||
} | ||
/> | ||
) | ||
}) | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
backgroundColor: COLOR.Dark3, | ||
height: 70, | ||
justifyContent: "space-between", | ||
flexDirection: "row", | ||
overflow: "hidden", | ||
}, | ||
input: { | ||
paddingLeft: 26, | ||
flex: 1, | ||
}, | ||
touchable: { | ||
justifyContent: "center", | ||
alignItems: "center", | ||
borderRadius: 40, | ||
padding: 26, | ||
}, | ||
buttonContainer: { | ||
justifyContent: "center", | ||
}, | ||
}); | ||
container: { | ||
backgroundColor: COLOR.Dark3, | ||
borderRadius: 20, | ||
}, | ||
input: { height: 70 }, | ||
error: { left: 0 }, | ||
touchable: { | ||
justifyContent: "center", | ||
alignItems: "center", | ||
borderRadius: 40, | ||
padding: 26, | ||
}, | ||
buttonContainer: { justifyContent: "center" }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters