mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
small address input format helper
This commit is contained in:
@@ -126,6 +126,20 @@ const ServerView: React.FC<{
|
|||||||
return !validate() || testing || removing || saving
|
return !validate() || testing || removing || saving
|
||||||
}, [validate, testing, removing, saving])
|
}, [validate, testing, removing, saving])
|
||||||
|
|
||||||
|
const formatAddress = useCallback(() => {
|
||||||
|
let addressFormatted = address.trim()
|
||||||
|
|
||||||
|
if (addressFormatted.endsWith('/')) {
|
||||||
|
addressFormatted = addressFormatted.substr(0, addressFormatted.length - 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addressFormatted.length > 0 && !addressFormatted.includes(':/')) {
|
||||||
|
addressFormatted = `http://${addressFormatted}`
|
||||||
|
}
|
||||||
|
|
||||||
|
setAddress(addressFormatted)
|
||||||
|
}, [address])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GradientScrollView style={styles.scroll} contentContainerStyle={styles.scrollContentContainer}>
|
<GradientScrollView style={styles.scroll} contentContainerStyle={styles.scrollContentContainer}>
|
||||||
<View style={styles.content}>
|
<View style={styles.content}>
|
||||||
@@ -138,6 +152,7 @@ const ServerView: React.FC<{
|
|||||||
placeholder="http://demo.navidrome.org"
|
placeholder="http://demo.navidrome.org"
|
||||||
value={address}
|
value={address}
|
||||||
onChangeText={setAddress}
|
onChangeText={setAddress}
|
||||||
|
onBlur={formatAddress}
|
||||||
/>
|
/>
|
||||||
<Text style={styles.inputTitle}>Username</Text>
|
<Text style={styles.inputTitle}>Username</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
Reference in New Issue
Block a user