Skip to content

Commit ccb870e

Browse files
committed
allow the webcam to provide a remote image as the thumbnail
1 parent 16cae59 commit ccb870e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/views/streaming/webcams.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {webcamImages} from '../../../images/webcam-images'
1616
import {trackedOpenUrl} from '../components/open-url'
1717
import LinearGradient from 'react-native-linear-gradient'
1818

19+
const transparentPixel = require('../../../images/transparent.png')
1920
const GITHUB_URL = 'https://stodevx.github.io/AAO-React-Native/webcams.json'
2021

2122
type WebcamType = {
@@ -124,12 +125,18 @@ class StreamThumbnail extends React.PureComponent {
124125
thumbnail,
125126
accentColor,
126127
textColor,
128+
thumbnailUrl,
127129
} = this.props.webcam
128130

129131
const [r, g, b] = accentColor
130132
const baseColor = `rgba(${r}, ${g}, ${b}, 1)`
131133
const startColor = `rgba(${r}, ${g}, ${b}, 0.1)`
132134

135+
const img = thumbnailUrl
136+
? {uri: thumbnailUrl}
137+
: webcamImages.hasOwnProperty(thumbnail)
138+
? webcamImages[thumbnail]
139+
: transparentPixel
133140

134141
return (
135142
<View style={styles.cell}>
@@ -139,7 +146,7 @@ class StreamThumbnail extends React.PureComponent {
139146
activeOpacity={0.7}
140147
onPress={this.handlePress}
141148
>
142-
<Image source={webcamImages[thumbnail]} style={[styles.image]}>
149+
<Image source={img} style={styles.image}>
143150
<View style={styles.titleWrapper}>
144151
<LinearGradient
145152
colors={[startColor, baseColor]}

0 commit comments

Comments
 (0)