import {useState} from 'react' import {Pressable, View} from 'react-native' import * as Clipboard from 'expo-clipboard' import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' import {atoms as a, native, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {ArrowRotateClockwise_Stroke2_Corner0_Rounded as ArrowRotate} from '#/components/icons/ArrowRotate' import {Loader} from '#/components/Loader' import * as ProfileCard from '#/components/ProfileCard' import * as Toast from '#/components/Toast' import {Text} from '#/components/Typography' import {Features, features, refresh} from '#/analytics/features' export function GrowthbookDialog({ control, }: { control: Dialog.DialogControlProps }) { return ( ) } function GrowthbookDialogInner() { const t = useTheme() const [isRefreshing, setIsRefreshing] = useState(false) return ( GrowthBook }> {Object.entries(Features).map(([name, key]) => ( ))} ) } function RefreshButton({ isRefreshing, setIsRefreshing, }: { isRefreshing: boolean setIsRefreshing: React.Dispatch> }) { const onPress = () => { setIsRefreshing(true) refresh({strategy: 'prefer-fresh-gates'}) .then(() => { Toast.show('Refreshed feature flags', {type: 'success'}) }) .catch(() => { Toast.show('Failed to refresh feature flags', {type: 'error'}) }) .finally(() => { setIsRefreshing(false) }) } return ( ) } function FeatureRow({ name, featureKey, isRefreshing, }: { name: string featureKey: string isRefreshing: boolean }) { const t = useTheme() const value = features.evalFeature(featureKey).value const onPress = () => { void Clipboard.setStringAsync(featureKey) Toast.show('Copied feature flag key to clipboard', {type: 'success'}) } return ( {name} {featureKey} {isRefreshing ? : } ) } function CurrentProfile() { const t = useTheme() const {currentAccount} = useSession() const moderationOpts = useModerationOpts() const {data: profile} = useProfileQuery({did: currentAccount?.did}) if (!currentAccount) { return ( No active account ) } const onPressDid = () => { void Clipboard.setStringAsync(currentAccount.did) Toast.show('Copied did to clipboard', {type: 'success'}) } return profile && moderationOpts ? ( ) : null } function FeatureValue({value}: {value: unknown}) { const t = useTheme() let label: string let color: string if (value === true) { label = 'true' color = t.palette.positive_500 } else if (value === false) { label = 'false' color = t.palette.negative_500 } else if (value === null || value === undefined) { label = 'null' color = t.palette.contrast_500 } else { label = JSON.stringify(value) color = t.palette.contrast_700 } return {label} }