-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
76 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 |
---|---|---|
@@ -1,86 +1,84 @@ | ||
// import { BlogPost } from 'edge-info-server/types' | ||
// import * as React from 'react' | ||
// import { Platform, View } from 'react-native' | ||
// import FastImage from 'react-native-fast-image' | ||
import { BlogPost } from 'edge-info-server/types' | ||
import * as React from 'react' | ||
import { Platform, View } from 'react-native' | ||
import FastImage from 'react-native-fast-image' | ||
|
||
// import { useHandler } from '../../hooks/useHandler' | ||
// import { getLocaleOrDefaultString } from '../../locales/intl' | ||
// import { openBrowserUri } from '../../util/WebUtils' | ||
// import { cacheStyles, Theme, useTheme } from '../services/ThemeContext' | ||
// import { EdgeText } from '../themed/EdgeText' | ||
// import { CardUi4 } from './CardUi4' | ||
import { useHandler } from '../../hooks/useHandler' | ||
import { getLocaleOrDefaultString } from '../../locales/intl' | ||
import { openBrowserUri } from '../../util/WebUtils' | ||
import { cacheStyles, Theme, useTheme } from '../services/ThemeContext' | ||
import { EdgeText } from '../themed/EdgeText' | ||
import { CardUi4 } from './CardUi4' | ||
|
||
// interface Props { | ||
// blogPost: BlogPost | ||
// } | ||
interface Props { | ||
blogPost: BlogPost | ||
} | ||
|
||
// const IMAGE_HEIGHT_RATIO = '65%' | ||
const IMAGE_HEIGHT_RATIO = '65%' | ||
|
||
// /** | ||
// * Blog post card with a top image and text below. | ||
// */ | ||
// export const BlogCard = (props: Props) => { | ||
// const { localeTitle, localeBody, localeBlogUrl, lightImageUrl, darkImageUrl } = props.blogPost | ||
/** | ||
* Blog post card with a top image and text below. | ||
*/ | ||
export const BlogCard = (props: Props) => { | ||
const { localeTitle, localeBody, localeBlogUrl, lightImageUrl, darkImageUrl } = props.blogPost | ||
|
||
// const theme = useTheme() | ||
// const styles = getStyles(theme) | ||
const theme = useTheme() | ||
const styles = getStyles(theme) | ||
|
||
// const textShadow = Platform.OS === 'ios' ? theme.shadowTextIosUi4 : theme.shadowTextAndroidUi4 | ||
const textShadow = Platform.OS === 'ios' ? theme.shadowTextIosUi4 : theme.shadowTextAndroidUi4 | ||
|
||
// const title = getLocaleOrDefaultString(localeTitle) | ||
// const body = getLocaleOrDefaultString(localeBody) | ||
// const url = getLocaleOrDefaultString(localeBlogUrl) | ||
// const image = theme.isDark ? darkImageUrl : lightImageUrl | ||
const title = getLocaleOrDefaultString(localeTitle) | ||
const body = getLocaleOrDefaultString(localeBody) | ||
const url = getLocaleOrDefaultString(localeBlogUrl) | ||
const image = theme.isDark ? darkImageUrl : lightImageUrl | ||
|
||
// const handlePress = useHandler(() => { | ||
// if (url != null) openBrowserUri(url) | ||
// }) | ||
const handlePress = useHandler(() => { | ||
if (url != null) openBrowserUri(url) | ||
}) | ||
|
||
// return ( | ||
// <CardUi4 | ||
// onPress={handlePress} | ||
// nodeBackground={ | ||
// <View style={styles.nodeBackground}> | ||
// <FastImage source={{ uri: image }} style={styles.bannerImage} /> | ||
// </View> | ||
// } | ||
// > | ||
// <View style={styles.backgroundSpacing} /> | ||
// <View style={styles.textContainer}> | ||
// <EdgeText style={[textShadow, styles.titleText]} numberOfLines={1}> | ||
// {title} | ||
// </EdgeText> | ||
// <EdgeText style={[styles.bodyText, textShadow]} numberOfLines={2}> | ||
// {body} | ||
// </EdgeText> | ||
// </View> | ||
// </CardUi4> | ||
// ) | ||
// } | ||
return ( | ||
<CardUi4 | ||
onPress={handlePress} | ||
nodeBackground={ | ||
<View style={styles.nodeBackground}> | ||
<FastImage source={{ uri: image }} style={styles.bannerImage} /> | ||
</View> | ||
} | ||
> | ||
<View style={styles.backgroundSpacing} /> | ||
<View style={styles.textContainer}> | ||
<EdgeText style={[textShadow, styles.titleText]} numberOfLines={1}> | ||
{title} | ||
</EdgeText> | ||
<EdgeText style={[styles.bodyText, textShadow]} numberOfLines={2}> | ||
{body} | ||
</EdgeText> | ||
</View> | ||
</CardUi4> | ||
) | ||
} | ||
|
||
// const getStyles = cacheStyles((theme: Theme) => ({ | ||
// backgroundSpacing: { | ||
// height: IMAGE_HEIGHT_RATIO | ||
// }, | ||
// textContainer: { | ||
// margin: theme.rem(0.5) | ||
// }, | ||
// titleText: { | ||
// fontFamily: theme.fontFaceMedium, | ||
// marginBottom: theme.rem(0.25) | ||
// }, | ||
// bodyText: { | ||
// fontSize: theme.rem(0.65) | ||
// }, | ||
// nodeBackground: { | ||
// height: IMAGE_HEIGHT_RATIO, | ||
// justifyConent: 'center', | ||
// alignItems: 'center' | ||
// }, | ||
// bannerImage: { | ||
// height: '100%', | ||
// width: '100%' | ||
// } | ||
// })) | ||
|
||
export const BlogCard = (props: any) => null // TODO | ||
const getStyles = cacheStyles((theme: Theme) => ({ | ||
backgroundSpacing: { | ||
height: IMAGE_HEIGHT_RATIO | ||
}, | ||
textContainer: { | ||
margin: theme.rem(0.5) | ||
}, | ||
titleText: { | ||
fontFamily: theme.fontFaceMedium, | ||
marginBottom: theme.rem(0.25) | ||
}, | ||
bodyText: { | ||
fontSize: theme.rem(0.65) | ||
}, | ||
nodeBackground: { | ||
height: IMAGE_HEIGHT_RATIO, | ||
justifyConent: 'center', | ||
alignItems: 'center' | ||
}, | ||
bannerImage: { | ||
height: '100%', | ||
width: '100%' | ||
} | ||
})) |