From 2d0818acdfaf827965bc37114a081268caa48e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Thu, 8 Jul 2021 00:35:01 -0400 Subject: [PATCH] FIX: Wallet carousel was not rending properly on large screens --- components/WalletsCarousel.js | 46 ++++++++++++++++++++----- components/addresses/AddressTypeTabs.js | 4 ++- ios/Podfile.lock | 2 +- screen/wallets/drawerList.js | 7 ++-- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/components/WalletsCarousel.js b/components/WalletsCarousel.js index 4ad9b70d5..f71278174 100644 --- a/components/WalletsCarousel.js +++ b/components/WalletsCarousel.js @@ -12,6 +12,7 @@ import { TouchableWithoutFeedback, useWindowDimensions, View, + Dimensions, FlatList, } from 'react-native'; import { useTheme } from '@react-navigation/native'; @@ -21,13 +22,11 @@ import { LightningCustodianWallet, MultisigHDWallet, PlaceholderWallet } from '. import WalletGradient from '../class/wallet-gradient'; import { BluePrivateBalance } from '../BlueComponents'; import { BlueStorageContext } from '../blue_modules/storage-context'; -import { isHandset } from '../blue_modules/environment'; +import { isHandset, isTablet, isDesktop } from '../blue_modules/environment'; const nStyles = StyleSheet.create({ root: {}, container: { - paddingHorizontal: 24, - paddingVertical: 16, borderRadius: 10, minHeight: Platform.OS === 'ios' ? 164 : 181, justifyContent: 'center', @@ -57,10 +56,31 @@ const NewWalletPanel = ({ onPress }) => { const { colors } = useTheme(); const { width } = useWindowDimensions(); const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82; + const isLargeScreen = Platform.OS === 'android' ? isTablet() : width >= Dimensions.get('screen').width / 2 && (isTablet() || isDesktop); + const nStylesHooks = StyleSheet.create({ + container: isLargeScreen + ? { + paddingHorizontal: 24, + marginVertical: 16, + } + : { paddingVertical: 16, paddingHorizontal: 24 }, + }); return ( - - + + {loc.wallets.list_create_a_wallet} {loc.wallets.list_create_a_wallet_text} @@ -77,6 +97,7 @@ NewWalletPanel.propTypes = { const iStyles = StyleSheet.create({ root: { paddingRight: 20 }, + rootLargeDevice: { marginVertical: 20 }, grad: { padding: 15, borderRadius: 12, @@ -131,7 +152,7 @@ const WalletCarouselItem = ({ item, index, onPress, handleLongPress, isSelectedW const { walletTransactionUpdateStatus } = useContext(BlueStorageContext); const { width } = useWindowDimensions(); const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82; - + const isLargeScreen = Platform.OS === 'android' ? isTablet() : width >= Dimensions.get('screen').width / 2 && (isTablet() || isDesktop); const onPressedIn = () => { const props = { duration: 50 }; props.useNativeDriver = true; @@ -159,7 +180,7 @@ const WalletCarouselItem = ({ item, index, onPress, handleLongPress, isSelectedW if (item.type === PlaceholderWallet.type) { return ( { const { width } = useWindowDimensions(); const sliderHeight = 190; const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82; + const isLargeScreen = Platform.OS === 'android' ? isTablet() : width >= Dimensions.get('screen').width / 2 && (isTablet() || isDesktop); return ( { disableIntervalMomentum={isHandset} snapToInterval={itemWidth} // Adjust to your content width decelerationRate="fast" - contentContainerStyle={cStyles.content} + contentContainerStyle={isLargeScreen ? cStyles.contentLargeScreen : cStyles.content} directionalLockEnabled showsHorizontalScrollIndicator={false} initialNumToRender={10} diff --git a/components/addresses/AddressTypeTabs.js b/components/addresses/AddressTypeTabs.js index 9e63ab698..a7a2da63b 100644 --- a/components/addresses/AddressTypeTabs.js +++ b/components/addresses/AddressTypeTabs.js @@ -51,7 +51,9 @@ const AddressTypeTabs = ({ currentTab, setCurrentTab }) => { return ( changeToTab(tab.key)} style={[styles.tab, tabStyle]}> - changeToTab(tab.key)} style={textStyle}>{tab.name} + changeToTab(tab.key)} style={textStyle}> + {tab.name} + ); }); diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 24958e958..50cce2325 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -729,7 +729,7 @@ SPEC CHECKSUMS: Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154 FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 - glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 + glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 lottie-ios: 3a3758ef5a008e762faec9c9d50a39842f26d124 lottie-react-native: 4dff8fe8d10ddef9e7880e770080f4a56121397e diff --git a/screen/wallets/drawerList.js b/screen/wallets/drawerList.js index c14812665..030fcc2bf 100644 --- a/screen/wallets/drawerList.js +++ b/screen/wallets/drawerList.js @@ -3,7 +3,7 @@ import { StatusBar, View, StyleSheet, Alert } from 'react-native'; import { DrawerContentScrollView } from '@react-navigation/drawer'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; import PropTypes from 'prop-types'; -import { useTheme } from '@react-navigation/native'; +import { useIsFocused, useTheme } from '@react-navigation/native'; import { BlueHeaderDefaultMain, BlueSpacing20 } from '../../BlueComponents'; import WalletsCarousel from '../../components/WalletsCarousel'; @@ -20,6 +20,7 @@ const DrawerList = props => { const [carouselData, setCarouselData] = useState([]); const { colors } = useTheme(); const walletsCount = useRef(wallets.length); + const isFocused = useIsFocused(); const stylesHook = StyleSheet.create({ root: { backgroundColor: colors.brandingColor, @@ -113,14 +114,16 @@ const DrawerList = props => { const renderWalletsCarousel = ( );