Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: adds dynamic tabs * moved bottom tabs * fix * update podfile * apollosconfig tabs * fixed * removed tabs from template * dont need to prop spread here * include android search fix * podfile Co-authored-by: Vincent Wilson <vince@classyh.at>
- Loading branch information
1 parent
2ad3fcb
commit 4671c1a
Showing
10 changed files
with
240 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/apollos-ui-connected/src/TabsConnected/createTab.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useNavigation, useRoute } from '@react-navigation/native'; | ||
|
||
import { BackgroundView } from '@apollosproject/ui-kit'; | ||
|
||
import { createNativeStackNavigator } from 'react-native-screens/native-stack'; | ||
import RockAuthedWebBrowser from '../RockAuthedWebBrowser'; | ||
import FeaturesFeedConnected from '../FeaturesFeedConnected'; | ||
|
||
import ContentFeed from '../ContentFeedConnected'; | ||
import TagFilterConnected from '../TagFilterConnected'; | ||
|
||
const Tab = ({ useTagFilter, feedViewProps, additionalFeatures }) => { | ||
const navigation = useNavigation(); | ||
const route = useRoute(); | ||
const [filteredTags, setFilteredTags] = useState([]); | ||
return ( | ||
<> | ||
{useTagFilter ? ( | ||
<TagFilterConnected | ||
filteredTags={filteredTags} | ||
setFilteredTags={setFilteredTags} | ||
/> | ||
) : null} | ||
<RockAuthedWebBrowser> | ||
{(openUrl) => ( | ||
<BackgroundView> | ||
<FeaturesFeedConnected | ||
openUrl={openUrl} | ||
featureFeedId={route.params.featureFeedId} | ||
navigation={navigation} | ||
feedViewProps={feedViewProps} | ||
additionalFeatures={additionalFeatures} | ||
/> | ||
</BackgroundView> | ||
)} | ||
</RockAuthedWebBrowser> | ||
</> | ||
); | ||
}; | ||
|
||
Tab.propTypes = { | ||
useTagFilter: PropTypes.bool, | ||
feedViewProps: PropTypes.shape({}), | ||
additionalFeatures: PropTypes.shape({}), | ||
}; | ||
|
||
Tab.defaultProps = { | ||
useTagFilter: false, | ||
feedViewProps: {}, | ||
additionalFeatures: {}, | ||
}; | ||
|
||
export const createTab = ({ featureFeedId, title, screenOptions, options }) => { | ||
const TabStack = createNativeStackNavigator(); | ||
const TabNav = () => ( | ||
<TabStack.Navigator | ||
screenOptions={{ | ||
headerHideShadow: true, | ||
headerLargeTitle: true, | ||
...screenOptions, | ||
}} | ||
> | ||
<TabStack.Screen | ||
name={title} | ||
component={Tab} | ||
options={options} | ||
initialParams={{ featureFeedId }} | ||
/> | ||
<TabStack.Screen | ||
component={ContentFeed} | ||
name="ContentFeed" | ||
options={({ route }) => ({ | ||
title: route?.params?.itemTitle || 'Content Feed', | ||
})} | ||
/> | ||
<TabStack.Screen | ||
component={FeaturesFeedConnected} | ||
name="FeatureFeed" | ||
options={({ route }) => ({ | ||
title: route?.params?.title || 'Feed', | ||
})} | ||
/> | ||
</TabStack.Navigator> | ||
); | ||
return TabNav; | ||
}; | ||
|
||
export default createTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { ActivityIndicator } from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import { useQuery, gql } from '@apollo/client'; | ||
import Tabs from './Tabs'; | ||
|
||
const GET_USER_CAMPUS_ID = gql` | ||
query GetUserCampusID { | ||
currentUser { | ||
id | ||
profile { | ||
id | ||
campus { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const GET_TABS = gql` | ||
query GetTabs($campusId: ID) { | ||
tabs(campusId: $campusId) { | ||
title | ||
icon | ||
feed { | ||
id | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const TabsConnected = ({ hasCampus }) => { | ||
const { data: campusData, loading, error } = useQuery(GET_USER_CAMPUS_ID); | ||
const { data } = useQuery(GET_TABS, { | ||
variables: { | ||
campusId: hasCampus ? campusData?.currentUser?.profile?.campus?.id : null, | ||
}, | ||
fetchPolicy: 'cache-and-network', | ||
}); | ||
if (error) return null; | ||
if (loading) return <ActivityIndicator />; | ||
return <Tabs tabs={data?.tabs ?? []} />; | ||
}; | ||
|
||
TabsConnected.propTypes = { | ||
hasCampus: PropTypes.bool, | ||
}; | ||
|
||
TabsConnected.defaultProps = { | ||
hasCampus: false, | ||
}; | ||
|
||
export default TabsConnected; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.