-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from whogurdevil/main
set as waallpaper component completed
- Loading branch information
Showing
5 changed files
with
26 additions
and
118 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,20 @@ | ||
import RNFS from 'react-native-fs'; | ||
import React, { useState } from 'react'; | ||
|
||
import {Dimensions} from 'react-native'; | ||
import WallPaperManager from "react-native-set-wallpaper"; | ||
const windowWidth = Math.round(Dimensions.get('window').width); | ||
const windowHeight = Math.round(Dimensions.get('window').height); | ||
|
||
function setWall(URL){ | ||
WallPaperManager.setWallpaper({ uri: URL }, (res) => { | ||
console.log(res); | ||
}); | ||
} | ||
|
||
// import ManageWallpaper, { TYPE } from 'react-native-manage-wallpaper'; | ||
const downloadImage = async (url, path) => { | ||
try { | ||
const { promise } = RNFS.downloadFile({ | ||
fromUrl: url, | ||
toFile: path, | ||
}); | ||
const downloaded = await promise; | ||
console.log(downloaded); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
function Wall() { | ||
|
||
const url = 'https://fakeimg.pl/850x1200/000000%2C128/fff%2C255/?text=Hello%0AWorld%0AMyself%0Asangam%20arora&font_size=56'; | ||
|
||
const sourcePath = `${RNFS.DocumentDirectoryPath}/image.jpg`; | ||
downloadImage(url, sourcePath); | ||
const targetPath = `${RNFS.ExternalStorageDirectoryPath}/Documents/hello4.jpg`; | ||
|
||
const moveFile = async () => { | ||
try { | ||
await RNFS.moveFile(sourcePath, targetPath); | ||
console.log('File moved successfully!'); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
moveFile(); | ||
setWall(url) | ||
} | ||
|
||
export default Wall | ||
function SetWallpaper() { | ||
const FontSize = '56' | ||
const plainText = "Hello \n How \n Are \n You" | ||
const Background = '000000,128' | ||
const TextColour = 'fff,255' | ||
const url = "https://fakeimg.pl/"+windowWidth+'x'+windowHeight+'/'+Background+'/'+TextColour+'/?font_size='+FontSize+'&text='+encodeURIComponent(plainText); | ||
setWall(url); | ||
} | ||
// SetWallpaper('000000', 'fff', "56", "Hello \n How \n Are \n You"); | ||
export default SetWallpaper; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.