-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Prakhar Agarwal <[email protected]>
- Loading branch information
1 parent
0509824
commit 233f8ed
Showing
9 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { useEffect, useState } from "react" | ||
import { View } from "react-native" | ||
|
||
import { useI18nContext } from "@app/i18n/i18n-react" | ||
import { | ||
JUNE_1_2024_12_AM_UTC_MINUS_6, | ||
getTimeLeft, | ||
JULY_1_2024_12_AM_UTC_MINUS_6, | ||
} from "@app/utils/date" | ||
import { Text, makeStyles, useTheme } from "@rneui/themed" | ||
|
||
import { GaloyIcon } from "../atomic/galoy-icon" | ||
import { PressableCard } from "../pressable-card" | ||
import { JuneChallengeModal } from "./modal" | ||
|
||
export const JuneChallengeCard: React.FC = () => { | ||
const [modalIsOpen, setModalIsOpen] = useState(false) | ||
const openModal = () => setModalIsOpen(true) | ||
|
||
const { | ||
theme: { colors }, | ||
} = useTheme() | ||
const styles = useStyles() | ||
const { LL } = useI18nContext() | ||
|
||
const [countDown, setCountDown] = useState( | ||
getTimeLeft({ | ||
after: JUNE_1_2024_12_AM_UTC_MINUS_6, | ||
until: JULY_1_2024_12_AM_UTC_MINUS_6, | ||
}), | ||
) | ||
|
||
useEffect(() => { | ||
const dateNow = Date.now() | ||
if (dateNow > JULY_1_2024_12_AM_UTC_MINUS_6) return | ||
|
||
const t = setInterval(() => { | ||
setCountDown( | ||
getTimeLeft({ | ||
after: JUNE_1_2024_12_AM_UTC_MINUS_6, | ||
until: JULY_1_2024_12_AM_UTC_MINUS_6, | ||
}), | ||
) | ||
}, 1000) | ||
|
||
return () => clearInterval(t) | ||
}, [setCountDown]) | ||
|
||
const currentTime = Date.now() | ||
if ( | ||
currentTime > JULY_1_2024_12_AM_UTC_MINUS_6 || | ||
currentTime < JUNE_1_2024_12_AM_UTC_MINUS_6 | ||
) | ||
return <></> | ||
|
||
return ( | ||
<PressableCard onPress={openModal}> | ||
<JuneChallengeModal isVisible={modalIsOpen} setIsVisible={setModalIsOpen} /> | ||
<View style={styles.card}> | ||
<View style={styles.textContainer}> | ||
<View style={styles.beside}> | ||
<Text type="p1" bold> | ||
{LL.Circles.juneChallenge.title()} | ||
</Text> | ||
<Text color={colors.grey3}>{countDown}</Text> | ||
</View> | ||
<Text type="p2">{LL.Circles.juneChallenge.description()}</Text> | ||
</View> | ||
<View> | ||
<GaloyIcon color={colors.primary} size={28} name="rank" /> | ||
</View> | ||
</View> | ||
</PressableCard> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles(({ colors }) => ({ | ||
card: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
padding: 16, | ||
borderRadius: 10, | ||
backgroundColor: colors.grey5, | ||
}, | ||
textContainer: { | ||
flex: 1, | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
rowGap: 6, | ||
}, | ||
beside: { | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
columnGap: 10, | ||
}, | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./modal" | ||
export * from "./card" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import * as React from "react" | ||
import { Linking, View } from "react-native" | ||
import Modal from "react-native-modal" | ||
|
||
import { useI18nContext } from "@app/i18n/i18n-react" | ||
import { useCirclesCard } from "@app/screens/people-screen/circles/use-circles-card" | ||
import { makeStyles, useTheme, Text } from "@rneui/themed" | ||
|
||
import { GaloyIcon } from "../atomic/galoy-icon" | ||
import { GaloyIconButton } from "../atomic/galoy-icon-button" | ||
import { GaloyPrimaryButton } from "../atomic/galoy-primary-button" | ||
import { GaloyToast } from "../galoy-toast" | ||
|
||
const LEARN_MORE_PAGE_URL = "https://sv24.adoptingbitcoin.org/" | ||
|
||
type Props = { | ||
isVisible: boolean | ||
setIsVisible: (isVisible: boolean) => void | ||
} | ||
|
||
export const JuneChallengeModal: React.FC<Props> = ({ isVisible, setIsVisible }) => { | ||
const { LL } = useI18nContext() | ||
|
||
const { | ||
theme: { colors }, | ||
} = useTheme() | ||
const styles = useStyles() | ||
|
||
const acknowledgeModal = () => { | ||
setIsVisible(false) | ||
} | ||
|
||
const { ShareImg, share } = useCirclesCard() | ||
|
||
return ( | ||
<Modal | ||
isVisible={isVisible} | ||
backdropOpacity={0.8} | ||
backdropTransitionOutTiming={0} | ||
backdropColor={colors.white} | ||
onBackdropPress={acknowledgeModal} | ||
> | ||
<View style={styles.modalCard}> | ||
<View style={styles.container}> | ||
<GaloyIconButton | ||
style={styles.cross} | ||
name="close" | ||
size="medium" | ||
onPress={acknowledgeModal} | ||
/> | ||
<GaloyIcon style={styles.top} name="rank" size={40} color={colors.primary} /> | ||
<Text type="h1" bold> | ||
{LL.Circles.juneChallenge.title()} | ||
</Text> | ||
<Text type="p1" style={styles.details}> | ||
{LL.Circles.juneChallenge.details()} | ||
</Text> | ||
{ShareImg} | ||
<GaloyPrimaryButton onPress={share} title={LL.Circles.shareCircles()} /> | ||
<Text style={styles.reminder} type="p3"> | ||
{LL.Circles.learnMore()} | ||
<Text | ||
style={styles.underline} | ||
color={colors.grey3} | ||
onPress={() => Linking.openURL(LEARN_MORE_PAGE_URL)} | ||
> | ||
{LEARN_MORE_PAGE_URL} | ||
</Text> | ||
</Text> | ||
{/* <Text style={styles.reminder} type="p3" color={colors.grey3}> | ||
{LL.Circles.connectOnSocial()} | ||
<Text | ||
style={styles.underline} | ||
color={colors.grey3} | ||
onPress={() => Linking.openURL(SOCIAL_LINK_TREE)} | ||
> | ||
{SOCIAL_LINK_TREE} | ||
</Text> | ||
</Text> | ||
<Text style={styles.reminder} type="p3"> | ||
{LL.Circles.fullDetails()} | ||
<Text | ||
style={styles.underline} | ||
color={colors.grey3} | ||
onPress={() => Linking.openURL(CHALLENGE_PAGE_URL)} | ||
> | ||
{CHALLENGE_PAGE} | ||
</Text> | ||
</Text> */} | ||
</View> | ||
</View> | ||
<GaloyToast /> | ||
</Modal> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles(({ colors }) => ({ | ||
container: { | ||
paddingHorizontal: 12, | ||
display: "flex", | ||
flexDirection: "column", | ||
rowGap: 20, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}, | ||
cross: { | ||
position: "absolute", | ||
right: 20, | ||
top: -10, | ||
}, | ||
top: { marginTop: 40 }, | ||
modalCard: { | ||
backgroundColor: colors.grey5, | ||
borderRadius: 16, | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
paddingVertical: 30, | ||
}, | ||
details: { | ||
textAlign: "center", | ||
paddingHorizontal: 20, | ||
}, | ||
reminder: { | ||
textAlign: "center", | ||
paddingHorizontal: 20, | ||
color: colors.grey2, | ||
}, | ||
underline: { | ||
textDecorationLine: "underline", | ||
}, | ||
containerData: { | ||
display: "flex", | ||
flexDirection: "column", | ||
rowGap: 2, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}, | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters