Skip to content

Commit 28b2155

Browse files
authored
Merge pull request #7 from fatfingers23/feature/ChangeHandleDomainSelect
Added the dropdown domain picker for change handle
2 parents e659870 + c12c626 commit 28b2155

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

src/screens/Settings/components/ChangeHandleDialog.tsx

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {CheckThick_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icon
4040
import {SquareBehindSquare4_Stroke2_Corner0_Rounded as CopyIcon} from '#/components/icons/SquareBehindSquare4'
4141
import {InlineLinkText} from '#/components/Link'
4242
import {Loader} from '#/components/Loader'
43+
import * as Menu from '#/components/Menu'
4344
import {Text} from '#/components/Typography'
4445
import {useSimpleVerificationState} from '#/components/verification'
4546
import {CopyButton} from './CopyButton'
@@ -149,6 +150,7 @@ function ProvidedHandlePage({
149150
goToOwnHandle: () => void
150151
}) {
151152
const {_} = useLingui()
153+
const t = useTheme()
152154
const [subdomain, setSubdomain] = useState('')
153155
const agent = useAgent()
154156
const control = Dialog.useDialogContext()
@@ -175,7 +177,12 @@ function ProvidedHandlePage({
175177
},
176178
})
177179

178-
const host = serviceInfo.availableUserDomains[0]
180+
const [host, setHost] = useState(serviceInfo.availableUserDomains?.[0] || '')
181+
182+
const availableDomains = useMemo(
183+
() => serviceInfo.availableUserDomains || [],
184+
[serviceInfo.availableUserDomains],
185+
)
179186

180187
const validation = useMemo(
181188
() => validateServiceHandle(subdomain, host),
@@ -240,6 +247,74 @@ function ProvidedHandlePage({
240247
{host}
241248
</TextField.SuffixText>
242249
</TextField.Root>
250+
{availableDomains.length > 1 && (
251+
<View style={[a.mt_md]}>
252+
<Text
253+
style={[a.text_sm, a.mb_xs, t.atoms.text_contrast_medium]}>
254+
<Trans>Domain</Trans>
255+
</Text>
256+
<Menu.Root>
257+
<Menu.Trigger label={_(msg`Select domain`)}>
258+
{({props}) => (
259+
<Button
260+
{...props}
261+
label={_(msg`Select domain`)}
262+
variant="solid"
263+
color="secondary"
264+
size="large"
265+
style={[
266+
a.flex_row,
267+
a.align_center,
268+
a.justify_between,
269+
a.w_full,
270+
]}>
271+
<View style={[a.flex_1, a.align_start]}>
272+
<ButtonText style={[a.text_md, a.font_bold]}>
273+
{host}
274+
</ButtonText>
275+
{host === availableDomains[0] && (
276+
<Text
277+
style={[a.text_xs, t.atoms.text_contrast_medium]}>
278+
<Trans>Default</Trans>
279+
</Text>
280+
)}
281+
</View>
282+
<ButtonIcon icon={ArrowRightIcon} />
283+
</Button>
284+
)}
285+
</Menu.Trigger>
286+
<Menu.Outer>
287+
<Menu.Group>
288+
{availableDomains.map((domain, index) => (
289+
<Menu.Item
290+
key={domain}
291+
label={domain}
292+
onPress={() => setHost(domain)}>
293+
<Menu.ItemText>
294+
<View
295+
style={[a.flex_row, a.align_center, a.gap_sm]}>
296+
<Text>{domain}</Text>
297+
{index === 0 && (
298+
<Text
299+
style={[
300+
a.text_xs,
301+
t.atoms.text_contrast_medium,
302+
]}>
303+
(<Trans>Default</Trans>)
304+
</Text>
305+
)}
306+
</View>
307+
</Menu.ItemText>
308+
{host === domain && (
309+
<Menu.ItemIcon icon={CheckIcon} />
310+
)}
311+
</Menu.Item>
312+
))}
313+
</Menu.Group>
314+
</Menu.Outer>
315+
</Menu.Root>
316+
</View>
317+
)}
243318
</View>
244319
<Text>
245320
<Trans>

0 commit comments

Comments
 (0)