I'm new to React, I managed to upload an image from the local phone gallery and store its URI in a global variable, but I can't find anywhere how to set the image to my phone background image (not in react!).
The end goal is to allow a change by date in the background.
Assuming I can use global.frstImgURI
, and global.secImgURI
and global.thrdImgURI
as my images path (by import). How can I achieve that?
Currently, I manage to upload an image, then show it in my react native, BG, but not on my phone. My current code for choosing image:
import React from 'react';
import {View, ImageBackground, StyleSheet, Dimensions} from 'react-native';
import global from '../components/global'
const screenHeight = Dimensions.get('window').height;
const screenWidth = Dimensions.get('window').width;
const BackgroundImg = () => {
return <View>
<ImageBackground
source={{uri: global.day1_image }}
resizeMode="stretch"
style={styles.img}>
</ImageBackground>
</View>
};
export default BackgroundImg;
const styles = StyleSheet.create({
img: {
height: screenHeight,
width: screenWidth,
justifyContent: 'center',
alignItems: 'center',
}
})
Show it on React BG:
import * as React from 'react';
import { View } from 'react-native';
import BackgroundImg from '../components/Background_image'
const App = () => {
return (
<View>
<BackgroundImg />
</View>
);
};
export default App;
My thought is using a dynamic list, and changing images by if statement connected to time (still didn't implement), but as said, I can't find how to change the phone image BG at all. Thanks!