add randomly generated name
This commit is contained in:
@@ -14,17 +14,56 @@ import * as Toast from '../util/Toast'
|
|||||||
|
|
||||||
export const snapPoints = ['70%']
|
export const snapPoints = ['70%']
|
||||||
|
|
||||||
|
const shadesOfBlue: string[] = [
|
||||||
|
'AliceBlue',
|
||||||
|
'Aqua',
|
||||||
|
'Aquamarine',
|
||||||
|
'Azure',
|
||||||
|
'BabyBlue',
|
||||||
|
'Blue',
|
||||||
|
'BlueViolet',
|
||||||
|
'CadetBlue',
|
||||||
|
'CornflowerBlue',
|
||||||
|
'Cyan',
|
||||||
|
'DarkBlue',
|
||||||
|
'DarkCyan',
|
||||||
|
'DarkSlateBlue',
|
||||||
|
'DeepSkyBlue',
|
||||||
|
'DodgerBlue',
|
||||||
|
'ElectricBlue',
|
||||||
|
'LightBlue',
|
||||||
|
'LightCyan',
|
||||||
|
'LightSkyBlue',
|
||||||
|
'LightSteelBlue',
|
||||||
|
'MediumAquaMarine',
|
||||||
|
'MediumBlue',
|
||||||
|
'MediumSlateBlue',
|
||||||
|
'MidnightBlue',
|
||||||
|
'Navy',
|
||||||
|
'PowderBlue',
|
||||||
|
'RoyalBlue',
|
||||||
|
'SkyBlue',
|
||||||
|
'SlateBlue',
|
||||||
|
'SteelBlue',
|
||||||
|
'Teal',
|
||||||
|
'Turquoise',
|
||||||
|
]
|
||||||
|
|
||||||
export function Component({}: {}) {
|
export function Component({}: {}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
const [name, setName] = useState('')
|
const [name, setName] = useState(
|
||||||
const [appPassword, setAppPassword] = useState('')
|
shadesOfBlue[Math.floor(Math.random() * shadesOfBlue.length)],
|
||||||
|
)
|
||||||
|
const [appPassword, setAppPassword] = useState<string>()
|
||||||
const [wasCopied, setWasCopied] = useState(false)
|
const [wasCopied, setWasCopied] = useState(false)
|
||||||
|
|
||||||
const onCopy = React.useCallback(() => {
|
const onCopy = React.useCallback(() => {
|
||||||
|
if (appPassword) {
|
||||||
Clipboard.setString(appPassword)
|
Clipboard.setString(appPassword)
|
||||||
Toast.show('Copied to clipboard')
|
Toast.show('Copied to clipboard')
|
||||||
setWasCopied(true)
|
setWasCopied(true)
|
||||||
|
}
|
||||||
}, [appPassword])
|
}, [appPassword])
|
||||||
|
|
||||||
const onDone = React.useCallback(() => {
|
const onDone = React.useCallback(() => {
|
||||||
@@ -46,7 +85,7 @@ export function Component({}: {}) {
|
|||||||
<View>
|
<View>
|
||||||
<Text type="lg">
|
<Text type="lg">
|
||||||
{!appPassword
|
{!appPassword
|
||||||
? 'Please enter a unique name for this App Password:'
|
? 'Please enter a unique name for this App Password. We have generated a random name for you.'
|
||||||
: "Please save this secret key somewhere safe and accessible. For security reasons, you won't be able to view it again. If you lose this secret key, you'll need to generate a new one."}
|
: "Please save this secret key somewhere safe and accessible. For security reasons, you won't be able to view it again. If you lose this secret key, you'll need to generate a new one."}
|
||||||
</Text>
|
</Text>
|
||||||
{!appPassword ? (
|
{!appPassword ? (
|
||||||
@@ -61,6 +100,11 @@ export function Component({}: {}) {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
|
selectTextOnFocus={true}
|
||||||
|
multiline={true} // need this to be true otherwise selectTextOnFocus doesn't work
|
||||||
|
numberOfLines={1} // hack for multiline so only one line shows (android)
|
||||||
|
scrollEnabled={false} // hack for multiline so only one line shows (ios)
|
||||||
|
blurOnSubmit={true} // hack for multiline so it submits
|
||||||
editable={!appPassword}
|
editable={!appPassword}
|
||||||
returnKeyType="done"
|
returnKeyType="done"
|
||||||
onEndEditing={createAppPassword}
|
onEndEditing={createAppPassword}
|
||||||
@@ -114,6 +158,7 @@ const styles = StyleSheet.create({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
paddingVertical: 10,
|
paddingVertical: 10,
|
||||||
paddingHorizontal: 8,
|
paddingHorizontal: 8,
|
||||||
|
marginTop: 6,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
letterSpacing: 0.25,
|
letterSpacing: 0.25,
|
||||||
fontWeight: '400',
|
fontWeight: '400',
|
||||||
|
|||||||
Reference in New Issue
Block a user