replace button with checkbox

This commit is contained in:
Hailey
2024-06-12 15:57:10 -07:00
parent aa454577aa
commit 3bf87eb1f2
2 changed files with 60 additions and 38 deletions
@@ -1,13 +1,15 @@
import React from 'react'
import {Keyboard, View} from 'react-native'
import {Keyboard, Pressable, View} from 'react-native'
import {GeneratorView} from '@atproto/api/dist/client/types/app/bsky/feed/defs'
import {msg, Trans} from '@lingui/macro'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isWeb} from 'platform/detection'
import {UserAvatar} from 'view/com/util/UserAvatar'
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Toggle from '#/components/forms/Toggle'
import {Checkbox} from '#/components/forms/Toggle'
import {Text} from '#/components/Typography'
export function WizardFeedCard({
@@ -23,7 +25,7 @@ export function WizardFeedCard({
const t = useTheme()
const includesFeed = state.feeds.some(f => f.uri === generator.uri)
const onAdd = () => {
const onPressAddRemove = () => {
Keyboard.dismiss()
if (includesFeed) {
dispatch({type: 'RemoveFeed', feedUri: generator.uri})
@@ -33,16 +35,22 @@ export function WizardFeedCard({
}
return (
<View
<Pressable
accessibilityRole="button"
style={[
a.flex_row,
a.align_center,
a.px_md,
a.py_sm,
a.border_b,
a.gap_md,
a.border_b,
t.atoms.border_contrast_low,
]}>
// @ts-expect-error web only
isWeb && {
cursor: 'default',
},
]}
onPress={onPressAddRemove}>
<UserAvatar type="algo" size={45} avatar={generator.avatar} />
<View style={[a.flex_1]}>
<Text style={[a.flex_1, a.font_bold, a.text_md]} numberOfLines={1}>
@@ -54,18 +62,17 @@ export function WizardFeedCard({
{_(msg`Feed by @${generator.creator.handle}`)}
</Text>
</View>
<Button
label={includesFeed ? _(msg`Remove`) : _(msg`Add`)}
variant="solid"
color={includesFeed ? 'secondary' : 'primary'}
size="small"
style={{paddingVertical: 6}}
disabled={!includesFeed && state.feeds.length >= 3}
onPress={onAdd}>
<ButtonText>
{includesFeed ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
</ButtonText>
</Button>
</View>
<Toggle.Item
name={_(msg`Person toggle`)}
label={
includesFeed
? _(msg`Remove ${generator.displayName} from starter pack`)
: _(msg`Add ${generator.displayName} to starter pack`)
}
value={includesFeed}
onChange={onPressAddRemove}>
<Checkbox />
</Toggle.Item>
</Pressable>
)
}
@@ -1,14 +1,16 @@
import React from 'react'
import {Keyboard, View} from 'react-native'
import {Keyboard, Pressable, View} from 'react-native'
import {AppBskyActorDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isWeb} from 'platform/detection'
import {useSession} from 'state/session'
import {UserAvatar} from 'view/com/util/UserAvatar'
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Toggle from '#/components/forms/Toggle'
import {Checkbox} from '#/components/forms/Toggle'
import {Text} from '#/components/Typography'
export function WizardProfileCard({
@@ -36,7 +38,8 @@ export function WizardProfileCard({
}
return (
<View
<Pressable
accessibilityRole="button"
style={[
a.flex_row,
a.align_center,
@@ -45,7 +48,12 @@ export function WizardProfileCard({
a.gap_md,
a.border_b,
t.atoms.border_contrast_low,
]}>
// @ts-expect-error web only
isWeb && {
cursor: 'default',
},
]}
onPress={onPressAddRemove}>
<UserAvatar size={45} avatar={profile?.avatar} />
<View style={[a.flex_1]}>
<Text style={[a.flex_1, a.font_bold, a.text_md]} numberOfLines={1}>
@@ -58,19 +66,26 @@ export function WizardProfileCard({
</Text>
</View>
{profile.did !== currentAccount?.did && (
<Button
label={includesProfile ? _(msg`Remove`) : _(msg`Add`)}
variant="solid"
color={includesProfile ? 'secondary' : 'primary'}
size="small"
style={{paddingVertical: 6}}
disabled={!includesProfile && state.profiles.length >= 50}
onPress={onPressAddRemove}>
<ButtonText>
{includesProfile ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
</ButtonText>
</Button>
<Toggle.Item
name={_(msg`Person toggle`)}
label={
includesProfile
? _(
msg`Remove ${
profile.displayName || profile.handle
} from starter pack`,
)
: _(
msg`Add ${
profile.displayName || profile.handle
} to starter pack`,
)
}
value={includesProfile}
onChange={onPressAddRemove}>
<Checkbox />
</Toggle.Item>
)}
</View>
</Pressable>
)
}