Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions src/components/EventCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,33 @@ const SCROLL_INDICATOR_HEIGHT = 20;

// takes date object returns readable day
function formatDay(date) {
return moment(date).format("ddd MMMM Do h:mm a");
return moment.unix(date).format("ddd MMMM Do h:mm a");
}

class EventCard extends Component {
yOffset = new Animated.Value(0);

onScroll = Animated.event([{ nativeEvent: { contentOffset: { y: this.yOffset } } }], {
useNativeDriver: true
});
onScroll = Animated.event(
[{ nativeEvent: { contentOffset: { y: this.yOffset } } }],
{
useNativeDriver: true
}
);

fitMapBounds = () => {
const { latitude, longitude, userLocation } = this.props;
this.map.fitBounds([+longitude, +latitude], [userLocation.longitude, userLocation.latitude], 5);
this.map.fitBounds(
[+longitude, +latitude],
[userLocation.longitude, userLocation.latitude],
5
);
};

render() {
const {
eventName,
tags,
startTimestamp,
startTime,
endTime,
imageUrl,
Expand All @@ -53,7 +61,10 @@ class EventCard extends Component {
{
translateY: this.yOffset.interpolate({
inputRange: [0, SCREEN_HEIGHT],
outputRange: [0, SCROLL_BAR_HEIGHT - SCROLL_INDICATOR_HEIGHT],
outputRange: [
0,
SCROLL_BAR_HEIGHT - SCROLL_INDICATOR_HEIGHT
],
extrapolate: "clamp"
})
}
Expand Down Expand Up @@ -83,12 +94,15 @@ class EventCard extends Component {
/>
<View style={styles.textContainer}>
<Header>{eventName}</Header>
<SubHeader>{formatDay(startTime)}</SubHeader>
<SubHeader>{formatDay(startTimestamp)}</SubHeader>
</View>
{!!tags && (
<LinearGradient
locations={[0, 1]}
colors={["rgba(255,255,255,0.1)", "rgba(255,255,255,0.14)"]}
colors={[
"rgba(255,255,255,0.1)",
"rgba(255,255,255,0.14)"
]}
style={styles.tags}
>
{tags.map((tag, i) => (
Expand All @@ -106,13 +120,25 @@ class EventCard extends Component {
style={styles.map}
styleURL={MapboxGL.StyleURL.Dark}
>
<MapboxGL.PointAnnotation id={"coord"} coordinate={[+longitude, +latitude]} />
<MapboxGL.PointAnnotation
id={"coord"}
coordinate={[+longitude, +latitude]}
/>
</MapboxGL.MapView>
<Description description={description} />
</Animated.ScrollView>
<ActionButton yOffset={this.yOffset} title="Get Tickets" url={ticketUrl} />
<ActionButton
yOffset={this.yOffset}
title="Get Tickets"
url={ticketUrl}
/>
<View style={styles.scrollContainer}>
<Animated.View style={[styles.scrollIndicator, animatedScrollIndicator]} />
<Animated.View
style={[
styles.scrollIndicator,
animatedScrollIndicator
]}
/>
</View>
</View>
);
Expand Down
25 changes: 20 additions & 5 deletions src/components/Timeline/EventCardPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TouchableOpacity
} from "react-native";
import { BlurView } from "react-native-blur";
import moment from "moment";
import { Header, SubHeader } from "../universal/Text";
import CalendarButton from "./CalendarButton";
import { SCREEN_HEIGHT, SCREEN_WIDTH } from "../../lib/constants";
Expand All @@ -26,6 +27,11 @@ const GoingButton = () => {
);
};

function formatDay(date) {
console.log("THE DATE:", moment.unix(date).format("ddd MMMM Do"));
return moment.unix(date).format("h:mm a");
}

const CARD_HEIGHT = 150;

class EventCardPreview extends Component {
Expand Down Expand Up @@ -73,16 +79,20 @@ class EventCardPreview extends Component {
}
]}
>
<Image source={{ uri: imageUrl }} resizeMode="cover" style={styles.image} />
<Image
source={{ uri: imageUrl }}
resizeMode="cover"
style={styles.image}
/>
<LinearGradient
style={styles.gradient}
locations={[0, 0.9]}
colors={["rgba(0,0,0,0.5)", "rgba(0,0,0,0.7)"]}
/>
<Header style={styles.header}>{title}</Header>
<SubHeader>
{startTime}
{!!endTime && ` - ${endTime}`}
{formatDay(startTime)}
{!!endTime && ` - ${formatDay(endTime)}`}
</SubHeader>
{!!date && <SubHeader>{date}</SubHeader>}
{!isAddedToCalendar ? (
Expand Down Expand Up @@ -120,8 +130,13 @@ class EventCardPreview extends Component {
]}
>
{!!action && (
<VibrancyView style={styles.action} blurType="xlight">
<Header style={styles.actionText}>{action}</Header>
<VibrancyView
style={styles.action}
blurType="xlight"
>
<Header style={styles.actionText}>
{action}
</Header>
</VibrancyView>
)}
</Animated.View>
Expand Down
68 changes: 50 additions & 18 deletions src/components/Timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function formatAMPM(date) {

// takes date object returns readable day
function formatDay(date) {
return moment(date).format("ddd MMMM Do");
console.log("THE DATE:", moment.unix(date).format("ddd MMMM Do"));
return moment.unix(date).format("ddd MMMM Do");
}

function sortFn(a, b) {
Expand All @@ -66,7 +67,9 @@ function compileSections(data) {
Past.push(item);
} else if (startDate.setHours(0, 0, 0, 0) == now.setHours(0, 0, 0, 0)) {
Today.push(item);
} else if (startDate.setHours(0, 0, 0, 0) == tomorrow.setHours(0, 0, 0, 0)) {
} else if (
startDate.setHours(0, 0, 0, 0) == tomorrow.setHours(0, 0, 0, 0)
) {
Tomorrow.push(item);
} else {
Later.push(item);
Expand Down Expand Up @@ -106,16 +109,22 @@ function compileSections(data) {
class Timeline extends Component {
yOffset = new Animated.Value(0);

onScroll = Animated.event([{ nativeEvent: { contentOffset: { y: this.yOffset } } }], {
useNativeDriver: true
});
onScroll = Animated.event(
[{ nativeEvent: { contentOffset: { y: this.yOffset } } }],
{
useNativeDriver: true
}
);

shouldComponentUpdate(nextProps, nextState) {
if (nextProps.timeline.length > this.props.timeline.length) {
return true;
} else {
for (var i = 0; i < this.props.timeline.length; i++) {
if (this.props.timeline[i].isAddedToCalendar != nextProps.timeline[i].isAddedToCalendar) {
if (
this.props.timeline[i].isAddedToCalendar !=
nextProps.timeline[i].isAddedToCalendar
) {
return true;
}
}
Expand All @@ -134,9 +143,16 @@ class Timeline extends Component {
const scrollTopDifference = IS_X ? 80 : 60;
const scrollPosition = y0 - scrollTopDifference + dy;
let scrollPercentage = scrollPosition / SCROLL_BAR_HEIGHT;
scrollPercentage = scrollPercentage > 0 ? (scrollPercentage < 1 ? scrollPercentage : 1) : 0;
scrollPercentage =
scrollPercentage > 0
? scrollPercentage < 1
? scrollPercentage
: 1
: 0;

const { sections, SECTION_LIST_HEIGHT } = compileSections(this.props.timeline);
const { sections, SECTION_LIST_HEIGHT } = compileSections(
this.props.timeline
);
this.yOffset.setValue(scrollPercentage * SECTION_LIST_HEIGHT);
// this.Timeline.getNode().scrollTo({
// y: scrollPercentage * SECTION_LIST_HEIGHT,
Expand All @@ -159,21 +175,28 @@ class Timeline extends Component {

render() {
const { uid } = this.props;
const { sections, SECTION_LIST_HEIGHT } = compileSections(this.props.timeline);
const { sections, SECTION_LIST_HEIGHT } = compileSections(
this.props.timeline
);

const animatedScrollIndicator = {
transform: [
{
translateY: this.yOffset.interpolate({
inputRange: [0, SECTION_LIST_HEIGHT],
outputRange: [0, SCROLL_BAR_HEIGHT - SCROLL_INDICATOR_HEIGHT],
outputRange: [
0,
SCROLL_BAR_HEIGHT - SCROLL_INDICATOR_HEIGHT
],
extrapolate: "clamp"
})
}
]
};

const AnimatedSectionList = Animated.createAnimatedComponent(SectionList);
const AnimatedSectionList = Animated.createAnimatedComponent(
SectionList
);
return (
<View style={styles.wrapper}>
<AnimatedSectionList
Expand All @@ -182,8 +205,8 @@ class Timeline extends Component {
style={styles.sectionList}
onScroll={this.onScroll}
renderItem={({ item, index, section }) => {
let startDate = new Date(item.startTime);
let endDate = new Date(item.endTime);
// let startDate = new Date(item.startTimestamp);
// let endDate = new Date(item.endTimestamp);
return (
<EventCardPreview
key={item.id}
Expand All @@ -192,12 +215,18 @@ class Timeline extends Component {
uid={this.uid}
isAddedToCalendar={item.isAddedToCalendar}
imageUrl={item.imageUrl}
startTime={formatAMPM(startDate)}
endTime={formatAMPM(endDate)}
date={["Past", "Later"].includes(section.title) ? formatDay(startDate) : null}
startTime={item.startTimestamp}
endTime={item.endTimestamp}
date={
["Past", "Later"].includes(section.title)
? formatDay(item.startTimestamp)
: null
}
momentStartDate={item.startTime}
momentEndDate={item.endTime}
action={section.title != "Past" ? item.action : null}
action={
section.title != "Past" ? item.action : null
}
onAction={() => {
// Alert.alert(`action for ${item.id}`);
}}
Expand All @@ -221,7 +250,10 @@ class Timeline extends Component {
<View style={styles.scrollContainer}>
<Animated.View
{...this._panResponder.panHandlers}
style={[styles.scrollIndicator, animatedScrollIndicator]}
style={[
styles.scrollIndicator,
animatedScrollIndicator
]}
/>
</View>
)}
Expand Down
Binary file added src/lib/Images/active.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/lib/Images/bar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/lib/Images/nightlife.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/lib/Images/outdoor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/lib/Images/outdoor2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.