Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add qna button highlight #50

Merged
merged 1 commit into from
Mar 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion components/common/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function Header({ children, className, corner, ...props }: HeaderProps) {
return (
<View className={cn('space-y-5 mx-5', className)} {...props}>
{(showBackButton || corner) && (
<View className='flex flex-row items-center justify-between'>
<View className='flex flex-row items-center justify-between z-10'>
{showBackButton && (
<Pressable onPress={navigation.goBack}>
<Feather name='arrow-left' size={30} color={extendedColors.primary['500']} />
Expand Down
47 changes: 42 additions & 5 deletions components/schedule/elements/qna-button.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,59 @@
import { Feather } from '@expo/vector-icons';
import { useNavigation } from 'expo-router';
import { Pressable } from 'react-native';
import { useState } from 'react';
import { Animated, Pressable, View } from 'react-native';
import { NativeStackNavigationProp } from 'react-native-screens/native-stack';

import { extendedColors } from '../../../theme/extendedColors';
import { usePulseAnimation } from '../../../utils/animation.utils';
import { cn } from '../../../utils/common.utils';
import { ItemCard } from '../../base/item-card';
import { StyledText } from '../../base/text';

interface QnaButtonProps {
slug: string;
highlight?: boolean;
}

export function QnaButton({ slug }: QnaButtonProps) {
export function QnaButton({ slug, highlight }: QnaButtonProps) {
const [promptOpen, setPromptOpen] = useState(highlight ?? false);
const animation = usePulseAnimation(1000);
const router = useNavigation<NativeStackNavigationProp<{ qna: { id: string } }>>();
const onPress = () => {
router.navigate('qna', { id: slug });
};
return (
<Pressable onPress={onPress}>
<Feather name='message-circle' color={extendedColors.slate['500']} size={30} />
</Pressable>
<View className='relative'>
<Pressable onPress={onPress}>
<Animated.View
style={{
opacity: highlight ? animation.opacity : 1,
}}
className={cn({
'bg-primary-500 rounded-full p-2': highlight,
})}
>
<Feather
name='message-circle'
color={highlight ? 'white' : extendedColors.slate[500]}
size={highlight ? 26 : 30}
/>
</Animated.View>
</Pressable>
{promptOpen && (
<ItemCard
onPress={onPress}
className='absolute top-full right-1/2 shadow-md w-40 rounded-tr-none flex-row items-center space-x-2'
>
<Pressable onPress={() => setPromptOpen(false)}>
<Feather name='x' size={20} color={extendedColors.slate[300]} />
</Pressable>
<View>
<StyledText className='text-xl font-raleway-bold'>Kérdezz</StyledText>
<StyledText>az előadótól!</StyledText>
</View>
</ItemCard>
)}
</View>
);
}
4 changes: 3 additions & 1 deletion components/schedule/layouts/presentation-details-page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { usePresentation } from '../../../hooks/use-presentation';
import { ConferenceService } from '../../../services/conference.service';
import { isPresentationCurrent } from '../../../utils/presentation.utils';
import { Screen } from '../../base/screen';
import { ScrollContent } from '../../base/scroll-content';
import { StyledText } from '../../base/text';
Expand All @@ -19,13 +20,14 @@ export function PresentationDetailsPage({ slug }: ScheduleDetailsPageProps) {
const { data, isLoading } = usePresentation(slug);
const startTime = ConferenceService.getFormattedTimestamp(data?.startTime ?? '');
const endTime = ConferenceService.getFormattedTimestamp(data?.endTime ?? '');
const isCurrent = data ? isPresentationCurrent(data) : false;
return (
<Screen analyticsScreenName={`presentation-details/` + slug}>
<Header
corner={
<>
{data && <FavoriteButton presentation={data} />}
<QnaButton slug={slug} />
<QnaButton highlight={isCurrent} slug={slug} />
</>
}
>
Expand Down
6 changes: 3 additions & 3 deletions utils/animation.utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { Animated, Easing } from 'react-native';

export function usePulseAnimation() {
export function usePulseAnimation(duration = 1000) {
const [pulseValue] = useState(new Animated.Value(0));

useEffect(() => {
Expand All @@ -10,13 +10,13 @@ export function usePulseAnimation() {
Animated.sequence([
Animated.timing(pulseValue, {
toValue: 1,
duration: 1000,
duration: duration,
easing: Easing.inOut(Easing.ease),
useNativeDriver: true,
}),
Animated.timing(pulseValue, {
toValue: 0,
duration: 1000,
duration: duration,
easing: Easing.inOut(Easing.ease),
useNativeDriver: true,
}),
Expand Down
Loading