mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at mod-auth 180 lines 5.0 kB view raw
1import React from 'react' 2import {SafeAreaView, StyleSheet, View} from 'react-native' 3import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 4import {msg, Trans} from '@lingui/macro' 5import {useLingui} from '@lingui/react' 6 7import {usePalette} from '#/lib/hooks/usePalette' 8import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' 9import {shareUrl} from '#/lib/sharing' 10import {isPossiblyAUrl, splitApexDomain} from '#/lib/strings/url-helpers' 11import {colors, s} from '#/lib/styles' 12import {isWeb} from '#/platform/detection' 13import {useModalControls} from '#/state/modals' 14import {useOpenLink} from '#/state/preferences/in-app-browser' 15import {Button} from '#/view/com/util/forms/Button' 16import {Text} from '#/view/com/util/text/Text' 17import {ScrollView} from './util' 18 19export const snapPoints = ['50%'] 20 21export function Component({ 22 text, 23 href, 24 share, 25}: { 26 text: string 27 href: string 28 share?: boolean 29}) { 30 const pal = usePalette('default') 31 const {closeModal} = useModalControls() 32 const {isMobile} = useWebMediaQueries() 33 const {_} = useLingui() 34 const potentiallyMisleading = isPossiblyAUrl(text) 35 const openLink = useOpenLink() 36 37 const onPressVisit = () => { 38 closeModal() 39 if (share) { 40 shareUrl(href) 41 } else { 42 openLink(href) 43 } 44 } 45 46 return ( 47 <SafeAreaView style={[s.flex1, pal.view]}> 48 <ScrollView 49 testID="linkWarningModal" 50 style={[s.flex1, isMobile && {paddingHorizontal: 18}]}> 51 <View style={styles.titleSection}> 52 {potentiallyMisleading ? ( 53 <> 54 <FontAwesomeIcon 55 icon="circle-exclamation" 56 color={pal.colors.text} 57 size={18} 58 /> 59 <Text type="title-lg" style={[pal.text, styles.title]}> 60 <Trans>Potentially Misleading Link</Trans> 61 </Text> 62 </> 63 ) : ( 64 <Text type="title-lg" style={[pal.text, styles.title]}> 65 <Trans>Leaving Bluesky</Trans> 66 </Text> 67 )} 68 </View> 69 70 <View style={{gap: 10}}> 71 <Text type="lg" style={pal.text}> 72 <Trans>This link is taking you to the following website:</Trans> 73 </Text> 74 75 <LinkBox href={href} /> 76 77 {potentiallyMisleading && ( 78 <Text type="lg" style={pal.text}> 79 <Trans>Make sure this is where you intend to go!</Trans> 80 </Text> 81 )} 82 </View> 83 84 <View style={[styles.btnContainer, isMobile && {paddingBottom: 40}]}> 85 <Button 86 testID="confirmBtn" 87 type="primary" 88 onPress={onPressVisit} 89 accessibilityLabel={share ? _(msg`Share Link`) : _(msg`Visit Site`)} 90 accessibilityHint={ 91 share 92 ? _(msg`Shares the linked website`) 93 : _(msg`Opens the linked website`) 94 } 95 label={share ? _(msg`Share Link`) : _(msg`Visit Site`)} 96 labelContainerStyle={{justifyContent: 'center', padding: 4}} 97 labelStyle={[s.f18]} 98 /> 99 <Button 100 testID="cancelBtn" 101 type="default" 102 onPress={() => { 103 closeModal() 104 }} 105 accessibilityLabel={_(msg`Cancel`)} 106 accessibilityHint={_(msg`Cancels opening the linked website`)} 107 label={_(msg`Cancel`)} 108 labelContainerStyle={{justifyContent: 'center', padding: 4}} 109 labelStyle={[s.f18]} 110 /> 111 </View> 112 </ScrollView> 113 </SafeAreaView> 114 ) 115} 116 117function LinkBox({href}: {href: string}) { 118 const pal = usePalette('default') 119 const [scheme, hostname, rest] = React.useMemo(() => { 120 try { 121 const urlp = new URL(href) 122 const [subdomain, apexdomain] = splitApexDomain(urlp.hostname) 123 return [ 124 urlp.protocol + '//' + subdomain, 125 apexdomain, 126 urlp.pathname + urlp.search + urlp.hash, 127 ] 128 } catch { 129 return ['', href, ''] 130 } 131 }, [href]) 132 return ( 133 <View style={[pal.view, pal.border, styles.linkBox]}> 134 <Text type="lg" style={pal.textLight}> 135 {scheme} 136 <Text type="lg-bold" style={pal.text}> 137 {hostname} 138 </Text> 139 {rest} 140 </Text> 141 </View> 142 ) 143} 144 145const styles = StyleSheet.create({ 146 container: { 147 flex: 1, 148 paddingBottom: isWeb ? 0 : 40, 149 }, 150 titleSection: { 151 flexDirection: 'row', 152 justifyContent: 'center', 153 alignItems: 'center', 154 gap: 6, 155 paddingTop: isWeb ? 0 : 4, 156 paddingBottom: isWeb ? 14 : 10, 157 }, 158 title: { 159 textAlign: 'center', 160 fontWeight: '600', 161 }, 162 linkBox: { 163 paddingHorizontal: 12, 164 paddingVertical: 10, 165 borderRadius: 6, 166 borderWidth: 1, 167 }, 168 btn: { 169 flexDirection: 'row', 170 alignItems: 'center', 171 justifyContent: 'center', 172 borderRadius: 32, 173 padding: 14, 174 backgroundColor: colors.blue3, 175 }, 176 btnContainer: { 177 paddingTop: 20, 178 gap: 6, 179 }, 180})