Skip to content

Commit 2e843f8

Browse files
committed
Add password length selector in the RandomPassword screen
1 parent 7fd0e03 commit 2e843f8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/screens/Try/RandomPassword.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
import { Gap12 } from '@components/Gap'
2-
import { SettText, SettWrapper } from '@components/Settings'
2+
import Range from '@components/Range'
3+
import { SettGroup, SettText, SettWrapper } from '@components/Settings'
4+
import { Txt } from '@components/Text'
35
import type { NavProp } from '@utils/types'
4-
import React from 'react'
6+
import React, { useState } from 'react'
7+
import { View } from 'react-native'
8+
9+
const MIN = 1
10+
const MAX = 49
11+
function getCurrVal(len: number) {
12+
return Math.floor(len * MAX + MIN)
13+
}
514

615
export default function RandomPassword({ navigation }: NavProp) {
16+
const [len, setLen] = useState<number>(10 / 50)
17+
718
return (
819
<SettWrapper navigation={navigation} title='Random Password'>
920
<Gap12>
1021
<SettText className='mt-3'>Here you will set some options to generate a random password</SettText>
22+
<SettGroup title='Password Length'>
23+
<View>
24+
<Range value={len} setValue={setLen} Left={<Txt>1</Txt>} Right={<Txt>50</Txt>} />
25+
<Txt className='pb-2 text-center'>Length {getCurrVal(len)}</Txt>
26+
</View>
27+
</SettGroup>
1128
</Gap12>
1229
</SettWrapper>
1330
)

0 commit comments

Comments
 (0)