From af452acf4449012900e36ece5c199fc3e692fdd1 Mon Sep 17 00:00:00 2001 From: feruz Date: Wed, 4 Dec 2019 14:52:10 +0200 Subject: [PATCH] add animated view --- src/screens/wallet/screen/walletScreen.js | 101 +++++++++++------- .../wallet/screen/walletScreenStyles.js | 32 ++++++ 2 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 src/screens/wallet/screen/walletScreenStyles.js diff --git a/src/screens/wallet/screen/walletScreen.js b/src/screens/wallet/screen/walletScreen.js index 0d959cce9..336e7dd60 100644 --- a/src/screens/wallet/screen/walletScreen.js +++ b/src/screens/wallet/screen/walletScreen.js @@ -1,6 +1,6 @@ import React, { Fragment, useState } from 'react'; import Swiper from 'react-native-swiper'; -import { SafeAreaView } from 'react-native'; +import { SafeAreaView, Animated, ScrollView, Text } from 'react-native'; // Containers import { LoggedInContainer } from '../../../containers'; @@ -14,18 +14,31 @@ import SbdView from './sbdView'; // Styles import globalStyles from '../../../globalStyles'; +import styles from './walletScreenStyles'; + +const HEADER_EXPANDED_HEIGHT = 260; +const HEADER_COLLAPSED_HEIGHT = 20; +const WALLETS = ['ESTM', 'STEEM', 'SBD', 'SP']; const WalletScreen = () => { const [selectedUserActivities, setSelectedUserActivities] = useState(null); const [isLoading, setIsLoading] = useState('points'); const [currentIndex, setCurrentIndex] = useState(0); const [refreshing, setRefreshing] = useState(false); + const [scrollY] = useState(new Animated.Value(0)); + const [isScroll, setScroll] = useState(false); const _handleSwipeItemChange = (userActivities, _isLoading) => { setSelectedUserActivities(userActivities); setIsLoading(_isLoading); }; + const headerHeight = scrollY.interpolate({ + inputRange: [0, HEADER_EXPANDED_HEIGHT - HEADER_COLLAPSED_HEIGHT], + outputRange: [HEADER_EXPANDED_HEIGHT, HEADER_COLLAPSED_HEIGHT], + extrapolate: 'clamp', + }); + return (
@@ -33,44 +46,60 @@ const WalletScreen = () => { {() => ( <> - setCurrentIndex(index)} - > - + setCurrentIndex(index)} + > + + + + + + + + - - - - - + )} diff --git a/src/screens/wallet/screen/walletScreenStyles.js b/src/screens/wallet/screen/walletScreenStyles.js new file mode 100644 index 000000000..c2b3650fa --- /dev/null +++ b/src/screens/wallet/screen/walletScreenStyles.js @@ -0,0 +1,32 @@ +import EStyleSheet from 'react-native-extended-stylesheet'; +import { Dimensions } from 'react-native'; + +const HEADER_EXPANDED_HEIGHT = 260; +const HEADER_COLLAPSED_HEIGHT = 20; + +const { width: SCREEN_WIDTH } = Dimensions.get('screen'); + +export default EStyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#eaeaea', + }, + scrollContainer: { + padding: 0, + paddingTop: HEADER_EXPANDED_HEIGHT, + }, + header: { + position: 'absolute', + width: SCREEN_WIDTH, + backgroundColor: '$primaryBackgroundColor', + top: 0, + left: 0, + zIndex: 9999, + }, + title: { + marginVertical: 16, + color: 'black', + fontWeight: 'bold', + fontSize: 24, + }, +});