Skip to content

Commit

Permalink
fixup! Add promo cards to HomeScene Pending close button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge authored and paullinator committed Jan 11, 2024
1 parent 8f8f909 commit 26d9544
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
25 changes: 13 additions & 12 deletions src/components/ui4/PromoCardsUi4.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { asArray } from 'cleaners'
import { asPromoCard2, PromoCard2 } from 'edge-info-server/types'
import { asInfoRollup, asPromoCard2, PromoCard2 } from 'edge-info-server/types'
import * as React from 'react'
import { Platform } from 'react-native'
import { getBuildNumber, getVersion } from 'react-native-device-info'
import DeviceInfo, { getBuildNumber, getVersion } from 'react-native-device-info'

import { getCountryCodeByIp } from '../../actions/AccountReferralActions'
import { getLocaleOrDefaultString } from '../../locales/intl'
import { config } from '../../theme/appConfig'
import { NavigationBase } from '../../types/routerTypes'
import { fetchInfo } from '../../util/network'
Expand All @@ -26,20 +27,21 @@ export const PromoCardsUi4 = (props: Props) => {

// Check for PromoCard2 from info server:
React.useEffect(() => {
fetchInfo(`v1/promoCards2/${config.appId ?? 'edge'}`)
const osType = Platform.OS.toLowerCase()
const osVersion = DeviceInfo.getSystemVersion()
const version = getVersion()

fetchInfo(`v1/inforollup/${config.appId ?? 'edge'}?os=${osType}&osVersion=${osVersion}&appVersion=${version}`)
.then(async res => {
if (!res.ok) {
console.error(await res.text())
return
}
const infoData = await res.json()
const infoPromoCards = asArray(asPromoCard2)(infoData)
const infoPromoCards = asArray(asPromoCard2)(asInfoRollup(infoData).promoCards2)

const buildNumber = getBuildNumber()
const countryCode = await getCountryCodeByIp()
const osType = Platform.OS.toLowerCase()
const osVersion = Platform.OS === 'ios' ? Platform.Version : `api${Platform.Version}`
const version = getVersion()
const currentDate = new Date()

setPromos(
Expand All @@ -55,9 +57,8 @@ export const PromoCardsUi4 = (props: Props) => {
if (appVersion != null && appVersion !== version) return false

// Look at min/max only if exact build or app version is not specified.
const isMinVersion = minBuildNum == null || minBuildNum <= buildNumber
const isMaxVersion = maxBuildNum == null || maxBuildNum >= buildNumber
if (!isMinVersion || !isMaxVersion) return false
if (minBuildNum != null && minBuildNum > buildNumber) return false
if (maxBuildNum != null && maxBuildNum < buildNumber) return false

// Validate country
const isCountryInclude =
Expand Down Expand Up @@ -98,10 +99,10 @@ export const PromoCardsUi4 = (props: Props) => {
}, [])

return promos == null || promos.length === 0 ? null : (
<EdgeAnim style={{ height: theme.rem(11.5) }} enter={{ type: 'fadeInUp', distance: 30 }}>
<EdgeAnim style={{ height: theme.rem(10) }} enter={{ type: 'fadeInUp', distance: 110 }}>
<CarouselUi4 height={theme.rem(10)} width={screenWidth}>
{promos.map(promoInfo => (
<PromoCardUi4 navigation={navigation} promoInfo={promoInfo} key={promoInfo.localeMessages[0]} />
<PromoCardUi4 navigation={navigation} promoInfo={promoInfo} key={getLocaleOrDefaultString(promoInfo.localeMessages)} />
))}
</CarouselUi4>
</EdgeAnim>
Expand Down
13 changes: 7 additions & 6 deletions src/components/ui4/scenes/HomeSceneUi4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ export const HomeSceneUi4 = (props: Props) => {
<View style={styles.tempMargin}>
<SectionView extendRight>
<>
<EdgeAnim enter={{ type: 'fadeInUp', distance: 120 }}>
<EdgeAnim enter={{ type: 'fadeInUp', distance: 140 }}>
<BalanceCardUi4 onViewAssetsPress={handleViewAssetsPress} navigation={navigation} />
</EdgeAnim>
<EdgeAnim style={[styles.homeRowContainer, { height: cardSize }]} enter={{ type: 'fadeInUp', distance: 90 }}>
{/* Animation inside PromoCardsUi4 component */}
<PromoCardsUi4 navigation={navigation} screenWidth={screenWidth} />
<EdgeAnim style={[styles.homeRowContainer, { height: cardSize }]} enter={{ type: 'fadeInUp', distance: 80 }}>
<HomeCardUi4
title={lstrings.buy_crypto}
footer={lstrings.buy_crypto_footer}
Expand Down Expand Up @@ -139,11 +141,10 @@ export const HomeSceneUi4 = (props: Props) => {
onPress={handleSwapPress}
/>
</EdgeAnim>
</>
<PromoCardsUi4 navigation={navigation} screenWidth={screenWidth} />
<>
<SectionHeaderUi4 leftTitle={lstrings.title_markets} rightNode={lstrings.see_all} onRightPress={() => navigation.navigate('coinRanking', {})} />
<MarketsCardUi4 navigation={navigation} numRows={5} />
<EdgeAnim style={[styles.homeRowContainer, { height: cardSize }]} enter={{ type: 'fadeInUp', distance: 30 }}>
<MarketsCardUi4 navigation={navigation} numRows={5} />
</EdgeAnim>
</>
{blogPosts == null || blogPosts.length === 0 ? null : (
<>
Expand Down

0 comments on commit 26d9544

Please sign in to comment.