Changeset View
Changeset View
Standalone View
Standalone View
native/navigation/community-drawer-content.react.js
// @flow | // @flow | ||||
import { useDrawerStatus } from '@react-navigation/drawer'; | import { useDrawerStatus } from '@react-navigation/drawer'; | ||||
import { useNavigation } from '@react-navigation/native'; | |||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { FlatList, Platform, View, Text } from 'react-native'; | import { FlatList, Platform, View, Text, TouchableOpacity } from 'react-native'; | ||||
import { SafeAreaView } from 'react-native-safe-area-context'; | import { SafeAreaView } from 'react-native-safe-area-context'; | ||||
import { useSelector } from 'react-redux'; | import { useSelector } from 'react-redux'; | ||||
import { | import { | ||||
fetchPrimaryInviteLinkActionTypes, | fetchPrimaryInviteLinkActionTypes, | ||||
fetchPrimaryInviteLinks, | fetchPrimaryInviteLinks, | ||||
} from 'lib/actions/link-actions.js'; | } from 'lib/actions/link-actions.js'; | ||||
import { | import { | ||||
childThreadInfos, | childThreadInfos, | ||||
communityThreadSelector, | communityThreadSelector, | ||||
} from 'lib/selectors/thread-selectors.js'; | } from 'lib/selectors/thread-selectors.js'; | ||||
import { | import { | ||||
useDispatchActionPromise, | useDispatchActionPromise, | ||||
useServerCall, | useServerCall, | ||||
} from 'lib/utils/action-utils.js'; | } from 'lib/utils/action-utils.js'; | ||||
import { | import { | ||||
createRecursiveDrawerItemsData, | createRecursiveDrawerItemsData, | ||||
appendSuffix, | appendSuffix, | ||||
} from 'lib/utils/drawer-utils.react.js'; | } from 'lib/utils/drawer-utils.react.js'; | ||||
import { useResolvedThreadInfos } from 'lib/utils/entity-helpers.js'; | import { useResolvedThreadInfos } from 'lib/utils/entity-helpers.js'; | ||||
import CommunityDrawerItemCommunity from './community-drawer-item-community.react.js'; | import CommunityDrawerItemCommunity from './community-drawer-item-community.react.js'; | ||||
import { CommunityCreationRouteName } from './route-names.js'; | |||||
import { useNavigateToThread } from '../chat/message-list-types.js'; | import { useNavigateToThread } from '../chat/message-list-types.js'; | ||||
import SWMansionIcon from '../components/swmansion-icon.react.js'; | import SWMansionIcon from '../components/swmansion-icon.react.js'; | ||||
import { useStyles } from '../themes/colors.js'; | import { useStyles } from '../themes/colors.js'; | ||||
const maxDepth = 2; | const maxDepth = 2; | ||||
const safeAreaEdges = Platform.select({ | const safeAreaEdges = Platform.select({ | ||||
ios: ['top'], | ios: ['top'], | ||||
default: ['top', 'bottom'], | default: ['top', 'bottom'], | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | () => | ||||
childThreadInfosMap, | childThreadInfosMap, | ||||
communitiesSuffixed, | communitiesSuffixed, | ||||
labelStyles, | labelStyles, | ||||
maxDepth, | maxDepth, | ||||
), | ), | ||||
[childThreadInfosMap, communitiesSuffixed, labelStyles], | [childThreadInfosMap, communitiesSuffixed, labelStyles], | ||||
); | ); | ||||
const { navigate } = useNavigation(); | |||||
const onPressCommunityCreation = React.useCallback(() => { | |||||
navigate(CommunityCreationRouteName); | |||||
}, [navigate]); | |||||
const isCommunityCreationButtonEnabled = false; | const isCommunityCreationButtonEnabled = false; | ||||
let communityCreationButton; | let communityCreationButton; | ||||
if (isCommunityCreationButtonEnabled) { | if (isCommunityCreationButtonEnabled) { | ||||
communityCreationButton = ( | communityCreationButton = ( | ||||
<TouchableOpacity onPress={onPressCommunityCreation} activeOpacity={0.4}> | |||||
<View style={styles.communityCreationContainer}> | <View style={styles.communityCreationContainer}> | ||||
<View style={styles.communityCreationIconContainer}> | <View style={styles.communityCreationIconContainer}> | ||||
<SWMansionIcon | <SWMansionIcon | ||||
name="plus" | name="plus" | ||||
size={22} | size={22} | ||||
style={styles.communityCreationIcon} | style={styles.communityCreationIcon} | ||||
/> | /> | ||||
</View> | </View> | ||||
<Text style={styles.communityCreationText}>Create community</Text> | <Text style={styles.communityCreationText}>Create community</Text> | ||||
</View> | </View> | ||||
</TouchableOpacity> | |||||
); | ); | ||||
} | } | ||||
return ( | return ( | ||||
<SafeAreaView style={styles.drawerContent} edges={safeAreaEdges}> | <SafeAreaView style={styles.drawerContent} edges={safeAreaEdges}> | ||||
<FlatList data={drawerItemsData} renderItem={renderItem} /> | <FlatList data={drawerItemsData} renderItem={renderItem} /> | ||||
{communityCreationButton} | {communityCreationButton} | ||||
</SafeAreaView> | </SafeAreaView> | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |