-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat / LIVE-3666 - New homepage tab navigator #1462
Merged
mcayuelas-ledger
merged 5 commits into
feat/LIVE-3665-nft-gallery-v0
from
feat/LIVE-3666-nft-tab-navigator
Oct 4, 2022
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26c1db8
Wip tab navigator
nparigi-ledger ae7d558
Customize tab navigator style + new (empty) wallet nft gallery screen
nparigi-ledger 1cca6be
tab bavigator initial route
nparigi-ledger 329e665
fix padding
nparigi-ledger 46fdb8e
fix padding
nparigi-ledger 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
22 changes: 6 additions & 16 deletions
22
apps/ledger-live-mobile/src/components/RootNavigator/PortfolioNavigator.tsx
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
123 changes: 123 additions & 0 deletions
123
apps/ledger-live-mobile/src/components/RootNavigator/WalletTabNavigator.tsx
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,123 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useTheme } from "styled-components/native"; | ||
import { | ||
createMaterialTopTabNavigator, | ||
MaterialTopTabBarProps, | ||
} from "@react-navigation/material-top-tabs"; | ||
import styled from "@ledgerhq/native-ui/components/styled"; | ||
import { Flex, Text } from "@ledgerhq/native-ui"; | ||
import { useSelector } from "react-redux"; | ||
import { ScreenName } from "../../const"; | ||
import Portfolio from "../../screens/Portfolio"; | ||
import WalletNftGallery from "../../screens/Nft/WalletNftGallery"; | ||
import { rgba } from "../../colors"; | ||
import { readOnlyModeEnabledSelector } from "../../reducers/settings"; | ||
import { accountsSelector } from "../../reducers/accounts"; | ||
// eslint-disable-next-line import/no-cycle | ||
import ReadOnlyPortfolio from "../../screens/Portfolio/ReadOnly"; | ||
|
||
const Tab = createMaterialTopTabNavigator(); | ||
|
||
const TabBarContainer = styled(Flex)` | ||
border-bottom-width: 1px; | ||
border-bottom-color: ${p => p.theme.colors.palette.neutral.c40}; | ||
background-color: transparent; | ||
`; | ||
|
||
const StyledTab = styled.TouchableOpacity``; | ||
|
||
function TabBar({ state, descriptors, navigation }: MaterialTopTabBarProps) { | ||
const { colors } = useTheme(); | ||
|
||
return ( | ||
<TabBarContainer | ||
paddingLeft={4} | ||
paddingRight={4} | ||
paddingBottom={4} | ||
paddingTop={4} | ||
> | ||
<Flex flexDirection={"row"}> | ||
{state.routes.map((route, index) => { | ||
const { options } = descriptors[route.key]; | ||
const label = options.title; | ||
|
||
const isActive = state.index === index; | ||
|
||
const onPress = () => { | ||
const event = navigation.emit({ | ||
type: "tabPress", | ||
target: route.key, | ||
canPreventDefault: true, | ||
}); | ||
|
||
if (!isActive && !event.defaultPrevented) { | ||
navigation.navigate(route.name); | ||
} | ||
}; | ||
|
||
return ( | ||
<StyledTab | ||
key={index} | ||
bg={isActive ? "primary.c70" : rgba(colors.constant.white, 0.08)} | ||
borderRadius={2} | ||
px={4} | ||
py={3} | ||
mr={4} | ||
onPress={onPress} | ||
> | ||
<Text | ||
fontWeight={"semiBold"} | ||
variant={"body"} | ||
color={"neutral.c100"} | ||
> | ||
{label} | ||
</Text> | ||
</StyledTab> | ||
); | ||
})} | ||
</Flex> | ||
</TabBarContainer> | ||
); | ||
} | ||
|
||
export default function WalletTabNavigator() { | ||
const readOnlyModeEnabled = useSelector(readOnlyModeEnabledSelector); | ||
const accounts = useSelector(accountsSelector); | ||
|
||
const { t } = useTranslation(); | ||
return ( | ||
// <Box bg={"red"} flex={1}> | ||
<Tab.Navigator | ||
tabBar={(props: MaterialTopTabBarProps) => <TabBar {...props} />} | ||
screenOptions={{ | ||
tabBarStyle: { backgroundColor: "red" }, | ||
}} | ||
style={{ backgroundColor: "transparent" }} | ||
sceneContainerStyle={{ backgroundColor: "transparent" }} | ||
tabBarOptions={{ style: { backgroundColor: "transparent" } }} | ||
// lazy | ||
lazy={true} | ||
> | ||
<Tab.Screen | ||
name={ScreenName.Portfolio} | ||
component={ | ||
readOnlyModeEnabled && accounts.length <= 0 | ||
? ReadOnlyPortfolio | ||
: Portfolio | ||
} | ||
options={{ | ||
title: t("wallet.tabs.crypto"), | ||
}} | ||
/> | ||
<Tab.Screen | ||
name={ScreenName.WalletNftGallery} | ||
component={WalletNftGallery} | ||
options={{ | ||
title: t("wallet.tabs.nft"), | ||
}} | ||
/> | ||
</Tab.Navigator> | ||
// </Box> | ||
); | ||
} |
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
9 changes: 9 additions & 0 deletions
9
apps/ledger-live-mobile/src/screens/Nft/WalletNftGallery/index.tsx
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,9 @@ | ||
import { Box } from "@ledgerhq/native-ui"; | ||
import React from "react"; | ||
|
||
const WalletNftGallery = () => { | ||
console.log("WalletNftGallery screen"); | ||
return <Box bg={"red"} height={200} width={400} />; | ||
}; | ||
|
||
export default WalletNftGallery; |
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.
p={4} no?
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.
YES
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.
thank you
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.
ok, seems that this was on purpose because with the styled wrapper, just putting p={4} doesn't work ...