From 77a933a1c9fcc93a7e3659e7cd2ff722d094779d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Berente?= <30603208+berenteb@users.noreply.github.com> Date: Sun, 17 Mar 2024 13:19:10 +0100 Subject: [PATCH] feat: add qna button highlight --- components/common/header.tsx | 2 +- components/schedule/elements/qna-button.tsx | 47 +++++++++++++++++-- .../layouts/presentation-details-page.tsx | 4 +- utils/animation.utils.ts | 6 +-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/components/common/header.tsx b/components/common/header.tsx index 09d6698..c7dc1c3 100644 --- a/components/common/header.tsx +++ b/components/common/header.tsx @@ -16,7 +16,7 @@ export function Header({ children, className, corner, ...props }: HeaderProps) { return ( {(showBackButton || corner) && ( - + {showBackButton && ( diff --git a/components/schedule/elements/qna-button.tsx b/components/schedule/elements/qna-button.tsx index e379363..9fc3160 100644 --- a/components/schedule/elements/qna-button.tsx +++ b/components/schedule/elements/qna-button.tsx @@ -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>(); const onPress = () => { router.navigate('qna', { id: slug }); }; return ( - - - + + + + + + + {promptOpen && ( + + setPromptOpen(false)}> + + + + Kérdezz + az előadótól! + + + )} + ); } diff --git a/components/schedule/layouts/presentation-details-page.tsx b/components/schedule/layouts/presentation-details-page.tsx index f4c4389..ea81950 100644 --- a/components/schedule/layouts/presentation-details-page.tsx +++ b/components/schedule/layouts/presentation-details-page.tsx @@ -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'; @@ -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 (
{data && } - + } > diff --git a/utils/animation.utils.ts b/utils/animation.utils.ts index 4b7bea4..356da71 100644 --- a/utils/animation.utils.ts +++ b/utils/animation.utils.ts @@ -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(() => { @@ -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, }),