Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import {
- StyleSheet,
- View,
- Text,
- TouchableOpacity,
- Image,
- Dimensions,
- ScrollView,
- Animated
- } from "react-native";
- import * as constClass from "../utils/constants";
- import LinearGradient from "react-native-linear-gradient";
- import profileThumbnail from "../assets/profile-photo.jpg";
- import expandIcon from "../assets/expandIcon.png";
- import CardView from "react-native-cardview";
- const HEADER_MAX_HEIGHT = Dimensions.get("window").height / 4;
- const HEADER_MIN_HEIGHT = 60;
- const HEADER_SCROLL_DISTANCE = HEADER_MAX_HEIGHT - HEADER_MIN_HEIGHT;
- export default class ProfileScreen extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- scrollY: new Animated.Value(0)
- };
- }
- render() {
- const headerHeight = this.state.scrollY.interpolate({
- inputRange: [0, HEADER_SCROLL_DISTANCE],
- outputRange: [HEADER_MAX_HEIGHT, HEADER_MIN_HEIGHT],
- extrapolate: "clamp"
- });
- const imageOpacity = this.state.scrollY.interpolate({
- inputRange: [0, 1, HEADER_SCROLL_DISTANCE],
- outputRange: [1, 1, 0],
- extrapolate: "clamp"
- });
- /*const imageTranslate = this.state.scrollY.interpolate({
- inputRange: [0, HEADER_SCROLL_DISTANCE],
- outputRange: [0, -20],
- extrapolate: "clamp"
- });*/
- return (
- <View
- style={{ backgroundColor: "#ededed", flex: 1, flexDirection: "column" }}
- >
- <Animated.View
- style={[
- styles.headerStyle,
- {
- height: headerHeight,
- useNativeDriver: true,
- backgroundColor: "lightblue"
- }
- ]}
- >
- </Animated.View>
- <ScrollView
- contentContainerStyle={styles.bodyStyle}
- scrollEventThrottle={16}
- onScroll={Animated.event([
- { nativeEvent: { contentOffset: { y: this.state.scrollY } } }
- ])}
- >
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Personal Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Birth date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Address: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Personal Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Birth date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Address: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Personal Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Birth date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Address: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Personal Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Birth date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Address: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Personal Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Birth date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Address: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={0}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Job Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Start date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Job Position: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- <CardView
- style={styles.infoBox}
- cardElevation={2}
- cardMaxElevation={2}
- cornerRadius={5}
- >
- <View
- style={{
- flex: 1,
- alignItems: "flex-start",
- justifyContent: "space-evenly"
- }}
- >
- <Text style={styles.titleInfoBox}>Other Info</Text>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Other date: </Text>
- <Text style={styles.valueInfoBox}>00/00/00</Text>
- </View>
- <View style={styles.attributeBox}>
- <Text style={styles.keyInfoBox}> Health Insurance: </Text>
- <Text style={styles.valueInfoBox}>
- Lorem ipsum dolor sit amet, consectetur
- </Text>
- </View>
- </View>
- <TouchableOpacity style={styles.expandedButtonStyle}>
- <Image
- source={expandIcon}
- style={styles.expandIconStyle}
- resizeMode="contain"
- />
- </TouchableOpacity>
- </CardView>
- </ScrollView>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- headerStyle: {
- width: "100%",
- height: Dimensions.get("window").height / 4,
- position: "relative",
- zIndex: 3
- },
- cardHeaderStyle: {
- width: "100%",
- height: "100%",
- zIndex: 2
- },
- bodyStyle: {
- paddingTop: 30,
- alignItems: "center"
- },
- profileImageStyle: {
- position: "absolute",
- top: "30%",
- left: "8%",
- width: "40%",
- aspectRatio: 1,
- borderWidth: 10,
- borderColor: "#ededed",
- backgroundColor: "#ededed",
- borderRadius: Dimensions.get("window").width * 0.4,
- zIndex: 4
- },
- infoBox: {
- position: "relative",
- width: "90%",
- height: 150,
- backgroundColor: "#FFF",
- marginBottom: 20,
- zIndex: 1
- },
- titleInfoBox: {
- fontFamily: constClass.MEDIUM,
- fontSize: 20,
- color: constClass.LIGHT_BLUE,
- paddingLeft: "6%"
- },
- keyInfoBox: {
- fontFamily: constClass.MEDIUM,
- fontSize: 16,
- color: constClass.LIGHT_BLUE,
- width: "30%"
- },
- valueInfoBox: {
- fontFamily: constClass.MEDIUM,
- fontSize: 16,
- color: constClass.DARK_BLUE,
- width: "60%"
- },
- attributeBox: {
- flexDirection: "row",
- justifyContent: "flex-start",
- alignItems: "center",
- paddingLeft: "5%"
- },
- expandedButtonStyle: {
- position: "absolute",
- bottom: "0%",
- right: "0%",
- //backgroundColor: "red",
- width: "13%",
- aspectRatio: 1
- },
- expandIconStyle: {
- maxWidth: "100%",
- maxHeight: "100%"
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement