This repository was archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
[C-1291] Add base layout for navbar overhaul #2139
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
packages/mobile/src/components/bottom-tab-bar/bottom-tab-bar-buttons/NotificationsButton.tsx
This file contains hidden or 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,37 @@ | ||
| import { useMemo } from 'react' | ||
|
|
||
| import IconExploreLight from 'app/assets/animations/iconExploreLight.json' | ||
| import { colorize } from 'app/utils/colorizeLottie' | ||
| import { useThemeColors } from 'app/utils/theme' | ||
|
|
||
| import type { BaseBottomTabBarButtonProps } from './BottomTabBarButton' | ||
| import { BottomTabBarButton } from './BottomTabBarButton' | ||
|
|
||
| type NotificationsButtonProps = BaseBottomTabBarButtonProps | ||
|
|
||
| export const NotificationsButton = (props: NotificationsButtonProps) => { | ||
| const { primary, neutral } = useThemeColors() | ||
|
|
||
| const IconExplore = useMemo( | ||
| () => | ||
| colorize(IconExploreLight, { | ||
| // icon_Explore Outlines.Group 1.Fill 1 | ||
| 'layers.0.shapes.0.it.4.c.k.0.s': neutral, | ||
| // icon_Explore Outlines.Group 1.Fill 1 | ||
| 'layers.0.shapes.0.it.4.c.k.1.s': primary, | ||
| // icon_Explore Outlines.Group 2.Fill 1 | ||
| 'layers.0.shapes.1.it.0.c.k.0.s': primary, | ||
| // icon_Explore Outlines.Group 2.Fill 1 | ||
| 'layers.0.shapes.1.it.0.c.k.1.s': neutral | ||
| }), | ||
| [primary, neutral] | ||
| ) | ||
|
|
||
| return ( | ||
| <BottomTabBarButton | ||
| name='notifications' | ||
| iconJSON={IconExplore} | ||
| {...props} | ||
| /> | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
28 changes: 28 additions & 0 deletions
28
packages/mobile/src/screens/account-screen/AccountDrawer.tsx
This file contains hidden or 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,28 @@ | ||
| import { useCallback } from 'react' | ||
|
|
||
| import { accountSelectors } from '@audius/common' | ||
| import type { DrawerContentComponentProps } from '@react-navigation/drawer' | ||
| import { DrawerContentScrollView } from '@react-navigation/drawer' | ||
| import { useSelector } from 'react-redux' | ||
|
|
||
| import { Text } from 'app/components/core' | ||
|
|
||
| import { useAppDrawerNavigation } from '../app-drawer-screen' | ||
| const { getAccountUser } = accountSelectors | ||
|
|
||
| type AccountDrawerProps = DrawerContentComponentProps | ||
|
|
||
| export const AccountDrawer = (props: AccountDrawerProps) => { | ||
| const accountUser = useSelector(getAccountUser) | ||
| const navigation = useAppDrawerNavigation() | ||
|
|
||
| const handlePressAccount = useCallback(() => { | ||
| navigation.navigate('Profile', { handle: 'accountUser' }) | ||
| }, [navigation]) | ||
|
|
||
| return ( | ||
| <DrawerContentScrollView {...props}> | ||
| <Text onPress={handlePressAccount}>{accountUser?.name}</Text> | ||
| </DrawerContentScrollView> | ||
| ) | ||
| } |
This file contains hidden or 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 @@ | ||
| export * from './AccountDrawer' |
This file contains hidden or 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
82 changes: 82 additions & 0 deletions
82
packages/mobile/src/screens/app-drawer-screen/AppDrawerScreen.tsx
This file contains hidden or 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,82 @@ | ||
| import { useMemo, useState } from 'react' | ||
|
|
||
| import { FeatureFlags } from '@audius/common' | ||
| import { createDrawerNavigator } from '@react-navigation/drawer' | ||
| // eslint-disable-next-line import/no-unresolved | ||
| import type { DrawerNavigationHelpers } from '@react-navigation/drawer/lib/typescript/src/types' | ||
| import { useNavigation } from '@react-navigation/native' | ||
| import { Dimensions } from 'react-native' | ||
|
|
||
| import { useFeatureFlag } from 'app/hooks/useRemoteConfig' | ||
| import { NotificationsDrawer } from 'app/screens/notifications-screen' | ||
|
|
||
| import { AccountDrawer } from '../account-screen' | ||
| import { AppScreen } from '../app-screen' | ||
|
|
||
| import { AppDrawerContextProvider } from './AppDrawerContext' | ||
|
|
||
| const SCREEN_WIDTH = Dimensions.get('window').width | ||
|
|
||
| const baseDrawerScreenOptions = { | ||
| drawerType: 'slide' as const, | ||
| headerShown: false, | ||
| swipeEdgeWidth: SCREEN_WIDTH | ||
| } | ||
|
|
||
| const Drawer = createDrawerNavigator() | ||
|
|
||
| type AppTabScreenProps = { | ||
| navigation: DrawerNavigationHelpers | ||
| } | ||
|
|
||
| /** | ||
| * The app stack after signing up or signing in | ||
| */ | ||
| const AppStack = (props: AppTabScreenProps) => { | ||
| const { navigation: drawerHelpers } = props | ||
| const drawerNavigation = useNavigation() | ||
| return ( | ||
| <AppDrawerContextProvider | ||
| drawerNavigation={drawerNavigation} | ||
| drawerHelpers={drawerHelpers} | ||
| > | ||
| <AppScreen /> | ||
| </AppDrawerContextProvider> | ||
| ) | ||
| } | ||
|
|
||
| export const AppDrawerScreen = () => { | ||
| const [disableGestures, setDisableGestures] = useState(false) | ||
| const { isEnabled } = useFeatureFlag(FeatureFlags.MOBILE_NAV_OVERHAUL) | ||
| const DrawerComponent = isEnabled ? AccountDrawer : NotificationsDrawer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
|
|
||
| const drawerScreenOptions = useMemo( | ||
| () => ({ | ||
| ...baseDrawerScreenOptions, | ||
| drawerStyle: { | ||
| width: isEnabled ? '75%' : '100%' | ||
| }, | ||
| gestureHandlerProps: { | ||
| enabled: !disableGestures | ||
| } | ||
| }), | ||
| [isEnabled, disableGestures] | ||
| ) | ||
|
|
||
| return ( | ||
| <Drawer.Navigator | ||
| // legacy implementation uses reanimated-v1 | ||
| useLegacyImplementation={true} | ||
| screenOptions={drawerScreenOptions} | ||
| drawerContent={(props) => ( | ||
| <DrawerComponent | ||
| disableGestures={disableGestures} | ||
| setDisableGestures={setDisableGestures} | ||
| {...props} | ||
| /> | ||
| )} | ||
| > | ||
| <Drawer.Screen name='App' component={AppStack} /> | ||
| </Drawer.Navigator> | ||
| ) | ||
| } | ||
This file contains hidden or 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,3 @@ | ||
| export * from './AppDrawerScreen' | ||
| export * from './AppDrawerContext' | ||
| export * from './useAppDrawerNavigation' |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this but I'm trying to think if it's really necessary. Can't we just flip the flag on for staging in optimizely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this gives us granularity between dev and staging though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah im also not sure if this is necessary... i think it's potentially helpful for that first paint where optimizely is still coming back? but yeah...