diff --git a/components/Header.tsx b/components/Header.tsx index 1be637b97..4beb47ccc 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; - +import { StyleSheet, Text, Animated } from 'react-native'; import loc from '../loc'; import PlusIcon from './icons/PlusIcon'; import { useTheme } from './themes'; @@ -9,9 +8,11 @@ interface HeaderProps { leftText: string; isDrawerList?: boolean; onNewWalletPress?: () => void; + scrollY?: Animated.Value; + staticText?: boolean; } -export const Header: React.FC = ({ leftText, isDrawerList, onNewWalletPress }) => { +export const Header: React.FC = ({ leftText, isDrawerList, onNewWalletPress, scrollY, staticText = false }) => { const { colors } = useTheme(); const styleWithProps = StyleSheet.create({ root: { @@ -24,11 +25,31 @@ export const Header: React.FC = ({ leftText, isDrawerList, onNewWal }, }); + const HEADER_MAX_HEIGHT = 55; + const HEADER_MIN_HEIGHT = 0; + const HEADER_SCROLL_DISTANCE = HEADER_MAX_HEIGHT - HEADER_MIN_HEIGHT; + + const headerHeightAnimated = scrollY?.interpolate({ + inputRange: [0, HEADER_SCROLL_DISTANCE], + outputRange: [HEADER_MAX_HEIGHT, HEADER_MIN_HEIGHT], + extrapolate: 'clamp', + }); + + const headerOpacity = scrollY?.interpolate({ + inputRange: [0, HEADER_SCROLL_DISTANCE / 2, HEADER_SCROLL_DISTANCE], + outputRange: [1, 0.5, 0], + extrapolate: 'clamp', + }); + return ( - - {leftText} + + {staticText ? ( + {leftText} + ) : ( + {leftText} + )} {onNewWalletPress && } - + ); }; diff --git a/navigation/DetailViewScreensStack.tsx b/navigation/DetailViewScreensStack.tsx index c9aab4249..38e6a4cf3 100644 --- a/navigation/DetailViewScreensStack.tsx +++ b/navigation/DetailViewScreensStack.tsx @@ -1,11 +1,10 @@ -import React, { useCallback, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { NativeStackNavigationOptions } from '@react-navigation/native-stack'; -import { I18nManager, View } from 'react-native'; +import { I18nManager } from 'react-native'; import { isDesktop } from '../blue_modules/environment'; import HeaderRightButton from '../components/HeaderRightButton'; import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle'; import { useTheme } from '../components/themes'; -import { useExtendedNavigation } from '../hooks/useExtendedNavigation'; import loc from '../loc'; import LdkInfo from '../screen/lnd/ldkInfo'; import LNDViewAdditionalInvoiceInformation from '../screen/lnd/lndViewAdditionalInvoiceInformation'; @@ -64,41 +63,26 @@ import SignVerifyStackRoot from './SignVerifyStack'; import ViewEditMultisigCosignersStackRoot from './ViewEditMultisigCosignersStack'; import WalletExportStack from './WalletExportStack'; import WalletXpubStackRoot from './WalletXpubStack'; -import PlusIcon from '../components/icons/PlusIcon'; import SettingsButton from '../components/icons/SettingsButton'; const DetailViewStackScreensStack = () => { const theme = useTheme(); - const navigation = useExtendedNavigation(); const SaveButton = useMemo(() => , []); const DetailButton = useMemo(() => , []); - const navigateToAddWallet = useCallback(() => { - navigation.navigate('AddWalletRoot'); - }, [navigation]); - const useWalletListScreenOptions = useMemo(() => { - const RightBarButtons = ( - <> - - - - - ); - return { title: loc.wallets.wallets, navigationBarColor: theme.colors.navigationBarColor, headerShown: !isDesktop, - headerLargeTitle: true, headerStyle: { backgroundColor: theme.colors.customHeader, }, - headerRight: I18nManager.isRTL ? undefined : () => RightBarButtons, - headerLeft: I18nManager.isRTL ? () => RightBarButtons : undefined, + headerRight: I18nManager.isRTL ? undefined : () => , + headerLeft: I18nManager.isRTL ? () => : undefined, }; - }, [navigateToAddWallet, theme.colors.customHeader, theme.colors.navigationBarColor]); + }, [theme.colors.customHeader, theme.colors.navigationBarColor]); const walletListScreenOptions = useWalletListScreenOptions; return ( @@ -161,8 +145,6 @@ const DetailViewStackScreensStack = () => { backgroundColor: theme.colors.customHeader, }, headerRight: () => DetailButton, - headerBackTitleStyle: { fontSize: 0 }, - headerBackTitleVisible: true, })(theme)} /> @@ -268,9 +250,6 @@ const DetailViewStackScreensStack = () => { options={navigationStyle({ headerTransparent: true, title: loc.settings.header, - // workaround to deal with the flicker when headerBackTitleVisible is false - headerBackTitleStyle: { fontSize: 0 }, - headerBackTitleVisible: true, headerShadowVisible: false, headerLargeTitle: true, animationTypeForReplace: 'push', @@ -388,9 +367,3 @@ const DetailViewStackScreensStack = () => { }; export default DetailViewStackScreensStack; - -const styles = { - width24: { - width: 24, - }, -}; diff --git a/screen/settings/SettingsPrivacy.tsx b/screen/settings/SettingsPrivacy.tsx index b192d5317..7be6f5067 100644 --- a/screen/settings/SettingsPrivacy.tsx +++ b/screen/settings/SettingsPrivacy.tsx @@ -102,7 +102,7 @@ const SettingsPrivacy: React.FC = () => { {Platform.OS === 'android' ? ( -
+
) : null} diff --git a/screen/wallets/DrawerList.tsx b/screen/wallets/DrawerList.tsx index f16e91ac6..caa1d6382 100644 --- a/screen/wallets/DrawerList.tsx +++ b/screen/wallets/DrawerList.tsx @@ -142,7 +142,7 @@ const DrawerList: React.FC = memo(({ navigation }) => { showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} > -
+
{ } = useStorage(); const { width } = useWindowDimensions(); const { colors, scanImage } = useTheme(); - const { navigate } = useExtendedNavigation(); + const { navigate, setOptions } = useExtendedNavigation(); const isFocused = useIsFocused(); const routeName = useRoute().name; const dataSource = getTransactions(undefined, 10); const walletsCount = useRef(wallets.length); const walletActionButtonsRef = useRef(); + const scrollY = useRef(new Animated.Value(0)).current; + const stylesHook = StyleSheet.create({ walletsListWrapper: { backgroundColor: colors.brandingColor, @@ -149,6 +162,21 @@ const WalletsList: React.FC = () => { walletsCount.current = wallets.length; }, [wallets]); + const HeaderTitle = useMemo(() => { + const titleOpacity = scrollY.interpolate({ + inputRange: [0, 200], + outputRange: [0, 1], + extrapolate: 'clamp', + }); + return {loc.wallets.list_title}; + }, [scrollY]); + + useEffect(() => { + setOptions({ + headerTitle: () => HeaderTitle, + }); + }, [HeaderTitle, scrollY, setOptions]); + const verifyBalance = useCallback(() => { if (getBalance() !== 0) { A(A.ENUM.GOT_NONZERO_BALANCE); @@ -405,6 +433,7 @@ const WalletsList: React.FC = () => { return ( +
navigate('AddWalletRoot')} scrollY={scrollY} /> removeClippedSubviews @@ -421,6 +450,8 @@ const WalletsList: React.FC = () => { windowSize={21} maxToRenderPerBatch={10} updateCellsBatchingPeriod={50} + onScroll={Animated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], { useNativeDriver: false })} + scrollEventThrottle={16} /> {renderScanButton()} @@ -473,4 +504,9 @@ const styles = StyleSheet.create({ transaction: { marginHorizontal: 0, }, + nativeHeaderTitle: { + fontSize: 17, + fontWeight: '600', + color: 'black', // adjust color if necessary + }, });